Some more JS indentation fixes.

Fixed issue 31: "Maximum number of facet values should be configurable." Now when we're showing "too many choices" we also display exactly how many choices there are and show a link to change the limit.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2201 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2011-08-14 01:05:43 +00:00
parent 680b8c989e
commit 41e4e1cd70
6 changed files with 1604 additions and 1555 deletions

View File

@ -107,6 +107,7 @@ public class ListFacet implements Facet {
writer.key("error"); writer.value(_errorMessage);
} else if (_choices.size() > getLimit()) {
writer.key("error"); writer.value("Too many choices");
writer.key("choiceCount"); writer.value(_choices.size());
} else {
writer.key("choices"); writer.array();
for (NominalFacetChoice choice : _choices) {

View File

@ -159,12 +159,13 @@ ListFacet.prototype._initializeUI = function() {
'</div>' +
'<div class="facet-expression" bind="expressionDiv" title="Click to edit expression"></div>' +
'<div class="facet-controls" bind="controlsDiv" style="display:none;">' +
'<a bind="choiceCountContainer" class="action" href="javascript:{}"></a> <span class="facet-controls-sortControls" bind="sortGroup">Sort by: ' +
'<a bind="choiceCountContainer" class="action" href="javascript:{}"></a> ' +
'<span class="facet-controls-sortControls" bind="sortGroup">Sort by: ' +
'<a href="javascript:{}" bind="sortByNameLink">name</a>' +
'<a href="javascript:{}" bind="sortByCountLink">count</a>' +
'</span>' +
'<button bind="clusterLink" class="facet-controls-button button">Cluster</button>' +
'</div></div>' +
'</div>' +
'<div class="facet-body" bind="bodyDiv">' +
'<div class="facet-body-inner" bind="bodyInnerDiv"></div>' +
'</div>'
@ -275,11 +276,31 @@ ListFacet.prototype._update = function(resetScroll) {
} else if ("error" in this._data) {
//this._elmts.statusDiv.hide();
this._elmts.controlsDiv.hide();
this._elmts.bodyInnerDiv.empty().append(
$('<div>').text(this._data.error).addClass("facet-body-message"));
if (this._data.error == "Too many choices") {
this._elmts.bodyInnerDiv.empty();
var messageDiv = $('<div>')
.text(this._data.choiceCount + " choices total, too many to display")
.addClass("facet-body-message")
.appendTo(this._elmts.bodyInnerDiv);
$('<br>').appendTo(messageDiv);
$('<a>')
.text("Set choice count limit")
.attr("href", "javascript:{}")
.addClass("action")
.addClass("secondary")
.appendTo(messageDiv)
.click(function() {
self._setChoiceCountLimit(self._data.choiceCount);
});
this._renderBodyControls();
} else {
this._elmts.bodyInnerDiv.empty().append(
$('<div>')
.text(this._data.error)
.addClass("facet-body-message"));
}
return;
}
@ -671,3 +692,30 @@ ListFacet.prototype._editExpression = function() {
}
);
};
ListFacet.prototype._setChoiceCountLimit = function(choiceCount) {
var limit = Math.ceil(choiceCount / 1000) * 1000;
var s = window.prompt('Set the maximum number of choices shown in each text facet (too many will slow down the application)', limit);
if (s) {
var n = parseInt(s);
if (!isNaN(n)) {
var self = this;
$.post(
"/command/core/set-preference",
{
name : "ui.browsing.listFacet.limit",
value : n
},
function(o) {
if (o.code == "ok") {
ui.browsingEngine.update();
} else if (o.code == "error") {
alert(o.message);
}
},
"json"
);
}
}
};