Browse Source

Merge pull request #197 in FUI/fineui from ~GUY/fineui:master to master

* commit '007b7fb9f6d6210d299be70825c366ea2bd43969':
  Merge remote-tracking branch 'remotes/origin/BI4.1'
  Merge remote-tracking branch 'remotes/origin/BI4.1'
  Merge remote-tracking branch 'remotes/origin/BI4.1'
  change single_select_combo value to string
  Merge remote-tracking branch 'remotes/origin/BI4.1'
  Merge remote-tracking branch 'remotes/origin/BI4.1'
  Merge remote-tracking branch 'remotes/origin/BI4.1'
  Merge remote-tracking branch 'remotes/origin/BI4.1'
  Merge remote-tracking branch 'remotes/origin/BI4.1'
es6
guy 7 years ago
parent
commit
d50fb7022e
  1. 2
      bi/case.js
  2. 76
      bi/widget.js
  3. 14
      demo/js/config/fix.js
  4. 15
      demo/js/widget/singleselct/demo.single_select_combo.js
  5. 78
      dist/bundle.js
  6. 82
      dist/bundle.min.js
  7. 2
      dist/case.js
  8. 29
      dist/demo.js
  9. 36
      dist/fix/fix.compact.js
  10. 2
      dist/fix/fix.js
  11. 76
      dist/widget.js
  12. 2
      src/case/richeditor/richeditor.js
  13. 6
      src/widget/singleselect/search/singleselect.search.loader.js
  14. 14
      src/widget/singleselect/singleselect.combo.js
  15. 10
      src/widget/singleselect/singleselect.list.js
  16. 21
      src/widget/singleselect/singleselect.loader.js
  17. 4
      src/widget/singleselect/singleselect.popup.view.js
  18. 4
      src/widget/singleselect/singleselect.trigger.js
  19. 17
      src/widget/singleselect/trigger/searcher.singleselect.js

2
bi/case.js

@ -10430,7 +10430,7 @@ BI.RichEditor = BI.inherit(BI.Widget, {
type: "bi.combo", type: "bi.combo",
element: this, element: this,
toggle: false, toggle: false,
direction: "top", direction: "top,left",
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
adjustLength: 1, adjustLength: 1,

76
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);
}); });
@ -17311,9 +17311,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 +17436,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 +17532,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 +17648,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 +17663,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 +17702,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 +17710,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 +17797,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 +17914,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 +18121,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);
} }
}, },

14
demo/js/config/fix.js

@ -94,37 +94,37 @@ Demo.FIX_CONFIG = [{
text: "state属性", text: "state属性",
value: "demo.fix_state" value: "demo.fix_state"
}, { }, {
id: 78, id: 73,
pId: 7, pId: 7,
text: "计算属性", text: "计算属性",
value: "demo.fix_computed" value: "demo.fix_computed"
}, { }, {
id: 73, id: 74,
pId: 7, pId: 7,
text: "store", text: "store",
value: "demo.fix_store" value: "demo.fix_store"
}, { }, {
id: 74, id: 75,
pId: 7, pId: 7,
text: "watcher且或表达式", text: "watcher且或表达式",
value: "demo.fix_watcher" value: "demo.fix_watcher"
}, { }, {
id: 75, id: 76,
pId: 7, pId: 7,
text: "watcher星号表达式", text: "watcher星号表达式",
value: "demo.fix_global_watcher" value: "demo.fix_global_watcher"
}, { }, {
id: 76, id: 77,
pId: 7, pId: 7,
text: "context", text: "context",
value: "demo.fix_context" value: "demo.fix_context"
}, { }, {
id: 77, id: 78,
pId: 7, pId: 7,
text: "一个混合的例子", text: "一个混合的例子",
value: "demo.fix" value: "demo.fix"
}, { }, {
id: 78, id: 79,
pId: 7, pId: 7,
text: "场景", text: "场景",
value: "demo.fix_scene" value: "demo.fix_scene"

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('柳州市针织总厂');
}
}
}] }]
} }
} }

78
dist/bundle.js vendored

@ -71892,7 +71892,7 @@ BI.RichEditor = BI.inherit(BI.Widget, {
type: "bi.combo", type: "bi.combo",
element: this, element: this,
toggle: false, toggle: false,
direction: "top", direction: "top,left",
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
adjustLength: 1, adjustLength: 1,
@ -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);
}); });
@ -92540,9 +92540,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 +92665,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 +92761,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 +92877,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 +92892,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 +92931,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 +92939,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 +93026,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 +93143,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 +93350,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);
} }
}, },

82
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/case.js vendored

