2010-02-09 20:23:11 +01:00
|
|
|
function DataTableColumnHeaderUI(dataTableView, column, columnIndex, td) {
|
|
|
|
this._dataTableView = dataTableView;
|
|
|
|
this._column = column;
|
|
|
|
this._columnIndex = columnIndex;
|
|
|
|
this._td = td;
|
|
|
|
|
|
|
|
this._render();
|
|
|
|
}
|
|
|
|
|
|
|
|
DataTableColumnHeaderUI.prototype._render = function() {
|
|
|
|
var self = this;
|
|
|
|
var td = this._td;
|
|
|
|
|
|
|
|
var headerTable = document.createElement("table");
|
|
|
|
$(headerTable).addClass("column-header-layout").attr("cellspacing", "0").attr("cellpadding", "0").attr("width", "100%").appendTo(td);
|
|
|
|
|
|
|
|
var headerTableRow = headerTable.insertRow(0);
|
|
|
|
var headerLeft = headerTableRow.insertCell(0);
|
|
|
|
var headerRight = headerTableRow.insertCell(1);
|
|
|
|
|
|
|
|
$('<span></span>').html(this._column.headerLabel).appendTo(headerLeft);
|
|
|
|
|
|
|
|
$(headerRight).attr("width", "1%");
|
|
|
|
$('<img src="/images/menu-dropdown.png" />').addClass("column-header-menu").appendTo(headerRight).click(function() {
|
|
|
|
self._createMenuForColumnHeader(this);
|
|
|
|
});
|
2010-02-27 00:33:16 +01:00
|
|
|
|
|
|
|
if ("reconStats" in this._column) {
|
|
|
|
var stats = this._column.reconStats;
|
|
|
|
if (stats.nonBlanks > 0) {
|
|
|
|
var newPercent = Math.ceil(100 * stats.newTopics / stats.nonBlanks);
|
|
|
|
var matchPercent = Math.ceil(100 * stats.matchedTopics / stats.nonBlanks);
|
|
|
|
var unreconciledPercent = Math.ceil(100 * (stats.nonBlanks - stats.matchedTopics - stats.newTopics) / stats.nonBlanks);
|
|
|
|
|
|
|
|
var whole = $('<div>')
|
|
|
|
.height("3px")
|
|
|
|
.css("background", "#333")
|
|
|
|
.css("position", "relative")
|
|
|
|
.attr("title", matchPercent + "% matched, " + newPercent + "% new, " + unreconciledPercent + "% to be reconciled")
|
|
|
|
.width("100%")
|
|
|
|
.appendTo(td);
|
|
|
|
|
|
|
|
$('<div>').height("100%").css("background", "white").css("position", "absolute")
|
|
|
|
.width(Math.round((stats.newTopics + stats.matchedTopics) * 100 / stats.nonBlanks) + "%")
|
|
|
|
.appendTo(whole);
|
|
|
|
|
|
|
|
$('<div>').height("100%").css("background", "#6d6").css("position", "absolute")
|
|
|
|
.width(Math.round(stats.matchedTopics * 100 / stats.nonBlanks) + "%")
|
|
|
|
.appendTo(whole);
|
|
|
|
}
|
|
|
|
}
|
2010-02-09 20:23:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) {
|
|
|
|
self = this;
|
|
|
|
MenuSystem.createAndShowStandardMenu([
|
|
|
|
{
|
2010-02-19 18:55:46 +01:00
|
|
|
label: "Edit Cells",
|
2010-02-09 20:23:11 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: "To Titlecase",
|
2010-03-04 01:00:46 +01:00
|
|
|
click: function() { self._doTextTransform("toTitlecase(value)", "store-blank", false, ""); }
|
2010-02-09 20:23:11 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "To Uppercase",
|
2010-03-04 01:00:46 +01:00
|
|
|
click: function() { self._doTextTransform("toUppercase(value)", "store-blank", false, ""); }
|
2010-02-09 20:23:11 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "To Lowercase",
|
2010-03-04 01:00:46 +01:00
|
|
|
click: function() { self._doTextTransform("toLowercase(value)", "store-blank", false, ""); }
|
2010-02-09 20:23:11 +01:00
|
|
|
},
|
|
|
|
{
|
2010-02-19 18:55:46 +01:00
|
|
|
label: "Custom Transform ...",
|
2010-02-09 20:23:11 +01:00
|
|
|
click: function() { self._doTextTransformPrompt(); }
|
|
|
|
},
|
2010-02-19 18:55:46 +01:00
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Split Multi-Valued Cells ...",
|
|
|
|
click: function() { self._doSplitMultiValueCells(); }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Join Multi-Valued Cells ...",
|
|
|
|
click: function() { self._doJoinMultiValueCells(); }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Edit Column",
|
|
|
|
submenu: [
|
2010-02-09 20:23:11 +01:00
|
|
|
{
|
|
|
|
label: "Add Column Based on This Column ...",
|
|
|
|
click: function() { self._doAddColumn("value"); }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Remove This Column",
|
|
|
|
click: function() { self._doRemoveColumn(); }
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2010-02-19 18:55:46 +01:00
|
|
|
{},
|
2010-02-09 20:23:11 +01:00
|
|
|
{
|
|
|
|
label: "Filter",
|
|
|
|
tooltip: "Filter rows by this column's cell content or characteristics",
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: "Text Facet",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel,
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : "value"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Custom Text Facet ...",
|
|
|
|
click: function() { self._doFilterByExpressionPrompt("value", "list"); }
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Numeric Facet",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel,
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : "value",
|
|
|
|
"mode" : "range",
|
|
|
|
"min" : 0,
|
|
|
|
"max" : 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Custom Numeric Facet ...",
|
|
|
|
click: function() { self._doFilterByExpressionPrompt("value", "range"); }
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Text Search",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"text",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel,
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"mode" : "text",
|
|
|
|
"caseSensitive" : false
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Regular Expression Search",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"text",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel + " (regex)",
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"mode" : "regex",
|
|
|
|
"caseSensitive" : true
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2010-03-04 08:32:30 +01:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "By Error",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel + ": Error?",
|
|
|
|
"columnName" : self._column.headerLabel,
|
|
|
|
"expression" : "isError(value)"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "By Blank",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel + ": Blank?",
|
|
|
|
"columnName" : self._column.headerLabel,
|
|
|
|
"expression" : "isBlank(value)"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "View",
|
|
|
|
tooltip: "Collapse/expand columns to make viewing the data more convenient",
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: "Collapse This Column",
|
|
|
|
click: function() {
|
|
|
|
theProject.columnModel.columns[self._columnIndex].collapsed = true;
|
|
|
|
self._dataTableView.render();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Collapse All Other Columns",
|
|
|
|
click: function() {
|
|
|
|
for (var i = 0; i < theProject.columnModel.columns.length; i++) {
|
|
|
|
if (i != self._columnIndex) {
|
|
|
|
theProject.columnModel.columns[i].collapsed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self._dataTableView.render();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Collapse All Columns To Right",
|
|
|
|
click: function() {
|
|
|
|
for (var i = self._columnIndex + 1; i < theProject.columnModel.columns.length; i++) {
|
|
|
|
theProject.columnModel.columns[i].collapsed = true;
|
|
|
|
}
|
|
|
|
self._dataTableView.render();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Reconcile",
|
|
|
|
tooltip: "Match this column's cells to topics on Freebase",
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: "Start Reconciling ...",
|
|
|
|
tooltip: "Reconcile text in this column with topics on Freebase",
|
|
|
|
click: function() {
|
2010-02-19 01:28:34 +01:00
|
|
|
self._doReconcile();
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
2010-02-22 02:28:13 +01:00
|
|
|
label: "Match Each Cell to Its Best Candidate",
|
|
|
|
tooltip: "Match each cell to its best candidate in this column for all current filtered rows",
|
2010-02-09 20:23:11 +01:00
|
|
|
click: function() {
|
2010-02-22 02:28:13 +01:00
|
|
|
self._doReconMatchBestCandidates();
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2010-02-22 02:28:13 +01:00
|
|
|
label: "Create a New Topic for Each Cell",
|
|
|
|
tooltip: "Mark to create one new topic for each cell in this column for all current filtered rows",
|
2010-02-09 20:23:11 +01:00
|
|
|
click: function() {
|
2010-02-22 02:28:13 +01:00
|
|
|
self._doReconMarkNewTopics(false);
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2010-02-22 23:15:48 +01:00
|
|
|
label: "Create One New Topic for Similar Cells",
|
|
|
|
tooltip: "Mark to create one new topic for each group of similar cells in this column for all current filtered rows",
|
2010-02-22 02:28:13 +01:00
|
|
|
click: function() {
|
|
|
|
self._doReconMarkNewTopics(true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Discard Reconciliation Judgments",
|
2010-02-09 20:23:11 +01:00
|
|
|
tooltip: "Discard reconciliaton results in this column for all current filtered rows",
|
|
|
|
click: function() {
|
2010-02-22 02:28:13 +01:00
|
|
|
self._doReconDiscardJudgments();
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
2010-02-20 01:47:08 +01:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Match Filtered Cells to ...",
|
|
|
|
tooltip: "Search for a topic to match all filtered cells to",
|
|
|
|
click: function() {
|
|
|
|
self._doSearchToMatch();
|
|
|
|
}
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Reconcile Filter",
|
|
|
|
tooltip: "Match this column's cells to topics on Freebase",
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: "By Judgment",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel + ": judgment",
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : "cell.recon.judgment"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"scroll" : false
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Relevance Score",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel + ": best candidate's relevance score",
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : "cell.recon.best.score",
|
2010-02-19 00:27:40 +01:00
|
|
|
"mode" : "range"
|
2010-02-09 20:23:11 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Type Match",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel + ": best candidate's type match",
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : "cell.recon.features.typeMatch"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"scroll" : false
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Name Match",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel + ": best candidate's name match",
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : "cell.recon.features.nameMatch"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"scroll" : false
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Name Edit Distance",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel + ": best candidate's name edit distance",
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : "cell.recon.features.nameLevenshtein",
|
2010-02-19 00:27:40 +01:00
|
|
|
"mode" : "range"
|
2010-02-09 20:23:11 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Name Word Similarity",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel + ": best candidate's name word similarity",
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : "cell.recon.features.nameWordDistance",
|
2010-02-19 00:27:40 +01:00
|
|
|
"mode" : "range"
|
2010-02-09 20:23:11 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Types",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : self._column.headerLabel + ": best candidate's types",
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : "cell.recon.best.type"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
], elmt, { width: "120px", horizontal: false });
|
|
|
|
};
|
|
|
|
|
|
|
|
DataTableColumnHeaderUI.prototype._doFilterByExpressionPrompt = function(expression, type) {
|
|
|
|
var self = this;
|
|
|
|
DataTableView.promptExpressionOnVisibleRows(
|
|
|
|
this._column,
|
2010-02-23 01:33:39 +01:00
|
|
|
(type == "list" ? "Custom Facet on column " : "Custom Numeric Facet on column") + this._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
expression,
|
|
|
|
function(expression) {
|
|
|
|
var config = {
|
|
|
|
"name" : self._column.headerLabel + ": " + expression,
|
2010-02-19 00:27:40 +01:00
|
|
|
"columnName" : self._column.headerLabel,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : expression
|
|
|
|
};
|
|
|
|
if (type == "range") {
|
|
|
|
config.mode = "range";
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.browsingEngine.addFacet(type, config);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2010-03-04 01:00:46 +01:00
|
|
|
DataTableColumnHeaderUI.prototype._doTextTransform = function(expression, onError, repeat, repeatCount) {
|
2010-02-26 22:56:41 +01:00
|
|
|
Gridworks.postProcess(
|
2010-02-09 20:23:11 +01:00
|
|
|
"do-text-transform",
|
2010-03-04 01:00:46 +01:00
|
|
|
{
|
|
|
|
columnName: this._column.headerLabel,
|
|
|
|
expression: expression,
|
|
|
|
onError: onError,
|
|
|
|
repeat: repeat,
|
|
|
|
repeatCount: repeatCount
|
|
|
|
},
|
2010-02-26 22:56:41 +01:00
|
|
|
null,
|
|
|
|
{ cellsChanged: true }
|
2010-02-09 20:23:11 +01:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
DataTableColumnHeaderUI.prototype._doTextTransformPrompt = function() {
|
|
|
|
var self = this;
|
2010-03-03 23:12:48 +01:00
|
|
|
var frame = DialogSystem.createDialog();
|
|
|
|
frame.width("700px");
|
|
|
|
|
|
|
|
var header = $('<div></div>').addClass("dialog-header").text("Custom text transform on column " + this._column.headerLabel).appendTo(frame);
|
|
|
|
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
|
|
|
|
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
|
|
|
|
|
2010-03-04 01:00:46 +01:00
|
|
|
body.html(
|
2010-03-03 23:12:48 +01:00
|
|
|
'<table class="expression-preview-layout">' +
|
|
|
|
'<tr>' +
|
2010-03-04 01:00:46 +01:00
|
|
|
'<td colspan="4">' + ExpressionPreviewDialog.generateWidgetHtml() + '</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr style="white-space: pre;">' +
|
|
|
|
'<td width="1%">' +
|
|
|
|
'On error' +
|
|
|
|
'</td>' +
|
|
|
|
'<td>' +
|
|
|
|
'<input type="radio" name="text-transform-dialog-onerror-choice" value="set-to-blank" checked /> set to blank<br/>' +
|
|
|
|
'<input type="radio" name="text-transform-dialog-onerror-choice" value="store-error" /> store error<br/>' +
|
2010-03-03 23:12:48 +01:00
|
|
|
'<input type="radio" name="text-transform-dialog-onerror-choice" value="keep-original" /> keep original' +
|
|
|
|
'</td>' +
|
2010-03-04 01:00:46 +01:00
|
|
|
'<td width="1%">' +
|
|
|
|
'<input type="checkbox" bind="repeatCheckbox" />' +
|
|
|
|
'</td>' +
|
|
|
|
'<td>' +
|
|
|
|
'Re-transform until no change<br/>' +
|
|
|
|
'up to <input bind="repeatCountInput" value="10" size="3" /> times' +
|
2010-03-03 23:12:48 +01:00
|
|
|
'</td>' +
|
|
|
|
'</tr>' +
|
2010-03-04 01:00:46 +01:00
|
|
|
'</table>'
|
|
|
|
);
|
|
|
|
var bodyElmts = DOM.bind(body);
|
|
|
|
|
|
|
|
footer.html(
|
|
|
|
'<button bind="okButton"> OK </button>' +
|
|
|
|
'<button bind="cancelButton">Cancel</button>'
|
|
|
|
);
|
2010-03-03 23:12:48 +01:00
|
|
|
var footerElmts = DOM.bind(footer);
|
|
|
|
|
|
|
|
var level = DialogSystem.showDialog(frame);
|
|
|
|
var dismiss = function() {
|
|
|
|
DialogSystem.dismissUntil(level - 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
footerElmts.okButton.click(function() {
|
|
|
|
self._doTextTransform(
|
|
|
|
previewWidget.getExpression(true),
|
2010-03-04 01:00:46 +01:00
|
|
|
$('input[name="text-transform-dialog-onerror-choice"]:checked')[0].value,
|
|
|
|
bodyElmts.repeatCheckbox[0].checked,
|
|
|
|
bodyElmts.repeatCountInput[0].value
|
2010-03-03 23:12:48 +01:00
|
|
|
);
|
|
|
|
dismiss();
|
|
|
|
})
|
|
|
|
footerElmts.cancelButton.click(dismiss);
|
|
|
|
|
|
|
|
var o = DataTableView.sampleVisibleRows(this._column);
|
|
|
|
var previewWidget = new ExpressionPreviewDialog.Widget(
|
|
|
|
bodyElmts,
|
|
|
|
this._column.cellIndex,
|
|
|
|
o.rowIndices,
|
|
|
|
o.values,
|
|
|
|
"value"
|
2010-02-09 20:23:11 +01:00
|
|
|
);
|
2010-03-04 03:25:42 +01:00
|
|
|
previewWidget._prepareUpdate = function(params) {
|
|
|
|
params.repeat = bodyElmts.repeatCheckbox[0].checked;
|
|
|
|
params.repeatCount = bodyElmts.repeatCountInput[0].value;
|
|
|
|
};
|
|
|
|
bodyElmts.repeatCheckbox.click(function() {
|
|
|
|
previewWidget.update();
|
|
|
|
});
|
2010-02-09 20:23:11 +01:00
|
|
|
};
|
|
|
|
|
2010-02-19 01:28:34 +01:00
|
|
|
DataTableColumnHeaderUI.prototype._doReconcile = function() {
|
|
|
|
var self = this;
|
2010-02-19 18:38:47 +01:00
|
|
|
var dismissBusy = DialogSystem.showBusy();
|
2010-02-19 01:28:34 +01:00
|
|
|
$.post(
|
|
|
|
"/command/guess-types-of-column?" + $.param({ project: theProject.id, columnName: this._column.headerLabel }),
|
|
|
|
null,
|
|
|
|
function(data) {
|
2010-02-21 08:32:16 +01:00
|
|
|
if (data.code != "ok") {
|
|
|
|
dismissBusy();
|
|
|
|
new ReconDialog(self._column, []);
|
|
|
|
} else {
|
|
|
|
data.types = data.types.slice(0, 20);
|
|
|
|
|
|
|
|
var ids = $.map(data.types, function(elmt) { return elmt.id; });
|
2010-03-02 19:19:20 +01:00
|
|
|
if (ids.length == 0) {
|
|
|
|
dismissBusy();
|
|
|
|
new ReconDialog(self._column, []);
|
|
|
|
} else {
|
|
|
|
var query = [{
|
|
|
|
"id|=" : ids,
|
|
|
|
"id" : null,
|
|
|
|
"/freebase/type_profile/kind" : []
|
|
|
|
}];
|
|
|
|
$.getJSON(
|
|
|
|
"http://api.freebase.com/api/service/mqlread?" + $.param({ "query" : JSON.stringify({ "query" : query }) }) + "&callback=?",
|
|
|
|
null,
|
|
|
|
function(o) {
|
|
|
|
dismissBusy();
|
|
|
|
|
|
|
|
var kindMap = {};
|
|
|
|
$.each(o.result, function() {
|
|
|
|
var m = kindMap[this.id] = {};
|
|
|
|
$.each(this["/freebase/type_profile/kind"], function() {
|
|
|
|
m[this] = true;
|
|
|
|
});
|
2010-02-21 08:32:16 +01:00
|
|
|
});
|
2010-03-02 19:19:20 +01:00
|
|
|
|
|
|
|
new ReconDialog(self._column, $.map(data.types, function(type) {
|
|
|
|
if (type.id in kindMap) {
|
|
|
|
var m = kindMap[type.id];
|
|
|
|
if (!("Role" in m) && !("Annotation" in m)) {
|
|
|
|
return type;
|
|
|
|
}
|
2010-02-21 08:32:16 +01:00
|
|
|
}
|
2010-03-02 19:19:20 +01:00
|
|
|
return null;
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
"jsonp"
|
|
|
|
);
|
|
|
|
}
|
2010-02-21 08:32:16 +01:00
|
|
|
}
|
2010-02-19 01:28:34 +01:00
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2010-02-22 02:28:13 +01:00
|
|
|
DataTableColumnHeaderUI.prototype._doReconDiscardJudgments = function() {
|
2010-02-26 22:56:41 +01:00
|
|
|
Gridworks.postProcess(
|
2010-02-20 01:47:08 +01:00
|
|
|
"recon-discard-judgments",
|
2010-02-26 22:56:41 +01:00
|
|
|
{ columnName: this._column.headerLabel },
|
|
|
|
null,
|
2010-02-27 00:33:16 +01:00
|
|
|
{ cellsChanged: true, columnStatsChanged: true }
|
2010-02-09 20:23:11 +01:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2010-02-22 02:28:13 +01:00
|
|
|
DataTableColumnHeaderUI.prototype._doReconMatchBestCandidates = function() {
|
2010-02-26 22:56:41 +01:00
|
|
|
Gridworks.postProcess(
|
2010-02-22 02:28:13 +01:00
|
|
|
"recon-match-best-candidates",
|
2010-02-26 22:56:41 +01:00
|
|
|
{ columnName: this._column.headerLabel },
|
|
|
|
null,
|
2010-02-27 00:33:16 +01:00
|
|
|
{ cellsChanged: true, columnStatsChanged: true }
|
2010-02-09 20:23:11 +01:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2010-02-22 23:15:48 +01:00
|
|
|
DataTableColumnHeaderUI.prototype._doReconMarkNewTopics = function(shareNewTopics) {
|
2010-02-26 22:56:41 +01:00
|
|
|
Gridworks.postProcess(
|
2010-02-20 01:47:08 +01:00
|
|
|
"recon-mark-new-topics",
|
2010-02-26 22:56:41 +01:00
|
|
|
{ columnName: this._column.headerLabel, shareNewTopics: shareNewTopics },
|
|
|
|
null,
|
2010-02-27 00:33:16 +01:00
|
|
|
{ cellsChanged: true, columnStatsChanged: true }
|
2010-02-09 20:23:11 +01:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2010-02-20 01:47:08 +01:00
|
|
|
DataTableColumnHeaderUI.prototype._doSearchToMatch = function() {
|
|
|
|
var self = this;
|
|
|
|
var frame = DialogSystem.createDialog();
|
2010-02-22 02:28:13 +01:00
|
|
|
frame.width("400px");
|
2010-02-20 01:47:08 +01:00
|
|
|
|
|
|
|
var header = $('<div></div>').addClass("dialog-header").text("Search for Match").appendTo(frame);
|
|
|
|
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
|
|
|
|
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
|
|
|
|
|
|
|
|
$('<p></p>').text("Search Freebase for a topic to match all filtered cells:").appendTo(body);
|
|
|
|
|
|
|
|
var input = $('<input />').appendTo($('<p></p>').appendTo(body));
|
|
|
|
|
|
|
|
input.suggest({}).bind("fb-select", function(e, data) {
|
2010-02-26 22:56:41 +01:00
|
|
|
Gridworks.postProcess(
|
2010-02-20 01:47:08 +01:00
|
|
|
"recon-match-specific-topic-to-cells",
|
|
|
|
{
|
|
|
|
columnName: self._column.headerLabel,
|
|
|
|
topicID: data.id,
|
|
|
|
topicGUID: data.guid,
|
|
|
|
topicName: data.name,
|
|
|
|
types: $.map(data.type, function(elmt) { return elmt.id; }).join(",")
|
2010-02-26 22:56:41 +01:00
|
|
|
},
|
|
|
|
null,
|
2010-02-27 00:33:16 +01:00
|
|
|
{ cellsChanged: true, columnStatsChanged: true }
|
2010-02-20 01:47:08 +01:00
|
|
|
);
|
2010-02-26 22:56:41 +01:00
|
|
|
|
2010-02-20 01:47:08 +01:00
|
|
|
DialogSystem.dismissUntil(level - 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('<button></button>').text("Cancel").click(function() {
|
|
|
|
DialogSystem.dismissUntil(level - 1);
|
|
|
|
}).appendTo(footer);
|
|
|
|
|
|
|
|
var level = DialogSystem.showDialog(frame);
|
2010-02-22 02:28:13 +01:00
|
|
|
input.focus().data("suggest").textchange();
|
2010-02-20 01:47:08 +01:00
|
|
|
};
|
|
|
|
|
2010-02-09 20:23:11 +01:00
|
|
|
DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
|
|
|
|
var self = this;
|
2010-03-04 01:12:39 +01:00
|
|
|
var frame = DialogSystem.createDialog();
|
|
|
|
frame.width("700px");
|
|
|
|
|
|
|
|
var header = $('<div></div>').addClass("dialog-header").text("Add Column Based on Column " + this._column.headerLabel).appendTo(frame);
|
|
|
|
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
|
|
|
|
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
|
|
|
|
|
|
|
|
body.html(
|
|
|
|
'<table class="expression-preview-layout" cols="2">' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td width="1%" style="white-space: pre;">' +
|
|
|
|
'New column name' +
|
|
|
|
'</td>' +
|
|
|
|
'<td>' +
|
|
|
|
'<input bind="columnNameInput" size="40" />' +
|
|
|
|
'</td>' +
|
|
|
|
'</tr>' +
|
2010-03-04 01:32:54 +01:00
|
|
|
'<tr>' +
|
|
|
|
'<td width="1%" style="white-space: pre;">' +
|
|
|
|
'On error' +
|
|
|
|
'</td>' +
|
|
|
|
'<td>' +
|
|
|
|
'<input type="radio" name="create-column-dialog-onerror-choice" value="set-to-blank" checked /> set to blank ' +
|
|
|
|
'<input type="radio" name="create-column-dialog-onerror-choice" value="store-error" /> store error ' +
|
|
|
|
'<input type="radio" name="create-column-dialog-onerror-choice" value="keep-original" /> keep original' +
|
|
|
|
'</td>' +
|
|
|
|
'</tr>' +
|
2010-03-04 01:12:39 +01:00
|
|
|
'<tr>' +
|
|
|
|
'<td colspan="2">' + ExpressionPreviewDialog.generateWidgetHtml() + '</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'</table>'
|
|
|
|
);
|
|
|
|
var bodyElmts = DOM.bind(body);
|
|
|
|
|
|
|
|
footer.html(
|
|
|
|
'<button bind="okButton"> OK </button>' +
|
|
|
|
'<button bind="cancelButton">Cancel</button>'
|
2010-02-09 20:23:11 +01:00
|
|
|
);
|
2010-03-04 01:12:39 +01:00
|
|
|
var footerElmts = DOM.bind(footer);
|
|
|
|
|
|
|
|
var level = DialogSystem.showDialog(frame);
|
|
|
|
var dismiss = function() {
|
|
|
|
DialogSystem.dismissUntil(level - 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
footerElmts.okButton.click(function() {
|
|
|
|
var columnName = $.trim(bodyElmts.columnNameInput[0].value);
|
|
|
|
if (columnName.length == 0) {
|
|
|
|
alert("You must enter a column name.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Gridworks.postProcess(
|
|
|
|
"add-column",
|
|
|
|
{
|
|
|
|
baseColumnName: self._column.headerLabel,
|
|
|
|
expression: previewWidget.getExpression(true),
|
|
|
|
headerLabel: columnName,
|
2010-03-04 01:32:54 +01:00
|
|
|
columnInsertIndex: self._columnIndex + 1,
|
|
|
|
onError: $('input[name="create-column-dialog-onerror-choice"]:checked')[0].value
|
2010-03-04 01:12:39 +01:00
|
|
|
},
|
|
|
|
null,
|
|
|
|
{ modelsChanged: true }
|
|
|
|
);
|
|
|
|
dismiss();
|
|
|
|
})
|
|
|
|
footerElmts.cancelButton.click(dismiss);
|
|
|
|
|
|
|
|
var o = DataTableView.sampleVisibleRows(this._column);
|
|
|
|
var previewWidget = new ExpressionPreviewDialog.Widget(
|
|
|
|
bodyElmts,
|
|
|
|
this._column.cellIndex,
|
|
|
|
o.rowIndices,
|
|
|
|
o.values,
|
|
|
|
"value"
|
|
|
|
);
|
2010-02-09 20:23:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
DataTableColumnHeaderUI.prototype._doRemoveColumn = function() {
|
2010-02-26 22:56:41 +01:00
|
|
|
Gridworks.postProcess(
|
|
|
|
"remove-column",
|
|
|
|
{
|
|
|
|
columnName: this._column.headerLabel
|
|
|
|
},
|
|
|
|
null,
|
|
|
|
{ modelsChanged: true }
|
2010-02-09 20:23:11 +01:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
DataTableColumnHeaderUI.prototype._doJoinMultiValueCells = function() {
|
|
|
|
var separator = window.prompt("Enter separator to use between values", ", ");
|
|
|
|
if (separator != null) {
|
2010-02-26 22:56:41 +01:00
|
|
|
Gridworks.postProcess(
|
|
|
|
"join-multi-value-cells",
|
2010-02-09 20:23:11 +01:00
|
|
|
{
|
2010-02-17 01:26:38 +01:00
|
|
|
columnName: this._column.headerLabel,
|
|
|
|
keyColumnName: theProject.columnModel.keyColumnName,
|
2010-02-09 20:23:11 +01:00
|
|
|
separator: separator
|
2010-02-26 22:56:41 +01:00
|
|
|
},
|
|
|
|
null,
|
|
|
|
{ rowsChanged: true }
|
2010-02-09 20:23:11 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
DataTableColumnHeaderUI.prototype._doSplitMultiValueCells = function() {
|
2010-02-19 18:55:46 +01:00
|
|
|
var separator = window.prompt("What separator currently separates the values?", ",");
|
2010-02-09 20:23:11 +01:00
|
|
|
if (separator != null) {
|
2010-02-26 22:56:41 +01:00
|
|
|
Gridworks.postProcess(
|
|
|
|
"split-multi-value-cells",
|
2010-02-09 20:23:11 +01:00
|
|
|
{
|
2010-02-17 01:26:38 +01:00
|
|
|
columnName: this._column.headerLabel,
|
|
|
|
keyColumnName: theProject.columnModel.keyColumnName,
|
2010-02-09 20:23:11 +01:00
|
|
|
separator: separator,
|
|
|
|
mode: "plain"
|
2010-02-26 22:56:41 +01:00
|
|
|
},
|
|
|
|
null,
|
|
|
|
{ rowsChanged: true }
|
2010-02-09 20:23:11 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|