Browse Source

change single_select_combo value to string

es6
Frank.Qiu 7 years ago
parent
commit
6987665fe4
  1. 77
      bi/widget.js
  2. 15
      demo/js/widget/singleselct/demo.single_select_combo.js
  3. 77
      dist/bundle.js
  4. 15
      dist/demo.js
  5. 77
      dist/widget.js
  6. 6
      src/widget/singleselect/search/singleselect.search.loader.js
  7. 15
      src/widget/singleselect/singleselect.combo.js
  8. 10
      src/widget/singleselect/singleselect.list.js
  9. 21
      src/widget/singleselect/singleselect.loader.js
  10. 4
      src/widget/singleselect/singleselect.popup.view.js
  11. 4
      src/widget/singleselect/singleselect.trigger.js
  12. 17
      src/widget/singleselect/trigger/searcher.singleselect.js

77
bi/widget.js

@ -16900,14 +16900,14 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
}, },
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
self.storeValue && (op = BI.extend(op || {}, { self.storeValue && (op = BI.extend(op || {}, {
selectedValues: self.storeValue.value selectedValues: [self.storeValue]
})); }));
opts.itemsCreator(op, function (ob) { opts.itemsCreator(op, function (ob) {
var keyword = ob.keyword = opts.keywordGetter(); var keyword = ob.keyword = opts.keywordGetter();
hasNext = ob.hasNext; hasNext = ob.hasNext;
var firstItems = []; var firstItems = [];
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
var json = BI.map(self.storeValue.value, function (i, v) { var json = BI.map([self.storeValue], function (i, v) {
var txt = opts.valueFormatter(v) || v; var txt = opts.valueFormatter(v) || v;
return { return {
text: txt, text: txt,
@ -16973,7 +16973,7 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
setValue: function (v) { setValue: function (v) {
//暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了 //暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
this.storeValue = BI.deepClone(v); this.storeValue = v;
this.button_group.setValue(v); this.button_group.setValue(v);
}, },
@ -17121,10 +17121,10 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
var self = this, o = this.options; var self = this, o = this.options;
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && (self.storeValue.value = [self._startValue]); BI.isKey(self._startValue) && (self.storeValue = self._startValue);
self.trigger.getSearcher().setState(self.storeValue); self.trigger.getSearcher().setState(self.storeValue);
}; };
this.storeValue = {}; this.storeValue = '';
//标记正在请求数据 //标记正在请求数据
this.requesting = false; this.requesting = false;
@ -17145,7 +17145,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
o.itemsCreator(op, function (res) { o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) { if (op.times === 1 && BI.isNotNull(op.keywords)) {
//预防trigger内部把当前的storeValue改掉 //预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue())); self.trigger.setValue(self.getValue());
} }
callback.apply(self, arguments); callback.apply(self, arguments);
}); });
@ -17223,6 +17223,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
listeners: [{ listeners: [{
eventName: BI.SingleSelectPopupView.EVENT_CHANGE, eventName: BI.SingleSelectPopupView.EVENT_CHANGE,
action: function () { action: function () {
console.log(this.getValue())
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -17311,9 +17312,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
}, },
_assertValue: function (val) { _assertValue: function (val) {
val || (val = {}); val || (val = '');
val.type || (val.type = BI.Selection.Single);
val.value || (val.value = []);
}, },
_makeMap: function (values) { _makeMap: function (values) {
@ -17438,13 +17437,13 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue = v || {}; this.storeValue = v || '';
this._assertValue(this.storeValue); this._assertValue(this.storeValue);
this.combo.setValue(this.storeValue); this.combo.setValue(this.storeValue);
}, },
getValue: function () { getValue: function () {
return BI.deepClone(this.storeValue); return this.storeValue;
}, },
populate: function () { populate: function () {
@ -17534,16 +17533,12 @@ BI.SingleSelectList = BI.inherit(BI.Widget, {
this.list.addItems.apply(this.list, arguments); this.list.addItems.apply(this.list, arguments);
}, },
setValue: function (data) { setValue: function (v) {
this.list["setValue"](data.value); this.list.setValue([v]);
}, },
getValue: function () { getValue: function () {
return { return this.list.getValue()[0];
type: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
value: this.list.getValue(),
assist: this.list.getNotSelectedValue()
};
}, },
empty: function () { empty: function () {
@ -17654,13 +17649,13 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
var startValue = self._startValue; var startValue = self._startValue;
self.storeValue && (op = BI.extend(op || {}, { self.storeValue && (op = BI.extend(op || {}, {
selectedValues: self.storeValue.value selectedValues: [self.storeValue]
})); }));
opts.itemsCreator(op, function (ob) { opts.itemsCreator(op, function (ob) {
hasNext = ob.hasNext; hasNext = ob.hasNext;
var firstItems = []; var firstItems = [];
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
var json = BI.map(self.storeValue.value, function (i, v) { var json = BI.map([self.storeValue], function (i, v) {
var txt = opts.valueFormatter(v) || v; var txt = opts.valueFormatter(v) || v;
return { return {
text: txt, text: txt,
@ -17669,20 +17664,11 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
selected: false selected: false
} }
}); });
if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) {
var txt = opts.valueFormatter(startValue) || startValue;
json.unshift({
text: txt,
value: startValue,
title: txt,
selected: true
})
}
firstItems = self._createItems(json); firstItems = self._createItems(json);
} }
callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
BI.isKey(startValue) && self.storeValue.value["pushDistinct"](startValue); BI.isKey(startValue) && (self.storeValue = startValue);
self.setValue(self.storeValue); self.setValue(self.storeValue);
} }
(op.times === 1) && self._scrollToTop(); (op.times === 1) && self._scrollToTop();
@ -17717,9 +17703,7 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
}, },
_assertValue: function (val) { _assertValue: function (val) {
val || (val = {}); val || (val = '');
val.type || (val.type = BI.Selection.Single);
val.value || (val.value = []);
}, },
setStartValue: function (v) { setStartValue: function (v) {
@ -17727,7 +17711,7 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
}, },
setValue: function (v) { setValue: function (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);
}, },
@ -17814,10 +17798,6 @@ BI.SingleSelectPopupView = BI.inherit(BI.Widget, {
}); });
}, },
isAllSelected: function () {
return this.loader.isAllSelected();
},
setStartValue: function (v) { setStartValue: function (v) {
this.loader.setStartValue(v); this.loader.setStartValue(v);
}, },
@ -17935,8 +17915,8 @@ BI.SingleSelectTrigger = BI.inherit(BI.Trigger, {
this.searcher.setAdapter(adapter); this.searcher.setAdapter(adapter);
}, },
setValue: function (ob) { setValue: function (v) {
this.searcher.setValue(ob); this.searcher.setValue(v);
}, },
getKey: function () { getKey: function () {
@ -18142,22 +18122,13 @@ BI.SingleSelectSearcher = BI.inherit(BI.Widget, {
this.searcher.setAdapter(adapter); this.searcher.setAdapter(adapter);
}, },
setState: function (ob) { setState: function (v) {
var o = this.options; var o = this.options;
ob || (ob = {}); v || (v = '');
ob.value || (ob.value = []); if (v === '') {
if (ob.value.length === 0) {
this.editor.setState(BI.Selection.None); this.editor.setState(BI.Selection.None);
} else { } else {
var state = ""; this.editor.setState(o.valueFormatter(v + "") || v);
BI.each(ob.value, function (i, v) {
if (i === 0) {
state += "" + (o.valueFormatter(v + "") || v);
} else {
state += "," + (o.valueFormatter(v + "") || v);
}
});
this.editor.setState(state);
} }
}, },

15
demo/js/widget/singleselct/demo.single_select_combo.js

@ -11,7 +11,10 @@ Demo.SingleSelectCombo = BI.inherit(BI.Widget, {
var widget = BI.createWidget({ var widget = BI.createWidget({
type: 'bi.single_select_combo', type: 'bi.single_select_combo',
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: BI.bind(this._itemsCreator, this),
width: 200 width: 200,
ref: function () {
self.SingleSelectCombo = this;
}
}); });
widget.on(BI.SingleSelectCombo.EVENT_CONFIRM, function () { widget.on(BI.SingleSelectCombo.EVENT_CONFIRM, function () {
@ -69,6 +72,7 @@ Demo.SingleSelectCombo = BI.inherit(BI.Widget, {
}, },
render: function () { render: function () {
var self = this;
return { return {
type: 'bi.absolute', type: 'bi.absolute',
scrolly: false, scrolly: false,
@ -76,6 +80,15 @@ Demo.SingleSelectCombo = BI.inherit(BI.Widget, {
el: this._createSingleSelectCombo(), el: this._createSingleSelectCombo(),
right: "50%", right: "50%",
top: 10 top: 10
}, {
el: {
type: 'bi.button',
text: 'setValue("柳州市针织总厂")',
handler: function () {
self.SingleSelectCombo.setValue('柳州市针织总厂');
}
}
}] }]
} }
} }

77
dist/bundle.js vendored

@ -92129,14 +92129,14 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
}, },
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
self.storeValue && (op = BI.extend(op || {}, { self.storeValue && (op = BI.extend(op || {}, {
selectedValues: self.storeValue.value selectedValues: [self.storeValue]
})); }));
opts.itemsCreator(op, function (ob) { opts.itemsCreator(op, function (ob) {
var keyword = ob.keyword = opts.keywordGetter(); var keyword = ob.keyword = opts.keywordGetter();
hasNext = ob.hasNext; hasNext = ob.hasNext;
var firstItems = []; var firstItems = [];
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
var json = BI.map(self.storeValue.value, function (i, v) { var json = BI.map([self.storeValue], function (i, v) {
var txt = opts.valueFormatter(v) || v; var txt = opts.valueFormatter(v) || v;
return { return {
text: txt, text: txt,
@ -92202,7 +92202,7 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
setValue: function (v) { setValue: function (v) {
//暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了 //暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
this.storeValue = BI.deepClone(v); this.storeValue = v;
this.button_group.setValue(v); this.button_group.setValue(v);
}, },
@ -92350,10 +92350,10 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
var self = this, o = this.options; var self = this, o = this.options;
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && (self.storeValue.value = [self._startValue]); BI.isKey(self._startValue) && (self.storeValue = self._startValue);
self.trigger.getSearcher().setState(self.storeValue); self.trigger.getSearcher().setState(self.storeValue);
}; };
this.storeValue = {}; this.storeValue = '';
//标记正在请求数据 //标记正在请求数据
this.requesting = false; this.requesting = false;
@ -92374,7 +92374,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
o.itemsCreator(op, function (res) { o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) { if (op.times === 1 && BI.isNotNull(op.keywords)) {
//预防trigger内部把当前的storeValue改掉 //预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue())); self.trigger.setValue(self.getValue());
} }
callback.apply(self, arguments); callback.apply(self, arguments);
}); });
@ -92452,6 +92452,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
listeners: [{ listeners: [{
eventName: BI.SingleSelectPopupView.EVENT_CHANGE, eventName: BI.SingleSelectPopupView.EVENT_CHANGE,
action: function () { action: function () {
console.log(this.getValue())
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -92540,9 +92541,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
}, },
_assertValue: function (val) { _assertValue: function (val) {
val || (val = {}); val || (val = '');
val.type || (val.type = BI.Selection.Single);
val.value || (val.value = []);
}, },
_makeMap: function (values) { _makeMap: function (values) {
@ -92667,13 +92666,13 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue = v || {}; this.storeValue = v || '';
this._assertValue(this.storeValue); this._assertValue(this.storeValue);
this.combo.setValue(this.storeValue); this.combo.setValue(this.storeValue);
}, },
getValue: function () { getValue: function () {
return BI.deepClone(this.storeValue); return this.storeValue;
}, },
populate: function () { populate: function () {
@ -92763,16 +92762,12 @@ BI.SingleSelectList = BI.inherit(BI.Widget, {
this.list.addItems.apply(this.list, arguments); this.list.addItems.apply(this.list, arguments);
}, },
setValue: function (data) { setValue: function (v) {
this.list["setValue"](data.value); this.list.setValue([v]);
}, },
getValue: function () { getValue: function () {
return { return this.list.getValue()[0];
type: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
value: this.list.getValue(),
assist: this.list.getNotSelectedValue()
};
}, },
empty: function () { empty: function () {
@ -92883,13 +92878,13 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
var startValue = self._startValue; var startValue = self._startValue;
self.storeValue && (op = BI.extend(op || {}, { self.storeValue && (op = BI.extend(op || {}, {
selectedValues: self.storeValue.value selectedValues: [self.storeValue]
})); }));
opts.itemsCreator(op, function (ob) { opts.itemsCreator(op, function (ob) {
hasNext = ob.hasNext; hasNext = ob.hasNext;
var firstItems = []; var firstItems = [];
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
var json = BI.map(self.storeValue.value, function (i, v) { var json = BI.map([self.storeValue], function (i, v) {
var txt = opts.valueFormatter(v) || v; var txt = opts.valueFormatter(v) || v;
return { return {
text: txt, text: txt,
@ -92898,20 +92893,11 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
selected: false selected: false
} }
}); });
if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) {
var txt = opts.valueFormatter(startValue) || startValue;
json.unshift({
text: txt,
value: startValue,
title: txt,
selected: true
})
}
firstItems = self._createItems(json); firstItems = self._createItems(json);
} }
callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
BI.isKey(startValue) && self.storeValue.value["pushDistinct"](startValue); BI.isKey(startValue) && (self.storeValue = startValue);
self.setValue(self.storeValue); self.setValue(self.storeValue);
} }
(op.times === 1) && self._scrollToTop(); (op.times === 1) && self._scrollToTop();
@ -92946,9 +92932,7 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
}, },
_assertValue: function (val) { _assertValue: function (val) {
val || (val = {}); val || (val = '');
val.type || (val.type = BI.Selection.Single);
val.value || (val.value = []);
}, },
setStartValue: function (v) { setStartValue: function (v) {
@ -92956,7 +92940,7 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
}, },
setValue: function (v) { setValue: function (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);
}, },
@ -93043,10 +93027,6 @@ BI.SingleSelectPopupView = BI.inherit(BI.Widget, {
}); });
}, },
isAllSelected: function () {
return this.loader.isAllSelected();
},
setStartValue: function (v) { setStartValue: function (v) {
this.loader.setStartValue(v); this.loader.setStartValue(v);
}, },
@ -93164,8 +93144,8 @@ BI.SingleSelectTrigger = BI.inherit(BI.Trigger, {
this.searcher.setAdapter(adapter); this.searcher.setAdapter(adapter);
}, },
setValue: function (ob) { setValue: function (v) {
this.searcher.setValue(ob); this.searcher.setValue(v);
}, },
getKey: function () { getKey: function () {
@ -93371,22 +93351,13 @@ BI.SingleSelectSearcher = BI.inherit(BI.Widget, {
this.searcher.setAdapter(adapter); this.searcher.setAdapter(adapter);
}, },
setState: function (ob) { setState: function (v) {
var o = this.options; var o = this.options;
ob || (ob = {}); v || (v = '');
ob.value || (ob.value = []); if (v === '') {
if (ob.value.length === 0) {
this.editor.setState(BI.Selection.None); this.editor.setState(BI.Selection.None);
} else { } else {
var state = ""; this.editor.setState(o.valueFormatter(v + "") || v);
BI.each(ob.value, function (i, v) {
if (i === 0) {
state += "" + (o.valueFormatter(v + "") || v);
} else {
state += "," + (o.valueFormatter(v + "") || v);
}
});
this.editor.setState(state);
} }
}, },

15
dist/demo.js vendored

@ -13001,7 +13001,10 @@ Demo.SingleSelectCombo = BI.inherit(BI.Widget, {
var widget = BI.createWidget({ var widget = BI.createWidget({
type: 'bi.single_select_combo', type: 'bi.single_select_combo',
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: BI.bind(this._itemsCreator, this),
width: 200 width: 200,
ref: function () {
self.SingleSelectCombo = this;
}
}); });
widget.on(BI.SingleSelectCombo.EVENT_CONFIRM, function () { widget.on(BI.SingleSelectCombo.EVENT_CONFIRM, function () {
@ -13059,6 +13062,7 @@ Demo.SingleSelectCombo = BI.inherit(BI.Widget, {
}, },
render: function () { render: function () {
var self = this;
return { return {
type: 'bi.absolute', type: 'bi.absolute',
scrolly: false, scrolly: false,
@ -13066,6 +13070,15 @@ Demo.SingleSelectCombo = BI.inherit(BI.Widget, {
el: this._createSingleSelectCombo(), el: this._createSingleSelectCombo(),
right: "50%", right: "50%",
top: 10 top: 10
}, {
el: {
type: 'bi.button',
text: 'setValue("柳州市针织总厂")',
handler: function () {
self.SingleSelectCombo.setValue('柳州市针织总厂');
}
}
}] }]
} }
} }

77
dist/widget.js vendored

@ -16900,14 +16900,14 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
}, },
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
self.storeValue && (op = BI.extend(op || {}, { self.storeValue && (op = BI.extend(op || {}, {
selectedValues: self.storeValue.value selectedValues: [self.storeValue]
})); }));
opts.itemsCreator(op, function (ob) { opts.itemsCreator(op, function (ob) {
var keyword = ob.keyword = opts.keywordGetter(); var keyword = ob.keyword = opts.keywordGetter();
hasNext = ob.hasNext; hasNext = ob.hasNext;
var firstItems = []; var firstItems = [];
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
var json = BI.map(self.storeValue.value, function (i, v) { var json = BI.map([self.storeValue], function (i, v) {
var txt = opts.valueFormatter(v) || v; var txt = opts.valueFormatter(v) || v;
return { return {
text: txt, text: txt,
@ -16973,7 +16973,7 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
setValue: function (v) { setValue: function (v) {
//暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了 //暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
this.storeValue = BI.deepClone(v); this.storeValue = v;
this.button_group.setValue(v); this.button_group.setValue(v);
}, },
@ -17121,10 +17121,10 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
var self = this, o = this.options; var self = this, o = this.options;
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && (self.storeValue.value = [self._startValue]); BI.isKey(self._startValue) && (self.storeValue = self._startValue);
self.trigger.getSearcher().setState(self.storeValue); self.trigger.getSearcher().setState(self.storeValue);
}; };
this.storeValue = {}; this.storeValue = '';
//标记正在请求数据 //标记正在请求数据
this.requesting = false; this.requesting = false;
@ -17145,7 +17145,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
o.itemsCreator(op, function (res) { o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) { if (op.times === 1 && BI.isNotNull(op.keywords)) {
//预防trigger内部把当前的storeValue改掉 //预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue())); self.trigger.setValue(self.getValue());
} }
callback.apply(self, arguments); callback.apply(self, arguments);
}); });
@ -17223,6 +17223,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
listeners: [{ listeners: [{
eventName: BI.SingleSelectPopupView.EVENT_CHANGE, eventName: BI.SingleSelectPopupView.EVENT_CHANGE,
action: function () { action: function () {
console.log(this.getValue())
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -17311,9 +17312,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
}, },
_assertValue: function (val) { _assertValue: function (val) {
val || (val = {}); val || (val = '');
val.type || (val.type = BI.Selection.Single);
val.value || (val.value = []);
}, },
_makeMap: function (values) { _makeMap: function (values) {
@ -17438,13 +17437,13 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue = v || {}; this.storeValue = v || '';
this._assertValue(this.storeValue); this._assertValue(this.storeValue);
this.combo.setValue(this.storeValue); this.combo.setValue(this.storeValue);
}, },
getValue: function () { getValue: function () {
return BI.deepClone(this.storeValue); return this.storeValue;
}, },
populate: function () { populate: function () {
@ -17534,16 +17533,12 @@ BI.SingleSelectList = BI.inherit(BI.Widget, {
this.list.addItems.apply(this.list, arguments); this.list.addItems.apply(this.list, arguments);
}, },
setValue: function (data) { setValue: function (v) {
this.list["setValue"](data.value); this.list.setValue([v]);
}, },
getValue: function () { getValue: function () {
return { return this.list.getValue()[0];
type: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
value: this.list.getValue(),
assist: this.list.getNotSelectedValue()
};
}, },
empty: function () { empty: function () {
@ -17654,13 +17649,13 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
var startValue = self._startValue; var startValue = self._startValue;
self.storeValue && (op = BI.extend(op || {}, { self.storeValue && (op = BI.extend(op || {}, {
selectedValues: self.storeValue.value selectedValues: [self.storeValue]
})); }));
opts.itemsCreator(op, function (ob) { opts.itemsCreator(op, function (ob) {
hasNext = ob.hasNext; hasNext = ob.hasNext;
var firstItems = []; var firstItems = [];
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
var json = BI.map(self.storeValue.value, function (i, v) { var json = BI.map([self.storeValue], function (i, v) {
var txt = opts.valueFormatter(v) || v; var txt = opts.valueFormatter(v) || v;
return { return {
text: txt, text: txt,
@ -17669,20 +17664,11 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
selected: false selected: false
} }
}); });
if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) {
var txt = opts.valueFormatter(startValue) || startValue;
json.unshift({
text: txt,
value: startValue,
title: txt,
selected: true
})
}
firstItems = self._createItems(json); firstItems = self._createItems(json);
} }
callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
BI.isKey(startValue) && self.storeValue.value["pushDistinct"](startValue); BI.isKey(startValue) && (self.storeValue = startValue);
self.setValue(self.storeValue); self.setValue(self.storeValue);
} }
(op.times === 1) && self._scrollToTop(); (op.times === 1) && self._scrollToTop();
@ -17717,9 +17703,7 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
}, },
_assertValue: function (val) { _assertValue: function (val) {
val || (val = {}); val || (val = '');
val.type || (val.type = BI.Selection.Single);
val.value || (val.value = []);
}, },
setStartValue: function (v) { setStartValue: function (v) {
@ -17727,7 +17711,7 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
}, },
setValue: function (v) { setValue: function (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);
}, },
@ -17814,10 +17798,6 @@ BI.SingleSelectPopupView = BI.inherit(BI.Widget, {
}); });
}, },
isAllSelected: function () {
return this.loader.isAllSelected();
},
setStartValue: function (v) { setStartValue: function (v) {
this.loader.setStartValue(v); this.loader.setStartValue(v);
}, },
@ -17935,8 +17915,8 @@ BI.SingleSelectTrigger = BI.inherit(BI.Trigger, {
this.searcher.setAdapter(adapter); this.searcher.setAdapter(adapter);
}, },
setValue: function (ob) { setValue: function (v) {
this.searcher.setValue(ob); this.searcher.setValue(v);
}, },
getKey: function () { getKey: function () {
@ -18142,22 +18122,13 @@ BI.SingleSelectSearcher = BI.inherit(BI.Widget, {
this.searcher.setAdapter(adapter); this.searcher.setAdapter(adapter);
}, },
setState: function (ob) { setState: function (v) {
var o = this.options; var o = this.options;
ob || (ob = {}); v || (v = '');
ob.value || (ob.value = []); if (v === '') {
if (ob.value.length === 0) {
this.editor.setState(BI.Selection.None); this.editor.setState(BI.Selection.None);
} else { } else {
var state = ""; this.editor.setState(o.valueFormatter(v + "") || v);
BI.each(ob.value, function (i, v) {
if (i === 0) {
state += "" + (o.valueFormatter(v + "") || v);
} else {
state += "," + (o.valueFormatter(v + "") || v);
}
});
this.editor.setState(state);
} }
}, },

6
src/widget/singleselect/search/singleselect.search.loader.js

@ -51,14 +51,14 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
}, },
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
self.storeValue && (op = BI.extend(op || {}, { self.storeValue && (op = BI.extend(op || {}, {
selectedValues: self.storeValue.value selectedValues: [self.storeValue]
})); }));
opts.itemsCreator(op, function (ob) { opts.itemsCreator(op, function (ob) {
var keyword = ob.keyword = opts.keywordGetter(); var keyword = ob.keyword = opts.keywordGetter();
hasNext = ob.hasNext; hasNext = ob.hasNext;
var firstItems = []; var firstItems = [];
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
var json = BI.map(self.storeValue.value, function (i, v) { var json = BI.map([self.storeValue], function (i, v) {
var txt = opts.valueFormatter(v) || v; var txt = opts.valueFormatter(v) || v;
return { return {
text: txt, text: txt,
@ -124,7 +124,7 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
setValue: function (v) { setValue: function (v) {
//暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了 //暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
this.storeValue = BI.deepClone(v); this.storeValue = v;
this.button_group.setValue(v); this.button_group.setValue(v);
}, },

15
src/widget/singleselect/singleselect.combo.js

@ -19,10 +19,10 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
var self = this, o = this.options; var self = this, o = this.options;
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && (self.storeValue.value = [self._startValue]); BI.isKey(self._startValue) && (self.storeValue = self._startValue);
self.trigger.getSearcher().setState(self.storeValue); self.trigger.getSearcher().setState(self.storeValue);
}; };
this.storeValue = {}; this.storeValue = '';
//标记正在请求数据 //标记正在请求数据
this.requesting = false; this.requesting = false;
@ -43,7 +43,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
o.itemsCreator(op, function (res) { o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) { if (op.times === 1 && BI.isNotNull(op.keywords)) {
//预防trigger内部把当前的storeValue改掉 //预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue())); self.trigger.setValue(self.getValue());
} }
callback.apply(self, arguments); callback.apply(self, arguments);
}); });
@ -121,6 +121,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
listeners: [{ listeners: [{
eventName: BI.SingleSelectPopupView.EVENT_CHANGE, eventName: BI.SingleSelectPopupView.EVENT_CHANGE,
action: function () { action: function () {
console.log(this.getValue())
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -209,9 +210,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
}, },
_assertValue: function (val) { _assertValue: function (val) {
val || (val = {}); val || (val = '');
val.type || (val.type = BI.Selection.Single);
val.value || (val.value = []);
}, },
_makeMap: function (values) { _makeMap: function (values) {
@ -336,13 +335,13 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue = v || {}; this.storeValue = v || '';
this._assertValue(this.storeValue); this._assertValue(this.storeValue);
this.combo.setValue(this.storeValue); this.combo.setValue(this.storeValue);
}, },
getValue: function () { getValue: function () {
return BI.deepClone(this.storeValue); return this.storeValue;
}, },
populate: function () { populate: function () {

10
src/widget/singleselect/singleselect.list.js

@ -72,16 +72,12 @@ BI.SingleSelectList = BI.inherit(BI.Widget, {
this.list.addItems.apply(this.list, arguments); this.list.addItems.apply(this.list, arguments);
}, },
setValue: function (data) { setValue: function (v) {
this.list["setValue"](data.value); this.list.setValue([v]);
}, },
getValue: function () { getValue: function () {
return { return this.list.getValue()[0];
type: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
value: this.list.getValue(),
assist: this.list.getNotSelectedValue()
};
}, },
empty: function () { empty: function () {

21
src/widget/singleselect/singleselect.loader.js

@ -56,13 +56,13 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
var startValue = self._startValue; var startValue = self._startValue;
self.storeValue && (op = BI.extend(op || {}, { self.storeValue && (op = BI.extend(op || {}, {
selectedValues: self.storeValue.value selectedValues: [self.storeValue]
})); }));
opts.itemsCreator(op, function (ob) { opts.itemsCreator(op, function (ob) {
hasNext = ob.hasNext; hasNext = ob.hasNext;
var firstItems = []; var firstItems = [];
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
var json = BI.map(self.storeValue.value, function (i, v) { var json = BI.map([self.storeValue], function (i, v) {
var txt = opts.valueFormatter(v) || v; var txt = opts.valueFormatter(v) || v;
return { return {
text: txt, text: txt,
@ -71,20 +71,11 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
selected: false selected: false
} }
}); });
if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) {
var txt = opts.valueFormatter(startValue) || startValue;
json.unshift({
text: txt,
value: startValue,
title: txt,
selected: true
})
}
firstItems = self._createItems(json); firstItems = self._createItems(json);
} }
callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
BI.isKey(startValue) && self.storeValue.value["pushDistinct"](startValue); BI.isKey(startValue) && (self.storeValue = startValue);
self.setValue(self.storeValue); self.setValue(self.storeValue);
} }
(op.times === 1) && self._scrollToTop(); (op.times === 1) && self._scrollToTop();
@ -119,9 +110,7 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
}, },
_assertValue: function (val) { _assertValue: function (val) {
val || (val = {}); val || (val = '');
val.type || (val.type = BI.Selection.Single);
val.value || (val.value = []);
}, },
setStartValue: function (v) { setStartValue: function (v) {
@ -129,7 +118,7 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
}, },
setValue: function (v) { setValue: function (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);
}, },

4
src/widget/singleselect/singleselect.popup.view.js

@ -54,10 +54,6 @@ BI.SingleSelectPopupView = BI.inherit(BI.Widget, {
}); });
}, },
isAllSelected: function () {
return this.loader.isAllSelected();
},
setStartValue: function (v) { setStartValue: function (v) {
this.loader.setStartValue(v); this.loader.setStartValue(v);
}, },

4
src/widget/singleselect/singleselect.trigger.js

@ -85,8 +85,8 @@ BI.SingleSelectTrigger = BI.inherit(BI.Trigger, {
this.searcher.setAdapter(adapter); this.searcher.setAdapter(adapter);
}, },
setValue: function (ob) { setValue: function (v) {
this.searcher.setValue(ob); this.searcher.setValue(v);
}, },
getKey: function () { getKey: function () {

17
src/widget/singleselect/trigger/searcher.singleselect.js

@ -102,22 +102,13 @@ BI.SingleSelectSearcher = BI.inherit(BI.Widget, {
this.searcher.setAdapter(adapter); this.searcher.setAdapter(adapter);
}, },
setState: function (ob) { setState: function (v) {
var o = this.options; var o = this.options;
ob || (ob = {}); v || (v = '');
ob.value || (ob.value = []); if (v === '') {
if (ob.value.length === 0) {
this.editor.setState(BI.Selection.None); this.editor.setState(BI.Selection.None);
} else { } else {
var state = ""; this.editor.setState(o.valueFormatter(v + "") || v);
BI.each(ob.value, function (i, v) {
if (i === 0) {
state += "" + (o.valueFormatter(v + "") || v);
} else {
state += "," + (o.valueFormatter(v + "") || v);
}
});
this.editor.setState(state);
} }
}, },

Loading…
Cancel
Save