@ -10430,7 +10430,7 @@ BI.RichEditor = BI.inherit(BI.Widget, {
type: "bi.combo", type: "bi.combo",
element: this, element: this,
toggle: false, toggle: false,
direction: "top", direction: "top,left",
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
adjustLength: 1, adjustLength: 1,

29
dist/demo.js vendored

@ -5268,37 +5268,37 @@ Demo.FIX_CONFIG = [{
text: "state属性", text: "state属性",
value: "demo.fix_state" value: "demo.fix_state"
}, { }, {
id: 78, id: 73,
pId: 7, pId: 7,
text: "计算属性", text: "计算属性",
value: "demo.fix_computed" value: "demo.fix_computed"
}, { }, {
id: 73, id: 74,
pId: 7, pId: 7,
text: "store", text: "store",
value: "demo.fix_store" value: "demo.fix_store"
}, { }, {
id: 74, id: 75,
pId: 7, pId: 7,
text: "watcher且或表达式", text: "watcher且或表达式",
value: "demo.fix_watcher" value: "demo.fix_watcher"
}, { }, {
id: 75, id: 76,
pId: 7, pId: 7,
text: "watcher星号表达式", text: "watcher星号表达式",
value: "demo.fix_global_watcher" value: "demo.fix_global_watcher"
}, { }, {
id: 76, id: 77,
pId: 7, pId: 7,
text: "context", text: "context",
value: "demo.fix_context" value: "demo.fix_context"
}, { }, {
id: 77, id: 78,
pId: 7, pId: 7,
text: "一个混合的例子", text: "一个混合的例子",
value: "demo.fix" value: "demo.fix"
}, { }, {
id: 78, id: 79,
pId: 7, pId: 7,
text: "场景", text: "场景",
value: "demo.fix_scene" value: "demo.fix_scene"
@ -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('柳州市针织总厂');
}
}
}] }]
} }
} }

36
dist/fix/fix.compact.js vendored

@ -13,8 +13,10 @@
} }
} }
function createWatcher(vm, keyOrFn, handler, options) { function createWatcher(vm, keyOrFn, handler) {
return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), options) return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), {
store: vm.store
})
} }
var target = null var target = null
@ -29,6 +31,23 @@
Fix.Model.target = target = targetStack.pop() Fix.Model.target = target = targetStack.pop()
} }
var oldWatch = Fix.watch;
Fix.watch = function (model, expOrFn, cb, options) {
if (BI.isPlainObject(cb)) {
options = cb
cb = cb.handler
}
if (typeof cb === 'string') {
cb = model[cb]
}
return oldWatch.call(this, model, expOrFn, function () {
pushTarget(options.store);
var res = cb.apply(this, arguments);
popTarget();
return res;
}, options);
}
var _init = BI.Widget.prototype._init; var _init = BI.Widget.prototype._init;
BI.Widget.prototype._init = function () { BI.Widget.prototype._init = function () {
var needPop = false; var needPop = false;
@ -74,6 +93,15 @@
this.store && (this.store._parent = null, this.store = null); this.store && (this.store._parent = null, this.store = null);
} }
_.each(["mounted", "populate"], function (name) {
var old = BI.Widget.prototype[name];
old && (BI.Widget.prototype[name] = function () {
this.store && pushTarget(this.store);
return old.apply(this, arguments);
this.store && popTarget();
});
})
_.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min", _.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
"sortBy", "groupBy", "indexBy", "countBy", "partition", "sortBy", "groupBy", "indexBy", "countBy", "partition",
"keys", "allKeys", "values", "pairs", "invert", "keys", "allKeys", "values", "pairs", "invert",
@ -82,9 +110,9 @@
BI[name] = function (obj, fn) { BI[name] = function (obj, fn) {
return typeof fn === "function" ? old(obj, function (key, value) { return typeof fn === "function" ? old(obj, function (key, value) {
if (!(key in Fix.$$skipArray)) { if (!(key in Fix.$$skipArray)) {
return fn.apply(null, arguments); return fn.apply(this, arguments);
} }
}) : old.apply(null, arguments); }) : old.apply(this, arguments);
} }
}); });
}()); }());

2
dist/fix/fix.js vendored

@ -1159,7 +1159,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
return vm.$$state[key]; return vm.$$state[key];
} }
if (vm.$$model && key in vm.$$model) { if (vm.$$model && key in vm.$$model) {
return vm.$$model; return vm.$$model[key];
} }
var p = vm._parent; var p = vm._parent;
while (p) { while (p) {

76
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);
}); });
@ -17311,9 +17311,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 +17436,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 +17532,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 +17648,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 +17663,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 +17702,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 +17710,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 +17797,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 +17914,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 +18121,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);
} }
}, },

2
src/case/richeditor/richeditor.js

@ -29,7 +29,7 @@ BI.RichEditor = BI.inherit(BI.Widget, {
type: "bi.combo", type: "bi.combo",
element: this, element: this,
toggle: false, toggle: false,
direction: "top", direction: "top,left",
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
adjustLength: 1, adjustLength: 1,

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);
}, },

14
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);
}); });
@ -209,9 +209,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 +334,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