Added custom dialog box for create column operation (with a field for the new column name).
git-svn-id: http://google-refine.googlecode.com/svn/trunk@180 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
2fe8f98e4e
commit
5a0a8bea4f
@ -136,7 +136,7 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
|
|||||||
ExpressionUtils.bind(bindings, row, rowIndex, cell);
|
ExpressionUtils.bind(bindings, row, rowIndex, cell);
|
||||||
|
|
||||||
Object v = eval.evaluate(bindings);
|
Object v = eval.evaluate(bindings);
|
||||||
if (v != null) {
|
if (ExpressionUtils.isNonBlankData(v)) {
|
||||||
Cell newCell = new Cell(v, null);
|
Cell newCell = new Cell(v, null);
|
||||||
|
|
||||||
cellsAtRows.add(new CellAtRow(rowIndex, newCell));
|
cellsAtRows.add(new CellAtRow(rowIndex, newCell));
|
||||||
|
@ -605,26 +605,70 @@ DataTableColumnHeaderUI.prototype._doSearchToMatch = function() {
|
|||||||
|
|
||||||
DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
|
DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
|
||||||
var self = this;
|
var self = this;
|
||||||
DataTableView.promptExpressionOnVisibleRows(
|
var frame = DialogSystem.createDialog();
|
||||||
this._column,
|
frame.width("700px");
|
||||||
"Add Column Based on Column " + this._column.headerLabel,
|
|
||||||
initialExpression,
|
var header = $('<div></div>').addClass("dialog-header").text("Add Column Based on Column " + this._column.headerLabel).appendTo(frame);
|
||||||
function(expression) {
|
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
|
||||||
var headerLabel = window.prompt("Enter header label for new column:");
|
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
|
||||||
if (headerLabel != null) {
|
|
||||||
|
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>' +
|
||||||
|
'<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>'
|
||||||
|
);
|
||||||
|
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(
|
Gridworks.postProcess(
|
||||||
"add-column",
|
"add-column",
|
||||||
{
|
{
|
||||||
baseColumnName: self._column.headerLabel,
|
baseColumnName: self._column.headerLabel,
|
||||||
expression: expression,
|
expression: previewWidget.getExpression(true),
|
||||||
headerLabel: headerLabel,
|
headerLabel: columnName,
|
||||||
columnInsertIndex: self._columnIndex + 1
|
columnInsertIndex: self._columnIndex + 1
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
{ modelsChanged: true }
|
{ 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"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user