import { shortcut, extend, emptyFn, createWidget, i18nText, Controller, size } from "@/core"; import { Single, TextButton, IconButton } from "@/base"; import { MultiSelectCheckSelectedButton } from "../../multiselect/trigger/button.checkselected"; @shortcut() export class MultiTreeCheckSelectedButton extends Single { static xtype = "bi.multi_tree_check_selected_button"; static EVENT_CHANGE = "EVENT_CHANGE"; _defaultConfig() { return extend(super._defaultConfig(...arguments), { baseCls: "bi-multi-tree-check-selected-button", itemsCreator: emptyFn, }); } _init() { super._init(...arguments); const self = this; this.indicator = createWidget({ type: IconButton.xtype, cls: "check-font trigger-check-selected icon-size-12", width: 16, height: 16, stopPropagation: true, }); this.checkSelected = createWidget({ type: TextButton.xtype, cls: "bi-high-light-background trigger-check-text", invisible: true, hgap: 4, text: i18nText("BI-Check_Selected"), textAlign: "center", }); this.checkSelected.on(Controller.EVENT_CHANGE, function () { self.fireEvent(Controller.EVENT_CHANGE, arguments); }); this.checkSelected.on(TextButton.EVENT_CHANGE, function () { self.fireEvent( MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments ); }); createWidget({ type: "bi.horizontal", element: this, items: [this.indicator, this.checkSelected], }); this.element.hover( () => { self.indicator.setVisible(false); self.checkSelected.setVisible(true); }, () => { self.indicator.setVisible(true); self.checkSelected.setVisible(false); } ); this.setVisible(false); } setValue(v) { v || (v = {}); const show = size(v.value) > 0; this.setVisible(show); } }