|
|
|
@ -6,33 +6,93 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
|
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_init: function () { |
|
|
|
|
BI.TextValueComboPopup.superclass._init.apply(this, arguments); |
|
|
|
|
render () { |
|
|
|
|
var o = this.options, self = this; |
|
|
|
|
this.popup = BI.createWidget({ |
|
|
|
|
type: "bi.button_group", |
|
|
|
|
items: this._formatItems(o.items), |
|
|
|
|
chooseType: o.chooseType, |
|
|
|
|
layouts: [{ |
|
|
|
|
type: "bi.vertical" |
|
|
|
|
}], |
|
|
|
|
value: o.value |
|
|
|
|
}); |
|
|
|
|
if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) { |
|
|
|
|
return { |
|
|
|
|
type: "bi.vertical", |
|
|
|
|
vgap: 5, |
|
|
|
|
items: [{ |
|
|
|
|
type: "bi.button_group", |
|
|
|
|
ref: (_ref) => { |
|
|
|
|
this.popup = _ref; |
|
|
|
|
}, |
|
|
|
|
items: this._formatItems(o.items), |
|
|
|
|
chooseType: o.chooseType, |
|
|
|
|
layouts: [{ |
|
|
|
|
type: "bi.vertical" |
|
|
|
|
}], |
|
|
|
|
value: o.value, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.Controller.EVENT_CHANGE, |
|
|
|
|
action: function (type, val, obj) { |
|
|
|
|
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
|
|
|
|
if (type === BI.Events.CLICK) { |
|
|
|
|
self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}] |
|
|
|
|
}] |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
return { |
|
|
|
|
type: "bi.vertical", |
|
|
|
|
verticalAlign: BI.VerticalAlign.Stretch, |
|
|
|
|
rowSize: ["fill", ""], |
|
|
|
|
items: [{ |
|
|
|
|
type: "bi.select_list", |
|
|
|
|
logic: { |
|
|
|
|
dynamic: true, |
|
|
|
|
innerVgap: 5, |
|
|
|
|
rowSize: ["", "fill"], |
|
|
|
|
verticalAlign: BI.VerticalAlign.Stretch |
|
|
|
|
}, |
|
|
|
|
ref: (_ref) => { |
|
|
|
|
this.popup = _ref; |
|
|
|
|
}, |
|
|
|
|
el: { |
|
|
|
|
el: { |
|
|
|
|
chooseType: o.chooseType |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
items: this._formatItems(o.items), |
|
|
|
|
value: { |
|
|
|
|
type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, |
|
|
|
|
value: o.value |
|
|
|
|
}, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.SelectList.EVENT_CHANGE, |
|
|
|
|
action: function (val) { |
|
|
|
|
self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); |
|
|
|
|
} |
|
|
|
|
}] |
|
|
|
|
}, { |
|
|
|
|
type: "bi.center", |
|
|
|
|
cls: "list-view-toolbar bi-high-light bi-split-top", |
|
|
|
|
height: 24, |
|
|
|
|
items: BI.createItems([{ |
|
|
|
|
type: "bi.text_button", |
|
|
|
|
text: BI.i18nText("BI-Basic_Clears"), |
|
|
|
|
handler: function () { |
|
|
|
|
self.fireEvent(BI.TextValueComboPopup.EVENT_CLEAR); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
type: "bi.text_button", |
|
|
|
|
text: BI.i18nText("BI-Basic_OK"), |
|
|
|
|
handler: function () { |
|
|
|
|
self.fireEvent(BI.TextValueComboPopup.EVENT_CONFIRM); |
|
|
|
|
} |
|
|
|
|
}], { |
|
|
|
|
once: false, |
|
|
|
|
shadow: true, |
|
|
|
|
isShadowShowingOnSelected: true |
|
|
|
|
}) |
|
|
|
|
}] |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { |
|
|
|
|
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
|
|
|
|
if (type === BI.Events.CLICK) { |
|
|
|
|
self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
mounted: function () { |
|
|
|
|
this.check(); |
|
|
|
|
|
|
|
|
|
BI.createWidget({ |
|
|
|
|
type: "bi.vertical", |
|
|
|
|
element: this, |
|
|
|
|
vgap: 5, |
|
|
|
|
items: [this.popup] |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_formatItems: function (items) { |
|
|
|
@ -40,6 +100,7 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
|
|
|
|
|
return BI.map(items, function (i, item) { |
|
|
|
|
return BI.extend({ |
|
|
|
|
type: o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE ? "bi.single_select_item" : "bi.multi_select_item", |
|
|
|
|
iconWrapperWidth: 36, |
|
|
|
|
textAlign: o.textAlign, |
|
|
|
|
title: item.title || item.text |
|
|
|
|
}, item); |
|
|
|
@ -52,13 +113,29 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getValue: function () { |
|
|
|
|
return this.popup.getValue(); |
|
|
|
|
if (this.options.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) { |
|
|
|
|
return this.popup.getValue(); |
|
|
|
|
} |
|
|
|
|
var val = this.popup.getValue(); |
|
|
|
|
if (val.type === BI.ButtonGroup.CHOOSE_TYPE_MULTI) { |
|
|
|
|
return val.value; |
|
|
|
|
} else { |
|
|
|
|
return val.assist; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
setValue: function (v) { |
|
|
|
|
this.popup.setValue(v); |
|
|
|
|
if (this.options.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) { |
|
|
|
|
return this.popup.setValue(v); |
|
|
|
|
} |
|
|
|
|
this.popup.setValue({ |
|
|
|
|
type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, |
|
|
|
|
value: v |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
BI.TextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
|
BI.TextValueComboPopup.EVENT_CLEAR = "EVENT_CLEAR"; |
|
|
|
|
BI.TextValueComboPopup.EVENT_CONFIRM = "EVENT_CONFIRM"; |
|
|
|
|
BI.shortcut("bi.text_value_combo_popup", BI.TextValueComboPopup); |
|
|
|
|