|
|
@ -9,7 +9,8 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { |
|
|
|
baseCls: "bi-multi-select-insert-list", |
|
|
|
baseCls: "bi-multi-select-insert-list", |
|
|
|
allowNoSelect: false, |
|
|
|
allowNoSelect: false, |
|
|
|
itemsCreator: BI.emptyFn, |
|
|
|
itemsCreator: BI.emptyFn, |
|
|
|
valueFormatter: BI.emptyFn |
|
|
|
valueFormatter: BI.emptyFn, |
|
|
|
|
|
|
|
searcherHeight: 24, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
_init: function () { |
|
|
|
_init: function () { |
|
|
@ -60,6 +61,17 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { |
|
|
|
|
|
|
|
|
|
|
|
this.trigger = BI.createWidget({ |
|
|
|
this.trigger = BI.createWidget({ |
|
|
|
type: "bi.searcher", |
|
|
|
type: "bi.searcher", |
|
|
|
|
|
|
|
el: { |
|
|
|
|
|
|
|
type: "bi.select_patch_editor", |
|
|
|
|
|
|
|
el: { |
|
|
|
|
|
|
|
type: "bi.search_editor", |
|
|
|
|
|
|
|
watermark: BI.i18nText("BI-Basic_Search_And_Patch_Paste"), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
ref: function (ref) { |
|
|
|
|
|
|
|
self.editor = ref; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
height: o.searcherHeight, |
|
|
|
|
|
|
|
}, |
|
|
|
isAutoSearch: false, |
|
|
|
isAutoSearch: false, |
|
|
|
isAutoSync: false, |
|
|
|
isAutoSync: false, |
|
|
|
onSearch: function (op, callback) { |
|
|
|
onSearch: function (op, callback) { |
|
|
@ -90,40 +102,16 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { |
|
|
|
eventName: BI.Searcher.EVENT_PAUSE, |
|
|
|
eventName: BI.Searcher.EVENT_PAUSE, |
|
|
|
action: function () { |
|
|
|
action: function () { |
|
|
|
var keyword = this.getKeyword(); |
|
|
|
var keyword = this.getKeyword(); |
|
|
|
if (this.hasMatched()) { |
|
|
|
self.storeValue = keyword; |
|
|
|
self.storeValue = keyword; |
|
|
|
self._showAdapter(); |
|
|
|
self._showAdapter(); |
|
|
|
self.adapter.setValue(self.storeValue); |
|
|
|
self.adapter.setValue(self.storeValue); |
|
|
|
self._setStartValue(keyword); |
|
|
|
self._setStartValue(keyword); |
|
|
|
assertShowValue(); |
|
|
|
assertShowValue(); |
|
|
|
self.adapter.populate(); |
|
|
|
self.adapter.populate(); |
|
|
|
self._setStartValue(); |
|
|
|
self._setStartValue(); |
|
|
|
self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); |
|
|
|
self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
self._showAdapter(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}, { |
|
|
|
|
|
|
|
eventName: BI.Searcher.EVENT_SEARCHING, |
|
|
|
|
|
|
|
action: function () { |
|
|
|
|
|
|
|
var keywords = this.getKeyword(); |
|
|
|
|
|
|
|
var last = BI.last(keywords); |
|
|
|
|
|
|
|
keywords = BI.initial(keywords || []); |
|
|
|
|
|
|
|
if (keywords.length > 0) { |
|
|
|
|
|
|
|
self._joinKeywords(keywords, function () { |
|
|
|
|
|
|
|
if (BI.endWith(last, BI.BlankSplitChar)) { |
|
|
|
|
|
|
|
self.adapter.setValue(self.storeValue); |
|
|
|
|
|
|
|
assertShowValue(); |
|
|
|
|
|
|
|
self.adapter.populate(); |
|
|
|
|
|
|
|
self._setStartValue(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
self.adapter.setValue(self.storeValue); |
|
|
|
|
|
|
|
assertShowValue(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, { |
|
|
|
}, { |
|
|
|
eventName: BI.Searcher.EVENT_CHANGE, |
|
|
|
eventName: BI.Searcher.EVENT_CHANGE, |
|
|
|
action: function () { |
|
|
|
action: function () { |
|
|
@ -177,31 +165,6 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { |
|
|
|
return BI.makeObject(values || []); |
|
|
|
return BI.makeObject(values || []); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
_joinKeywords: function (keywords, callback) { |
|
|
|
|
|
|
|
var self = this, o = this.options; |
|
|
|
|
|
|
|
this._assertValue(this.storeValue); |
|
|
|
|
|
|
|
if (!this._allData) { |
|
|
|
|
|
|
|
o.itemsCreator({ |
|
|
|
|
|
|
|
type: BI.SingleSelectInsertList.REQ_GET_ALL_DATA |
|
|
|
|
|
|
|
}, function (ob) { |
|
|
|
|
|
|
|
self._allData = BI.map(ob.items, "value"); |
|
|
|
|
|
|
|
digest(self._allData); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
digest(this._allData); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function digest (items) { |
|
|
|
|
|
|
|
var selectedMap = self._makeMap(items); |
|
|
|
|
|
|
|
BI.each(keywords, function (i, val) { |
|
|
|
|
|
|
|
if (BI.isNotNull(selectedMap[val])) { |
|
|
|
|
|
|
|
BI.pushDistinct(self.storeValue.value, val) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
callback(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_setStartValue: function (value) { |
|
|
|
_setStartValue: function (value) { |
|
|
|
this._startValue = value; |
|
|
|
this._startValue = value; |
|
|
|
this.adapter.setStartValue(value); |
|
|
|
this.adapter.setStartValue(value); |
|
|
|