Browse Source

Merge branch 'master' of ssh://code.fineres.com:7999/~dailer/fineui

es6
zsmj 2 years ago
parent
commit
f303068ad3
  1. 2
      package.json
  2. 33
      src/case/combo/textvaluecombo/combo.textvalue.js
  3. 72
      src/case/combo/textvaluecombo/combo.textvaluesmall.js
  4. 2
      src/case/combo/textvaluecombo/popup.textvalue.js
  5. 7
      src/case/trigger/trigger.text.select.js
  6. 1
      src/core/4.widget.js

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "fineui", "name": "fineui",
"version": "2.0.20220908094558", "version": "2.0.20220909180703",
"description": "fineui", "description": "fineui",
"main": "dist/fineui_without_conflict.min.js", "main": "dist/fineui_without_conflict.min.js",
"types": "dist/lib/index.d.ts", "types": "dist/lib/index.d.ts",

33
src/case/combo/textvaluecombo/combo.textvalue.js

@ -13,6 +13,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
text: "", text: "",
value: "", value: "",
defaultText: "", defaultText: "",
el: {},
allowClear: false, allowClear: false,
status: "success", // success | warning | error, status: "success", // success | warning | error,
title: null, title: null,
@ -71,7 +72,9 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
} }
} }
], ],
...o.el
}; };
let changeTag = false;
const popup = { const popup = {
type: "bi.text_value_combo_popup", type: "bi.text_value_combo_popup",
ref: ref => this.popup = ref, ref: ref => this.popup = ref,
@ -81,9 +84,12 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
{ {
eventName: BI.TextValueComboPopup.EVENT_CHANGE, eventName: BI.TextValueComboPopup.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
changeTag = true;
this.setValue(this.popup.getValue()); this.setValue(this.popup.getValue());
this.combo.hideView(); if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) {
this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); this.combo.hideView();
this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args);
}
} }
}, { }, {
eventName: BI.Controller.EVENT_CHANGE, eventName: BI.Controller.EVENT_CHANGE,
@ -101,6 +107,21 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
direction: o.direction, direction: o.direction,
adjustLength: 2, adjustLength: 2,
el: trigger, el: trigger,
listeners: [
{
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
action: (...args) => {
changeTag = false;
}
}, {
eventName: BI.Combo.EVENT_AFTER_HIDEVIEW,
action: (...args) => {
if (changeTag) {
this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args);
}
}
}
],
popup: { popup: {
el: popup, el: popup,
value: o.value, value: o.value,
@ -112,7 +133,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
mounted: function () { mounted: function () {
const o = this.options; const o = this.options;
if (BI.isKey(o.value)) { if (BI.isKey(o.value) || BI.isObject(o.value)) {
this._checkError(o.value); this._checkError(o.value);
} }
}, },
@ -131,11 +152,9 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
var vals = BI.isArray(v) ? v : [v]; var vals = BI.isArray(v) ? v : [v];
var result = BI.find(this.options.items, function (idx, item) { var result = BI.intersection(BI.map(this.options.items, (i, item) => item.value), vals);
return BI.contains(vals, item.value);
});
if (BI.isNull(result)) { if (result.length !== vals.length) {
this.setStatus("error"); this.setStatus("error");
} else { } else {
this.setStatus("success"); this.setStatus("success");

72
src/case/combo/textvaluecombo/combo.textvaluesmall.js

@ -15,64 +15,44 @@ BI.SmallTextValueCombo = BI.inherit(BI.Widget, {
}); });
}, },
_init: function () { render: function () {
var self = this, o = this.options; var o = this.options;
o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { return {
self.setValue(newValue); type: "bi.text_value_combo",
}) : o.value; ref: (_ref) => {
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { this.combo = _ref;
self.populate(newValue); },
}) : o.items;
BI.SmallTextValueCombo.superclass._init.apply(this, arguments);
this.trigger = BI.createWidget(o.el, {
type: "bi.small_select_text_trigger",
items: o.items,
height: o.height, height: o.height,
text: o.text
});
this.popup = BI.createWidget({
type: "bi.text_value_combo_popup",
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items el: {
}); type: "bi.small_select_text_trigger",
this.popup.on(BI.TextValueComboPopup.EVENT_CHANGE, function () { ...o.el
self.setValue(self.popup.getValue()); },
self.SmallTextValueCombo.hideView(); text: o.text,
self.fireEvent(BI.SmallTextValueCombo.EVENT_CHANGE); value: o.value,
}); defaultText: o.defaultText,
this.popup.on(BI.Controller.EVENT_CHANGE, function () { allowClear: o.allowClear,
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); status: o.status,
}); title: o.title,
this.SmallTextValueCombo = BI.createWidget({ listeners: [{
type: "bi.combo", eventName: BI.TextValueCombo.EVENT_CHANGE,
element: this, action: (...args) => {
container: o.container, this.fireEvent(BI.SmallTextValueCombo.EVENT_CHANGE, ...args);
adjustLength: 2, }
el: this.trigger, }]
popup: {
el: this.popup,
maxHeight: 240,
minHeight: 25
}
});
if(BI.isKey(o.value)){
this.setValue(o.value);
} }
}, },
setValue: function (v) { setValue: function (v) {
this.trigger.setValue(v); this.combo.setValue(v);
this.popup.setValue(v);
}, },
getValue: function () { getValue: function () {
return this.popup.getValue(); return this.combo.getValue();
}, },
populate: function (items) { populate: function (items) {
this.options.items = items; this.combo.populate(items);
this.SmallTextValueCombo.populate(items);
} }
}); });
BI.SmallTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.SmallTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";

