Browse Source

Merge pull request #415 in FUI/fineui from ~WINDY/fui:master to master

* commit '3a13391a90d315990363cb43c82ade798b6017cc':
  BI-19983
  update
  update
  BI-20841
  BI-20978
master
guy 7 years ago
parent
commit
2264077f81
  1. 4
      demo/js/widget/singleselct/demo.single_select_combo.js
  2. 42
      dist/_fineui.min.js
  3. 1949
      dist/bundle.js
  4. 42
      dist/bundle.min.js
  5. 9
      dist/case.js
  6. 109
      dist/demo.js
  7. 1949
      dist/fineui.js
  8. 42
      dist/fineui.min.js
  9. 1948
      dist/widget.js
  10. 9
      src/case/colorchooser/colorpicker/editor.colorpicker.js
  11. 12
      src/widget/datepane/datepane.js
  12. 12
      src/widget/datetimepane/datetimepane.js
  13. 15
      src/widget/dynamicdate/dynamicdate.combo.js
  14. 15
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  15. 0
      src/widget/multiselect/multiselect.insert.combo.js
  16. 18
      src/widget/singleselect/search/singleselect.search.loader.js
  17. 69
      src/widget/singleselect/singleselect.combo.js
  18. 106
      src/widget/singleselect/singleselect.insert.combo.js
  19. 2
      src/widget/singleselect/singleselect.loader.js
  20. 86
      src/widget/singleselect/singleselectlist.insert.js
  21. 174
      src/widget/singleselectaddsearch/search/singleselect.search.loader.js
  22. 98
      src/widget/singleselectaddsearch/search/singleselect.search.pane.js
  23. 110
      src/widget/singleselectaddsearch/singleselect.trigger.js
  24. 139
      src/widget/singleselectaddsearch/trigger/searcher.singleselect.js

4
demo/js/widget/singleselct/demo.single_select_combo.js

