|
|
|
import {
|
|
|
|
shortcut,
|
|
|
|
extend,
|
|
|
|
createWidget,
|
|
|
|
createItems,
|
|
|
|
Controller,
|
|
|
|
Events,
|
|
|
|
VerticalLayout
|
|
|
|
} from "@/core";
|
|
|
|
import { Pane, ButtonGroup } from "@/base";
|
|
|
|
import { SingleSelectIconTextItem } from "../../button";
|
|
|
|
|
|
|
|
@shortcut()
|
|
|
|
export class IconComboPopup extends Pane {
|
|
|
|
static xtype = "bi.icon_combo_popup";
|
|
|
|
|
|
|
|
static EVENT_CHANGE = "EVENT_CHANGE";
|
|
|
|
|
|
|
|
_defaultConfig() {
|
|
|
|
return extend(super._defaultConfig(...arguments), {
|
|
|
|
baseCls: "bi.icon-combo-popup",
|
|
|
|
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_init() {
|
|
|
|
super._init(...arguments);
|
|
|
|
const o = this.options;
|
|
|
|
this.popup = createWidget({
|
|
|
|
type: ButtonGroup.xtype,
|
|
|
|
items: createItems(o.items, {
|
|
|
|
type: SingleSelectIconTextItem.xtype,
|
|
|
|
}),
|
|
|
|
chooseType: o.chooseType,
|
|
|
|
layouts: [
|
|
|
|
{
|
|
|
|
type: VerticalLayout.xtype,
|
|
|
|
}
|
|
|
|
],
|
|
|
|
value: o.value,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.popup.on(Controller.EVENT_CHANGE, (...args) => {
|
|
|
|
const [type, val, obj] = args;
|
|
|
|
this.fireEvent(Controller.EVENT_CHANGE, ...args);
|
|
|
|
if (type === Events.CLICK) {
|
|
|
|
this.fireEvent(IconComboPopup.EVENT_CHANGE, val, obj);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
createWidget({
|
|
|
|
type: VerticalLayout.xtype,
|
|
|
|
element: this,
|
|
|
|
vgap: 5,
|
|
|
|
items: [this.popup],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
populate(items) {
|
|
|
|
super.populate(...arguments);
|
|
|
|
items = createItems(items, {
|
|
|
|
type: SingleSelectIconTextItem.xtype,
|
|
|
|
});
|
|
|
|
this.popup.populate(items);
|
|
|
|
}
|
|
|
|
|
|
|
|
getValue() {
|
|
|
|
return this.popup.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
setValue(v) {
|
|
|
|
this.popup.setValue(v);
|
|
|
|
}
|
|
|
|
}
|