import { shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core"; import { MultiPopupView } from "@/case"; import { SearchMultiSelectLoader } from "@/widget"; @shortcut() export class SearchMultiSelectPopupView extends Widget { static xtype = "bi.search_multi_select_popup_view"; static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; static EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; _defaultConfig() { return extend(super._defaultConfig(...arguments), { baseCls: "bi-multi-select-popup-view", maxWidth: "auto", minWidth: 135, maxHeight: 400, valueFormatter: emptyFn, itemsCreator: emptyFn, onLoaded: emptyFn, }); } _init() { super._init(...arguments); const opts = this.options; this.loader = createWidget({ type: SearchMultiSelectLoader.xtype, itemsCreator: opts.itemsCreator, valueFormatter: opts.valueFormatter, onLoaded: opts.onLoaded, value: opts.value, }); this.popupView = createWidget({ type: MultiPopupView.xtype, stopPropagation: false, maxWidth: opts.maxWidth, minWidth: opts.minWidth, maxHeight: opts.maxHeight, element: this, buttons: [i18nText("BI-Basic_Clears"), i18nText("BI-Basic_OK")], el: this.loader, value: opts.value, }); this.popupView.on(MultiPopupView.EVENT_CHANGE, () => { this.fireEvent(SearchMultiSelectPopupView.EVENT_CHANGE); }); this.popupView.on( MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, index => { switch (index) { case 0: this.fireEvent( SearchMultiSelectPopupView.EVENT_CLICK_CLEAR ); break; case 1: this.fireEvent( SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM ); break; default: break; } } ); } isAllSelected() { return this.loader.isAllSelected(); } setStartValue(v) { this.loader.setStartValue(v); } setValue(v) { this.popupView.setValue(v); } getValue() { return this.popupView.getValue(); } populate(items) { this.popupView.populate(...arguments); } resetHeight(h) { this.popupView.resetHeight(h); } resetWidth(w) { this.popupView.resetWidth(w); } setDirection(direction, position) { this.popupView.setDirection(direction, position); } }