diff --git a/build.xml b/build.xml index c28735358..2e566cc9a 100644 --- a/build.xml +++ b/build.xml @@ -14,6 +14,7 @@ + diff --git a/src/main/webapp/scripts/project/schema-alignment.js b/src/main/webapp/scripts/project/schema-alignment.js index a0f1b7845..0c5ef5f6f 100644 --- a/src/main/webapp/scripts/project/schema-alignment.js +++ b/src/main/webapp/scripts/project/schema-alignment.js @@ -205,7 +205,11 @@ SchemaAlignmentDialog.UINode.prototype._renderMain = function() { .addClass("schema-alignment-node-tag") .appendTo(this._tdMain) .click(function(evt) { - self._showTagMenu(this); + if (self._options.mustBeCellTopic) { + self._showTagMenu(this); + } else { + self._showTagDialog(); + } }); if (this._node.nodeType == "cell-as-topic" || this._node.nodeType == "cell-as-value") { @@ -217,7 +221,7 @@ SchemaAlignmentDialog.UINode.prototype._renderMain = function() { .addClass("schema-alignment-node-column") .prependTo(a); } else { - a.html("Which column?"); + a.html(this._options.mustBeCellTopic ? "Which column?" : "Configure..."); } } else if (this._node.nodeType == "topic") { if ("topic" in this._node) { @@ -371,6 +375,103 @@ SchemaAlignmentDialog.UINode.prototype._showTagMenu = function(elmt) { MenuSystem.createAndShowStandardMenu(menu, elmt); }; +SchemaAlignmentDialog.UINode.prototype._showTagDialog = function() { + var self = this; + var frame = DialogSystem.createDialog(); + + frame.width("800px"); + + var header = $('
').addClass("dialog-header").text("Protograph Node").appendTo(frame); + var body = $('
').addClass("dialog-body").appendTo(frame); + var footer = $('
').addClass("dialog-footer").appendTo(frame); + + /* + * Body + */ + + var table = $('
') + .attr("width", "100%") + .attr("cellspacing", "10") + .attr("cellpadding", "0") + .appendTo(body)[0]; + + var tr0 = table.insertRow(0); + var tr1 = table.insertRow(1); + + var tdTop = tr0.insertCell(0); + var tdRightColumn = tr0.insertCell(1); + var tdLeftColumn = tr1.insertCell(0); + var tdMiddleColumn = tr1.insertCell(1); + + $(tdTop).attr("colspan", "2"); + $(tdRightColumn).attr("rowspan", "2"); + + var makeNodeTypeChoice = function(label, value, checked, parent) { + var heading = $('

').appendTo(parent); + + var radio = $('') + .attr("type", "radio") + .attr("value", value) + .attr("name", "schema-align-node-dialog-node-type") + .appendTo(heading); + + if (checked) { + radio.attr("checked", "true"); + } + + $('').text(label).appendTo(heading); + }; + + makeNodeTypeChoice("Set to Cell in Column", "cell-as-topic", this._node.nodeType == "cell-as-value" || this._node.nodeType == "cell-as-topic", tdTop); + + var divColumns = $('
') + .addClass("schema-alignment-node-dialog-column-list") + .appendTo(tdLeftColumn); + + var makeColumnChoice = function(column) { + var div = $('
') + .addClass("schema-alignment-node-dialog-column-choice") + .appendTo(divColumns); + + var radio = $('') + .attr("type", "radio") + .attr("value", column.cellIndex) + .attr("name", "schema-align-node-dialog-column") + .appendTo(div); + + if (column.cellIndex == self._node.cellIndex) { + radio.attr("checked", "true"); + } + + $('').text(column.headerLabel).appendTo(div); + }; + var columns = theProject.columnModel.columns; + for (var i = 0; i < columns.length; i++) { + makeColumnChoice(columns[i]); + } + + makeNodeTypeChoice("Set to Anonymous Node", "anonymous", this._node.nodeType == "anonymous", tdRightColumn); + makeNodeTypeChoice("Set to Freebase Topic", "topic", this._node.nodeType == "topic", tdRightColumn); + makeNodeTypeChoice("Set to Value", "value", this._node.nodeType == "value", tdRightColumn); + + /* + * Footer + */ + + $('').html("  OK  ").click(function() { + DialogSystem.dismissUntil(level - 1); + self._onDone(self._getNewProtograph()); + }).appendTo(footer); + + $('').text("Cancel").click(function() { + DialogSystem.dismissUntil(level - 1); + }).appendTo(footer); + + var level = DialogSystem.showDialog(frame); +}; + + + /*---------------------------------------------------------------------- * UILink *---------------------------------------------------------------------- diff --git a/src/main/webapp/styles/schema-alignment-dialog.css b/src/main/webapp/styles/schema-alignment-dialog.css index 2a165970c..e326b2313 100644 --- a/src/main/webapp/styles/schema-alignment-dialog.css +++ b/src/main/webapp/styles/schema-alignment-dialog.css @@ -63,3 +63,13 @@ a.schema-alignment-link-tag { a.schema-alignment-link-tag:hover { color: #88f; } + +.schema-alignment-node-dialog-column-list { + height: 300px; + overflow: auto; + border: 1px solid #aaa; + padding: 2px; +} +.schema-alignment-node-dialog-column-choice { + margin: 5px; +} \ No newline at end of file