@ -9,7 +9,7 @@ Demo.SingleSelectCombo = BI.inherit(BI.Widget, {
_createSingleSelectCombo: function () { _createSingleSelectCombo: function () {
var self = this; var self = this;
var widget = BI.createWidget({ var widget = BI.createWidget({
type: "bi.single_select_combo", type: "bi.single_select_insert_combo",
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: BI.bind(this._itemsCreator, this),
width: 200, width: 200,
ref: function () { ref: function () {
@ -18,6 +18,8 @@ Demo.SingleSelectCombo = BI.inherit(BI.Widget, {
value: "柳州市针织总厂" value: "柳州市针织总厂"
}); });
widget.populate();
widget.on(BI.SingleSelectCombo.EVENT_CONFIRM, function () { widget.on(BI.SingleSelectCombo.EVENT_CONFIRM, function () {
BI.Msg.toast(JSON.stringify(this.getValue())); BI.Msg.toast(JSON.stringify(this.getValue()));
}); });

42
dist/_fineui.min.js vendored

File diff suppressed because one or more lines are too long

1949
dist/bundle.js vendored

File diff suppressed because it is too large Load Diff

42
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

9
dist/case.js vendored

@ -4486,7 +4486,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
} else { } else {
self.setValue(self.lastColor || "#ffffff"); self.setValue(self.lastColor || "#ffffff");
} }
if (self.R.isValid() && self.G.isValid() && self.B.isValid()) { if ((self.R.isValid() && self.G.isValid() && self.B.isValid()) || self._isEmptyRGB()) {
self.colorShow.element.css("background-color", self.getValue()); self.colorShow.element.css("background-color", self.getValue());
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
} }
@ -4511,7 +4511,8 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
} }
self.setValue(self.lastColor || "#ffffff"); self.setValue(self.lastColor || "#ffffff");
} }
if (self.R.isValid() && self.G.isValid() && self.B.isValid()) { if ((self.R.isValid() && self.G.isValid() && self.B.isValid()) ||
self._isEmptyRGB()) {
self.colorShow.element.css("background-color", self.getValue()); self.colorShow.element.css("background-color", self.getValue());
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
} }
@ -4577,6 +4578,10 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
}; };
}, },
_isEmptyRGB: function () {
return BI.isEmptyString(this.storeValue.r) && BI.isEmptyString(this.storeValue.g) && BI.isEmptyString(this.storeValue.b);
},
_showPreColor: function (color) { _showPreColor: function (color) {
if (color === "") { if (color === "") {
this.colorShow.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-background"); this.colorShow.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-background");

109
dist/demo.js vendored

@ -11017,6 +11017,111 @@ BI.shortcut("demo.tmp", Demo.Func);
}); });
BI.shortcut("demo.fix_global_watcher", Demo.Fix); BI.shortcut("demo.fix_global_watcher", Demo.Fix);
}());(function () {
var State = BI.inherit(Fix.Model, {
state: function () {
return {
name: "原始属性",
info: {
age: 12,
sex: "male",
birth: {
year: 2018,
month: 9,
day: 11
}
},
career: [{
a: 1,
b: 2,
c: 3
}]
};
},
computed: {
b: function () {
return this.model.name + "-计算属性";
},
birth: function () {
return this.model.info.birth;
}
}
});
Demo.Fix = BI.inherit(BI.Widget, {
_store: function () {
return new State();
},
watch: {
b: function () {
this.button.setText(this.model.b);
},
"birth.**": function () {
console.log(123);
}
},
render: function () {
var self = this;
return {
type: "bi.vertical",
items: [{
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.model.name = "这是改变后的属性";
},
text: this.model.b
}
}, {
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.model.birth.year = 2019;
},
text: "birthYearButton"
}
}, {
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.model.career.push({
year: 2017,
month: 3,
day: 24
});
},
text: "careerAddButton"
}
}, {
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.model.career[0].a = 24;
},
text: "careerChangeButton"
}
}]
};
},
mounted: function () {
}
});
BI.shortcut("demo.fix_immutable", Demo.Fix);
}());/** }());/**
* @Author: Young * @Author: Young
* @CreationDate 2017-11-06 10:32 * @CreationDate 2017-11-06 10:32
@ -13248,7 +13353,7 @@ Demo.SingleSelectCombo = BI.inherit(BI.Widget, {
_createSingleSelectCombo: function () { _createSingleSelectCombo: function () {
var self = this; var self = this;
var widget = BI.createWidget({ var widget = BI.createWidget({
type: "bi.single_select_combo", type: "bi.single_select_insert_combo",
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: BI.bind(this._itemsCreator, this),
width: 200, width: 200,
ref: function () { ref: function () {
@ -13257,6 +13362,8 @@ Demo.SingleSelectCombo = BI.inherit(BI.Widget, {
value: "柳州市针织总厂" value: "柳州市针织总厂"
}); });
widget.populate();
widget.on(BI.SingleSelectCombo.EVENT_CONFIRM, function () { widget.on(BI.SingleSelectCombo.EVENT_CONFIRM, function () {
BI.Msg.toast(JSON.stringify(this.getValue())); BI.Msg.toast(JSON.stringify(this.getValue()));
}); });

1949
dist/fineui.js vendored

File diff suppressed because it is too large Load Diff

42
dist/fineui.min.js vendored

File diff suppressed because one or more lines are too long

1948
dist/widget.js vendored

File diff suppressed because it is too large Load Diff

9
src/case/colorchooser/colorpicker/editor.colorpicker.js

@ -73,7 +73,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
} else { } else {
self.setValue(self.lastColor || "#ffffff"); self.setValue(self.lastColor || "#ffffff");
} }
if (self.R.isValid() && self.G.isValid() && self.B.isValid()) { if ((self.R.isValid() && self.G.isValid() && self.B.isValid()) || self._isEmptyRGB()) {
self.colorShow.element.css("background-color", self.getValue()); self.colorShow.element.css("background-color", self.getValue());
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
} }
@ -98,7 +98,8 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
} }
self.setValue(self.lastColor || "#ffffff"); self.setValue(self.lastColor || "#ffffff");
} }
if (self.R.isValid() && self.G.isValid() && self.B.isValid()) { if ((self.R.isValid() && self.G.isValid() && self.B.isValid()) ||
self._isEmptyRGB()) {
self.colorShow.element.css("background-color", self.getValue()); self.colorShow.element.css("background-color", self.getValue());
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
} }
@ -164,6 +165,10 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
}; };
}, },
_isEmptyRGB: function () {
return BI.isEmptyString(this.storeValue.r) && BI.isEmptyString(this.storeValue.g) && BI.isEmptyString(this.storeValue.b);
},
_showPreColor: function (color) { _showPreColor: function (color) {
if (color === "") { if (color === "") {
this.colorShow.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-background"); this.colorShow.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-background");

12
src/widget/datepane/datepane.js

@ -79,8 +79,10 @@ BI.DynamicDatePane = BI.inherit(BI.Widget, {
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
if(self._checkValue(self.getValue())) {
self.fireEvent("EVENT_CHANGE"); self.fireEvent("EVENT_CHANGE");
} }
}
}], }],
ref: function () { ref: function () {
self.dynamicPane = this; self.dynamicPane = this;
@ -100,6 +102,16 @@ BI.DynamicDatePane = BI.inherit(BI.Widget, {
return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value);
}, },
_checkValue: function (v) {
switch (v.type) {
case BI.DynamicDateCombo.Dynamic:
return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static:
default:
return true;
}
},
setValue: function (v) { setValue: function (v) {
v = v || {}; v = v || {};
var type = v.type || BI.DynamicDateCombo.Static; var type = v.type || BI.DynamicDateCombo.Static;

12
src/widget/datetimepane/datetimepane.js

@ -79,8 +79,10 @@ BI.DynamicDateTimePane = BI.inherit(BI.Widget, {
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
if(self._checkValue(self.getValue())) {
self.fireEvent("EVENT_CHANGE"); self.fireEvent("EVENT_CHANGE");
} }
}
}], }],
ref: function () { ref: function () {
self.dynamicPane = this; self.dynamicPane = this;
@ -100,6 +102,16 @@ BI.DynamicDateTimePane = BI.inherit(BI.Widget, {
return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value);
}, },
_checkValue: function (v) {
switch (v.type) {
case BI.DynamicDateCombo.Dynamic:
return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static:
default:
return true;
}
},
setValue: function (v) { setValue: function (v) {
v = v || {}; v = v || {};
var type = v.type || BI.DynamicDateTimePane.Static; var type = v.type || BI.DynamicDateTimePane.Static;

15
src/widget/dynamicdate/dynamicdate.combo.js

@ -156,7 +156,10 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
}, { }, {
eventName: BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE, eventName: BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE,
action: function () { action: function () {
self.setValue(self.popup.getValue()); var value = self.popup.getValue();
if(self._checkValue(value)) {
self.setValue(value);
}
self.combo.hideView(); self.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
} }
@ -233,6 +236,16 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
} }
}, },
_checkValue: function (v) {
switch (v.type) {
case BI.DynamicDateCombo.Dynamic:
return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static:
default:
return true;
}
},
setValue: function (v) { setValue: function (v) {
this.storeValue = v; this.storeValue = v;
this.trigger.setValue(v); this.trigger.setValue(v);

15
src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -159,7 +159,10 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
}, { }, {
eventName: BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE, eventName: BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE,
action: function () { action: function () {
self.setValue(self.popup.getValue()); var value = self.popup.getValue();
if(self._checkValue(value)) {
self.setValue(value);
}
self.combo.hideView(); self.combo.hideView();
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
} }
@ -236,6 +239,16 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
} }
}, },
_checkValue: function (v) {
switch (v.type) {
case BI.DynamicDateCombo.Dynamic:
return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static:
default:
return true;
}
},
setValue: function (v) { setValue: function (v) {
this.storeValue = v; this.storeValue = v;
this.trigger.setValue(v); this.trigger.setValue(v);

0
src/widget/multiselect/multiselect..insert.combo.js → src/widget/multiselect/multiselect.insert.combo.js

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

@ -58,19 +58,11 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
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 && BI.isNotNull(self.storeValue)) {
var json = BI.map([self.storeValue], function (i, v) { var json = self._filterValues(self.storeValue);
var txt = opts.valueFormatter(v) || v;
return {
text: txt,
value: v,
title: txt,
selected: false
};
});
firstItems = self._createItems(json); firstItems = self._createItems(json);
} }
callback(firstItems.concat(self._createItems(ob.items)), keyword); callback(firstItems.concat(self._createItems(ob.items)), keyword || "");
if (op.times === 1 && self.storeValue) { if (op.times === 1 && self.storeValue) {
self.setValue(self.storeValue); self.setValue(self.storeValue);
} }
@ -102,8 +94,8 @@ BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
_filterValues: function (src) { _filterValues: function (src) {
var o = this.options; var o = this.options;
var keyword = o.keywordGetter(); var keyword = o.keywordGetter();
var values = BI.deepClone(src.value) || []; var values = src || [];
var newValues = BI.map(values, function (i, v) { var newValues = BI.map(BI.isArray(values) ? values : [values], function (i, v) {
return { return {
text: o.valueFormatter(v) || v, text: o.valueFormatter(v) || v,
value: v value: v

69
src/widget/singleselect/singleselect.combo.js

@ -61,16 +61,11 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () { this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) { if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword(); var keyword = this.getSearcher().getKeyword();
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self.combo.setValue(self.storeValue); self.combo.setValue(self.storeValue);
self._setStartValue(keyword); self._setStartValue(keyword);
assertShowValue(); assertShowValue();
self.populate(); self.populate();
self._setStartValue(); self._setStartValue();
});
} }
}); });
this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) { this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) {
@ -222,44 +217,6 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
} }
}, },
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this.requesting = true;
o.itemsCreator({
type: BI.SingleSelectCombo.REQ_GET_ALL_DATA,
keywords: [this.trigger.getKey()]
}, function (ob) {
var items = BI.map(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];
BI.each(items, function (i, item) {
if (BI.isNotNull(selectedMap[items[i]])) {
delete selectedMap[items[i]];
}
if (BI.isNull(notSelectedMap[items[i]])) {
newItems.push(item);
}
});
self.storeValue.value = newItems.concat(BI.values(selectedMap));
self._adjust(callback);
});
},
_adjust: function (callback) { _adjust: function (callback) {
var self = this, o = this.options; var self = this, o = this.options;
if (!this._count) { if (!this._count) {
@ -285,32 +242,6 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
} }
}, },
_join: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this._assertValue(this.storeValue);
if (this.storeValue.type === res.type) {
var map = this._makeMap(this.storeValue.value);
BI.each(res.value, function (i, v) {
if (!map[v]) {
self.storeValue.value.push(v);
map[v] = v;
}
});
var change = false;
BI.each(res.assist, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
this._joinAll(res, callback);
},
_setStartValue: function (value) { _setStartValue: function (value) {
this._startValue = value; this._startValue = value;
this.popup.setStartValue(value); this.popup.setStartValue(value);

106
src/widget/singleselectaddsearch/singleselect.combo.js → src/widget/singleselect/singleselect.insert.combo.js

@ -22,12 +22,12 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
BI.isKey(self._startValue) && (self.storeValue = 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 = o.value;
// 标记正在请求数据 // 标记正在请求数据
this.requesting = false; this.requesting = false;
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.single_select_add_trigger", type: "bi.single_select_trigger",
height: o.height, height: o.height,
// adapter: this.popup, // adapter: this.popup,
masker: { masker: {
@ -47,30 +47,25 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
} }
callback.apply(self, arguments); callback.apply(self, arguments);
}); });
} },
value: this.storeValue
}); });
this.trigger.on(BI.SingleSelectTrigger.EVENT_START, function () { this.trigger.on(BI.SingleSelectTrigger.EVENT_START, function () {
self._setStartValue(""); self._setStartValue();
this.getSearcher().setValue(self.storeValue); this.getSearcher().setValue(self.storeValue);
}); });
this.trigger.on(BI.SingleSelectTrigger.EVENT_STOP, function () { this.trigger.on(BI.SingleSelectTrigger.EVENT_STOP, function () {
self._setStartValue(""); self._setStartValue();
}); });
this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () { this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword(); var keyword = this.getSearcher().getKeyword();
self._join({ self.storeValue = keyword;
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self.combo.setValue(self.storeValue); self.combo.setValue(self.storeValue);
self._setStartValue(keyword); self._setStartValue(keyword);
assertShowValue(); assertShowValue();
self.populate(); self.populate();
self._setStartValue(""); self._setStartValue();
});
}
}); });
this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) { this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords); var last = BI.last(keywords);
@ -81,7 +76,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
self.combo.setValue(self.storeValue); self.combo.setValue(self.storeValue);
assertShowValue(); assertShowValue();
self.combo.populate(); self.combo.populate();
self._setStartValue(""); self._setStartValue();
} else { } else {
self.combo.setValue(self.storeValue); self.combo.setValue(self.storeValue);
assertShowValue(); assertShowValue();
@ -93,6 +88,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
this.trigger.on(BI.SingleSelectTrigger.EVENT_CHANGE, function (value, obj) { this.trigger.on(BI.SingleSelectTrigger.EVENT_CHANGE, function (value, obj) {
self.storeValue = this.getValue(); self.storeValue = this.getValue();
assertShowValue(); assertShowValue();
self._defaultState();
}); });
this.trigger.on(BI.SingleSelectTrigger.EVENT_COUNTER_CLICK, function () { this.trigger.on(BI.SingleSelectTrigger.EVENT_COUNTER_CLICK, function () {
if (!self.combo.isViewVisible()) { if (!self.combo.isViewVisible()) {
@ -133,7 +129,8 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
}, },
hideChecker: function (e) { hideChecker: function (e) {
return triggerBtn.element.find(e.target).length === 0; return triggerBtn.element.find(e.target).length === 0;
} },
value: o.value
}); });
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
@ -191,7 +188,6 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
}, },
_assertValue: function (val) { _assertValue: function (val) {
val || (val = "");
}, },
_makeMap: function (values) { _makeMap: function (values) {
@ -221,60 +217,11 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
} }
}, },
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this.requesting = true;
o.itemsCreator({
type: BI.SingleSelectInsertCombo.REQ_GET_ALL_DATA,
keywords: [this.trigger.getKey()]
}, function (ob) {
var items = BI.map(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];
BI.each(items, function (i, item) {
if (BI.isNotNull(selectedMap[items[i]])) {
delete selectedMap[items[i]];
}
if (BI.isNull(notSelectedMap[items[i]])) {
newItems.push(item);
}
});
self.storeValue.value = newItems.concat(BI.values(selectedMap));
self._adjust(callback);
});
},
_adjust: function (callback) { _adjust: function (callback) {
var self = this, o = this.options; var self = this, o = this.options;
if (!this._count) {
o.itemsCreator({
type: BI.SingleSelectInsertCombo.REQ_GET_DATA_LENGTH
}, function (res) {
self._count = res.count;
adjust();
callback();
});
} else {
adjust(); adjust();
callback(); callback();
}
function adjust () { function adjust () {
if (self.wants2Quit === true) { if (self.wants2Quit === true) {
self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM); self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM);
@ -284,39 +231,13 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
} }
}, },
_join: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this._assertValue(this.storeValue);
if (this.storeValue.type === res.type) {
var map = this._makeMap(this.storeValue.value);
BI.each(res.value, function (i, v) {
if (!map[v]) {
self.storeValue.value.push(v);
map[v] = v;
}
});
var change = false;
BI.each(res.assist, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
this._joinAll(res, callback);
},
_setStartValue: function (value) { _setStartValue: function (value) {
this._startValue = value; this._startValue = value;
this.popup.setStartValue(value); this.popup.setStartValue(value);
}, },
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);
}, },
@ -326,7 +247,6 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
}, },
populate: function () { populate: function () {
this._count = null;
this.combo.populate.apply(this.combo, arguments); this.combo.populate.apply(this.combo, arguments);
} }
}); });

2
src/widget/singleselect/singleselect.loader.js

@ -26,7 +26,7 @@ BI.SingleSelectLoader = BI.inherit(BI.Widget, {
var self = this, opts = this.options; var self = this, opts = this.options;
var hasNext = false; var hasNext = false;
this.storeValue = opts.value;
this.button_group = BI.createWidget({ this.button_group = BI.createWidget({
type: "bi.single_select_list", type: "bi.single_select_list",
element: this, element: this,

86
src/widget/singleselect/singleselectlist.insert.js

@ -18,7 +18,7 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, {
this.storeValue = o.value; this.storeValue = o.value;
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); BI.isKey(self._startValue) && (self.storeValue = self._startValue);
// self.trigger.setValue(self.storeValue); // self.trigger.setValue(self.storeValue);
}; };
@ -87,14 +87,7 @@ 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._join({
type: BI.Selection.Single,
value: [keyword]
}, function () {
if (self.storeValue.type === BI.Selection.Single) {
self.storeValue.value.pushDistinct(keyword);
}
self._showAdapter(); self._showAdapter();
self.adapter.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
self._setStartValue(keyword); self._setStartValue(keyword);
@ -102,18 +95,6 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, {
self.adapter.populate(); self.adapter.populate();
self._setStartValue(); self._setStartValue();
self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE);
});
} else {
if (self.storeValue.type === BI.Selection.Single) {
self.storeValue.value.pushDistinct(keyword);
}
self._showAdapter();
self.adapter.setValue(self.storeValue);
self.adapter.populate();
if (self.storeValue.type === BI.Selection.Single) {
self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE);
}
}
} }
}, { }, {
eventName: BI.Searcher.EVENT_SEARCHING, eventName: BI.Searcher.EVENT_SEARCHING,
@ -213,69 +194,6 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, {
} }
}, },
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
o.itemsCreator({
type: BI.SingleSelectInsertList.REQ_GET_ALL_DATA,
keyword: self.trigger.getKeyword()
}, function (ob) {
var items = BI.map(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
callback();
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];
BI.each(items, function (i, item) {
if (BI.isNotNull(selectedMap[items[i]])) {
delete selectedMap[items[i]];
}
if (BI.isNull(notSelectedMap[items[i]])) {
newItems.push(item);
}
});
self.storeValue.value = newItems.concat(BI.values(selectedMap));
callback();
});
},
_join: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this._assertValue(this.storeValue);
if (this.storeValue.type === res.type) {
var map = this._makeMap(this.storeValue.value);
BI.each(res.value, function (i, v) {
if (!map[v]) {
self.storeValue.value.push(v);
map[v] = v;
}
});
var change = false;
BI.each(res.assist, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
callback();
return;
}
this._joinAll(res, callback);
},
_setStartValue: function (value) { _setStartValue: function (value) {
this._startValue = value; this._startValue = value;
this.adapter.setStartValue(value); this.adapter.setStartValue(value);

174
src/widget/singleselectaddsearch/search/singleselect.search.loader.js

@ -1,174 +0,0 @@
/**
* 单选加载数据搜索loader面板
* Created by guy on 15/11/4.
* @class BI.SingleSelectSearchLoader
* @extends Widget
*/
BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SingleSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-select-search-loader",
itemsCreator: BI.emptyFn,
keywordGetter: BI.emptyFn,
valueFormatter: BI.emptyFn
});
},
_init: function () {
BI.SingleSelectSearchLoader.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
var hasNext = false;
this.button_group = BI.createWidget({
type: "bi.single_select_list",
element: this,
logic: {
dynamic: false
},
el: {
tipText: BI.i18nText("BI-No_Select"),
el: {
type: "bi.loader",
isDefaultInit: false,
logic: {
dynamic: true,
scrolly: true
},
el: {
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
behaviors: {
redmark: function () {
return true;
}
},
layouts: [{
type: "bi.vertical"
}]
}
}
},
itemsCreator: function (op, callback) {
self.storeValue && (op = BI.extend(op || {}, {
selectedValues: [self.storeValue]
}));
opts.itemsCreator(op, function (ob) {
var keyword = ob.keyword = opts.keywordGetter();
hasNext = ob.hasNext;
var firstItems = [];
if (op.times === 1 && self.storeValue) {
var json = BI.map([self.storeValue], function (i, v) {
var txt = opts.valueFormatter(v) || v;
return {
text: txt,
value: v,
title: txt,
selected: false
};
});
firstItems = self._createItems(json);
}
if(keyword) {
var flag = false;
for(var i = 0; i < ob.items.length; i++) {
if(BI.contains(ob.items[i], keyword)) {
flag = true;
}
}
if(!flag) {
var preItems = self._createItems([{
text: keyword,
value: keyword,
title: keyword,
selected: false
}]);
firstItems = firstItems.concat(preItems);
}
}
callback(firstItems.concat(self._createItems(ob.items)), keyword);
if (op.times === 1 && self.storeValue) {
self.setValue(self.storeValue);
}
});
},
hasNext: function () {
return hasNext;
}
});
this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.button_group.on(BI.SingleSelectList.EVENT_CHANGE, function () {
self.fireEvent(BI.SingleSelectSearchLoader.EVENT_CHANGE, arguments);
});
},
_createItems: function (items) {
return BI.createItems(items, {
type: "bi.single_select_combo.item",
logic: {
dynamic: false
},
height: 25,
selected: false
});
},
_filterValues: function (src) {
var o = this.options;
var keyword = o.keywordGetter();
var values = BI.deepClone(src.value) || [];
var newValues = BI.map(values, function (i, v) {
return {
text: o.valueFormatter(v) || v,
value: v
};
});
if (BI.isKey(keyword)) {
var search = BI.Func.getSearchResult(newValues, keyword);
values = search.match.concat(search.find);
}
return BI.map(values, function (i, v) {
return {
text: v.text,
title: v.text,
value: v.value,
selected: false
};
});
},
setValue: function (v) {
// 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
this.storeValue = v;
this.button_group.setValue(v);
},
getValue: function () {
return this.button_group.getValue();
},
getAllButtons: function () {
return this.button_group.getAllButtons();
},
empty: function () {
this.button_group.empty();
},
populate: function (items) {
this.button_group.populate.apply(this.button_group, arguments);
},
resetHeight: function (h) {
this.button_group.resetHeight(h);
},
resetWidth: function (w) {
this.button_group.resetWidth(w);
}
});
BI.SingleSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.single_select_search_add_loader", BI.SingleSelectSearchLoader);

