forked from fanruan/fineui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.7 KiB
101 lines
2.7 KiB
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText, Controller, VerticalFillLayout, SIZE_CONSANTS } from "@/core"; |
|
import { Label } from "@/base"; |
|
import { MultiSelectSearchLoader } from "./multiselect.search.loader"; |
|
|
|
@shortcut() |
|
export class MultiSelectSearchInsertPane extends Widget { |
|
static xtype = "bi.multi_select_search_insert_pane"; |
|
|
|
constants = { height: 24, lgap: 10, tgap: 5 }; |
|
|
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
_defaultConfig() { |
|
return extend(super._defaultConfig(...arguments), { |
|
baseCls: "bi-multi-select-search-pane bi-card", |
|
itemsCreator: emptyFn, |
|
valueFormatter: emptyFn, |
|
keywordGetter: emptyFn, |
|
allowSelectAll: true, |
|
itemHeight: 24, |
|
}); |
|
} |
|
|
|
_init() { |
|
super._init(...arguments); |
|
const self = this, |
|
o = this.options; |
|
|
|
this.addNotMatchTip = createWidget({ |
|
type: Label.xtype, |
|
text: i18nText("BI-Basic_Press_Enter_To_Add_Text", ""), |
|
height: SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
|
cls: "bi-keyword-red-mark", |
|
hgap: 5, |
|
}); |
|
|
|
this.loader = createWidget({ |
|
type: MultiSelectSearchLoader.xtype, |
|
keywordGetter: o.keywordGetter, |
|
valueFormatter: o.valueFormatter, |
|
itemFormatter: o.itemFormatter, |
|
itemsCreator(op, callback) { |
|
o.itemsCreator.apply(self, [ |
|
op, |
|
function (res) { |
|
callback(res); |
|
self.setKeyword(o.keywordGetter()); |
|
} |
|
]); |
|
}, |
|
itemHeight: o.itemHeight, |
|
value: o.value, |
|
allowSelectAll: o.allowSelectAll, |
|
}); |
|
this.loader.on(Controller.EVENT_CHANGE, function () { |
|
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
|
}); |
|
|
|
this.resizer = createWidget({ |
|
type: VerticalFillLayout.xtype, |
|
rowSize: ["", "fill"], |
|
element: this, |
|
items: [ |
|
{ |
|
el: this.addNotMatchTip, |
|
}, |
|
{ |
|
el: this.loader, |
|
} |
|
], |
|
}); |
|
} |
|
|
|
setKeyword(keyword) { |
|
this.addNotMatchTip.setText(i18nText("BI-Basic_Press_Enter_To_Add_Text", keyword)); |
|
} |
|
|
|
isAllSelected() { |
|
return this.loader.isAllSelected(); |
|
} |
|
|
|
hasMatched() { |
|
return false; |
|
} |
|
|
|
setValue(v) { |
|
this.loader.setValue(v); |
|
} |
|
|
|
getValue() { |
|
return this.loader.getValue(); |
|
} |
|
|
|
empty() { |
|
this.loader.empty(); |
|
} |
|
|
|
populate(items) { |
|
this.loader.populate(...arguments); |
|
} |
|
}
|
|
|