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