98
src/widget/singleselectaddsearch/search/singleselect.search.pane.js

@ -1,98 +0,0 @@
/**
*
* 在搜索框中输入文本弹出的面板
* @class BI.SingleSelectSearchPane
* @extends Widget
*/
BI.SingleSelectSearchPane = BI.inherit(BI.Widget, {
constants: {
height: 25,
lgap: 10,
tgap: 5
},
_defaultConfig: function () {
return BI.extend(BI.SingleSelectSearchPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-select-search-pane bi-card",
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
keywordGetter: BI.emptyFn
});
},
_init: function () {
BI.SingleSelectSearchPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.tooltipClick = BI.createWidget({
type: "bi.label",
invisible: true,
text: BI.i18nText("BI-Click_Blank_To_Select"),
cls: "single-select-toolbar",
height: this.constants.height
});
this.loader = BI.createWidget({
type: "bi.single_select_search_add_loader",
keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter,
itemsCreator: function (op, callback) {
o.itemsCreator.apply(self, [op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
}]);
}
});
this.loader.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.resizer = BI.createWidget({
type: "bi.vtape",
element: this,
items: [{
el: this.tooltipClick,
height: 0
}, {
el: this.loader
}]
});
this.tooltipClick.setVisible(false);
},
setKeyword: function (keyword) {
var btn;
var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue());
if (isVisible !== this.tooltipClick.isVisible()) {
this.tooltipClick.setVisible(isVisible);
this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0);
this.resizer.resize();
}
},
hasMatched: function () {
return this.tooltipClick.isVisible();
},
setValue: function (v) {
this.loader.setValue(v);
},
getValue: function () {
return this.loader.getValue();
},
empty: function () {
this.loader.empty();
},
populate: function (items) {
this.loader.populate.apply(this.loader, arguments);
}
});
BI.SingleSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.single_select_search_add_pane", BI.SingleSelectSearchPane);

