Skip to content

Commit

Permalink
Merge branch 'fix-editable-option'
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoisset committed Mar 2, 2015
2 parents 4a39e30 + fc320db commit 0496587
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/js/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1756,17 +1756,20 @@ define(['./appendNodeFactory', './util'], function (appendNodeFactory, util) {
domValue.innerHTML = '';
var valueLabel = this.value?this.value.getLabel():'';
for (var i = 0; i < this.type.getChildren().length; i++) {
var option = document.createElement('option')
var option = document.createElement('option');
option.innerHTML = this.type.getChildren()[i].getLabel();
option.setAttribute('value', this.type.getChildren()[i].getLabel());
domValue.appendChild(option);
}
domValue.value = valueLabel;
if (!this.editable.value) {
domValue.setAttribute('disabled', true);
}
}
else if (this.type.getType() == 'Anything') {
domValue.innerHTML = '';
function addOption(optionName) {
var option = document.createElement('option')
var option = document.createElement('option');
option.innerHTML = optionName;
option.setAttribute('value', optionName);
domValue.appendChild(option);
Expand All @@ -1786,6 +1789,9 @@ define(['./appendNodeFactory', './util'], function (appendNodeFactory, util) {
var valueType = this.value?this.value.getLabel():'';
}
domValue.value = valueType;
if (!this.editable.value) {
domValue.setAttribute('disabled', true);
}
}
else {
domValue.innerHTML = this._escapeHTML(this.value);
Expand Down Expand Up @@ -2739,8 +2745,8 @@ define(['./appendNodeFactory', './util'], function (appendNodeFactory, util) {
Node.prototype._isRemovable = function () {
if (this.parent) {
var ptype = this.parent.type.getType();
return (ptype === "List") || (ptype === "Dict");
};
return this.editable.value && (ptype === "List") || (ptype === "Dict");
}
return false
};

Expand Down
3 changes: 2 additions & 1 deletion src/js/appendNodeFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ define(['./util'], function (util) {
* @return {boolean} isVisible
*/
AppendNode.prototype.isVisible = function () {
return this.parent.type.getType() == 'List' || this.parent.type.getType() == 'Dict';
return this.editable.value &&
(this.parent.type.getType() == 'List' || this.parent.type.getType() == 'Dict');
};

/**
Expand Down

0 comments on commit 0496587

Please sign in to comment.