Browse Source

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

* commit '76909b78712e67adb93254bb0ec01bda0abab77c':
  combo设置状态value后的问题
  multiselectbar加上selected和halfSeleced
  sqleditor supportParam
  value传值 editor
es6
guy 7 years ago
parent
commit
1691b078da
  1. 22
      demo/js/base/button/demo.button.js
  2. 1
      demo/js/base/editor/demo.editor.js
  3. 1
      demo/js/base/editor/demo.sql_editor.js
  4. 3
      demo/js/case/combo/demo.icon_text_value_combo.js
  5. 23
      dist/base.js
  6. 57
      dist/bundle.js
  7. 34
      dist/case.js
  8. 27
      dist/demo.js
  9. 57
      dist/fineui.js
  10. 9
      src/base/combination/group.button.js
  11. 4
      src/base/single/editor/editor.js
  12. 3
      src/base/single/input/input.js
  13. 7
      src/base/sql/editor.sql.js
  14. 1
      src/case/combo/icontextvaluecombo/combo.icontextvalue.js
  15. 4
      src/case/combo/staticcombo/combo.static.js
  16. 3
      src/case/combo/textvaluecombo/popup.textvalue.js
  17. 24
      src/case/toolbar/toolbar.multiselect.js
  18. 2
      src/case/trigger/trigger.icon.text.select.js

22
demo/js/base/button/demo.button.js