110
src/widget/singleselectaddsearch/singleselect.trigger.js

@ -1,110 +0,0 @@
/**
*
* 单选下拉框
* @class BI.SingleSelectTrigger
* @extends BI.Trigger
*/
BI.SingleSelectTrigger = BI.inherit(BI.Trigger, {
constants: {
height: 14,
rgap: 4,
lgap: 4
},
_defaultConfig: function () {
return BI.extend(BI.SingleSelectTrigger.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-select-trigger bi-border",
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
searcher: {},
switcher: {},
adapter: null,
masker: {}
});
},
_init: function () {
BI.SingleSelectTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (o.height) {
this.setHeight(o.height - 2);
}
this.searcher = BI.createWidget(o.searcher, {
type: "bi.single_select_add_searcher",
height: o.height,
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
popup: {},
adapter: o.adapter,
masker: o.masker
});
this.searcher.on(BI.SingleSelectSearcher.EVENT_START, function () {
self.fireEvent(BI.SingleSelectTrigger.EVENT_START);
});
this.searcher.on(BI.SingleSelectSearcher.EVENT_PAUSE, function () {
self.fireEvent(BI.SingleSelectTrigger.EVENT_PAUSE);
});
this.searcher.on(BI.SingleSelectSearcher.EVENT_SEARCHING, function () {
self.fireEvent(BI.SingleSelectTrigger.EVENT_SEARCHING, arguments);
});
this.searcher.on(BI.SingleSelectSearcher.EVENT_STOP, function () {
self.fireEvent(BI.SingleSelectTrigger.EVENT_STOP);
});
this.searcher.on(BI.SingleSelectSearcher.EVENT_CHANGE, function () {
self.fireEvent(BI.SingleSelectTrigger.EVENT_CHANGE, arguments);
});
var wrapper = BI.createWidget({
type: "bi.htape",
element: this,
items: [
{
el: this.searcher,
width: "fill"
}, {
el: BI.createWidget(),
width: 30
}]
});
},
getSearcher: function () {
return this.searcher;
},
stopEditing: function () {
this.searcher.stopSearch();
},
setAdapter: function (adapter) {
this.searcher.setAdapter(adapter);
},
setValue: function (v) {
this.searcher.setValue(v);
},
getKey: function () {
return this.searcher.getKey();
},
getValue: function () {
return this.searcher.getValue();
}
});
BI.SingleSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
BI.SingleSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
BI.SingleSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.SingleSelectTrigger.EVENT_START = "EVENT_START";
BI.SingleSelectTrigger.EVENT_STOP = "EVENT_STOP";
BI.SingleSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE";
BI.SingleSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.SingleSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
BI.shortcut("bi.single_select_add_trigger", BI.SingleSelectTrigger);

