forked from fanruan/fineui
crawford.zhou
2 years ago
8 changed files with 748 additions and 653 deletions
@ -0,0 +1,5 @@
|
||||
export { SearchMultiTextValueCombo } from "./multitextvalue.combo.search"; |
||||
export { SearchMultiSelectPopupView } from "./multitextvalue.popup.view.search"; |
||||
export { SearchMultiSelectTrigger } from "./multitextvalue.combo.trigger.search"; |
||||
export { SearchMultiSelectLoader } from "./multitextvalue.loader.search"; |
||||
export { SearchMultiSelectSearcher } from "./trigger/searcher.multitextvalue"; |
@ -1,184 +1,202 @@
|
||||
/** |
||||
* 多选加载数据面板 |
||||
* Created by guy on 15/11/2. |
||||
* @class BI.SearchMultiSelectLoader |
||||
* @extends Widget |
||||
*/ |
||||
BI.SearchMultiSelectLoader = BI.inherit(BI.Widget, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.SearchMultiSelectLoader.superclass._defaultConfig.apply(this, arguments), { |
||||
import { shortcut, Widget, extend, emptyFn, createWidget, isKey, Selection, map, contains, remove, pushDistinct, Controller, VerticalLayout, createItems, delay, isNotNull } from "@/core"; |
||||
import { ButtonGroup, Loader } from "@/base"; |
||||
import { SelectList, MultiSelectBar, MultiSelectItem } from "@/case"; |
||||
|
||||
@shortcut() |
||||
export class SearchMultiSelectLoader extends Widget { |
||||
static xtype = "bi.search_multi_select_loader"; |
||||
|
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
|
||||
_defaultConfig() { |
||||
return extend(super._defaultConfig(...arguments), { |
||||
baseCls: "bi-multi-select-loader", |
||||
logic: { |
||||
dynamic: true |
||||
dynamic: true, |
||||
}, |
||||
el: { |
||||
height: 400 |
||||
height: 400, |
||||
}, |
||||
valueFormatter: BI.emptyFn, |
||||
itemsCreator: BI.emptyFn, |
||||
valueFormatter: emptyFn, |
||||
itemsCreator: emptyFn, |
||||
itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
||||
onLoaded: BI.emptyFn |
||||
onLoaded: emptyFn, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.SearchMultiSelectLoader.superclass._init.apply(this, arguments); |
||||
_init() { |
||||
super._init(...arguments); |
||||
|
||||
var self = this, opts = this.options; |
||||
var hasNext = false; |
||||
const opts = this.options; |
||||
let hasNext = false; |
||||
|
||||
this.storeValue = opts.value || {}; |
||||
this._assertValue(this.storeValue); |
||||
|
||||
this.button_group = BI.createWidget({ |
||||
type: "bi.select_list", |
||||
this.button_group = createWidget({ |
||||
type: SelectList.xtype, |
||||
element: this, |
||||
logic: opts.logic, |
||||
toolbar: { |
||||
type: "bi.multi_select_bar", |
||||
type: MultiSelectBar.xtype, |
||||
cls: "bi-list-item-active", |
||||
height: this.options.itemHeight, |
||||
iconWrapperWidth: 36 |
||||
iconWrapperWidth: 36, |
||||
}, |
||||
el: BI.extend({ |
||||
el: extend( |
||||
{ |
||||
onLoaded: opts.onLoaded, |
||||
el: { |
||||
type: "bi.loader", |
||||
type: Loader.xtype, |
||||
isDefaultInit: false, |
||||
logic: { |
||||
dynamic: true, |
||||
scrolly: true |
||||
scrolly: true, |
||||
}, |
||||
el: { |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
chooseType: ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
behaviors: { |
||||
redmark: function () { |
||||
return true; |
||||
} |
||||
redmark: () => true, |
||||
}, |
||||
layouts: [{ |
||||
type: "bi.vertical" |
||||
}] |
||||
} |
||||
layouts: [ |
||||
{ |
||||
type: VerticalLayout.xtype, |
||||
} |
||||
}, opts.el), |
||||
itemsCreator: function (op, callback) { |
||||
var startValue = self._startValue; |
||||
self.storeValue && (op = BI.extend(op || {}, { |
||||
selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi |
||||
? self.storeValue.value.concat(startValue) : self.storeValue.value |
||||
], |
||||
}, |
||||
}, |
||||
}, |
||||
opts.el |
||||
), |
||||
itemsCreator: (op, callback) => { |
||||
const startValue = this._startValue; |
||||
this.storeValue && |
||||
(op = extend(op || {}, { |
||||
selectedValues: |
||||
isKey(startValue) && |
||||
this.storeValue.type === Selection.Multi |
||||
? this.storeValue.value.concat(startValue) |
||||
: this.storeValue.value, |
||||
})); |
||||
opts.itemsCreator(op, function (ob) { |
||||
opts.itemsCreator(op, ob => { |
||||
hasNext = ob.hasNext; |
||||
var firstItems = []; |
||||
if (op.times === 1 && self.storeValue) { |
||||
var json = BI.map(self.storeValue.value, function (i, v) { |
||||
var txt = opts.valueFormatter(v) || v; |
||||
let firstItems = []; |
||||
if (op.times === 1 && this.storeValue) { |
||||
const json = map(this.storeValue.value, (i, v) => { |
||||
const txt = opts.valueFormatter(v) || v; |
||||
|
||||
return { |
||||
text: txt, |
||||
value: v, |
||||
title: txt, |
||||
selected: self.storeValue.type === BI.Selection.Multi |
||||
selected: |
||||
this.storeValue.type === Selection.Multi, |
||||
}; |
||||
}); |
||||
if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { |
||||
var txt = opts.valueFormatter(startValue) || startValue; |
||||
if ( |
||||
isKey(this._startValue) && |
||||
!contains(this.storeValue.value, this._startValue) |
||||
) { |
||||
const txt = |
||||
opts.valueFormatter(startValue) || startValue; |
||||
json.unshift({ |
||||
text: txt, |
||||
value: startValue, |
||||
title: txt, |
||||
selected: true |
||||
selected: true, |
||||
}); |
||||
} |
||||
firstItems = self._createItems(json); |
||||
firstItems = this._createItems(json); |
||||
} |
||||
callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); |
||||
if (op.times === 1 && self.storeValue) { |
||||
BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); |
||||
self.setValue(self.storeValue); |
||||
callback( |
||||
firstItems.concat(this._createItems(ob.items)), |
||||
ob.keyword || "" |
||||
); |
||||
if (op.times === 1 && this.storeValue) { |
||||
isKey(startValue) && |
||||
(this.storeValue.type === Selection.All |
||||
? remove(this.storeValue.value, startValue) |
||||
: pushDistinct( |
||||
this.storeValue.value, |
||||
startValue |
||||
)); |
||||
this.setValue(this.storeValue); |
||||
} |
||||
(op.times === 1) && self._scrollToTop(); |
||||
op.times === 1 && this._scrollToTop(); |
||||
}); |
||||
}, |
||||
hasNext: function () { |
||||
return hasNext; |
||||
}, |
||||
value: this.storeValue |
||||
hasNext: () => hasNext, |
||||
value: this.storeValue, |
||||
}); |
||||
this.button_group.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
this.button_group.on(Controller.EVENT_CHANGE, () => { |
||||
this.fireEvent(Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.SearchMultiSelectLoader.EVENT_CHANGE, arguments); |
||||
this.button_group.on(SelectList.EVENT_CHANGE, () => { |
||||
this.fireEvent(SearchMultiSelectLoader.EVENT_CHANGE, ...arguments); |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_createItems: function (items) { |
||||
return BI.createItems(items, { |
||||
type: "bi.multi_select_item", |
||||
_createItems(items) { |
||||
return createItems(items, { |
||||
type: MultiSelectItem.xtype, |
||||
logic: this.options.logic, |
||||
cls: "bi-list-item-active", |
||||
height: this.options.itemHeight, |
||||
selected: this.isAllSelected(), |
||||
iconWrapperWidth: 36 |
||||
iconWrapperWidth: 36, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_scrollToTop: function () { |
||||
var self = this; |
||||
BI.delay(function () { |
||||
self.button_group.element.scrollTop(0); |
||||
_scrollToTop() { |
||||
delay(() => { |
||||
this.button_group.element.scrollTop(0); |
||||
}, 30); |
||||
}, |
||||
} |
||||
|
||||
isAllSelected: function () { |
||||
isAllSelected() { |
||||
return this.button_group.isAllSelected(); |
||||
}, |
||||
} |
||||
|
||||
_assertValue: function (val) { |
||||
_assertValue(val) { |
||||
val || (val = {}); |
||||
val.type || (val.type = BI.Selection.Multi); |
||||
val.type || (val.type = Selection.Multi); |
||||
val.value || (val.value = []); |
||||
}, |
||||
} |
||||
|
||||
setStartValue: function (v) { |
||||
setStartValue(v) { |
||||
this._startValue = v; |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.storeValue = v || {}; |
||||
this._assertValue(this.storeValue); |
||||
this.button_group.setValue(this.storeValue); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.button_group.getValue(); |
||||
}, |
||||
} |
||||
|
||||
getAllButtons: function () { |
||||
getAllButtons() { |
||||
return this.button_group.getAllButtons(); |
||||
}, |
||||
} |
||||
|
||||
empty: function () { |
||||
empty() { |
||||
this.button_group.empty(); |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
if (BI.isNotNull(items)) { |
||||
populate(items) { |
||||
if (isNotNull(items)) { |
||||
arguments[0] = this._createItems(items); |
||||
} |
||||
this.button_group.populate.apply(this.button_group, arguments); |
||||
}, |
||||
this.button_group.populate(...arguments); |
||||
} |
||||
|
||||
resetHeight: function (h) { |
||||
resetHeight(h) { |
||||
this.button_group.resetHeight(h); |
||||
}, |
||||
} |
||||
|
||||
resetWidth: function (w) { |
||||
resetWidth(w) { |
||||
this.button_group.resetWidth(w); |
||||
} |
||||
}); |
||||
|
||||
BI.SearchMultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.search_multi_select_loader", BI.SearchMultiSelectLoader); |
||||
} |
||||
|
@ -1,92 +1,104 @@
|
||||
BI.SearchMultiSelectPopupView = BI.inherit(BI.Widget, { |
||||
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core"; |
||||
import { MultiPopupView } from "@/case"; |
||||
import { SearchMultiSelectLoader } from "@/widget"; |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.SearchMultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), { |
||||
@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: BI.emptyFn, |
||||
itemsCreator: BI.emptyFn, |
||||
onLoaded: BI.emptyFn |
||||
valueFormatter: emptyFn, |
||||
itemsCreator: emptyFn, |
||||
onLoaded: emptyFn, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.SearchMultiSelectPopupView.superclass._init.apply(this, arguments); |
||||
var self = this, opts = this.options; |
||||
_init() { |
||||
super._init(...arguments); |
||||
const opts = this.options; |
||||
|
||||
this.loader = BI.createWidget({ |
||||
type: "bi.search_multi_select_loader", |
||||
this.loader = createWidget({ |
||||
type: SearchMultiSelectLoader.xtype, |
||||
itemsCreator: opts.itemsCreator, |
||||
valueFormatter: opts.valueFormatter, |
||||
onLoaded: opts.onLoaded, |
||||
value: opts.value |
||||
value: opts.value, |
||||
}); |
||||
|
||||
this.popupView = BI.createWidget({ |
||||
type: "bi.multi_popup_view", |
||||
this.popupView = createWidget({ |
||||
type: MultiPopupView.xtype, |
||||
stopPropagation: false, |
||||
maxWidth: opts.maxWidth, |
||||
minWidth: opts.minWidth, |
||||
maxHeight: opts.maxHeight, |
||||
element: this, |
||||
buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_OK")], |
||||
buttons: [i18nText("BI-Basic_Clears"), i18nText("BI-Basic_OK")], |
||||
el: this.loader, |
||||
value: opts.value |
||||
value: opts.value, |
||||
}); |
||||
|
||||
this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CHANGE); |
||||
this.popupView.on(MultiPopupView.EVENT_CHANGE, () => { |
||||
this.fireEvent(SearchMultiSelectPopupView.EVENT_CHANGE); |
||||
}); |
||||
this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { |
||||
this.popupView.on( |
||||
MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, |
||||
index => { |
||||
switch (index) { |
||||
case 0: |
||||
self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CLEAR); |
||||
this.fireEvent( |
||||
SearchMultiSelectPopupView.EVENT_CLICK_CLEAR |
||||
); |
||||
break; |
||||
case 1: |
||||
self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM); |
||||
this.fireEvent( |
||||
SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM |
||||
); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
}, |
||||
} |
||||
); |
||||
} |
||||
|
||||
isAllSelected: function () { |
||||
isAllSelected() { |
||||
return this.loader.isAllSelected(); |
||||
}, |
||||
} |
||||
|
||||
setStartValue: function (v) { |
||||
setStartValue(v) { |
||||
this.loader.setStartValue(v); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.popupView.setValue(v); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.popupView.getValue(); |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
this.popupView.populate.apply(this.popupView, arguments); |
||||
}, |
||||
populate(items) { |
||||
this.popupView.populate(...arguments); |
||||
} |
||||
|
||||
resetHeight: function (h) { |
||||
resetHeight(h) { |
||||
this.popupView.resetHeight(h); |
||||
}, |
||||
} |
||||
|
||||
resetWidth: function (w) { |
||||
resetWidth(w) { |
||||
this.popupView.resetWidth(w); |
||||
}, |
||||
} |
||||
|
||||
setDirection: function (direction, position) { |
||||
setDirection(direction, position) { |
||||
this.popupView.setDirection(direction, position); |
||||
}, |
||||
}); |
||||
|
||||
BI.SearchMultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; |
||||
BI.SearchMultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; |
||||
|
||||
|
||||
BI.shortcut("bi.search_multi_select_popup_view", BI.SearchMultiSelectPopupView); |
||||
} |
||||
} |
||||
|
@ -1,175 +1,179 @@
|
||||
BI.SearchMultiSelectSearcher = BI.inherit(BI.Widget, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.SearchMultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), { |
||||
import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, Selection, size, each } from "@/core"; |
||||
import { Searcher } from "@/base"; |
||||
import { MultiSelectEditor, MultiSelectSearchPane } from "@/widget"; |
||||
|
||||
@shortcut() |
||||
export class SearchMultiSelectSearcher extends Widget { |
||||
static xtype = "bi.search_multi_select_searcher"; |
||||
|
||||
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
static EVENT_START = "EVENT_START"; |
||||
static EVENT_STOP = "EVENT_STOP"; |
||||
static EVENT_PAUSE = "EVENT_PAUSE"; |
||||
static EVENT_SEARCHING = "EVENT_SEARCHING"; |
||||
|
||||
_defaultConfig() { |
||||
return extend(super._defaultConfig(...arguments), { |
||||
baseCls: "bi-multi-select-searcher", |
||||
itemsCreator: BI.emptyFn, |
||||
itemsCreator: emptyFn, |
||||
el: {}, |
||||
popup: {}, |
||||
valueFormatter: BI.emptyFn, |
||||
valueFormatter: emptyFn, |
||||
adapter: null, |
||||
masker: {} |
||||
masker: {}, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.SearchMultiSelectSearcher.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.editor = BI.createWidget(o.el, { |
||||
type: "bi.multi_select_editor", |
||||
_init() { |
||||
super._init(...arguments); |
||||
const o = this.options; |
||||
this.editor = createWidget(o.el, { |
||||
type: MultiSelectEditor.xtype, |
||||
height: o.height, |
||||
text: o.text, |
||||
tipType: o.tipType, |
||||
warningTitle: o.warningTitle |
||||
warningTitle: o.warningTitle, |
||||
}); |
||||
|
||||
this.searcher = BI.createWidget({ |
||||
type: "bi.searcher", |
||||
this.searcher = createWidget({ |
||||
type: Searcher.xtype, |
||||
element: this, |
||||
height: o.height, |
||||
isAutoSearch: false, |
||||
isAutoSync: false, |
||||
onSearch: function (op, callback) { |
||||
onSearch: (op, callback) => { |
||||
callback(); |
||||
}, |
||||
el: this.editor, |
||||
|
||||
popup: BI.extend({ |
||||
type: "bi.multi_select_search_pane", |
||||
popup: extend( |
||||
{ |
||||
type: MultiSelectSearchPane.xtype, |
||||
valueFormatter: o.valueFormatter, |
||||
keywordGetter: function () { |
||||
return self.editor.getValue(); |
||||
}, |
||||
itemsCreator: function (op, callback) { |
||||
var keyword = self.editor.getValue(); |
||||
keywordGetter: () => this.editor.getValue(), |
||||
itemsCreator: (op, callback) => { |
||||
const keyword = this.editor.getValue(); |
||||
op.keywords = [keyword]; |
||||
o.itemsCreator(op, callback); |
||||
}, |
||||
value: o.value |
||||
}, o.popup), |
||||
value: o.value, |
||||
}, |
||||
o.popup |
||||
), |
||||
|
||||
adapter: o.adapter, |
||||
masker: o.masker |
||||
masker: o.masker, |
||||
}); |
||||
this.searcher.on(BI.Searcher.EVENT_START, function () { |
||||
self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_START); |
||||
this.searcher.on(Searcher.EVENT_START, () => { |
||||
this.fireEvent(SearchMultiSelectSearcher.EVENT_START); |
||||
}); |
||||
this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { |
||||
if (this.hasMatched()) { |
||||
|
||||
} |
||||
self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_PAUSE); |
||||
this.searcher.on(Searcher.EVENT_PAUSE, () => { |
||||
this.fireEvent(SearchMultiSelectSearcher.EVENT_PAUSE); |
||||
}); |
||||
this.searcher.on(BI.Searcher.EVENT_STOP, function () { |
||||
self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_STOP); |
||||
this.searcher.on(Searcher.EVENT_STOP, () => { |
||||
this.fireEvent(SearchMultiSelectSearcher.EVENT_STOP); |
||||
}); |
||||
this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_CHANGE, arguments); |
||||
this.searcher.on(Searcher.EVENT_CHANGE, () => { |
||||
this.fireEvent(SearchMultiSelectSearcher.EVENT_CHANGE, ...arguments); |
||||
}); |
||||
this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { |
||||
var keywords = this.getKeywords(); |
||||
self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_SEARCHING, keywords); |
||||
this.searcher.on(Searcher.EVENT_SEARCHING, () => { |
||||
const keywords = this.getKeywords(); |
||||
this.fireEvent(SearchMultiSelectSearcher.EVENT_SEARCHING, keywords); |
||||
}); |
||||
if(BI.isNotNull(o.value)) { |
||||
if (isNotNull(o.value)) { |
||||
this.setState(o.value); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
adjustView: function () { |
||||
adjustView() { |
||||
this.searcher.adjustView(); |
||||
}, |
||||
} |
||||
|
||||
isSearching: function () { |
||||
isSearching() { |
||||
return this.searcher.isSearching(); |
||||
}, |
||||
} |
||||
|
||||
stopSearch: function () { |
||||
stopSearch() { |
||||
this.searcher.stopSearch(); |
||||
}, |
||||
} |
||||
|
||||
getKeyword: function () { |
||||
getKeyword() { |
||||
return this.editor.getValue(); |
||||
}, |
||||
} |
||||
|
||||
hasMatched: function () { |
||||
hasMatched() { |
||||
return this.searcher.hasMatched(); |
||||
}, |
||||
} |
||||
|
||||
hasChecked: function () { |
||||
hasChecked() { |
||||
return this.searcher.getView() && this.searcher.getView().hasChecked(); |
||||
}, |
||||
} |
||||
|
||||
setAdapter: function (adapter) { |
||||
setAdapter(adapter) { |
||||
this.searcher.setAdapter(adapter); |
||||
}, |
||||
} |
||||
|
||||
setState: function (obj) { |
||||
var o = this.options; |
||||
var ob = {}; |
||||
setState(obj) { |
||||
let state; |
||||
const o = this.options; |
||||
const ob = {}; |
||||
ob.type = obj.type; |
||||
ob.value = o.allValueGetter() || []; |
||||
ob.assist = obj.assist; |
||||
if (ob.type === BI.Selection.All) { |
||||
if (ob.type === Selection.All) { |
||||
if (ob.value.length === 0) { |
||||
this.editor.setState(BI.Selection.All); |
||||
} else if (BI.size(ob.assist) <= 20) { |
||||
var state = ""; |
||||
BI.each(ob.assist, function (i, v) { |
||||
this.editor.setState(Selection.All); |
||||
} else if (size(ob.assist) <= 20) { |
||||
state = ""; |
||||
each(ob.assist, (i, v) => { |
||||
if (i === 0) { |
||||
state += "" + (o.valueFormatter(v + "") || v); |
||||
state += `${o.valueFormatter(`${v}`) || v}`; |
||||
} else { |
||||
state += "," + (o.valueFormatter(v + "") || v); |
||||
state += `,${o.valueFormatter(`${v}`) || v}`; |
||||
} |
||||
}); |
||||
this.editor.setState(state); |
||||
} else { |
||||
this.editor.setState(BI.Selection.Multi); |
||||
this.editor.setState(Selection.Multi); |
||||
} |
||||
} else { |
||||
if (ob.value.length === 0) { |
||||
this.editor.setState(BI.Selection.None); |
||||
} else if (BI.size(ob.value) <= 20) { |
||||
var state = ""; |
||||
BI.each(ob.value, function (i, v) { |
||||
this.editor.setState(Selection.None); |
||||
} else if (size(ob.value) <= 20) { |
||||
state = ""; |
||||
each(ob.value, (i, v) => { |
||||
if (i === 0) { |
||||
state += "" + (o.valueFormatter(v + "") || v); |
||||
state += `${o.valueFormatter(`${v}`) || v}`; |
||||
} else { |
||||
state += "," + (o.valueFormatter(v + "") || v); |
||||
state += `,${o.valueFormatter(`${v}`) || v}`; |
||||
} |
||||
}); |
||||
this.editor.setState(state); |
||||
} else { |
||||
this.editor.setState(BI.Selection.Multi); |
||||
this.editor.setState(Selection.Multi); |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
|
||||
setTipType: function (v) { |
||||
setTipType(v) { |
||||
this.editor.setTipType(v); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (ob) { |
||||
setValue(ob) { |
||||
this.setState(ob); |
||||
this.searcher.setValue(ob); |
||||
}, |
||||
} |
||||
|
||||
getKey: function () { |
||||
getKey() { |
||||
return this.editor.getValue(); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.searcher.getValue(); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.searcher.populate.apply(this.searcher, arguments); |
||||
} |
||||
}); |
||||
|
||||
BI.SearchMultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
||||
BI.SearchMultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.SearchMultiSelectSearcher.EVENT_START = "EVENT_START"; |
||||
BI.SearchMultiSelectSearcher.EVENT_STOP = "EVENT_STOP"; |
||||
BI.SearchMultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; |
||||
BI.SearchMultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; |
||||
BI.shortcut("bi.search_multi_select_searcher", BI.SearchMultiSelectSearcher); |
||||
populate(items) { |
||||
this.searcher.populate(...arguments); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue