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();
|
|
|
|
}
|
|
|
|
|
2010-05-21 06:11:08 +02:00
|
|
|
DataTableColumnHeaderUI.prototype.getColumn = function() {
|
|
|
|
return this._column;
|
|
|
|
};
|
|
|
|
|
2010-02-09 20:23:11 +01:00
|
|
|
DataTableColumnHeaderUI.prototype._render = function() {
|
|
|
|
var self = this;
|
|
|
|
|
2010-03-18 01:35:34 +01:00
|
|
|
var html = $(
|
|
|
|
'<table class="column-header-layout">' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td width="1%">' +
|
|
|
|
'<a class="column-header-menu" bind="dropdownMenu"> </a>' +
|
|
|
|
'</td>' +
|
2010-04-17 00:39:30 +02:00
|
|
|
'<td bind="nameContainer"></td>' +
|
2010-03-18 01:35:34 +01:00
|
|
|
'</tr>' +
|
|
|
|
'</table>' +
|
|
|
|
'<div style="display:none;" bind="reconStatsContainer"></div>'
|
|
|
|
).appendTo(this._td);
|
2010-02-09 20:23:11 +01:00
|
|
|
|
2010-03-18 01:35:34 +01:00
|
|
|
var elmts = DOM.bind(html);
|
2010-02-09 20:23:11 +01:00
|
|
|
|
2010-03-18 01:35:34 +01:00
|
|
|
elmts.nameContainer.text(this._column.name);
|
|
|
|
elmts.dropdownMenu.click(function() {
|
2010-02-09 20:23:11 +01:00
|
|
|
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);
|
2010-03-18 01:35:34 +01:00
|
|
|
var title = matchPercent + "% matched, " + newPercent + "% new, " + unreconciledPercent + "% to be reconciled";
|
2010-02-27 00:33:16 +01:00
|
|
|
|
|
|
|
var whole = $('<div>')
|
2010-03-18 01:35:34 +01:00
|
|
|
.addClass("column-header-recon-stats-bar")
|
|
|
|
.attr("title", title)
|
|
|
|
.appendTo(elmts.reconStatsContainer.show());
|
2010-02-27 00:33:16 +01:00
|
|
|
|
2010-03-18 01:35:34 +01:00
|
|
|
$('<div>')
|
|
|
|
.addClass("column-header-recon-stats-blanks")
|
2010-02-27 00:33:16 +01:00
|
|
|
.width(Math.round((stats.newTopics + stats.matchedTopics) * 100 / stats.nonBlanks) + "%")
|
|
|
|
.appendTo(whole);
|
|
|
|
|
2010-03-18 01:35:34 +01:00
|
|
|
$('<div>')
|
|
|
|
.addClass("column-header-recon-stats-matched")
|
2010-02-27 00:33:16 +01:00
|
|
|
.width(Math.round(stats.matchedTopics * 100 / stats.nonBlanks) + "%")
|
|
|
|
.appendTo(whole);
|
|
|
|
}
|
|
|
|
}
|
2010-02-09 20:23:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) {
|
2010-05-21 06:11:08 +02:00
|
|
|
var self = this;
|
2010-02-09 20:23:11 +01:00
|
|
|
MenuSystem.createAndShowStandardMenu([
|
|
|
|
{
|
2010-04-17 00:39:30 +02:00
|
|
|
label: "Facet",
|
2010-02-09 20:23:11 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: "Text Facet",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
2010-03-06 08:43:45 +01:00
|
|
|
"name" : self._column.name,
|
|
|
|
"columnName" : self._column.name,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : "value"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Numeric Facet",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
2010-03-06 08:43:45 +01:00
|
|
|
"name" : self._column.name,
|
|
|
|
"columnName" : self._column.name,
|
2010-02-09 20:23:11 +01:00
|
|
|
"expression" : "value",
|
2010-03-09 07:57:08 +01:00
|
|
|
"mode" : "range"
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2010-04-17 00:39:30 +02:00
|
|
|
{
|
|
|
|
label: "Scatterplot Facet",
|
|
|
|
click: function() {
|
|
|
|
new ScatterplotDialog(self._column.name);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Custom Text Facet ...",
|
|
|
|
click: function() { self._doFilterByExpressionPrompt("value", "list"); }
|
|
|
|
},
|
2010-02-09 20:23:11 +01:00
|
|
|
{
|
|
|
|
label: "Custom Numeric Facet ...",
|
|
|
|
click: function() { self._doFilterByExpressionPrompt("value", "range"); }
|
|
|
|
},
|
2010-03-09 07:57:08 +01:00
|
|
|
{
|
2010-04-17 00:39:30 +02:00
|
|
|
label: "Customized Facets",
|
2010-03-09 07:57:08 +01:00
|
|
|
submenu: [
|
2010-04-17 00:39:30 +02:00
|
|
|
{
|
|
|
|
label: "Word Facet",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
2010-04-21 09:21:05 +02:00
|
|
|
"name" : self._column.name,
|
2010-04-17 00:39:30 +02:00
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "value.split(' ')"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
2010-03-18 23:58:06 +01:00
|
|
|
{
|
|
|
|
label: "Numeric Log Facet",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
2010-04-21 09:21:05 +02:00
|
|
|
"name" : self._column.name,
|
2010-03-18 23:58:06 +01:00
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "value.log()",
|
|
|
|
"mode" : "range"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2010-03-20 00:04:17 +01:00
|
|
|
{
|
|
|
|
label: "1-bounded Numeric Log Facet",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
2010-04-21 09:21:05 +02:00
|
|
|
"name" : self._column.name,
|
2010-03-20 00:04:17 +01:00
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "log(max(1, value))",
|
|
|
|
"mode" : "range"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
2010-03-09 07:57:08 +01:00
|
|
|
{
|
|
|
|
label: "Text Length Facet",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
2010-04-21 09:21:05 +02:00
|
|
|
"name" : self._column.name,
|
2010-03-09 07:57:08 +01:00
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "value.length()",
|
|
|
|
"mode" : "range"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Log of Text Length Facet",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
2010-04-21 09:21:05 +02:00
|
|
|
"name" : self._column.name,
|
2010-03-09 07:57:08 +01:00
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "value.length().log()",
|
|
|
|
"mode" : "range"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Unicode Char-code Facet",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
2010-04-21 09:21:05 +02:00
|
|
|
"name" : self._column.name,
|
2010-03-09 07:57:08 +01:00
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "value.unicode()",
|
|
|
|
"mode" : "range"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2010-04-17 00:39:30 +02:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Facet by Error",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
2010-04-21 09:21:05 +02:00
|
|
|
"name" : self._column.name,
|
2010-04-17 00:39:30 +02:00
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "isError(value)"
|
|
|
|
}
|
|
|
|
);
|
2010-03-04 08:32:30 +01:00
|
|
|
}
|
2010-04-17 00:39:30 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Facet by Blank",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
2010-04-21 09:21:05 +02:00
|
|
|
"name" : self._column.name,
|
2010-04-17 00:39:30 +02:00
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "isBlank(value)"
|
|
|
|
}
|
|
|
|
);
|
2010-03-04 08:32:30 +01:00
|
|
|
}
|
2010-04-17 00:39:30 +02:00
|
|
|
}
|
|
|
|
]
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2010-04-17 00:39:30 +02:00
|
|
|
{
|
|
|
|
label: "Text Filter",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"text",
|
|
|
|
{
|
|
|
|
"name" : self._column.name,
|
|
|
|
"columnName" : self._column.name,
|
|
|
|
"mode" : "text",
|
|
|
|
"caseSensitive" : false
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2010-03-09 07:57:08 +01:00
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Edit Cells",
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: "Transform ...",
|
|
|
|
click: function() { self._doTextTransformPrompt(); }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Common Transforms",
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: "Unescape HTML entities",
|
|
|
|
click: function() { self._doTextTransform("value.unescape('html')", "store-blank", true, 10); }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Collapse whitespace",
|
|
|
|
click: function() { self._doTextTransform("value.replaceRegexp('\\s+', ' ')", "store-blank", false, ""); }
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "To Titlecase",
|
|
|
|
click: function() { self._doTextTransform("toTitlecase(value)", "store-blank", false, ""); }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "To Uppercase",
|
|
|
|
click: function() { self._doTextTransform("toUppercase(value)", "store-blank", false, ""); }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "To Lowercase",
|
|
|
|
click: function() { self._doTextTransform("toLowercase(value)", "store-blank", false, ""); }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Split Multi-Valued Cells ...",
|
|
|
|
click: function() { self._doSplitMultiValueCells(); }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Join Multi-Valued Cells ...",
|
|
|
|
click: function() { self._doJoinMultiValueCells(); }
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Cluster & Edit ...",
|
2010-03-13 10:32:06 +01:00
|
|
|
click: function() { new ClusteringDialog(self._column.name, "value"); }
|
2010-03-09 07:57:08 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Edit Column",
|
|
|
|
submenu: [
|
2010-04-21 01:08:14 +02:00
|
|
|
{
|
|
|
|
label: "Split into Several Columns",
|
|
|
|
click: function() { self._doSplitColumn(); }
|
|
|
|
},
|
2010-03-09 07:57:08 +01:00
|
|
|
{
|
|
|
|
label: "Add Column Based on This Column ...",
|
|
|
|
click: function() { self._doAddColumn("value"); }
|
|
|
|
},
|
2010-03-13 08:13:18 +01:00
|
|
|
{
|
|
|
|
label: "Add Columns From Freebase ...",
|
|
|
|
click: function() { self._doAddColumnFromFreebase(); }
|
|
|
|
},
|
|
|
|
{},
|
2010-04-06 09:15:34 +02:00
|
|
|
{
|
|
|
|
label: "Rename This Column",
|
|
|
|
click: function() { self._doRenameColumn(); }
|
|
|
|
},
|
2010-03-09 07:57:08 +01:00
|
|
|
{
|
|
|
|
label: "Remove This Column",
|
|
|
|
click: function() { self._doRemoveColumn(); }
|
2010-04-06 09:15:34 +02:00
|
|
|
}
|
2010-03-09 07:57:08 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{},
|
2010-05-21 06:11:08 +02:00
|
|
|
(
|
|
|
|
this._dataTableView._getSortingCriterionForColumn(this._column.name) == null ?
|
|
|
|
{
|
|
|
|
"label": "Sort ...",
|
|
|
|
"click": function() {
|
|
|
|
self._showSortingCriterion(null, self._dataTableView._getSortingCriteriaCount() > 0)
|
|
|
|
}
|
|
|
|
} :
|
|
|
|
{
|
|
|
|
label: "Sort",
|
|
|
|
submenu: this.createSortingMenu()
|
|
|
|
}
|
|
|
|
),
|
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() {
|
2010-03-10 08:12:09 +01:00
|
|
|
self._dataTableView._collapsedColumnNames[self._column.name] = true;
|
2010-02-09 20:23:11 +01:00
|
|
|
self._dataTableView.render();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Collapse All Other Columns",
|
|
|
|
click: function() {
|
2010-04-08 21:52:23 +02:00
|
|
|
var collapsedColumnNames = {};
|
2010-02-09 20:23:11 +01:00
|
|
|
for (var i = 0; i < theProject.columnModel.columns.length; i++) {
|
|
|
|
if (i != self._columnIndex) {
|
2010-03-10 08:12:09 +01:00
|
|
|
collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
|
|
|
}
|
2010-03-10 08:12:09 +01:00
|
|
|
self._dataTableView._collapsedColumnNames = collapsedColumnNames;
|
|
|
|
self._dataTableView.render();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Collapse All Columns To Left",
|
|
|
|
click: function() {
|
|
|
|
for (var i = 0; i < self._columnIndex; i++) {
|
|
|
|
self._dataTableView._collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
|
|
|
|
}
|
2010-02-09 20:23:11 +01:00
|
|
|
self._dataTableView.render();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Collapse All Columns To Right",
|
|
|
|
click: function() {
|
|
|
|
for (var i = self._columnIndex + 1; i < theProject.columnModel.columns.length; i++) {
|
2010-03-10 08:12:09 +01:00
|
|
|
self._dataTableView._collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
|
|
|
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-04-26 07:28:18 +02:00
|
|
|
label: "Facets",
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: "By Judgment",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : self._column.name,
|
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "cell.recon.judgment",
|
|
|
|
"omitError" : true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"scroll" : false
|
|
|
|
}
|
|
|
|
);
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
2010-04-26 07:28:18 +02:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Relevance Score",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name" : self._column.name,
|
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "cell.recon.best.score",
|
|
|
|
"mode" : "range"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
}
|
|
|
|
);
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
2010-04-26 07:28:18 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Type Match",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : self._column.name,
|
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "cell.recon.features.typeMatch",
|
|
|
|
"omitError" : true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"scroll" : false
|
|
|
|
}
|
|
|
|
);
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
2010-04-26 07:28:18 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Name Match",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : self._column.name,
|
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "cell.recon.features.nameMatch",
|
|
|
|
"omitError" : true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"scroll" : false
|
|
|
|
}
|
|
|
|
);
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
2010-04-26 07:28:18 +02:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Name Edit Distance",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name" : self._column.name,
|
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "cell.recon.features.nameLevenshtein",
|
|
|
|
"mode" : "range"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
}
|
|
|
|
);
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
2010-04-26 07:28:18 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Name Word Similarity",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name" : self._column.name,
|
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "cell.recon.features.nameWordDistance",
|
|
|
|
"mode" : "range"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
}
|
|
|
|
);
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
2010-04-26 07:28:18 +02:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Best Candidate's Types",
|
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name" : self._column.name,
|
|
|
|
"columnName" : self._column.name,
|
|
|
|
"expression" : "cell.recon.best.type",
|
|
|
|
"omitError" : true
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2010-02-09 20:23:11 +01:00
|
|
|
},
|
|
|
|
{
|
2010-04-26 07:28:18 +02:00
|
|
|
label: "Actions",
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: "Match Each Cell to Its Best Candidate",
|
|
|
|
tooltip: "Match each cell to its best candidate in this column for all current filtered rows",
|
|
|
|
click: function() {
|
|
|
|
self._doReconMatchBestCandidates();
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
2010-04-26 07:28:18 +02: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",
|
|
|
|
click: function() {
|
|
|
|
self._doReconMarkNewTopics(false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
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",
|
|
|
|
click: function() {
|
|
|
|
self._doReconMarkNewTopics(true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Match All Filtered Cells to ...",
|
|
|
|
tooltip: "Search for a topic to match all filtered cells to",
|
|
|
|
click: function() {
|
|
|
|
self._doSearchToMatch();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
label: "Discard Reconciliation Judgments",
|
|
|
|
tooltip: "Discard reconciliaton judgments in this column for all current filtered rows",
|
|
|
|
click: function() {
|
|
|
|
self._doReconDiscardJudgments();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2010-02-09 20:23:11 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
], elmt, { width: "120px", horizontal: false });
|
|
|
|
};
|
|
|
|
|
2010-05-21 02:48:36 +02:00
|
|
|
DataTableColumnHeaderUI.prototype.createSortingMenu = function() {
|
|
|
|
var self = this;
|
|
|
|
var criterion = this._dataTableView._getSortingCriterionForColumn(this._column.name);
|
|
|
|
var criteriaCount = this._dataTableView._getSortingCriteriaCount();
|
|
|
|
var hasOtherCriteria = criterion == null ? (criteriaCount > 0) : criteriaCount > 1;
|
|
|
|
|
|
|
|
var items = [
|
|
|
|
{
|
|
|
|
"label": "Sort ...",
|
|
|
|
"click": function() {
|
|
|
|
self._showSortingCriterion(criterion, hasOtherCriteria)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
if (criterion != null) {
|
|
|
|
items.push({
|
|
|
|
"label": "Reverse",
|
|
|
|
"click": function() {
|
|
|
|
criterion.reverse = !criterion.reverse;
|
|
|
|
self._dataTableView._addSortingCriterion(criterion);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
items.push({
|
|
|
|
"label": "Un-sort",
|
|
|
|
"click": function() {
|
|
|
|
self._dataTableView._removeSortingCriterionOfColumn(criterion.column);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return items;
|
|
|
|
};
|
|
|
|
|
2010-02-09 20:23:11 +01:00
|
|
|
DataTableColumnHeaderUI.prototype._doFilterByExpressionPrompt = function(expression, type) {
|
|
|
|
var self = this;
|
|
|
|
DataTableView.promptExpressionOnVisibleRows(
|
|
|
|
this._column,
|
2010-03-06 08:43:45 +01:00
|
|
|
(type == "list" ? "Custom Facet on column " : "Custom Numeric Facet on column") + this._column.name,
|
2010-02-09 20:23:11 +01:00
|
|
|
expression,
|
|
|
|
function(expression) {
|
|
|
|
var config = {
|
2010-04-21 09:21:05 +02:00
|
|
|
"name" : self._column.name,
|
2010-03-06 08:43:45 +01:00
|
|
|
"columnName" : self._column.name,
|
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-03-07 01:25:00 +01:00
|
|
|
"text-transform",
|
2010-03-04 01:00:46 +01:00
|
|
|
{
|
2010-03-06 08:43:45 +01:00
|
|
|
columnName: this._column.name,
|
2010-03-04 01:00:46 +01:00
|
|
|
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");
|
|
|
|
|
2010-03-06 08:43:45 +01:00
|
|
|
var header = $('<div></div>').addClass("dialog-header").text("Custom text transform on column " + this._column.name).appendTo(frame);
|
2010-03-03 23:12:48 +01:00
|
|
|
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-13 08:13:18 +01:00
|
|
|
'<div class="grid-layout layout-tight layout-full"><table>' +
|
2010-03-03 23:12:48 +01:00
|
|
|
'<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();
|
2010-04-08 21:52:23 +02:00
|
|
|
});
|
2010-03-03 23:12:48 +01:00
|
|
|
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(
|
2010-03-06 08:43:45 +01:00
|
|
|
"/command/guess-types-of-column?" + $.param({ project: theProject.id, columnName: this._column.name }),
|
2010-02-19 01:28:34 +01:00
|
|
|
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-04-08 22:16:08 +02:00
|
|
|
if (!ids.length) {
|
2010-03-02 19:19:20 +01:00
|
|
|
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-03-06 08:43:45 +01:00
|
|
|
{ columnName: this._column.name },
|
2010-02-26 22:56:41 +01:00
|
|
|
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-03-06 08:43:45 +01:00
|
|
|
{ columnName: this._column.name },
|
2010-02-26 22:56:41 +01:00
|
|
|
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-03-06 08:43:45 +01:00
|
|
|
{ columnName: this._column.name, shareNewTopics: shareNewTopics },
|
2010-02-26 22:56:41 +01:00
|
|
|
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-04-12 05:59:19 +02:00
|
|
|
var query = {
|
|
|
|
"id" : data.id,
|
|
|
|
"type" : []
|
|
|
|
};
|
|
|
|
var baseUrl = "http://api.freebase.com/api/service/mqlread";
|
|
|
|
var url = baseUrl + "?" + $.param({ query: JSON.stringify({ query: query }) }) + "&callback=?";
|
|
|
|
|
|
|
|
$.getJSON(
|
|
|
|
url,
|
2010-02-26 22:56:41 +01:00
|
|
|
null,
|
2010-04-12 05:59:19 +02:00
|
|
|
function(o) {
|
|
|
|
var types = "result" in o ? o.result.type : [];
|
|
|
|
|
|
|
|
Gridworks.postProcess(
|
|
|
|
"recon-match-specific-topic-to-cells",
|
|
|
|
{
|
|
|
|
columnName: self._column.name,
|
|
|
|
topicID: data.id,
|
|
|
|
topicGUID: data.guid,
|
|
|
|
topicName: data.name,
|
|
|
|
types: types.join(",")
|
|
|
|
},
|
|
|
|
null,
|
|
|
|
{ cellsChanged: true, columnStatsChanged: true }
|
|
|
|
);
|
2010-02-26 22:56:41 +01:00
|
|
|
|
2010-04-12 05:59:19 +02:00
|
|
|
DialogSystem.dismissUntil(level - 1);
|
|
|
|
}
|
|
|
|
);
|
2010-02-20 01:47:08 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$('<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");
|
|
|
|
|
2010-03-06 08:43:45 +01:00
|
|
|
var header = $('<div></div>').addClass("dialog-header").text("Add Column Based on Column " + this._column.name).appendTo(frame);
|
2010-03-04 01:12:39 +01:00
|
|
|
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
|
|
|
|
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
|
|
|
|
|
|
|
|
body.html(
|
2010-03-13 08:13:18 +01:00
|
|
|
'<div class="grid-layout layout-normal layout-full"><table cols="2">' +
|
2010-03-04 01:12:39 +01:00
|
|
|
'<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>' +
|
2010-03-13 08:13:18 +01:00
|
|
|
'</table></div>'
|
2010-03-04 01:12:39 +01:00
|
|
|
);
|
|
|
|
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);
|
2010-04-08 22:16:08 +02:00
|
|
|
if (!columnName.length) {
|
2010-03-04 01:12:39 +01:00
|
|
|
alert("You must enter a column name.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Gridworks.postProcess(
|
|
|
|
"add-column",
|
|
|
|
{
|
2010-03-06 08:43:45 +01:00
|
|
|
baseColumnName: self._column.name,
|
2010-03-04 01:12:39 +01:00
|
|
|
expression: previewWidget.getExpression(true),
|
2010-03-06 08:43:45 +01:00
|
|
|
newColumnName: 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();
|
2010-04-08 21:52:23 +02:00
|
|
|
});
|
2010-03-04 01:12:39 +01:00
|
|
|
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-13 08:13:18 +01:00
|
|
|
DataTableColumnHeaderUI.prototype._doAddColumnFromFreebase = function() {
|
2010-05-03 00:27:17 +02:00
|
|
|
var o = DataTableView.sampleVisibleRows(this._column);
|
|
|
|
var self = this;
|
|
|
|
new ExtendDataPreviewDialog(
|
|
|
|
this._column,
|
|
|
|
this._columnIndex,
|
|
|
|
o.rowIndices,
|
|
|
|
function(extension) {
|
|
|
|
Gridworks.postProcess(
|
|
|
|
"extend-data",
|
|
|
|
{
|
|
|
|
baseColumnName: self._column.name,
|
|
|
|
columnInsertIndex: self._columnIndex + 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
extension: JSON.stringify(extension)
|
|
|
|
},
|
|
|
|
{ rowsChanged: true, modelsChanged: true }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2010-03-13 08:13:18 +01:00
|
|
|
};
|
|
|
|
|
2010-02-09 20:23:11 +01:00
|
|
|
DataTableColumnHeaderUI.prototype._doRemoveColumn = function() {
|
2010-02-26 22:56:41 +01:00
|
|
|
Gridworks.postProcess(
|
|
|
|
"remove-column",
|
|
|
|
{
|
2010-03-06 08:43:45 +01:00
|
|
|
columnName: this._column.name
|
2010-02-26 22:56:41 +01:00
|
|
|
},
|
|
|
|
null,
|
|
|
|
{ modelsChanged: true }
|
2010-02-09 20:23:11 +01:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2010-04-06 09:15:34 +02:00
|
|
|
DataTableColumnHeaderUI.prototype._doRenameColumn = function() {
|
|
|
|
var newColumnName = window.prompt("Enter new column name", this._column.name);
|
2010-04-09 03:00:44 +02:00
|
|
|
if (newColumnName !== null) {
|
2010-04-06 09:15:34 +02:00
|
|
|
Gridworks.postProcess(
|
|
|
|
"rename-column",
|
|
|
|
{
|
|
|
|
oldColumnName: this._column.name,
|
|
|
|
newColumnName: newColumnName
|
|
|
|
},
|
|
|
|
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", ", ");
|
2010-04-09 03:00:44 +02:00
|
|
|
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-03-06 08:43:45 +01:00
|
|
|
columnName: this._column.name,
|
2010-02-17 01:26:38 +01:00
|
|
|
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-04-09 03:00:44 +02: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-03-06 08:43:45 +01:00
|
|
|
columnName: this._column.name,
|
2010-02-17 01:26:38 +01:00
|
|
|
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
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
2010-04-21 01:08:14 +02:00
|
|
|
|
|
|
|
DataTableColumnHeaderUI.prototype._doSplitColumn = function() {
|
|
|
|
var self = this;
|
|
|
|
var frame = DialogSystem.createDialog();
|
|
|
|
frame.width("600px");
|
|
|
|
|
|
|
|
var header = $('<div></div>').addClass("dialog-header").text("Split Column " + this._column.name + " into Several Columns").appendTo(frame);
|
|
|
|
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
|
|
|
|
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
|
|
|
|
|
|
|
|
body.html(
|
|
|
|
'<div class="grid-layout layout-looser layout-full"><table><tr>' +
|
|
|
|
'<td>' +
|
|
|
|
'<div class="grid-layout layout-tighter"><table>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td colspan="3"><h3>How to Split Column</h3></td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td width="1%"><input type="radio" checked="true" name="split-by-mode" value="separator" /></td>' +
|
|
|
|
'<td colspan="2">by separator</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr><td></td>' +
|
|
|
|
'<td>Separator</td>' +
|
|
|
|
'<td style="white-space: pre;">' +
|
|
|
|
'<input size="15" value="," bind="separatorInput" /> ' +
|
|
|
|
'<input type="checkbox" bind="regexInput" /> regular expression' +
|
|
|
|
'</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr><td></td>' +
|
|
|
|
'<td>Split into</td>' +
|
|
|
|
'<td style="white-space: pre;"><input size="3" bind="maxColumnsInput" /> ' +
|
|
|
|
'columns at most (leave blank for no limit)</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td width="1%"><input type="radio" name="split-by-mode" value="lengths" /></td>' +
|
|
|
|
'<td colspan="2">by field lengths</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr><td></td>' +
|
|
|
|
'<td colspan="2">' +
|
|
|
|
'<textarea style="width: 100%;" bind="lengthsTextarea"></textarea>' +
|
|
|
|
'</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr><td></td>' +
|
|
|
|
'<td colspan="2">' +
|
|
|
|
'List of integers separated by commas, e.g., 5, 7, 15' +
|
|
|
|
'</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'</table></div>' +
|
|
|
|
'</td>' +
|
|
|
|
'<td>' +
|
|
|
|
'<div class="grid-layout layout-tighter"><table>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td colspan="3"><h3>After Splitting</h3></td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td width="1%"><input type="checkbox" checked="true" bind="guessCellTypeInput" /></td>' +
|
|
|
|
'<td colspan="2">Guess cell type</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td width="1%"><input type="checkbox" checked="true" bind="removeColumnInput" /></td>' +
|
|
|
|
'<td colspan="2">Remove this column</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'</table></div>' +
|
|
|
|
'</td>' +
|
|
|
|
'</table></div>'
|
|
|
|
);
|
|
|
|
var bodyElmts = DOM.bind(body);
|
|
|
|
|
|
|
|
footer.html(
|
|
|
|
'<button bind="okButton"> OK </button>' +
|
|
|
|
'<button bind="cancelButton">Cancel</button>'
|
|
|
|
);
|
|
|
|
var footerElmts = DOM.bind(footer);
|
|
|
|
|
|
|
|
var level = DialogSystem.showDialog(frame);
|
|
|
|
var dismiss = function() {
|
|
|
|
DialogSystem.dismissUntil(level - 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
footerElmts.okButton.click(function() {
|
|
|
|
var mode = $("input[name='split-by-mode']:checked")[0].value;
|
|
|
|
var config = {
|
|
|
|
columnName: self._column.name,
|
|
|
|
mode: mode,
|
|
|
|
guessCellType: bodyElmts.guessCellTypeInput[0].checked,
|
|
|
|
removeOriginalColumn: bodyElmts.removeColumnInput[0].checked
|
|
|
|
};
|
|
|
|
if (mode == "separator") {
|
|
|
|
config.separator = bodyElmts.separatorInput[0].value;
|
|
|
|
if (!(config.separator)) {
|
|
|
|
alert("Please specify a separator.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
config.regex = bodyElmts.regexInput[0].checked;
|
|
|
|
|
|
|
|
var s = bodyElmts.maxColumnsInput[0].value;
|
|
|
|
if (s) {
|
2010-05-05 02:26:26 +02:00
|
|
|
var n = parseInt(s,10);
|
2010-04-21 01:08:14 +02:00
|
|
|
if (!isNaN(n)) {
|
|
|
|
config.maxColumns = n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var s = "[" + bodyElmts.lengthsTextarea[0].value + "]";
|
|
|
|
try {
|
|
|
|
var a = JSON.parse(s);
|
|
|
|
} catch (e) {
|
|
|
|
alert("The given field lengths are not properly formatted.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var lengths = [];
|
|
|
|
$.each(a, function(i,n) { if (typeof n == "number") lengths.push(n); });
|
|
|
|
|
2010-05-05 02:26:26 +02:00
|
|
|
if (lengths.length === 0) {
|
2010-04-21 01:08:14 +02:00
|
|
|
alert("No field length is specified.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
config.fieldLengths = JSON.stringify(lengths);
|
|
|
|
}
|
|
|
|
|
|
|
|
Gridworks.postProcess(
|
|
|
|
"split-column",
|
|
|
|
config,
|
|
|
|
null,
|
|
|
|
{ modelsChanged: true }
|
|
|
|
);
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
footerElmts.cancelButton.click(dismiss);
|
|
|
|
};
|
2010-05-21 02:48:36 +02:00
|
|
|
|
|
|
|
DataTableColumnHeaderUI.prototype._showSortingCriterion = function(criterion, hasOtherCriteria) {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
criterion = criterion || {
|
|
|
|
column: this._column.name,
|
|
|
|
valueType: "string",
|
|
|
|
caseSensitive: false,
|
|
|
|
errorPosition: 1,
|
|
|
|
blankPosition: 2
|
|
|
|
};
|
|
|
|
|
|
|
|
var frame = DialogSystem.createDialog();
|
|
|
|
frame.width("400px");
|
|
|
|
|
|
|
|
var header = $('<div></div>').addClass("dialog-header").text("Sort by " + this._column.name).appendTo(frame);
|
|
|
|
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
|
|
|
|
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
|
|
|
|
|
|
|
|
body.html(
|
|
|
|
'<div class="grid-layout layout-normal layout-full "><table>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td>Sort cell values as</td>' +
|
|
|
|
'<td>Position blanks and errors</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td>' +
|
|
|
|
'<div class="grid-layout layout-tightest grid-layout-for-text" bind="valueTypeOptions"><table>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td width="1"><input type="radio" name="sorting-dialog-value-type" value="string" /></td>' +
|
|
|
|
'<td>text <input type="checkbox" class="inline" bind="caseSensitiveCheckbox" /> case-sensitive</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td width="1"><input type="radio" name="sorting-dialog-value-type" value="number" /></td>' +
|
|
|
|
'<td>numbers</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td width="1"><input type="radio" name="sorting-dialog-value-type" value="date" /></td>' +
|
|
|
|
'<td>dates</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td width="1"><input type="radio" name="sorting-dialog-value-type" value="boolean" /></td>' +
|
|
|
|
'<td>booleans</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'</table></div>' +
|
|
|
|
'</td>' +
|
|
|
|
'<td>' +
|
2010-05-21 06:46:36 +02:00
|
|
|
'<ul class="sorting-dialog-blank-error-positions" bind="blankErrorPositions"></ul>' +
|
2010-05-21 02:48:36 +02:00
|
|
|
'<p>Drag and drop to re-order</p>' +
|
|
|
|
'</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'<tr><td colspan="2" bind="directionOptions">' +
|
2010-05-21 06:11:08 +02:00
|
|
|
'<input type="radio" class="inline" name="sorting-dialog-direction" value="forward" /><label id="sorting-dialog-direction-forward">forward</label> ' +
|
|
|
|
'<input type="radio" class="inline" name="sorting-dialog-direction" value="reverse" /><label id="sorting-dialog-direction-reverse">reverse</label> ' +
|
2010-05-21 02:48:36 +02:00
|
|
|
'<span bind="sortAloneContainer" style="display:none;"><input type="checkbox" class="inline" /><label>sort by this column alone</label></span>' +
|
|
|
|
'</td></tr>' +
|
|
|
|
'</table></div>'
|
|
|
|
);
|
|
|
|
|
|
|
|
var bodyElmts = DOM.bind(body);
|
|
|
|
|
|
|
|
bodyElmts.valueTypeOptions.find("input[type='radio'][value='" + criterion.valueType + "']")
|
|
|
|
.attr("checked", "checked");
|
|
|
|
|
2010-05-21 06:11:08 +02:00
|
|
|
var setValueType = function(valueType) {
|
|
|
|
var forward = $("#sorting-dialog-direction-forward");
|
|
|
|
var reverse = $("#sorting-dialog-direction-reverse");
|
|
|
|
if (valueType == "string") {
|
|
|
|
forward.html("a - z");
|
|
|
|
reverse.html("z - a");
|
|
|
|
} else if (valueType == "number") {
|
|
|
|
forward.html("smallest first");
|
|
|
|
reverse.html("largest first");
|
|
|
|
} else if (valueType == "date") {
|
|
|
|
forward.html("earliest first");
|
|
|
|
reverse.html("latest first");
|
|
|
|
} else if (valueType == "boolean") {
|
|
|
|
forward.html("false then true");
|
|
|
|
reverse.html("true then false");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
bodyElmts.valueTypeOptions.find("input[type='radio']").change(function() {
|
|
|
|
setValueType(this.value);
|
|
|
|
});
|
|
|
|
|
2010-05-21 02:48:36 +02:00
|
|
|
if (criterion.valueType == "string" && criterion.caseSensitive) {
|
|
|
|
bodyElmts.caseSensitiveCheckbox.attr("checked", "checked");
|
|
|
|
}
|
|
|
|
|
|
|
|
bodyElmts.directionOptions.find("input[type='radio'][value='" + (criterion.reverse ? "reverse" : "forward") + "']")
|
|
|
|
.attr("checked", "checked");
|
|
|
|
|
|
|
|
if (hasOtherCriteria) {
|
|
|
|
bodyElmts.sortAloneContainer.show();
|
|
|
|
}
|
|
|
|
|
2010-05-21 06:46:36 +02:00
|
|
|
var validValuesHtml = '<li kind="value">Valid Values</li>';
|
|
|
|
var blankValuesHtml = '<li kind="blank">Blanks</li>';
|
|
|
|
var errorValuesHtml = '<li kind="error">Errors</li>';
|
|
|
|
var positionsHtml;
|
|
|
|
if (criterion.blankPosition < 0) {
|
|
|
|
if (criterion.errorPosition > 0) {
|
|
|
|
positionsHtml = [ blankValuesHtml, validValuesHtml, errorValuesHtml ];
|
|
|
|
} else if (criterion.errorPosition < criterion.blankPosition) {
|
|
|
|
positionsHtml = [ errorValuesHtml, blankValuesHtml, validValuesHtml ];
|
|
|
|
} else {
|
|
|
|
positionsHtml = [ blankValuesHtml, errorValuesHtml, validValuesHtml ];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (criterion.errorPosition < 0) {
|
|
|
|
positionsHtml = [ errorValuesHtml, validValuesHtml, blankValuesHtml ];
|
|
|
|
} else if (criterion.errorPosition < criterion.blankPosition) {
|
|
|
|
positionsHtml = [ validValuesHtml, errorValuesHtml, blankValuesHtml ];
|
|
|
|
} else {
|
|
|
|
positionsHtml = [ validValuesHtml, blankValuesHtml, errorValuesHtml ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bodyElmts.blankErrorPositions.html(positionsHtml.join("")).sortable().disableSelection();
|
|
|
|
|
2010-05-21 02:48:36 +02:00
|
|
|
footer.html(
|
|
|
|
'<button bind="okButton"> OK </button>' +
|
|
|
|
'<button bind="cancelButton">Cancel</button>'
|
|
|
|
);
|
|
|
|
var footerElmts = DOM.bind(footer);
|
|
|
|
|
|
|
|
var level = DialogSystem.showDialog(frame);
|
|
|
|
var dismiss = function() {
|
|
|
|
DialogSystem.dismissUntil(level - 1);
|
|
|
|
};
|
|
|
|
|
2010-05-21 06:11:08 +02:00
|
|
|
setValueType(criterion.valueType);
|
|
|
|
|
2010-05-21 02:48:36 +02:00
|
|
|
footerElmts.cancelButton.click(dismiss);
|
|
|
|
footerElmts.okButton.click(function() {
|
|
|
|
var criterion2 = {
|
|
|
|
column: self._column.name,
|
|
|
|
valueType: bodyElmts.valueTypeOptions.find("input[type='radio']:checked")[0].value,
|
|
|
|
reverse: bodyElmts.directionOptions.find("input[type='radio']:checked")[0].value == "reverse"
|
|
|
|
};
|
|
|
|
|
2010-05-21 06:46:36 +02:00
|
|
|
var valuePosition, blankPosition, errorPosition;
|
|
|
|
bodyElmts.blankErrorPositions.find("li").each(function(index, elmt) {
|
|
|
|
var kind = this.getAttribute("kind");
|
|
|
|
if (kind == "value") {
|
|
|
|
valuePosition = index;
|
|
|
|
} else if (kind == "blank") {
|
|
|
|
blankPosition = index;
|
|
|
|
} else if (kind == "error") {
|
|
|
|
errorPosition = index;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
criterion2.blankPosition = blankPosition - valuePosition;
|
|
|
|
criterion2.errorPosition = errorPosition - valuePosition;
|
|
|
|
|
2010-05-21 02:48:36 +02:00
|
|
|
if (criterion2.valueType == "string") {
|
|
|
|
criterion2.caseSensitive = bodyElmts.caseSensitiveCheckbox[0].checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
self._dataTableView._addSortingCriterion(
|
|
|
|
criterion2, bodyElmts.sortAloneContainer.find("input")[0].checked);
|
|
|
|
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
};
|