@ -177,6 +177,28 @@ Demo.Button = BI.inherit(BI.Widget, {
iconClass: "close-font", iconClass: "close-font",
height: 30 height: 30
} }
}, {
el: {
type: "bi.multi_select_bar",
selected: true,
halfSelected: true
}
}, {
el: {
type: "bi.multi_select_bar",
selected: true,
halfSelected: false
}
}, {
el: {
type: "bi.multi_select_bar",
selected: false,
halfSelected: true
}
}, {
el: {
type: "bi.multi_select_bar"
}
} }
]; ];
BI.each(items, function (i, item) { BI.each(items, function (i, item) {

1
demo/js/base/editor/demo.editor.js

@ -35,6 +35,7 @@ Demo.Editor = BI.inherit(BI.Widget, {
cls: "mvc-border", cls: "mvc-border",
watermark: "输入'a'会有错误信息且回车键不能退出编辑", watermark: "输入'a'会有错误信息且回车键不能退出编辑",
errorText: "字段不可重名", errorText: "字段不可重名",
value: "a",
validationChecker: function (v) { validationChecker: function (v) {
if (v == "a") { if (v == "a") {
return false; return false;

1
demo/js/base/editor/demo.sql_editor.js

@ -9,6 +9,7 @@ Demo.SQLEditor = BI.inherit(BI.Widget, {
var self = this; var self = this;
this.formula = BI.createWidget({ this.formula = BI.createWidget({
type : 'bi.sql_editor', type : 'bi.sql_editor',
supportParam: true,
width : 300, width : 300,
height : 200, height : 200,
value : "select * from DEMO_CONTRACT where 合同类型 = ${长期协议} and 购买数量 = sum([1,2,3,4])" value : "select * from DEMO_CONTRACT where 合同类型 = ${长期协议} and 购买数量 = sum([1,2,3,4])"

3
demo/js/case/combo/demo.icon_text_value_combo.js

@ -11,7 +11,8 @@ Demo.IconTextValueCombo = BI.inherit(BI.Widget, {
type: "bi.horizontal_auto", type: "bi.horizontal_auto",
items: [{ items: [{
type: "bi.icon_text_value_combo", type: "bi.icon_text_value_combo",
value: "默认值", text: "默认值",
value: 1,
width: 300, width: 300,
items: [{ items: [{
text: "MVC-1", text: "MVC-1",

23
dist/base.js vendored

@ -1021,6 +1021,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
baseCls: "bi-button-group", baseCls: "bi-button-group",
behaviors: {}, behaviors: {},
items: [], items: [],
value: "",
chooseType: BI.Selection.Single, chooseType: BI.Selection.Single,
layouts: [{ layouts: [{
type: "bi.center", type: "bi.center",
@ -1032,14 +1033,18 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
BI.ButtonGroup.superclass._init.apply(this, arguments); BI.ButtonGroup.superclass._init.apply(this, arguments);
var o = this.options;
var behaviors = {}; var behaviors = {};
BI.each(this.options.behaviors, function (key, rule) { BI.each(o.behaviors, function (key, rule) {
behaviors[key] = BI.BehaviorFactory.createBehavior(key, { behaviors[key] = BI.BehaviorFactory.createBehavior(key, {
rule: rule rule: rule
}); });
}); });
this.behaviors = behaviors; this.behaviors = behaviors;
this.populate(this.options.items); this.populate(o.items);
if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){
this.setValue(o.value);
}
}, },
_createBtns: function (items) { _createBtns: function (items) {
@ -18071,6 +18076,7 @@ BI.Editor = BI.inherit(BI.Single, {
type: "bi.input", type: "bi.input",
element: "<input type='" + o.inputType + "'/>", element: "<input type='" + o.inputType + "'/>",
root: true, root: true,
value: o.value,
watermark: o.watermark, watermark: o.watermark,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
@ -18213,7 +18219,8 @@ BI.Editor = BI.inherit(BI.Single, {
return false; return false;
}); });
if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) {
this.setValue(this.options.value); this._checkError();
this._checkWaterMark();
} else { } else {
this._checkWaterMark(); this._checkWaterMark();
} }
@ -19417,6 +19424,9 @@ BI.Input = BI.inherit(BI.Single, {
.focusout(function (e) { .focusout(function (e) {
self._blurDebounce(); self._blurDebounce();
}); });
if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) {
this.setValue(this.options.value);
}
}, },
_focus: function () { _focus: function () {
@ -21067,7 +21077,8 @@ BI.SQLEditor = BI.inherit(BI.Widget, {
value: "", value: "",
lineHeight: 2, lineHeight: 2,
showHint: true, showHint: true,
supportFunction: false supportFunction: false,
supportParam: false
}); });
}, },
_init: function () { _init: function () {
@ -21191,14 +21202,14 @@ BI.SQLEditor = BI.inherit(BI.Widget, {
}, },
setValue: function (v) { setValue: function (v) {
var self = this, result; var self = this, result, o = this.options;
this.refresh(); this.refresh();
self.editor.setValue(""); self.editor.setValue("");
result = this._analyzeContent(v || ""); result = this._analyzeContent(v || "");
BI.each(result, function (i, item) { BI.each(result, function (i, item) {
var fieldRegx = /\$[\{][^\}]*[\}]/; var fieldRegx = /\$[\{][^\}]*[\}]/;
var str = item.match(fieldRegx); var str = item.match(fieldRegx);
if (BI.isNotEmptyArray(str)) { if (BI.isNotEmptyArray(str) && o.supportParam) {
self.insertParam(str[0].substring(2, item.length - 1)); self.insertParam(str[0].substring(2, item.length - 1));
} else { } else {
self.insertString(item); self.insertString(item);

57
dist/bundle.js vendored

@ -26894,6 +26894,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
baseCls: "bi-button-group", baseCls: "bi-button-group",
behaviors: {}, behaviors: {},
items: [], items: [],
value: "",
chooseType: BI.Selection.Single, chooseType: BI.Selection.Single,
layouts: [{ layouts: [{
type: "bi.center", type: "bi.center",
@ -26905,14 +26906,18 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
BI.ButtonGroup.superclass._init.apply(this, arguments); BI.ButtonGroup.superclass._init.apply(this, arguments);
var o = this.options;
var behaviors = {}; var behaviors = {};
BI.each(this.options.behaviors, function (key, rule) { BI.each(o.behaviors, function (key, rule) {
behaviors[key] = BI.BehaviorFactory.createBehavior(key, { behaviors[key] = BI.BehaviorFactory.createBehavior(key, {
rule: rule rule: rule
}); });
}); });
this.behaviors = behaviors; this.behaviors = behaviors;
this.populate(this.options.items); this.populate(o.items);
if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){
this.setValue(o.value);
}
}, },
_createBtns: function (items) { _createBtns: function (items) {
@ -43944,6 +43949,7 @@ BI.Editor = BI.inherit(BI.Single, {
type: "bi.input", type: "bi.input",
element: "<input type='" + o.inputType + "'/>", element: "<input type='" + o.inputType + "'/>",
root: true, root: true,
value: o.value,
watermark: o.watermark, watermark: o.watermark,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
@ -44086,7 +44092,8 @@ BI.Editor = BI.inherit(BI.Single, {
return false; return false;
}); });
if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) {
this.setValue(this.options.value); this._checkError();
this._checkWaterMark();
} else { } else {
this._checkWaterMark(); this._checkWaterMark();
} }
@ -45290,6 +45297,9 @@ BI.Input = BI.inherit(BI.Single, {
.focusout(function (e) { .focusout(function (e) {
self._blurDebounce(); self._blurDebounce();
}); });
if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) {
this.setValue(this.options.value);
}
}, },
_focus: function () { _focus: function () {
@ -46940,7 +46950,8 @@ BI.SQLEditor = BI.inherit(BI.Widget, {
value: "", value: "",
lineHeight: 2, lineHeight: 2,
showHint: true, showHint: true,
supportFunction: false supportFunction: false,
supportParam: false
}); });
}, },
_init: function () { _init: function () {
@ -47064,14 +47075,14 @@ BI.SQLEditor = BI.inherit(BI.Widget, {
}, },
setValue: function (v) { setValue: function (v) {
var self = this, result; var self = this, result, o = this.options;
this.refresh(); this.refresh();
self.editor.setValue(""); self.editor.setValue("");
result = this._analyzeContent(v || ""); result = this._analyzeContent(v || "");
BI.each(result, function (i, item) { BI.each(result, function (i, item) {
var fieldRegx = /\$[\{][^\}]*[\}]/; var fieldRegx = /\$[\{][^\}]*[\}]/;
var str = item.match(fieldRegx); var str = item.match(fieldRegx);
if (BI.isNotEmptyArray(str)) { if (BI.isNotEmptyArray(str) && o.supportParam) {
self.insertParam(str[0].substring(2, item.length - 1)); self.insertParam(str[0].substring(2, item.length - 1));
} else { } else {
self.insertString(item); self.insertString(item);
@ -67687,6 +67698,7 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, {
type: "bi.select_icon_text_trigger", type: "bi.select_icon_text_trigger",
items: o.items, items: o.items,
height: o.height, height: o.height,
text: o.text,
value: o.value value: o.value
}); });
this.popup = BI.createWidget({ this.popup = BI.createWidget({
@ -67813,6 +67825,7 @@ BI.StaticCombo = BI.inherit(BI.Widget, {
type: "bi.text_icon_item", type: "bi.text_icon_item",
cls: "bi-select-text-trigger bi-border pull-down-font", cls: "bi-select-text-trigger bi-border pull-down-font",
text: o.text, text: o.text,
value: o.value,
readonly: true, readonly: true,
textLgap: 5, textLgap: 5,
height: o.height - 2 height: o.height - 2
@ -67821,7 +67834,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, {
type: "bi.text_value_combo_popup", type: "bi.text_value_combo_popup",
textAlign: o.textAlign, textAlign: o.textAlign,
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items items: o.items,
value: o.value
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function () { this.popup.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -68205,7 +68219,8 @@ BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo);BI.TextValueCom
chooseType: o.chooseType, chooseType: o.chooseType,
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical"
}] }],
value: o.value
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) {
@ -74636,25 +74651,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
disableSelected: true, disableSelected: true,
isHalfCheckedBySelectedValue: function (selectedValues) { isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0; return selectedValues.length > 0;
} },
halfSelected: false
}); });
}, },
_init: function () { _init: function () {
BI.MultiSelectBar.superclass._init.apply(this, arguments); BI.MultiSelectBar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var isSelect = o.selected === true;
var isHalfSelect = !o.selected && o.halfSelected;
this.checkbox = BI.createWidget({ this.checkbox = BI.createWidget({
type: "bi.checkbox", type: "bi.checkbox",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(self.isSelected()); self.setSelected(self.isSelected());
} },
selected: isSelect,
invisible: isHalfSelect
}); });
this.half = BI.createWidget({ this.half = BI.createWidget({
type: "bi.half_icon_button", type: "bi.half_icon_button",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(true); self.setSelected(true);
} },
invisible: isSelect || !isHalfSelect
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self);
@ -74693,7 +74714,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
el: this.text el: this.text
}] }]
}); });
this.half.invisible(); },
_setSelected: function (v) {
this.checkbox.setSelected(!!v);
}, },
// 自己手动控制选中 // 自己手动控制选中
@ -74712,8 +74736,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
setHalfSelected: function (b) { setHalfSelected: function (b) {
this._half = !!b; this.halfSelected = !!b;
if (b === true) { if (b === true) {
this.checkbox.setSelected(false);
this.half.visible(); this.half.visible();
this.checkbox.invisible(); this.checkbox.invisible();
} else { } else {
@ -74723,7 +74748,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
isHalfSelected: function () { isHalfSelected: function () {
return !!this._half; return !this.isSelected() && !!this.halfSelected;
}, },
isSelected: function () { isSelected: function () {
@ -74733,7 +74758,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
setValue: function (selectedValues) { setValue: function (selectedValues) {
BI.MultiSelectBar.superclass.setValue.apply(this, arguments); BI.MultiSelectBar.superclass.setValue.apply(this, arguments);
var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
this.setSelected(isAllChecked); this._setSelected(isAllChecked);
!isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
} }
}); });
@ -76027,7 +76052,7 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, {
}; };
} else { } else {
return { return {
text: o.value, text: o.text,
iconClass: "" iconClass: ""
}; };
} }

34
dist/case.js vendored

@ -5458,6 +5458,7 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, {
type: "bi.select_icon_text_trigger", type: "bi.select_icon_text_trigger",
items: o.items, items: o.items,
height: o.height, height: o.height,
text: o.text,
value: o.value value: o.value
}); });
this.popup = BI.createWidget({ this.popup = BI.createWidget({
@ -5584,6 +5585,7 @@ BI.StaticCombo = BI.inherit(BI.Widget, {
type: "bi.text_icon_item", type: "bi.text_icon_item",
cls: "bi-select-text-trigger bi-border pull-down-font", cls: "bi-select-text-trigger bi-border pull-down-font",
text: o.text, text: o.text,
value: o.value,
readonly: true, readonly: true,
textLgap: 5, textLgap: 5,
height: o.height - 2 height: o.height - 2
@ -5592,7 +5594,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, {
type: "bi.text_value_combo_popup", type: "bi.text_value_combo_popup",
textAlign: o.textAlign, textAlign: o.textAlign,
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items items: o.items,
value: o.value
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function () { this.popup.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -5976,7 +5979,8 @@ BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo);BI.TextValueCom
chooseType: o.chooseType, chooseType: o.chooseType,
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical"
}] }],
value: o.value
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) {
@ -12407,25 +12411,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
disableSelected: true, disableSelected: true,
isHalfCheckedBySelectedValue: function (selectedValues) { isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0; return selectedValues.length > 0;
} },
halfSelected: false
}); });
}, },
_init: function () { _init: function () {
BI.MultiSelectBar.superclass._init.apply(this, arguments); BI.MultiSelectBar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var isSelect = o.selected === true;
var isHalfSelect = !o.selected && o.halfSelected;
this.checkbox = BI.createWidget({ this.checkbox = BI.createWidget({
type: "bi.checkbox", type: "bi.checkbox",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(self.isSelected()); self.setSelected(self.isSelected());
} },
selected: isSelect,
invisible: isHalfSelect
}); });
this.half = BI.createWidget({ this.half = BI.createWidget({
type: "bi.half_icon_button", type: "bi.half_icon_button",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(true); self.setSelected(true);
} },
invisible: isSelect || !isHalfSelect
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self);
@ -12464,7 +12474,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
el: this.text el: this.text
}] }]
}); });
this.half.invisible(); },
_setSelected: function (v) {
this.checkbox.setSelected(!!v);
}, },
// 自己手动控制选中 // 自己手动控制选中
@ -12483,8 +12496,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
setHalfSelected: function (b) { setHalfSelected: function (b) {
this._half = !!b; this.halfSelected = !!b;
if (b === true) { if (b === true) {
this.checkbox.setSelected(false);
this.half.visible(); this.half.visible();
this.checkbox.invisible(); this.checkbox.invisible();
} else { } else {
@ -12494,7 +12508,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
isHalfSelected: function () { isHalfSelected: function () {
return !!this._half; return !this.isSelected() && !!this.halfSelected;
}, },
isSelected: function () { isSelected: function () {
@ -12504,7 +12518,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
setValue: function (selectedValues) { setValue: function (selectedValues) {
BI.MultiSelectBar.superclass.setValue.apply(this, arguments); BI.MultiSelectBar.superclass.setValue.apply(this, arguments);
var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
this.setSelected(isAllChecked); this._setSelected(isAllChecked);
!isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
} }
}); });
@ -13798,7 +13812,7 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, {
}; };
} else { } else {
return { return {
text: o.value, text: o.text,
iconClass: "" iconClass: ""
}; };
} }

27
dist/demo.js vendored

@ -196,6 +196,28 @@ $(function () {
iconClass: "close-font", iconClass: "close-font",
height: 30 height: 30
} }
}, {
el: {
type: "bi.multi_select_bar",
selected: true,
halfSelected: true
}
}, {
el: {
type: "bi.multi_select_bar",
selected: true,
halfSelected: false
}
}, {
el: {
type: "bi.multi_select_bar",
selected: false,
halfSelected: true
}
}, {
el: {
type: "bi.multi_select_bar"
}
} }
]; ];
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
@ -704,6 +726,7 @@ BI.shortcut("demo.code_editor", Demo.CodeEditor);Demo.Editor = BI.inherit(BI.Wid
cls: "mvc-border", cls: "mvc-border",
watermark: "输入'a'会有错误信息且回车键不能退出编辑", watermark: "输入'a'会有错误信息且回车键不能退出编辑",
errorText: "字段不可重名", errorText: "字段不可重名",
value: "a",
validationChecker: function (v) { validationChecker: function (v) {
if (v == "a") { if (v == "a") {
return false; return false;
@ -842,6 +865,7 @@ Demo.SQLEditor = BI.inherit(BI.Widget, {
var self = this; var self = this;
this.formula = BI.createWidget({ this.formula = BI.createWidget({
type : 'bi.sql_editor', type : 'bi.sql_editor',
supportParam: true,
width : 300, width : 300,
height : 200, height : 200,
value : "select * from DEMO_CONTRACT where 合同类型 = ${长期协议} and 购买数量 = sum([1,2,3,4])" value : "select * from DEMO_CONTRACT where 合同类型 = ${长期协议} and 购买数量 = sum([1,2,3,4])"
@ -1808,7 +1832,8 @@ Demo.IconTextValueCombo = BI.inherit(BI.Widget, {
type: "bi.horizontal_auto", type: "bi.horizontal_auto",
items: [{ items: [{
type: "bi.icon_text_value_combo", type: "bi.icon_text_value_combo",
value: "默认值", text: "默认值",
value: 1,
width: 300, width: 300,
items: [{ items: [{
text: "MVC-1", text: "MVC-1",

57
dist/fineui.js vendored

@ -28588,6 +28588,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
baseCls: "bi-button-group", baseCls: "bi-button-group",
behaviors: {}, behaviors: {},
items: [], items: [],
value: "",
chooseType: BI.Selection.Single, chooseType: BI.Selection.Single,
layouts: [{ layouts: [{
type: "bi.center", type: "bi.center",
@ -28599,14 +28600,18 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
BI.ButtonGroup.superclass._init.apply(this, arguments); BI.ButtonGroup.superclass._init.apply(this, arguments);
var o = this.options;
var behaviors = {}; var behaviors = {};
BI.each(this.options.behaviors, function (key, rule) { BI.each(o.behaviors, function (key, rule) {
behaviors[key] = BI.BehaviorFactory.createBehavior(key, { behaviors[key] = BI.BehaviorFactory.createBehavior(key, {
rule: rule rule: rule
}); });
}); });
this.behaviors = behaviors; this.behaviors = behaviors;
this.populate(this.options.items); this.populate(o.items);
if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){
this.setValue(o.value);
}
}, },
_createBtns: function (items) { _createBtns: function (items) {
@ -45638,6 +45643,7 @@ BI.Editor = BI.inherit(BI.Single, {
type: "bi.input", type: "bi.input",
element: "<input type='" + o.inputType + "'/>", element: "<input type='" + o.inputType + "'/>",
root: true, root: true,
value: o.value,
watermark: o.watermark, watermark: o.watermark,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
@ -45780,7 +45786,8 @@ BI.Editor = BI.inherit(BI.Single, {
return false; return false;
}); });
if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) {
this.setValue(this.options.value); this._checkError();
this._checkWaterMark();
} else { } else {
this._checkWaterMark(); this._checkWaterMark();
} }
@ -46984,6 +46991,9 @@ BI.Input = BI.inherit(BI.Single, {
.focusout(function (e) { .focusout(function (e) {
self._blurDebounce(); self._blurDebounce();
}); });
if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) {
this.setValue(this.options.value);
}
}, },
_focus: function () { _focus: function () {
@ -48634,7 +48644,8 @@ BI.SQLEditor = BI.inherit(BI.Widget, {
value: "", value: "",
lineHeight: 2, lineHeight: 2,
showHint: true, showHint: true,
supportFunction: false supportFunction: false,
supportParam: false
}); });
}, },
_init: function () { _init: function () {
@ -48758,14 +48769,14 @@ BI.SQLEditor = BI.inherit(BI.Widget, {
}, },
setValue: function (v) { setValue: function (v) {
var self = this, result; var self = this, result, o = this.options;
this.refresh(); this.refresh();
self.editor.setValue(""); self.editor.setValue("");
result = this._analyzeContent(v || ""); result = this._analyzeContent(v || "");
BI.each(result, function (i, item) { BI.each(result, function (i, item) {
var fieldRegx = /\$[\{][^\}]*[\}]/; var fieldRegx = /\$[\{][^\}]*[\}]/;
var str = item.match(fieldRegx); var str = item.match(fieldRegx);
if (BI.isNotEmptyArray(str)) { if (BI.isNotEmptyArray(str) && o.supportParam) {
self.insertParam(str[0].substring(2, item.length - 1)); self.insertParam(str[0].substring(2, item.length - 1));
} else { } else {
self.insertString(item); self.insertString(item);
@ -69381,6 +69392,7 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, {
type: "bi.select_icon_text_trigger", type: "bi.select_icon_text_trigger",
items: o.items, items: o.items,
height: o.height, height: o.height,
text: o.text,
value: o.value value: o.value
}); });
this.popup = BI.createWidget({ this.popup = BI.createWidget({
@ -69507,6 +69519,7 @@ BI.StaticCombo = BI.inherit(BI.Widget, {
type: "bi.text_icon_item", type: "bi.text_icon_item",
cls: "bi-select-text-trigger bi-border pull-down-font", cls: "bi-select-text-trigger bi-border pull-down-font",
text: o.text, text: o.text,
value: o.value,
readonly: true, readonly: true,
textLgap: 5, textLgap: 5,
height: o.height - 2 height: o.height - 2
@ -69515,7 +69528,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, {
type: "bi.text_value_combo_popup", type: "bi.text_value_combo_popup",
textAlign: o.textAlign, textAlign: o.textAlign,
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items items: o.items,
value: o.value
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function () { this.popup.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -69899,7 +69913,8 @@ BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo);BI.TextValueCom
chooseType: o.chooseType, chooseType: o.chooseType,
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical"
}] }],
value: o.value
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) {
@ -76330,25 +76345,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
disableSelected: true, disableSelected: true,
isHalfCheckedBySelectedValue: function (selectedValues) { isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0; return selectedValues.length > 0;
} },
halfSelected: false
}); });
}, },
_init: function () { _init: function () {
BI.MultiSelectBar.superclass._init.apply(this, arguments); BI.MultiSelectBar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var isSelect = o.selected === true;
var isHalfSelect = !o.selected && o.halfSelected;
this.checkbox = BI.createWidget({ this.checkbox = BI.createWidget({
type: "bi.checkbox", type: "bi.checkbox",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(self.isSelected()); self.setSelected(self.isSelected());
} },
selected: isSelect,
invisible: isHalfSelect
}); });
this.half = BI.createWidget({ this.half = BI.createWidget({
type: "bi.half_icon_button", type: "bi.half_icon_button",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(true); self.setSelected(true);
} },
invisible: isSelect || !isHalfSelect
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self);
@ -76387,7 +76408,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
el: this.text el: this.text
}] }]
}); });
this.half.invisible(); },
_setSelected: function (v) {
this.checkbox.setSelected(!!v);
}, },
// 自己手动控制选中 // 自己手动控制选中
@ -76406,8 +76430,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
setHalfSelected: function (b) { setHalfSelected: function (b) {
this._half = !!b; this.halfSelected = !!b;
if (b === true) { if (b === true) {
this.checkbox.setSelected(false);
this.half.visible(); this.half.visible();
this.checkbox.invisible(); this.checkbox.invisible();
} else { } else {
@ -76417,7 +76442,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
isHalfSelected: function () { isHalfSelected: function () {
return !!this._half; return !this.isSelected() && !!this.halfSelected;
}, },
isSelected: function () { isSelected: function () {
@ -76427,7 +76452,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
setValue: function (selectedValues) { setValue: function (selectedValues) {
BI.MultiSelectBar.superclass.setValue.apply(this, arguments); BI.MultiSelectBar.superclass.setValue.apply(this, arguments);
var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
this.setSelected(isAllChecked); this._setSelected(isAllChecked);
!isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
} }
}); });
@ -77721,7 +77746,7 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, {
}; };
} else { } else {
return { return {
text: o.value, text: o.text,
iconClass: "" iconClass: ""
}; };
} }

9
src/base/combination/group.button.js

@ -10,6 +10,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
baseCls: "bi-button-group", baseCls: "bi-button-group",
behaviors: {}, behaviors: {},
items: [], items: [],
value: "",
chooseType: BI.Selection.Single, chooseType: BI.Selection.Single,
layouts: [{ layouts: [{
type: "bi.center", type: "bi.center",
@ -21,14 +22,18 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
BI.ButtonGroup.superclass._init.apply(this, arguments); BI.ButtonGroup.superclass._init.apply(this, arguments);
var o = this.options;
var behaviors = {}; var behaviors = {};
BI.each(this.options.behaviors, function (key, rule) { BI.each(o.behaviors, function (key, rule) {
behaviors[key] = BI.BehaviorFactory.createBehavior(key, { behaviors[key] = BI.BehaviorFactory.createBehavior(key, {
rule: rule rule: rule
}); });
}); });
this.behaviors = behaviors; this.behaviors = behaviors;
this.populate(this.options.items); this.populate(o.items);
if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){
this.setValue(o.value);
}
}, },
_createBtns: function (items) { _createBtns: function (items) {

4
src/base/single/editor/editor.js

@ -32,6 +32,7 @@ BI.Editor = BI.inherit(BI.Single, {
type: "bi.input", type: "bi.input",
element: "<input type='" + o.inputType + "'/>", element: "<input type='" + o.inputType + "'/>",
root: true, root: true,
value: o.value,
watermark: o.watermark, watermark: o.watermark,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
@ -174,7 +175,8 @@ BI.Editor = BI.inherit(BI.Single, {
return false; return false;
}); });
if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) {
this.setValue(this.options.value); this._checkError();
this._checkWaterMark();
} else { } else {
this._checkWaterMark(); this._checkWaterMark();
} }

3
src/base/single/input/input.js

@ -57,6 +57,9 @@ BI.Input = BI.inherit(BI.Single, {
.focusout(function (e) { .focusout(function (e) {
self._blurDebounce(); self._blurDebounce();
}); });
if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) {
this.setValue(this.options.value);
}
}, },
_focus: function () { _focus: function () {

7
src/base/sql/editor.sql.js

@ -8,7 +8,8 @@ BI.SQLEditor = BI.inherit(BI.Widget, {
value: "", value: "",
lineHeight: 2, lineHeight: 2,
showHint: true, showHint: true,
supportFunction: false supportFunction: false,
supportParam: false
}); });
}, },
_init: function () { _init: function () {
@ -132,14 +133,14 @@ BI.SQLEditor = BI.inherit(BI.Widget, {
}, },
setValue: function (v) { setValue: function (v) {
var self = this, result; var self = this, result, o = this.options;
this.refresh(); this.refresh();
self.editor.setValue(""); self.editor.setValue("");
result = this._analyzeContent(v || ""); result = this._analyzeContent(v || "");
BI.each(result, function (i, item) { BI.each(result, function (i, item) {
var fieldRegx = /\$[\{][^\}]*[\}]/; var fieldRegx = /\$[\{][^\}]*[\}]/;
var str = item.match(fieldRegx); var str = item.match(fieldRegx);
if (BI.isNotEmptyArray(str)) { if (BI.isNotEmptyArray(str) && o.supportParam) {
self.insertParam(str[0].substring(2, item.length - 1)); self.insertParam(str[0].substring(2, item.length - 1));
} else { } else {
self.insertString(item); self.insertString(item);

1
src/case/combo/icontextvaluecombo/combo.icontextvalue.js

@ -19,6 +19,7 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, {
type: "bi.select_icon_text_trigger", type: "bi.select_icon_text_trigger",
items: o.items, items: o.items,
height: o.height, height: o.height,
text: o.text,
value: o.value value: o.value
}); });
this.popup = BI.createWidget({ this.popup = BI.createWidget({

4
src/case/combo/staticcombo/combo.static.js

@ -23,6 +23,7 @@ BI.StaticCombo = BI.inherit(BI.Widget, {
type: "bi.text_icon_item", type: "bi.text_icon_item",
cls: "bi-select-text-trigger bi-border pull-down-font", cls: "bi-select-text-trigger bi-border pull-down-font",
text: o.text, text: o.text,
value: o.value,
readonly: true, readonly: true,
textLgap: 5, textLgap: 5,
height: o.height - 2 height: o.height - 2
@ -31,7 +32,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, {
type: "bi.text_value_combo_popup", type: "bi.text_value_combo_popup",
textAlign: o.textAlign, textAlign: o.textAlign,
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items items: o.items,
value: o.value
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function () { this.popup.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);

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

@ -19,7 +19,8 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
chooseType: o.chooseType, chooseType: o.chooseType,
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical"
}] }],
value: o.value
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) {

24
src/case/toolbar/toolbar.multiselect.js

@ -16,25 +16,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
disableSelected: true, disableSelected: true,
isHalfCheckedBySelectedValue: function (selectedValues) { isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0; return selectedValues.length > 0;
} },
halfSelected: false
}); });
}, },
_init: function () { _init: function () {
BI.MultiSelectBar.superclass._init.apply(this, arguments); BI.MultiSelectBar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var isSelect = o.selected === true;
var isHalfSelect = !o.selected && o.halfSelected;
this.checkbox = BI.createWidget({ this.checkbox = BI.createWidget({
type: "bi.checkbox", type: "bi.checkbox",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(self.isSelected()); self.setSelected(self.isSelected());
} },
selected: isSelect,
invisible: isHalfSelect
}); });
this.half = BI.createWidget({ this.half = BI.createWidget({
type: "bi.half_icon_button", type: "bi.half_icon_button",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(true); self.setSelected(true);
} },
invisible: isSelect || !isHalfSelect
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self);
@ -73,7 +79,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
el: this.text el: this.text
}] }]
}); });
this.half.invisible(); },
_setSelected: function (v) {
this.checkbox.setSelected(!!v);
}, },
// 自己手动控制选中 // 自己手动控制选中
@ -92,8 +101,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
setHalfSelected: function (b) { setHalfSelected: function (b) {
this._half = !!b; this.halfSelected = !!b;
if (b === true) { if (b === true) {
this.checkbox.setSelected(false);
this.half.visible(); this.half.visible();
this.checkbox.invisible(); this.checkbox.invisible();
} else { } else {
@ -103,7 +113,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
isHalfSelected: function () { isHalfSelected: function () {
return !!this._half; return !this.isSelected() && !!this.halfSelected;
}, },
isSelected: function () { isSelected: function () {
@ -113,7 +123,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
setValue: function (selectedValues) { setValue: function (selectedValues) {
BI.MultiSelectBar.superclass.setValue.apply(this, arguments); BI.MultiSelectBar.superclass.setValue.apply(this, arguments);
var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
this.setSelected(isAllChecked); this._setSelected(isAllChecked);
!isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
} }
}); });

2
src/case/trigger/trigger.icon.text.select.js

@ -46,7 +46,7 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, {
}; };
} else { } else {
return { return {
text: o.value, text: o.text,
iconClass: "" iconClass: ""
}; };
} }

Loading…
Cancel
Save