automatically update dropdown label when setting items

pull/125/merge
nightwing 2017-04-11 15:49:57 +04:00
rodzic f349a97928
commit 6f2c99ae3e
2 zmienionych plików z 5 dodań i 16 usunięć

Wyświetl plik

@ -203,9 +203,7 @@ define(function(require, exports, module) {
value: options.path value: options.path
? settings.get(options.path) ? settings.get(options.path)
: (options.defaultValue || ""), : (options.defaultValue || ""),
// each: options.each || "item",
caption: options.caption, caption: options.caption,
// eachvalue: options.eachvalue || "value",
"empty-message": options["empty-message"] "empty-message": options["empty-message"]
}) })
]; ];
@ -458,16 +456,11 @@ define(function(require, exports, module) {
case "dropdown": case "dropdown":
var dropdown = el.lastChild; var dropdown = el.lastChild;
if (item.items) { if (item.items)
dropdown.setChildren(item.items); dropdown.setChildren(item.items);
var value = item.value || dropdown.value; if (item.value != null)
dropdown.value = -999;
dropdown.setAttribute("value", value);
}
else if (item.value) {
dropdown.setAttribute("value", item.value); dropdown.setAttribute("value", item.value);
}
break; break;
default: default:
// supported attributes // supported attributes

Wyświetl plik

@ -328,6 +328,7 @@ apf.dropdown = function(struct, tagName) {
return; return;
} }
} }
this.$setLabel(String(value));
}; };
function isValueEqual(v1, v2) { function isValueEqual(v1, v2) {
@ -469,7 +470,6 @@ apf.dropdown = function(struct, tagName) {
this.$setLabel = function(value) { this.$setLabel = function(value) {
this.oLabel.innerHTML = value || this["initial-message"] || ""; this.oLabel.innerHTML = value || this["initial-message"] || "";
this.$setStyleClass(this.$ext, value ? "" : this.$baseCSSname + "Initial", this.$setStyleClass(this.$ext, value ? "" : this.$baseCSSname + "Initial",
!value ? [] : [this.$baseCSSname + "Initial"]); !value ? [] : [this.$baseCSSname + "Initial"]);
}; };
@ -477,17 +477,12 @@ apf.dropdown = function(struct, tagName) {
// Private functions // Private functions
this.$blur = function() { this.$blur = function() {
this.slideUp(); this.slideUp();
//this.$ext.dispatchEvent("mouseout")
if (!this.isOpen) if (!this.isOpen)
this.$setStyleClass(this.$ext, "", [this.$baseCSSname + "Over"]) this.$setStyleClass(this.$ext, "", [this.$baseCSSname + "Over"]);
this.$setStyleClass(this.$ext, "", [this.$baseCSSname + "Focus"]); this.$setStyleClass(this.$ext, "", [this.$baseCSSname + "Focus"]);
}; };
/*this.$focus = function(){
apf.popup.forceHide();
this.$setStyleClass(this.oFocus || this.$ext, this.$baseCSSname + "Focus");
}*/
this.$setClearMessage = function(msg) { this.$setClearMessage = function(msg) {
this.$setLabel(msg); this.$setLabel(msg);
@ -504,6 +499,7 @@ apf.dropdown = function(struct, tagName) {
this.items = data; this.items = data;
if (this.isOpen) if (this.isOpen)
this.$updateChildren(); this.$updateChildren();
this.$propHandlers["value"].call(this, this.value);
}; };
this.change = this.change =