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:
parent
680b8c989e
commit
41e4e1cd70
@ -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) {
|
||||
|
@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
function ListFacet(div, config, options, selection) {
|
||||
this._div = div;
|
||||
@ -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"
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
function RangeFacet(div, config, options) {
|
||||
this._div = div;
|
||||
|
@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
function ScatterplotFacet(div, config, options) {
|
||||
this._div = div;
|
||||
|
@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
function TextSearchFacet(div, config, options) {
|
||||
this._div = div;
|
||||
|
@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
function TimeRangeFacet(div, config, options) {
|
||||
this._div = div;
|
||||
@ -275,7 +275,7 @@ TimeRangeFacet.prototype.steps = [
|
||||
1000*31556952*10, // decade
|
||||
1000*31556952*100, // century
|
||||
1000*31556952*1000, // millennium
|
||||
];
|
||||
];
|
||||
|
||||
TimeRangeFacet.prototype._setRangeIndicators = function() {
|
||||
var fromDate = new Date(this._from);
|
||||
|
Loading…
Reference in New Issue
Block a user