|
|
@ -12,6 +12,7 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { |
|
|
|
text: "", |
|
|
|
text: "", |
|
|
|
items: [], |
|
|
|
items: [], |
|
|
|
value: "", |
|
|
|
value: "", |
|
|
|
|
|
|
|
allowClear: false, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -26,9 +27,15 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { |
|
|
|
text: o.text, |
|
|
|
text: o.text, |
|
|
|
height: o.height, |
|
|
|
height: o.height, |
|
|
|
items: o.items, |
|
|
|
items: o.items, |
|
|
|
value: o.value |
|
|
|
value: o.value, |
|
|
|
|
|
|
|
allowClear: o.allowClear, |
|
|
|
|
|
|
|
warningTitle: o.warningTitle, |
|
|
|
}, o.trigger)); |
|
|
|
}, o.trigger)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.trigger.on(BI.SingleTreeTrigger.EVENT_CLEAR, function () { |
|
|
|
|
|
|
|
self._clear(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.popup = BI.createWidget({ |
|
|
|
this.popup = BI.createWidget({ |
|
|
|
type: "bi.single_level_tree", |
|
|
|
type: "bi.single_level_tree", |
|
|
|
items: o.items, |
|
|
|
items: o.items, |
|
|
@ -58,6 +65,36 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { |
|
|
|
self.combo.hideView(); |
|
|
|
self.combo.hideView(); |
|
|
|
self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); |
|
|
|
self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (BI.isKey(o.value)) { |
|
|
|
|
|
|
|
this._checkError(o.value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_checkError: function (v) { |
|
|
|
|
|
|
|
if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { |
|
|
|
|
|
|
|
this.trigger.options.tipType = "success"; |
|
|
|
|
|
|
|
this.trigger.element.removeClass("error"); |
|
|
|
|
|
|
|
this.element.removeClass("error"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
v = BI.isArray(v) ? v : [v]; |
|
|
|
|
|
|
|
var result = BI.find(this.options.items, function (idx, item) { |
|
|
|
|
|
|
|
return BI.contains(v, item.value); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (BI.isNull(result)) { |
|
|
|
|
|
|
|
this.trigger.setTipType("warning"); |
|
|
|
|
|
|
|
this.element.removeClass("error").addClass("error"); |
|
|
|
|
|
|
|
this.trigger.element.removeClass("error").addClass("error"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.trigger.setTipType("success"); |
|
|
|
|
|
|
|
this.trigger.element.removeClass("error"); |
|
|
|
|
|
|
|
this.element.removeClass("error"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_clear: function () { |
|
|
|
|
|
|
|
this.setValue([]); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
populate: function (items) { |
|
|
|
populate: function (items) { |
|
|
@ -68,6 +105,7 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { |
|
|
|
v = BI.isArray(v) ? v : [v]; |
|
|
|
v = BI.isArray(v) ? v : [v]; |
|
|
|
this.trigger.setValue(v); |
|
|
|
this.trigger.setValue(v); |
|
|
|
this.popup.setValue(v); |
|
|
|
this.popup.setValue(v); |
|
|
|
|
|
|
|
this._checkError(v); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
getValue: function () { |
|
|
|
getValue: function () { |
|
|
@ -77,4 +115,4 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { |
|
|
|
|
|
|
|
|
|
|
|
BI.SingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
BI.SingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
|
|
|
BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
|
|
|
BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo); |
|
|
|
BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo); |
|
|
|