Fix UI for quantity values

This commit is contained in:
Antonin Delpeuch 2018-03-16 11:52:44 +00:00
parent 9583053b1b
commit 7ded62d78e

View File

@ -715,10 +715,13 @@ SchemaAlignmentDialog._initField = function(inputContainer, mode, initialValue,
var unitValue = null; var unitValue = null;
if (initialValue) { if (initialValue) {
amountValue = initialValue.amount; amountValue = initialValue.amount;
unitValue = initalValue.unit; unitValue = initialValue.unit;
} }
var propagateValue = function() { var propagateValue = function() {
console.log('quantity changed callback');
console.log('unit jsonValue is');
console.log(inputContainerUnit.data("jsonValue"));
inputContainer.data("jsonValue", { inputContainer.data("jsonValue", {
type: "wbquantityexpr", type: "wbquantityexpr",
amount: inputContainerAmount.data("jsonValue"), amount: inputContainerAmount.data("jsonValue"),
@ -769,6 +772,7 @@ SchemaAlignmentDialog._initField = function(inputContainer, mode, initialValue,
var acceptDraggableColumn = function(column) { var acceptDraggableColumn = function(column) {
input.hide(); input.hide();
input.val("");
var columnDiv = $('<div></div>').appendTo(inputContainer); var columnDiv = $('<div></div>').appendTo(inputContainer);
column.appendTo(columnDiv); column.appendTo(columnDiv);
var origText = column.text(); var origText = column.text();
@ -779,6 +783,7 @@ SchemaAlignmentDialog._initField = function(inputContainer, mode, initialValue,
deleteButton.click(function () { deleteButton.click(function () {
columnDiv.remove(); columnDiv.remove();
input.show(); input.show();
inputContainer.data("jsonValue", null);
changedCallback(); changedCallback();
}); });
}; };
@ -786,14 +791,14 @@ SchemaAlignmentDialog._initField = function(inputContainer, mode, initialValue,
// Make it droppable // Make it droppable
var acceptClass = ".wbs-draggable-column"; var acceptClass = ".wbs-draggable-column";
var wbVariableType = "wbstringvariable"; var wbVariableType = "wbstringvariable";
if (mode === "wikibase-item") { if (mode === "wikibase-item" || mode === "unit") {
acceptClass = ".wbs-reconciled-column"; acceptClass = ".wbs-reconciled-column";
wbVariableType = "wbitemvariable"; wbVariableType = "wbitemvariable";
} else if (mode === "time") { } else if (mode === "time") {
wbVariableType = "wbdatevariable"; wbVariableType = "wbdatevariable";
} else if (mode === "globe-coordinate") { } else if (mode === "globe-coordinate") {
wbVariableType = "wblocationvariable"; wbVariableType = "wblocationvariable";
} else if (mode === "monolingualtext") { } else if (mode === "monolingualtext" || mode === "quantity") {
wbVariableType = null; // not droppable directly wbVariableType = null; // not droppable directly
} else if (mode === "language") { } else if (mode === "language") {
wbVariableType = "wblanguagevariable"; wbVariableType = "wblanguagevariable";