2
src/case/combo/textvaluecombo/popup.textvalue.js

@ -39,7 +39,7 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
var o = this.options; var o = this.options;
return BI.map(items, function (i, item) { return BI.map(items, function (i, item) {
return BI.extend({ return BI.extend({
type: "bi.single_select_item", type: o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE ? "bi.single_select_item" : "bi.multi_select_item",
textAlign: o.textAlign, textAlign: o.textAlign,
title: item.title || item.text title: item.title || item.text
}, item); }, item);

7
src/case/trigger/trigger.text.select.js

@ -52,7 +52,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
_digest: function (val, items) { _digest: function (val, items) {
var o = this.options; var o = this.options;
val = BI.isArray(val) ? val[0] : val; val = BI.isArray(val) ? val : [val];
// 提升valueFormatter的优先级 // 提升valueFormatter的优先级
if (o.valueFormatter !== BI.emptyFn && BI.isFunction(o.valueFormatter)) { if (o.valueFormatter !== BI.emptyFn && BI.isFunction(o.valueFormatter)) {
@ -65,12 +65,13 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
var formatItems = BI.Tree.transformToArrayFormat(items); var formatItems = BI.Tree.transformToArrayFormat(items);
BI.each(formatItems, function (i, item) { BI.each(formatItems, function (i, item) {
if (val === item.value && !BI.contains(result, item.text || item.value)) { if (BI.contains(val, item.value) && !BI.contains(result, item.text || item.value)) {
result.push(item.text || item.value); result.push(item.text || item.value);
BI.remove(val, item.value);
} }
}); });
if (result.length > 0) { if (result.length > 0 && val.length === 0) {
return { return {
textCls: "", textCls: "",
text: result.join(","), text: result.join(","),

1
src/core/4.widget.js

@ -743,6 +743,7 @@
}, },
_unMount: function () { _unMount: function () {
this._assetMounted();
this.__destroy(); this.__destroy();
this.fireEvent(BI.Events.UNMOUNT); this.fireEvent(BI.Events.UNMOUNT);
this.purgeListeners(); this.purgeListeners();

Loading…
Cancel
Save