139
src/widget/singleselectaddsearch/trigger/searcher.singleselect.js

@ -1,139 +0,0 @@
/**
* searcher
* Created by guy on 15/11/3.
* @class BI.SingleSelectSearcher
* @extends Widget
*/
BI.SingleSelectSearcher = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SingleSelectSearcher.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-select-searcher",
itemsCreator: BI.emptyFn,
el: {},
popup: {},
valueFormatter: BI.emptyFn,
adapter: null,
masker: {}
});
},
_init: function () {
BI.SingleSelectSearcher.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget(o.el, {
type: "bi.single_select_editor",
height: o.height
});
this.searcher = BI.createWidget({
type: "bi.searcher",
element: this,
height: o.height,
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback();
},
el: this.editor,
popup: BI.extend({
type: "bi.single_select_search_add_pane",
valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.editor.getValue();
},
itemsCreator: function (op, callback) {
op.keyword = self.editor.getValue();
this.setKeyword(op.keyword);
o.itemsCreator(op, callback);
}
}, o.popup),
adapter: o.adapter,
masker: o.masker
});
this.searcher.on(BI.Searcher.EVENT_START, function () {
self.fireEvent(BI.SingleSelectSearcher.EVENT_START);
});
this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
if (this.hasMatched()) {
}
self.fireEvent(BI.SingleSelectSearcher.EVENT_PAUSE);
});
this.searcher.on(BI.Searcher.EVENT_STOP, function () {
self.fireEvent(BI.SingleSelectSearcher.EVENT_STOP);
});
this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
self.fireEvent(BI.SingleSelectSearcher.EVENT_CHANGE, arguments);
});
this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () {
var keywords = this.getKeywords();
self.fireEvent(BI.SingleSelectSearcher.EVENT_SEARCHING, keywords);
});
},
adjustView: function () {
this.searcher.adjustView();
},
isSearching: function () {
return this.searcher.isSearching();
},
stopSearch: function () {
this.searcher.stopSearch();
},
getKeyword: function () {
return this.editor.getValue();
},
hasMatched: function () {
return this.searcher.hasMatched();
},
hasChecked: function () {
return this.searcher.getView() && this.searcher.getView().hasChecked();
},
setAdapter: function (adapter) {
this.searcher.setAdapter(adapter);
},
setState: function (v) {
var o = this.options;
v || (v = "");
if (v === "") {
this.editor.setState(BI.Selection.None);
} else {
this.editor.setState(o.valueFormatter(v + "") || (v + ""));
}
},
setValue: function (ob) {
this.setState(ob);
this.searcher.setValue(ob);
},
getKey: function () {
return this.editor.getValue();
},
getValue: function () {
return this.searcher.getValue();
},
populate: function (items) {
this.searcher.populate.apply(this.searcher, arguments);
}
});
BI.SingleSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.SingleSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE";
BI.SingleSelectSearcher.EVENT_START = "EVENT_START";
BI.SingleSelectSearcher.EVENT_STOP = "EVENT_STOP";
BI.SingleSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE";
BI.SingleSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.shortcut("bi.single_select_add_searcher", BI.SingleSelectSearcher);
Loading…
Cancel
Save