Browse Source

没写dataChange的整理下

es6
guy 3 years ago
parent
commit
c10d61889d
  1. 2
      src/widget/multiselect/multiselect.insert.combo.nobar.js
  2. 2
      src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js
  3. 13
      src/widget/singleselect/singleselect.combo.js
  4. 12
      src/widget/singleselect/singleselect.insert.combo.js

2
src/widget/multiselect/multiselect.insert.combo.nobar.js

@ -401,7 +401,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
callback(); callback();
function adjust () { function adjust () {
if (self.wants2Quit === true) { if (self.wants2Quit === true) {
self.fireEvent(BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM); self._dataChange && self.fireEvent(BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM);
self.wants2Quit = false; self.wants2Quit = false;
} }
self.requesting = false; self.requesting = false;

2
src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js

@ -333,7 +333,7 @@ BI.SearchMultiTextValueCombo = BI.inherit(BI.Single, {
self._updateAllValue(); self._updateAllValue();
self._checkError(); self._checkError();
if (self.wants2Quit === true) { if (self.wants2Quit === true) {
self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM); self._dataChange && self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM);
self.wants2Quit = false; self.wants2Quit = false;
} }
self.requesting = false; self.requesting = false;

13
src/widget/singleselect/singleselect.combo.js

@ -64,6 +64,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
self.fireEvent(BI.SingleSelectCombo.EVENT_STOP); self.fireEvent(BI.SingleSelectCombo.EVENT_STOP);
}); });
this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function () { this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function () {
self._dataChange = true;
self.fireEvent(BI.SingleSelectCombo.EVENT_SEARCHING); self.fireEvent(BI.SingleSelectCombo.EVENT_SEARCHING);
}); });
@ -71,6 +72,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
self.storeValue = this.getValue(); self.storeValue = this.getValue();
assertShowValue(); assertShowValue();
self._defaultState(); self._defaultState();
self._dataChange = true;
}); });
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()) {
@ -95,6 +97,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
listeners: [{ listeners: [{
eventName: BI.SingleSelectPopupView.EVENT_CHANGE, eventName: BI.SingleSelectPopupView.EVENT_CHANGE,
action: function () { action: function () {
self._dataChange = true;
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -120,6 +123,9 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
}); });
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
if (!this.isViewVisible()) {
self._dataChange = false;// 标记数据是否发生变化
}
this.setValue(self.storeValue); this.setValue(self.storeValue);
BI.nextTick(function () { BI.nextTick(function () {
self.populate(); self.populate();
@ -133,7 +139,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
if (self.requesting === true) { if (self.requesting === true) {
self.wants2Quit = true; self.wants2Quit = true;
} else { } else {
self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM); self._dataChange && self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM);
} }
}); });
@ -173,7 +179,8 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
this.combo.hideView(); this.combo.hideView();
}, },
_assertValue: function (val) {}, _assertValue: function (val) {
},
_makeMap: function (values) { _makeMap: function (values) {
return BI.makeObject(values || []); return BI.makeObject(values || []);
@ -220,7 +227,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
function adjust () { function adjust () {
if (self.wants2Quit === true) { if (self.wants2Quit === true) {
self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM); self._dataChange && self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM);
self.wants2Quit = false; self.wants2Quit = false;
} }
self.requesting = false; self.requesting = false;

12
src/widget/singleselect/singleselect.insert.combo.js

@ -75,6 +75,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
self._defaultState(); self._defaultState();
}); });
this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function () { this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function () {
self._dataChange = true;
self.fireEvent(BI.SingleSelectInsertCombo.EVENT_SEARCHING); self.fireEvent(BI.SingleSelectInsertCombo.EVENT_SEARCHING);
}); });
@ -82,6 +83,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
self.storeValue = this.getValue(); self.storeValue = this.getValue();
assertShowValue(); assertShowValue();
self._defaultState(); self._defaultState();
self._dataChange = true;
}); });
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()) {
@ -106,6 +108,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
listeners: [{ listeners: [{
eventName: BI.SingleSelectPopupView.EVENT_CHANGE, eventName: BI.SingleSelectPopupView.EVENT_CHANGE,
action: function () { action: function () {
self._dataChange = true;
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -131,6 +134,9 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
}); });
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
if (!this.isViewVisible()) {
self._dataChange = false;// 标记数据是否发生变化
}
this.setValue(self.storeValue); this.setValue(self.storeValue);
BI.nextTick(function () { BI.nextTick(function () {
self.populate(); self.populate();
@ -144,7 +150,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
if (self.requesting === true) { if (self.requesting === true) {
self.wants2Quit = true; self.wants2Quit = true;
} else { } else {
self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM); self._dataChange && self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM);
} }
}); });
@ -198,7 +204,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
function adjust () { function adjust () {
if (self.wants2Quit === true) { if (self.wants2Quit === true) {
self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM); self._dataChange && self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM);
self.wants2Quit = false; self.wants2Quit = false;
} }
self.requesting = false; self.requesting = false;
@ -237,4 +243,4 @@ BI.SingleSelectInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.SingleSelectInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM"; BI.SingleSelectInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.SingleSelectInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.SingleSelectInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.single_select_insert_combo", BI.SingleSelectInsertCombo); BI.shortcut("bi.single_select_insert_combo", BI.SingleSelectInsertCombo);

Loading…
Cancel
Save