Display cluster sizes and number of cluster in facet-based edit dialog.
Added command to invoke that dialog from column popup menu, so you don't have to create a text facet first to get to it. git-svn-id: http://google-refine.googlecode.com/svn/trunk@221 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
253874b1a1
commit
02cd59a5c0
@ -1,7 +1,6 @@
|
|||||||
function FacetBasedEditDialog(columnName, expression, entries) {
|
function FacetBasedEditDialog(columnName, expression) {
|
||||||
this._columnName = columnName;
|
this._columnName = columnName;
|
||||||
this._expression = expression;
|
this._expression = expression;
|
||||||
this._entries = entries;
|
|
||||||
this._method = "binning";
|
this._method = "binning";
|
||||||
this._function = "fingerprint";
|
this._function = "fingerprint";
|
||||||
this._params = {};
|
this._params = {};
|
||||||
@ -50,6 +49,8 @@ FacetBasedEditDialog.prototype._createDialog = function() {
|
|||||||
'Ngram Size: <input type="text" value="1" bind="ngramSize">' +
|
'Ngram Size: <input type="text" value="1" bind="ngramSize">' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</td>' +
|
'</td>' +
|
||||||
|
'<td bind="resultSummary" align="right">' +
|
||||||
|
'</td>' +
|
||||||
'</tr></table></div>' +
|
'</tr></table></div>' +
|
||||||
'<div bind="tableContainer" class="facet-based-edit-dialog-table-container"></div>' +
|
'<div bind="tableContainer" class="facet-based-edit-dialog-table-container"></div>' +
|
||||||
'</div>'
|
'</div>'
|
||||||
@ -105,21 +106,24 @@ FacetBasedEditDialog.prototype._createDialog = function() {
|
|||||||
|
|
||||||
FacetBasedEditDialog.prototype._renderTable = function() {
|
FacetBasedEditDialog.prototype._renderTable = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var container = this._elmts.tableContainer;
|
|
||||||
|
|
||||||
|
var container = this._elmts.tableContainer;
|
||||||
var table = $('<table></table>').addClass("facet-based-edit-dialog-entry-table")[0];
|
var table = $('<table></table>').addClass("facet-based-edit-dialog-entry-table")[0];
|
||||||
|
|
||||||
var trHead = table.insertRow(table.rows.length);
|
var trHead = table.insertRow(table.rows.length);
|
||||||
trHead.className = "header";
|
trHead.className = "header";
|
||||||
$(trHead.insertCell(0)).text("Current facet choices");
|
$(trHead.insertCell(0)).text("Cluster size");
|
||||||
$(trHead.insertCell(1)).text("Edit?");
|
$(trHead.insertCell(1)).text("Facet choices in Cluster");
|
||||||
$(trHead.insertCell(2)).text("New cell value");
|
$(trHead.insertCell(2)).text("Edit?");
|
||||||
|
$(trHead.insertCell(3)).text("New cell value");
|
||||||
|
|
||||||
var renderCluster = function(cluster) {
|
var renderCluster = function(cluster) {
|
||||||
var tr = table.insertRow(table.rows.length);
|
var tr = table.insertRow(table.rows.length);
|
||||||
tr.className = table.rows.length % 2 == 0 ? "odd" : "even";
|
tr.className = table.rows.length % 2 == 0 ? "odd" : "even";
|
||||||
|
|
||||||
var ul = $(tr.insertCell(0));
|
$(tr.insertCell(0)).text(cluster.choices.length);
|
||||||
|
|
||||||
|
var ul = $(tr.insertCell(1));
|
||||||
var choices = cluster.choices;
|
var choices = cluster.choices;
|
||||||
for (var c = 0; c < choices.length; c++) {
|
for (var c = 0; c < choices.length; c++) {
|
||||||
var choice = choices[c];
|
var choice = choices[c];
|
||||||
@ -129,7 +133,7 @@ FacetBasedEditDialog.prototype._renderTable = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var editCheck = $('<input type="checkbox" />')
|
var editCheck = $('<input type="checkbox" />')
|
||||||
.appendTo(tr.insertCell(1))
|
.appendTo(tr.insertCell(2))
|
||||||
.click(function() {
|
.click(function() {
|
||||||
cluster.edit = !cluster.edit;
|
cluster.edit = !cluster.edit;
|
||||||
});
|
});
|
||||||
@ -139,7 +143,7 @@ FacetBasedEditDialog.prototype._renderTable = function() {
|
|||||||
|
|
||||||
var input = $('<input size="55" />')
|
var input = $('<input size="55" />')
|
||||||
.attr("value", cluster.value)
|
.attr("value", cluster.value)
|
||||||
.appendTo(tr.insertCell(2))
|
.appendTo(tr.insertCell(3))
|
||||||
.keyup(function() {
|
.keyup(function() {
|
||||||
cluster.value = this.value;
|
cluster.value = this.value;
|
||||||
});
|
});
|
||||||
@ -149,6 +153,8 @@ FacetBasedEditDialog.prototype._renderTable = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
container.empty().append(table);
|
container.empty().append(table);
|
||||||
|
|
||||||
|
this._elmts.resultSummary.text(this._clusters.length + " clusters found.");
|
||||||
};
|
};
|
||||||
|
|
||||||
FacetBasedEditDialog.prototype._cluster = function() {
|
FacetBasedEditDialog.prototype._cluster = function() {
|
||||||
@ -158,6 +164,8 @@ FacetBasedEditDialog.prototype._cluster = function() {
|
|||||||
'<div style="margin: 1em; font-size: 130%; color: #888;">Loading... <img src="/images/small-spinner.gif"></div>'
|
'<div style="margin: 1em; font-size: 130%; color: #888;">Loading... <img src="/images/small-spinner.gif"></div>'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this._elmts.resultSummary.empty();
|
||||||
|
|
||||||
$.post(
|
$.post(
|
||||||
"/command/compute-clusters?" + $.param({ project: theProject.id }),
|
"/command/compute-clusters?" + $.param({ project: theProject.id }),
|
||||||
{
|
{
|
||||||
|
@ -214,15 +214,7 @@ ListFacet.prototype.render = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._doEdit = function() {
|
ListFacet.prototype._doEdit = function() {
|
||||||
var entries = [];
|
new FacetBasedEditDialog(this._config.columnName, this._config.expression);
|
||||||
for (var i = 0; i < this._data.choices.length; i++) {
|
|
||||||
var choice = this._data.choices[i];
|
|
||||||
entries.push({
|
|
||||||
v: choice.v,
|
|
||||||
c: choice.c
|
|
||||||
});
|
|
||||||
}
|
|
||||||
new FacetBasedEditDialog(this._config.columnName, this._config.expression, entries);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._select = function(choice, only) {
|
ListFacet.prototype._select = function(choice, only) {
|
||||||
|
@ -81,6 +81,11 @@ DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) {
|
|||||||
{
|
{
|
||||||
label: "Join Multi-Valued Cells ...",
|
label: "Join Multi-Valued Cells ...",
|
||||||
click: function() { self._doJoinMultiValueCells(); }
|
click: function() { self._doJoinMultiValueCells(); }
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
label: "Cluster & Edit ...",
|
||||||
|
click: function() { new FacetBasedEditDialog(self._column.name, "value"); }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user