Browse Source

Pull request #3375: KERNEL-14060 refact: combo && KERNEL-14076 fix: 修复了部分发现的错误

Merge in VISUAL/fineui from ~TREECAT/fineui:es6 to es6

* commit '842be683c23a6b0dc8161fbeb333bba238fd33a4':
  KERNEL-14060 refact: combo没有导出
  KERNEL-14060 refact: combo && KERNEL-14076 fix: 修复了部分发现的错误
es6
treecat-罗群 2 years ago
parent
commit
9e61eb360a
  1. 8
      es6.js
  2. 24
      es6.xtype.js
  3. 139
      src/case/combo/bubblecombo/combo.bubble.js
  4. 142
      src/case/combo/bubblecombo/popup.bubble.js
  5. 118
      src/case/combo/editoriconcheckcombo/combo.editiconcheck.js
  6. 117
      src/case/combo/iconcombo/combo.icon.js
  7. 97
      src/case/combo/iconcombo/popup.iconcombo.js
  8. 125
      src/case/combo/iconcombo/trigger.iconcombo.js
  9. 138
      src/case/combo/icontextvaluecombo/combo.icontextvalue.js
  10. 102
      src/case/combo/icontextvaluecombo/popup.icontextvalue.js
  11. 22
      src/case/combo/index.js
  12. 207
      src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js
  13. 142
      src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js
  14. 202
      src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js
  15. 131
      src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js
  16. 101
      src/case/combo/textvaluecheckcombo/popup.textvaluecheck.js
  17. 229
      src/case/combo/textvaluecombo/combo.textvalue.js
  18. 76
      src/case/combo/textvaluecombo/combo.textvaluesmall.js
  19. 312
      src/case/combo/textvaluecombo/popup.textvalue.js
  20. 3
      src/case/index.js

8
es6.js

@ -214,7 +214,8 @@ async function handleFile(srcName) {
M += `${f}\n`; M += `${f}\n`;
}); });
Object.keys(G).forEach(moduleKey => { Object.keys(G).forEach(key => {
let moduleKey = key;
if (moduleKey === path.basename(srcName).replace(/.js$/g, "")) { if (moduleKey === path.basename(srcName).replace(/.js$/g, "")) {
return; return;
} }
@ -222,6 +223,11 @@ async function handleFile(srcName) {
Object.keys(G[moduleKey]).forEach(key => { Object.keys(G[moduleKey]).forEach(key => {
i += `${key}, `; i += `${key}, `;
}); });
const single = !/\//.test(moduleKey);
if (single) {
moduleKey = `./${moduleKey}`;
}
I += `import {${i}} from '${moduleKey}'\n`; I += `import {${i}} from '${moduleKey}'\n`;
}); });

24
es6.xtype.js

@ -106,22 +106,28 @@ function search(src, module) {
while (dstPath[i] === srcPath[i] && i < dstPath.length && i < srcPath.length) { while (dstPath[i] === srcPath[i] && i < dstPath.length && i < srcPath.length) {
i++; i++;
} }
// i 代表同名的位置
i--;
// 没有匹配完
if (i < srcPath.length) { if (i < srcPath.length) {
let result = ""; let result = "";
const rawI = i;
// 回溯,向上找,回到目录 i
// 回溯 for (let j = srcPath.length - 1; j > i; j--) {
for (let j = 0; j < srcPath.length - rawI; j++) {
result += "../"; result += "../";
i--;
} }
// 匹配过的下一个位置
i++; i++;
// dstPath 也没有了
if (i < dstPath.length) { if (i >= dstPath.length) {
return result + findDstIndexPath(dstPath, i); // 越界
} else if (i === dstPath.length) {
return `${result}${dstName}`; return `${result}${dstName}`;
} else {
// 看看这个目录下有没有 index
return result + findDstIndexPath(dstPath, i);
} }
} else if (i === srcPath.length) { } else if (i === srcPath.length) {
if (i === dstPath.length) { if (i === dstPath.length) {

139
src/case/combo/bubblecombo/combo.bubble.js

@ -1,12 +1,29 @@
/** import {
* Created by GUY on 2017/2/8. shortcut,
* Widget,
* @class BI.BubbleCombo extend,
* @extends BI.Widget emptyFn,
*/ createWidget,
BI.BubbleCombo = BI.inherit(BI.Widget, { isFunction
_defaultConfig: function () { } from "@/core";
return BI.extend(BI.BubbleCombo.superclass._defaultConfig.apply(this, arguments), { import { Combo } from "@/base";
@shortcut()
export class BubbleCombo extends Widget {
static xtype = "bi.bubble_combo";
static EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_EXPAND = "EVENT_EXPAND";
static EVENT_COLLAPSE = "EVENT_COLLAPSE";
static EVENT_AFTER_INIT = "EVENT_AFTER_INIT";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
static EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW";
static EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW";
static EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-bubble-combo", baseCls: "bi-bubble-combo",
trigger: "click", trigger: "click",
toggle: true, toggle: true,
@ -22,17 +39,18 @@ BI.BubbleCombo = BI.inherit(BI.Widget, {
adjustLength: 0, // 调整的距离 adjustLength: 0, // 调整的距离
adjustXOffset: 0, adjustXOffset: 0,
adjustYOffset: 0, adjustYOffset: 0,
hideChecker: BI.emptyFn, hideChecker: emptyFn,
offsetStyle: "left", // left,right,center offsetStyle: "left", // left,right,center
el: {}, el: {},
popup: {} popup: {},
}); });
}, }
_init: function () {
BI.BubbleCombo.superclass._init.apply(this, arguments); _init() {
var self = this, o = this.options; super._init(...arguments);
this.combo = BI.createWidget({ const o = this.options;
type: "bi.combo", this.combo = createWidget({
type: Combo.xtype,
element: this, element: this,
trigger: o.trigger, trigger: o.trigger,
toggle: o.toggle, toggle: o.toggle,
@ -55,72 +73,67 @@ BI.BubbleCombo = BI.inherit(BI.Widget, {
comboClass: o.comboClass, comboClass: o.comboClass,
supportCSSTransform: o.supportCSSTransform, supportCSSTransform: o.supportCSSTransform,
el: o.el, el: o.el,
popup: () => BI.extend({ popup: () =>
type: "bi.bubble_popup_view", extend(
animation: "bi-zoom-big", {
animationDuring: 200, type: "bi.bubble_popup_view",
primary: o.primary animation: "bi-zoom-big",
}, BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup) animationDuring: 200,
primary: o.primary,
},
isFunction(this.options.popup)
? this.options.popup()
: this.options.popup
),
}); });
this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { this.combo.on(Combo.EVENT_TRIGGER_CHANGE, (...args) => {
self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments); this.fireEvent(BubbleCombo.EVENT_TRIGGER_CHANGE, ...args);
}); });
this.combo.on(BI.Combo.EVENT_CHANGE, function () { this.combo.on(Combo.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.BubbleCombo.EVENT_CHANGE, arguments); this.fireEvent(BubbleCombo.EVENT_CHANGE, ...args);
}); });
this.combo.on(BI.Combo.EVENT_EXPAND, function () { this.combo.on(Combo.EVENT_EXPAND, (...args) => {
self.fireEvent(BI.BubbleCombo.EVENT_EXPAND, arguments); this.fireEvent(BubbleCombo.EVENT_EXPAND, ...args);
}); });
this.combo.on(BI.Combo.EVENT_COLLAPSE, function () { this.combo.on(Combo.EVENT_COLLAPSE, (...args) => {
self.fireEvent(BI.BubbleCombo.EVENT_COLLAPSE, arguments); this.fireEvent(BubbleCombo.EVENT_COLLAPSE, ...args);
}); });
this.combo.on(BI.Combo.EVENT_AFTER_INIT, function () { this.combo.on(Combo.EVENT_AFTER_INIT, (...args) => {
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_INIT, arguments); this.fireEvent(BubbleCombo.EVENT_AFTER_INIT, ...args);
}); });
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { this.combo.on(Combo.EVENT_BEFORE_POPUPVIEW, (...args) => {
self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, arguments); this.fireEvent(BubbleCombo.EVENT_BEFORE_POPUPVIEW, ...args);
}); });
this.combo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () { this.combo.on(Combo.EVENT_AFTER_POPUPVIEW, (...args) => {
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_POPUPVIEW, arguments); this.fireEvent(BubbleCombo.EVENT_AFTER_POPUPVIEW, ...args);
}); });
this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, (...args) => {
self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW, arguments); this.fireEvent(BubbleCombo.EVENT_BEFORE_HIDEVIEW, ...args);
}); });
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { this.combo.on(Combo.EVENT_AFTER_HIDEVIEW, (...args) => {
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_HIDEVIEW, arguments); this.fireEvent(BubbleCombo.EVENT_AFTER_HIDEVIEW, ...args);
}); });
}, }
hideView: function () { hideView() {
this.combo && this.combo.hideView(); this.combo && this.combo.hideView();
}, }
showView: function () { showView() {
this.combo && this.combo.showView(); this.combo && this.combo.showView();
}, }
isViewVisible: function () { isViewVisible() {
return this.combo.isViewVisible(); return this.combo.isViewVisible();
}, }
adjustWidth: function () { adjustWidth() {
this.combo.adjustWidth(); this.combo.adjustWidth();
}, }
adjustHeight: function () { adjustHeight() {
this.combo.adjustHeight(); this.combo.adjustHeight();
} }
}); }
BI.BubbleCombo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE";
BI.BubbleCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.BubbleCombo.EVENT_EXPAND = "EVENT_EXPAND";
BI.BubbleCombo.EVENT_COLLAPSE = "EVENT_COLLAPSE";
BI.BubbleCombo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT";
BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.BubbleCombo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW";
BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW";
BI.BubbleCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
BI.shortcut("bi.bubble_combo", BI.BubbleCombo);

142
src/case/combo/bubblecombo/popup.bubble.js

@ -1,133 +1,37 @@
/** import { shortcut, extend } from "@/core";
* Created by GUY on 2017/2/8. import { PopupView, Label } from "@/base";
*
* @class BI.BubblePopupView
* @extends BI.PopupView
*/
BI.BubblePopupView = BI.inherit(BI.PopupView, {
_defaultConfig: function () {
var config = BI.BubblePopupView.superclass._defaultConfig.apply(this, arguments);
return BI.extend(config, {
baseCls: config.baseCls + " bi-bubble-popup-view",
minWidth: 70,
maxWidth: 300,
// minHeight: 50,
showArrow: true,
});
}
});
BI.shortcut("bi.bubble_popup_view", BI.BubblePopupView);
/**
* Created by GUY on 2017/2/8.
*
* @class BI.BubblePopupBarView
* @extends BI.BubblePopupView
*/
BI.BubblePopupBarView = BI.inherit(BI.BubblePopupView, {
_defaultConfig: function () {
return BI.extend(BI.BubblePopupBarView.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-bubble-bar-popup-view",
buttons: [{
value: false,
text: BI.i18nText("BI-Basic_Cancel"),
level: "ignore"
}, {
text: BI.i18nText(BI.i18nText("BI-Basic_OK")),
value: true
}],
innerVgap: 16,
innerHgap: 16,
});
},
_createToolBar: function () {
var o = this.options, self = this;
var items = [];
BI.each(o.buttons, function (i, buttonOpt) {
if (BI.isWidget(buttonOpt)) {
items.push({
el: buttonOpt,
lgap: 12,
});
} else {
items.push({
el: BI.extend({
type: "bi.button",
height: 24,
handler: function (v) {
self.fireEvent(BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, v);
}
}, buttonOpt),
lgap: 12,
});
}
});
return BI.createWidget({
type: "bi.right_vertical_adapt",
innerVgap: o.innerVgap,
innerHgap: o.innerHgap,
items: items
});
},
_createContent: function () { @shortcut()
return this.options.el; export class BubblePopupView extends PopupView {
}, static xtype = "bi.text_bubble_bar_popup_view";
_createView: function () { static EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON";
var o = this.options; static EVENT_CHANGE = "EVENT_CLICK_TOOLBAR_BUTTON";
var view = BI.createWidget({ _defaultConfig() {
type: "bi.vertical", const config = super._defaultConfig(...arguments);
items: [this._createContent()],
cls: "bar-popup-container", return extend(config, {
hgap: o.innerHgap, baseCls: `${config.baseCls} bi-text-bubble-bar-popup-view`,
tgap: o.innerVgap,
});
view.element.css("min-height", o.minHeight);
return view;
}
});
BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON";
BI.shortcut("bi.bubble_bar_popup_view", BI.BubblePopupBarView);
/**
* Created by Windy on 2018/2/2.
*
* @class BI.TextBubblePopupBarView
* @extends BI.BubblePopupView
*/
BI.TextBubblePopupBarView = BI.inherit(BI.BubblePopupBarView, {
_defaultConfig: function () {
var config = BI.TextBubblePopupBarView.superclass._defaultConfig.apply(this, arguments);
return BI.extend(config, {
baseCls: config.baseCls + " bi-text-bubble-bar-popup-view",
text: "", text: "",
}); });
}, }
_createContent: function () { _createContent() {
var self = this, o = this.options; const o = this.options;
return { return {
type: "bi.label", type: Label.xtype,
text: o.text, text: o.text,
whiteSpace: "normal", whiteSpace: "normal",
textAlign: "left", textAlign: "left",
ref: function () { ref: _ref => {
self.text = this; this.text = _ref;
} },
}; };
}, }
populate: function (v) { populate(v) {
this.text.setText(v || this.options.text); this.text.setText(v || this.options.text);
} }
}); }
BI.TextBubblePopupBarView.EVENT_CHANGE = "EVENT_CLICK_TOOLBAR_BUTTON";
BI.shortcut("bi.text_bubble_bar_popup_view", BI.TextBubblePopupBarView);

118
src/case/combo/editoriconcheckcombo/combo.editiconcheck.js

@ -1,26 +1,44 @@
/** import {
* Created by Young's on 2016/4/28. shortcut,
*/ Widget,
BI.EditorIconCheckCombo = BI.inherit(BI.Widget, { extend,
_defaultConfig: function () { emptyFn,
return BI.extend(BI.EditorIconCheckCombo.superclass._defaultConfig.apply(this, arguments), { createWidget,
Controller
} from "@/core";
import { ButtonGroup, Combo } from "@/base";
import { EditorTrigger } from "../../trigger";
import { TextValueCheckComboPopup } from "../textvaluecheckcombo/popup.textvaluecheck";
@shortcut()
export class EditorIconCheckCombo extends Widget {
static xtype = "bi.editor_icon_check_combo";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_EMPTY = "EVENT_EMPTY";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseClass: "bi-check-editor-combo", baseClass: "bi-check-editor-combo",
width: 100, width: 100,
height: 24, height: 24,
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
validationChecker: BI.emptyFn, validationChecker: emptyFn,
quitChecker: BI.emptyFn, quitChecker: emptyFn,
allowBlank: true, allowBlank: true,
watermark: "", watermark: "",
errorText: "" errorText: "",
}); });
}, }
_init: function () { _init() {
BI.EditorIconCheckCombo.superclass._init.apply(this, arguments); super._init(...arguments);
var self = this, o = this.options; const o = this.options;
this.trigger = BI.createWidget({ this.trigger = createWidget({
type: "bi.editor_trigger", type: EditorTrigger.xtype,
items: o.items, items: o.items,
height: o.height, height: o.height,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
@ -28,41 +46,41 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, {
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
watermark: o.watermark, watermark: o.watermark,
errorText: o.errorText, errorText: o.errorText,
value: o.value value: o.value,
}); });
this.trigger.on(BI.EditorTrigger.EVENT_CHANGE, function () { this.trigger.on(EditorTrigger.EVENT_CHANGE, (...args) => {
self.popup.setValue(this.getValue()); this.popup.setValue(this.getValue());
self.fireEvent(BI.EditorIconCheckCombo.EVENT_CHANGE, arguments); this.fireEvent(EditorIconCheckCombo.EVENT_CHANGE, ...args);
}); });
this.trigger.on(BI.EditorTrigger.EVENT_FOCUS, function () { this.trigger.on(EditorTrigger.EVENT_FOCUS, (...args) => {
self.fireEvent(BI.EditorIconCheckCombo.EVENT_FOCUS, arguments); this.fireEvent(EditorIconCheckCombo.EVENT_FOCUS, ...args);
}); });
this.trigger.on(BI.EditorTrigger.EVENT_EMPTY, function () { this.trigger.on(EditorTrigger.EVENT_EMPTY, (...args) => {
self.fireEvent(BI.EditorIconCheckCombo.EVENT_EMPTY, arguments); this.fireEvent(EditorIconCheckCombo.EVENT_EMPTY, ...args);
}); });
this.trigger.on(BI.EditorTrigger.EVENT_VALID, function () { this.trigger.on(EditorTrigger.EVENT_VALID, (...args) => {
self.fireEvent(BI.EditorIconCheckCombo.EVENT_VALID, arguments); this.fireEvent(EditorIconCheckCombo.EVENT_VALID, ...args);
}); });
this.trigger.on(BI.EditorTrigger.EVENT_ERROR, function () { this.trigger.on(EditorTrigger.EVENT_ERROR, (...args) => {
self.fireEvent(BI.EditorIconCheckCombo.EVENT_ERROR, arguments); this.fireEvent(EditorIconCheckCombo.EVENT_ERROR, ...args);
}); });
this.popup = BI.createWidget({ this.popup = createWidget({
type: "bi.text_value_check_combo_popup", type: "bi.text_value_check_combo_popup",
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items, items: o.items,
value: o.value value: o.value,
}); });
this.popup.on(BI.TextValueCheckComboPopup.EVENT_CHANGE, function () { this.popup.on(TextValueCheckComboPopup.EVENT_CHANGE, () => {
self.setValue(self.popup.getValue()); this.setValue(this.popup.getValue());
self.editorIconCheckCombo.hideView(); this.editorIconCheckCombo.hideView();
self.fireEvent(BI.EditorIconCheckCombo.EVENT_CHANGE); this.fireEvent(EditorIconCheckCombo.EVENT_CHANGE);
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function () { this.popup.on(Controller.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(Controller.EVENT_CHANGE, ...args);
}); });
this.editorIconCheckCombo = BI.createWidget({ this.editorIconCheckCombo = createWidget({
type: "bi.combo", type: Combo.xtype,
container: o.container, container: o.container,
direction: o.direction, direction: o.direction,
element: this, element: this,
@ -70,27 +88,21 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, {
el: this.trigger, el: this.trigger,
popup: { popup: {
el: this.popup, el: this.popup,
maxHeight: 300 maxHeight: 300,
} },
}); });
}, }
setValue: function (v) { setValue(v) {
this.editorIconCheckCombo.setValue(v); this.editorIconCheckCombo.setValue(v);
}, }
getValue: function () { getValue() {
return this.trigger.getValue(); return this.trigger.getValue();
}, }
populate: function (items) { populate(items) {
this.options.items = items; this.options.items = items;
this.editorIconCheckCombo.populate(items); this.editorIconCheckCombo.populate(items);
} }
}); }
BI.EditorIconCheckCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.EditorIconCheckCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.EditorIconCheckCombo.EVENT_EMPTY = "EVENT_EMPTY";
BI.EditorIconCheckCombo.EVENT_VALID = "EVENT_VALID";
BI.EditorIconCheckCombo.EVENT_ERROR = "EVENT_ERROR";
BI.shortcut("bi.editor_icon_check_combo", BI.EditorIconCheckCombo);

117
src/case/combo/iconcombo/combo.icon.js

@ -1,12 +1,24 @@
/** import {
* Created by GUY on 2016/2/2. shortcut,
* Widget,
* @class BI.IconCombo extend,
* @extend BI.Widget isFunction,
*/ createWidget,
BI.IconCombo = BI.inherit(BI.Widget, { Controller,
_defaultConfig: function () { isNull,
return BI.extend(BI.IconCombo.superclass._defaultConfig.apply(this, arguments), { isArray
} from "@/core";
import { ButtonGroup, Combo } from "@/base";
import { IconComboPopup } from "./popup.iconcombo";
@shortcut()
export class IconCombo extends Widget {
static xtype = "bi.icon_combo";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-icon-combo", baseCls: "bi-icon-combo",
width: 24, width: 24,
height: 24, height: 24,
@ -20,22 +32,26 @@ BI.IconCombo = BI.inherit(BI.Widget, {
adjustXOffset: 0, adjustXOffset: 0,
adjustYOffset: 0, adjustYOffset: 0,
offsetStyle: "left", offsetStyle: "left",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
isShowDown: true, isShowDown: true,
hideWhenAnotherComboOpen: false hideWhenAnotherComboOpen: false,
}); });
}, }
_init: function () { _init() {
var self = this, o = this.options; const o = this.options;
o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { o.value = isFunction(o.value)
self.setValue(newValue); ? this.__watch(o.value, (context, newValue) => {
}) : o.value; this.setValue(newValue);
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { })
self.populate(newValue); : o.value;
}) : o.items; o.items = isFunction(o.items)
BI.IconCombo.superclass._init.apply(this, arguments); ? this.__watch(o.items, (context, newValue) => {
this.trigger = BI.createWidget(o.el, { this.populate(newValue);
})
: o.items;
super._init(...arguments);
this.trigger = createWidget(o.el, {
type: "bi.icon_combo_trigger", type: "bi.icon_combo_trigger",
iconCls: o.iconCls, iconCls: o.iconCls,
title: o.title, title: o.title,
@ -45,24 +61,24 @@ BI.IconCombo = BI.inherit(BI.Widget, {
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
value: o.value, value: o.value,
isShowDown: o.isShowDown isShowDown: o.isShowDown,
}); });
this.popup = BI.createWidget(o.popup, { this.popup = createWidget(o.popup, {
type: "bi.icon_combo_popup", type: IconComboPopup.xtype,
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items, items: o.items,
value: o.value value: o.value,
}); });
this.popup.on(BI.IconComboPopup.EVENT_CHANGE, function () { this.popup.on(IconComboPopup.EVENT_CHANGE, () => {
self.setValue(self.popup.getValue()); this.setValue(this.popup.getValue());
self.iconCombo.hideView(); this.iconCombo.hideView();
self.fireEvent(BI.IconCombo.EVENT_CHANGE); this.fireEvent(IconCombo.EVENT_CHANGE);
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function () { this.popup.on(Controller.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(Controller.EVENT_CHANGE, ...args);
}); });
this.iconCombo = BI.createWidget({ this.iconCombo = createWidget({
type: "bi.combo", type: Combo.xtype,
element: this, element: this,
direction: o.direction, direction: o.direction,
trigger: o.trigger, trigger: o.trigger,
@ -77,33 +93,32 @@ BI.IconCombo = BI.inherit(BI.Widget, {
el: this.popup, el: this.popup,
maxWidth: o.maxWidth, maxWidth: o.maxWidth,
maxHeight: o.maxHeight, maxHeight: o.maxHeight,
minWidth: o.minWidth minWidth: o.minWidth,
} },
}); });
}, }
showView: function () { showView() {
this.iconCombo.showView(); this.iconCombo.showView();
}, }
hideView: function () { hideView() {
this.iconCombo.hideView(); this.iconCombo.hideView();
}, }
setValue: function (v) { setValue(v) {
this.trigger.setValue(v); this.trigger.setValue(v);
this.popup.setValue(v); this.popup.setValue(v);
}, }
getValue: function () { getValue() {
var value = this.popup.getValue(); const value = this.popup.getValue();
return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
}, return isNull(value) ? [] : isArray(value) ? value : [value];
}
populate: function (items) { populate(items) {
this.options.items = items; this.options.items = items;
this.iconCombo.populate(items); this.iconCombo.populate(items);
} }
}); }
BI.IconCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_combo", BI.IconCombo);

97
src/case/combo/iconcombo/popup.iconcombo.js

@ -1,63 +1,74 @@
/** import {
* Created by GUY on 2016/2/2. shortcut,
* extend,
* @class BI.IconComboPopup createWidget,
* @extend BI.Pane createItems,
*/ Controller,
BI.IconComboPopup = BI.inherit(BI.Pane, { Events,
_defaultConfig: function () { VerticalLayout
return BI.extend(BI.IconComboPopup.superclass._defaultConfig.apply(this, arguments), { } from "@/core";
import { Pane, ButtonGroup } from "@/base";
import { SingleSelectIconTextItem } from "../../button";
@shortcut()
export class IconComboPopup extends Pane {
static xtype = "bi.icon_combo_popup";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi.icon-combo-popup", baseCls: "bi.icon-combo-popup",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
}); });
}, }
_init: function () { _init() {
BI.IconComboPopup.superclass._init.apply(this, arguments); super._init(...arguments);
var o = this.options, self = this; const o = this.options;
this.popup = BI.createWidget({ this.popup = createWidget({
type: "bi.button_group", type: ButtonGroup.xtype,
items: BI.createItems(o.items, { items: createItems(o.items, {
type: "bi.single_select_icon_text_item", type: SingleSelectIconTextItem.xtype,
}), }),
chooseType: o.chooseType, chooseType: o.chooseType,
layouts: [{ layouts: [
type: "bi.vertical" {
}], type: VerticalLayout.xtype,
value: o.value }
],
value: o.value,
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { this.popup.on(Controller.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); const [type, val, obj] = args;
if (type === BI.Events.CLICK) { this.fireEvent(Controller.EVENT_CHANGE, ...args);
self.fireEvent(BI.IconComboPopup.EVENT_CHANGE, val, obj); if (type === Events.CLICK) {
this.fireEvent(IconComboPopup.EVENT_CHANGE, val, obj);
} }
}); });
BI.createWidget({ createWidget({
type: "bi.vertical", type: VerticalLayout.xtype,
element: this, element: this,
vgap: 5, vgap: 5,
items: [this.popup] items: [this.popup],
}); });
}, }
populate: function (items) { populate(items) {
BI.IconComboPopup.superclass.populate.apply(this, arguments); super.populate(...arguments);
items = BI.createItems(items, { items = createItems(items, {
type: "bi.single_select_icon_text_item", type: SingleSelectIconTextItem.xtype,
}); });
this.popup.populate(items); this.popup.populate(items);
}, }
getValue: function () { getValue() {
return this.popup.getValue(); return this.popup.getValue();
}, }
setValue: function (v) { setValue(v) {
this.popup.setValue(v); this.popup.setValue(v);
} }
}
});
BI.IconComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_combo_popup", BI.IconComboPopup);

125
src/case/combo/iconcombo/trigger.iconcombo.js

@ -1,12 +1,24 @@
/** import {
* Created by GUY on 2016/2/2. shortcut,
* extend,
* @class BI.IconComboTrigger isKey,
* @extend BI.Widget createWidget,
*/ isNotEmptyString,
BI.IconComboTrigger = BI.inherit(BI.Trigger, { AbsoluteLayout,
_defaultConfig: function () { isArray,
return BI.extend(BI.IconComboTrigger.superclass._defaultConfig.apply(this, arguments), { any
} from "@/core";
import { Trigger, IconButton } from "@/base";
import { IconChangeButton } from "../../button";
@shortcut()
export class IconComboTrigger extends Trigger {
static xtype = "bi.icon_combo_trigger";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-icon-combo-trigger", extraCls: "bi-icon-combo-trigger",
el: {}, el: {},
items: [], items: [],
@ -14,80 +26,85 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, {
width: 24, width: 24,
height: 24, height: 24,
isShowDown: true, isShowDown: true,
value: "" value: "",
}); });
}, }
_init: function () { _init() {
BI.IconComboTrigger.superclass._init.apply(this, arguments); super._init(...arguments);
var o = this.options, self = this; const o = this.options;
var iconCls = ""; let iconCls = "";
if(BI.isKey(o.value)){ if (isKey(o.value)) {
iconCls = this._digest(o.value, o.items); iconCls = this._digest(o.value, o.items);
} }
this.button = BI.createWidget(o.el, { this.button = createWidget(o.el, {
type: "bi.icon_change_button", type: IconChangeButton.xtype,
cls: "icon-combo-trigger-icon", cls: "icon-combo-trigger-icon",
iconCls: iconCls, iconCls,
disableSelected: true, disableSelected: true,
width: o.isShowDown ? o.width - 12 : o.width, width: o.isShowDown ? o.width - 12 : o.width,
height: o.height, height: o.height,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
selected: BI.isNotEmptyString(iconCls) selected: isNotEmptyString(iconCls),
}); });
this.down = BI.createWidget({ this.down = createWidget({
type: "bi.icon_button", type: IconButton.xtype,
disableSelected: true, disableSelected: true,
cls: "icon-combo-down-icon trigger-triangle-font font-size-12", cls: "icon-combo-down-icon trigger-triangle-font font-size-12",
width: 12, width: 12,
height: 8, height: 8,
selected: BI.isNotEmptyString(iconCls), selected: isNotEmptyString(iconCls),
invisible: !o.isShowDown invisible: !o.isShowDown,
}); });
BI.createWidget({ createWidget({
type: "bi.absolute", type: AbsoluteLayout.xtype,
element: this, element: this,
items: [{ items: [
el: this.button, {
left: 0, el: this.button,
right: 0, left: 0,
top: 0, right: 0,
bottom: 0 top: 0,
}, { bottom: 0,
el: this.down, },
right: 3, {
bottom: 0 el: this.down,
}] right: 3,
bottom: 0,
}
],
}); });
}, }
_digest: function (v, items) { _digest(v, items) {
var iconCls = ""; let iconCls = "";
v = BI.isArray(v) ? v[0] : v; v = isArray(v) ? v[0] : v;
BI.any(items, function (i, item) { any(items, (i, item) => {
if (v === item.value) { if (v === item.value) {
iconCls = item.iconCls; iconCls = item.iconCls;
return true; return true;
} }
}); });
return iconCls; return iconCls;
}, }
populate: function (items) { populate(items) {
var o = this.options; const o = this.options;
this.options.items = items || []; this.options.items = items || [];
this.button.setIcon(o.iconCls); this.button.setIcon(o.iconCls);
this.button.setSelected(false); this.button.setSelected(false);
this.down.setSelected(false); this.down.setSelected(false);
}, }
setValue: function (v) { setValue(v) {
BI.IconComboTrigger.superclass.setValue.apply(this, arguments); super.setValue(...arguments);
var o = this.options; const o = this.options;
var iconCls = this._digest(v, this.options.items); const iconCls = this._digest(v, this.options.items);
v = BI.isArray(v) ? v[0] : v; v = isArray(v) ? v[0] : v;
if (BI.isNotEmptyString(iconCls)) { if (isNotEmptyString(iconCls)) {
this.button.setIcon(iconCls); this.button.setIcon(iconCls);
this.button.setSelected(true); this.button.setSelected(true);
this.down.setSelected(true); this.down.setSelected(true);
@ -97,6 +114,4 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, {
this.down.setSelected(false); this.down.setSelected(false);
} }
} }
}); }
BI.IconComboTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_combo_trigger", BI.IconComboTrigger);

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

@ -1,32 +1,61 @@
/** import {
* Created by Windy on 2017/12/12. shortcut,
* combo : icon + text + icon, popup : icon + text Widget,
*/ extend,
BI.IconTextValueCombo = BI.inherit(BI.Widget, { isFunction,
_defaultConfig: function (config) { createWidget,
return BI.extend(BI.IconTextValueCombo.superclass._defaultConfig.apply(this, arguments), { toPix,
baseCls: "bi-icon-text-value-combo " + (config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), Controller,
isKey,
isNull,
isEmptyArray,
isEmptyString,
isArray,
find,
contains
} from "@/core";
import { IconTextValueComboPopup } from "./popup.icontextvalue";
import { SelectIconTextTrigger } from "../../trigger";
import { Combo } from "@/base";
@shortcut()
export class IconTextValueCombo extends Widget {
static xtype = "bi.icon_text_value_combo";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig(config) {
return extend(super._defaultConfig(...arguments), {
baseCls:
`bi-icon-text-value-combo ${
config.simple
? "bi-border-bottom"
: "bi-border bi-border-radius"}`,
height: 24, height: 24,
iconHeight: null, iconHeight: null,
iconWidth: null, iconWidth: null,
value: "", value: "",
}); });
}, }
_init: function () { _init() {
var self = this, o = this.options; const o = this.options;
o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { o.value = isFunction(o.value)
self.setValue(newValue); ? this.__watch(o.value, (context, newValue) => {
}) : o.value; this.setValue(newValue);
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { })
self.populate(newValue); : o.value;
}) : o.items; o.items = isFunction(o.items)
BI.IconTextValueCombo.superclass._init.apply(this, arguments); ? this.__watch(o.items, (context, newValue) => {
this.trigger = BI.createWidget({ this.populate(newValue);
type: "bi.select_icon_text_trigger", })
: o.items;
super._init(...arguments);
this.trigger = createWidget({
type: SelectIconTextTrigger.xtype,
cls: "icon-text-value-trigger", cls: "icon-text-value-trigger",
items: o.items, items: o.items,
height: BI.toPix(o.height, 2), height: toPix(o.height, 2),
text: o.text, text: o.text,
iconCls: o.iconCls, iconCls: o.iconCls,
value: o.value, value: o.value,
@ -34,28 +63,28 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, {
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconWrapperWidth: o.iconWrapperWidth, iconWrapperWidth: o.iconWrapperWidth,
title: o.title, title: o.title,
warningTitle: o.warningTitle warningTitle: o.warningTitle,
}); });
this.popup = BI.createWidget({ this.popup = createWidget({
type: "bi.icon_text_value_combo_popup", type: "bi.icon_text_value_combo_popup",
items: o.items, items: o.items,
value: o.value, value: o.value,
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconWrapperWidth: o.iconWrapperWidth iconWrapperWidth: o.iconWrapperWidth,
}); });
this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { this.popup.on(IconTextValueComboPopup.EVENT_CHANGE, (...args) => {
self.setValue(self.popup.getValue()); this.setValue(this.popup.getValue());
self.textIconCombo.hideView(); this.textIconCombo.hideView();
self.fireEvent(BI.IconTextValueCombo.EVENT_CHANGE, arguments); this.fireEvent(IconTextValueCombo.EVENT_CHANGE, ...args);
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function () { this.popup.on(Controller.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(Controller.EVENT_CHANGE, ...args);
}); });
this.textIconCombo = BI.createWidget({ this.textIconCombo = createWidget({
type: "bi.combo", type: Combo.xtype,
height: BI.toPix(o.height, 2), height: toPix(o.height, 2),
width: BI.toPix(o.width, 2), width: toPix(o.width, 2),
element: this, element: this,
container: o.container, container: o.container,
direction: o.direction, direction: o.direction,
@ -64,24 +93,22 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, {
popup: { popup: {
el: this.popup, el: this.popup,
maxHeight: 240, maxHeight: 240,
minHeight: 25 minHeight: 25,
} },
}); });
if (BI.isKey(o.value)) { if (isKey(o.value)) {
this.setValue(o.value); this.setValue(o.value);
} }
}, }
_checkError: function (v) { _checkError(v) {
if(BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { if (isNull(v) || isEmptyArray(v) || isEmptyString(v)) {
this.trigger.options.tipType = "success"; this.trigger.options.tipType = "success";
this.element.removeClass("combo-error"); this.element.removeClass("combo-error");
} else { } else {
v = BI.isArray(v) ? v : [v]; v = isArray(v) ? v : [v];
var result = BI.find(this.options.items, function (idx, item) { const result = find(this.options.items, (idx, item) => contains(v, item.value));
return BI.contains(v, item.value); if (isNull(result)) {
});
if (BI.isNull(result)) {
this.trigger.options.tipType = "warning"; this.trigger.options.tipType = "warning";
this.element.removeClass("combo-error").addClass("combo-error"); this.element.removeClass("combo-error").addClass("combo-error");
} else { } else {
@ -89,23 +116,22 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, {
this.element.removeClass("combo-error"); this.element.removeClass("combo-error");
} }
} }
}, }
setValue: function (v) { setValue(v) {
this.trigger.setValue(v); this.trigger.setValue(v);
this.popup.setValue(v); this.popup.setValue(v);
this._checkError(v); this._checkError(v);
}, }
getValue: function () { getValue() {
var value = this.popup.getValue(); const value = this.popup.getValue();
return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
}, return isNull(value) ? [] : isArray(value) ? value : [value];
}
populate: function (items) { populate(items) {
this.options.items = items; this.options.items = items;
this.textIconCombo.populate(items); this.textIconCombo.populate(items);
} }
}); }
BI.IconTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_value_combo", BI.IconTextValueCombo);

102
src/case/combo/icontextvaluecombo/popup.icontextvalue.js

@ -1,74 +1,88 @@
/** import {
* Created by Windy on 2017/12/12. shortcut,
*/ extend,
BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { createWidget,
_defaultConfig: function () { createItems,
return BI.extend(BI.IconTextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { Controller,
Events,
VerticalLayout
} from "@/core";
import { Pane, ButtonGroup } from "@/base";
import { SingleSelectIconTextItem } from "../../button";
@shortcut()
export class IconTextValueComboPopup extends Pane {
static xtype = "bi.icon_text_value_combo_popup";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-icon-text-icon-popup", baseCls: "bi-icon-text-icon-popup",
behaviors: { behaviors: {
redmark: function () { redmark () {
return true; return true;
} },
} },
}); });
}, }
_init: function () { _init() {
BI.IconTextValueComboPopup.superclass._init.apply(this, arguments); super._init(...arguments);
var o = this.options, self = this; const o = this.options;
this.popup = BI.createWidget({ this.popup = createWidget({
type: "bi.button_group", type: ButtonGroup.xtype,
items: BI.createItems(o.items, { items: createItems(o.items, {
type: "bi.single_select_icon_text_item", type: SingleSelectIconTextItem.xtype,
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconWrapperWidth: o.iconWrapperWidth iconWrapperWidth: o.iconWrapperWidth,
}), }),
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
layouts: [{ layouts: [
type: "bi.vertical" {
}], type: VerticalLayout.xtype,
}
],
behaviors: o.behaviors, behaviors: o.behaviors,
value: o.value value: o.value,
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { this.popup.on(Controller.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); const [type, val, obj] = args;
if (type === BI.Events.CLICK) { this.fireEvent(Controller.EVENT_CHANGE, ...args);
self.fireEvent(BI.IconTextValueComboPopup.EVENT_CHANGE, val, obj); if (type === Events.CLICK) {
this.fireEvent(IconTextValueComboPopup.EVENT_CHANGE, val, obj);
} }
}); });
this.check(); this.check();
BI.createWidget({ createWidget({
type: "bi.vertical", type: VerticalLayout.xtype,
element: this, element: this,
vgap: 5, vgap: 5,
items: [this.popup] items: [this.popup],
}); });
}, }
populate: function (items, keyword) { populate(items, keyword) {
BI.IconTextValueComboPopup.superclass.populate.apply(this, arguments); super.populate(...arguments);
var o = this.options; const o = this.options;
items = BI.createItems(items, { items = createItems(items, {
type: "bi.single_select_icon_text_item", type: SingleSelectIconTextItem.xtype,
iconWrapperWidth: o.iconWrapperWidth, iconWrapperWidth: o.iconWrapperWidth,
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
}); });
this.popup.populate(items, keyword); this.popup.populate(items, keyword);
}, }
getValue: function () { getValue() {
return this.popup.getValue(); return this.popup.getValue();
}, }
setValue: function (v) { setValue(v) {
this.popup.setValue(v); this.popup.setValue(v);
} }
}
});
BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);

22
src/case/combo/index.js

@ -0,0 +1,22 @@
export { BubbleCombo } from "./bubblecombo/combo.bubble";
export { BubblePopupView } from "./bubblecombo/popup.bubble";
export { EditorIconCheckCombo } from "./editoriconcheckcombo/combo.editiconcheck";
export { IconCombo } from "./iconcombo/combo.icon";
export { IconComboPopup } from "./iconcombo/popup.iconcombo";
export { IconComboTrigger } from "./iconcombo/trigger.iconcombo";
export { IconTextValueCombo } from "./icontextvaluecombo/combo.icontextvalue";
export { IconTextValueComboPopup } from "./icontextvaluecombo/popup.icontextvalue";
export { SearchTextValueCombo } from "./searchtextvaluecombo/combo.searchtextvalue";
export { SearchTextValueComboPopup } from "./searchtextvaluecombo/popup.searchtextvalue";
export { SearchTextValueTrigger } from "./searchtextvaluecombo/trigger.searchtextvalue";
export { TextValueCheckCombo } from "./textvaluecheckcombo/combo.textvaluecheck";
export { TextValueCheckComboPopup } from "./textvaluecheckcombo/popup.textvaluecheck";
export { TextValueCombo } from "./textvaluecombo/combo.textvalue";
export { SmallTextValueCombo } from "./textvaluecombo/combo.textvaluesmall";
export { TextValueComboPopup } from "./textvaluecombo/popup.textvalue";

207
src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js

@ -1,9 +1,25 @@
/** import {
* Created by Windy on 2018/2/2. shortcut,
*/ Widget,
BI.SearchTextValueCombo = BI.inherit(BI.Widget, { isFunction,
toPix,
isKey,
isNull,
isEmptyArray,
isEmptyString,
isArray,
find,
contains
} from "@/core";
import { SearchTextValueTrigger } from "./trigger.searchtextvalue";
import { ButtonGroup, Combo } from "@/base";
import { TextValueComboPopup } from "../textvaluecombo/popup.textvalue";
props: { @shortcut()
export class SearchTextValueCombo extends Widget {
static xtype = "bi.search_text_value_combo";
props = {
baseCls: "bi-search-text-value-combo", baseCls: "bi-search-text-value-combo",
height: 24, height: 24,
text: "", text: "",
@ -12,36 +28,46 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
tipType: "", tipType: "",
warningTitle: "", warningTitle: "",
allowClear: false, allowClear: false,
}, };
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
static EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
render: function () { render() {
var self = this, o = this.options; const o = this.options;
o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { o.value = isFunction(o.value)
self.setValue(newValue); ? this.__watch(o.value, (context, newValue) => {
}) : o.value; this.setValue(newValue);
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { })
self.populate(newValue); : o.value;
}) : o.items; o.items = isFunction(o.items)
? this.__watch(o.items, (context, newValue) => {
this.populate(newValue);
})
: o.items;
return { return {
type: "bi.combo", type: Combo.xtype,
cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius") + " bi-focus-shadow", cls:
`${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"
} bi-focus-shadow`,
container: o.container, container: o.container,
adjustLength: 2, adjustLength: 2,
height: BI.toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
width: BI.toPix(o.width, 2), width: toPix(o.width, 2),
ref: function () { ref: _ref => {
self.combo = this; this.combo = _ref;
}, },
el: { el: {
type: "bi.search_text_value_trigger", type: "bi.search_text_value_trigger",
cls: "search-text-value-trigger", cls: "search-text-value-trigger",
watermark: o.watermark, watermark: o.watermark,
ref: function () { ref: _ref => {
self.trigger = this; this.trigger = _ref;
}, },
items: o.items, items: o.items,
height: BI.toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
text: o.text, text: o.text,
defaultText: o.defaultText, defaultText: o.defaultText,
value: o.value, value: o.value,
@ -49,80 +75,92 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
warningTitle: o.warningTitle, warningTitle: o.warningTitle,
title: o.title, title: o.title,
allowClear: o.allowClear, allowClear: o.allowClear,
listeners: [{ listeners: [
eventName: BI.SearchTextValueTrigger.EVENT_CHANGE, {
action: function () { eventName: SearchTextValueTrigger.EVENT_CHANGE,
self.setValue(this.getValue()[0]); action: () => {
self.combo.hideView(); this.setValue(this.getValue()[0]);
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); this.combo.hideView();
} this.fireEvent(SearchTextValueCombo.EVENT_CHANGE);
}, { },
eventName: BI.SearchTextValueTrigger.EVENT_CLEAR, },
action: function () { {
self._clear(); eventName: SearchTextValueTrigger.EVENT_CLEAR,
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); action: () => {
this._clear();
this.fireEvent(SearchTextValueCombo.EVENT_CHANGE);
},
} }
}] ],
}, },
popup: { popup: {
el: { el: {
type: "bi.text_value_combo_popup", type: "bi.text_value_combo_popup",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
value: o.value, value: o.value,
items: o.items, items: o.items,
ref: function () { ref: _ref => {
self.popup = this; this.popup = _ref;
self.trigger.getSearcher().setAdapter(self.popup); this.trigger.getSearcher().setAdapter(this.popup);
}, },
listeners: [{ listeners: [
eventName: BI.TextValueComboPopup.EVENT_CHANGE, {
action: function () { eventName: TextValueComboPopup.EVENT_CHANGE,
self.setValue(this.getValue()[0]); action: () => {
self.combo.hideView(); this.setValue(this.getValue()[0]);
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); this.combo.hideView();
this.fireEvent(
SearchTextValueCombo.EVENT_CHANGE
);
},
} }
}] ],
}, },
value: o.value, value: o.value,
maxHeight: 252, maxHeight: 252,
minHeight: 25 minHeight: 25,
}, },
listeners: [{ listeners: [
eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, {
action: function () { eventName: Combo.EVENT_AFTER_HIDEVIEW,
self.trigger.stopEditing(); action: () => {
self.fireEvent(BI.SearchTextValueCombo.EVENT_AFTER_HIDEVIEW); this.trigger.stopEditing();
} this.fireEvent(
}, { SearchTextValueCombo.EVENT_AFTER_HIDEVIEW
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, );
action: function () { },
self.fireEvent(BI.SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW); },
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.fireEvent(
SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW
);
},
} }
}], ],
}; };
}, }
created: function () { created() {
var o = this.options; const o = this.options;
if (BI.isKey(o.value)) { if (isKey(o.value)) {
this._checkError(o.value); this._checkError(o.value);
} }
}, }
_clear: function () { _clear() {
this.setValue(); this.setValue();
}, }
_checkError: function (v) { _checkError(v) {
if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { if (isNull(v) || isEmptyArray(v) || isEmptyString(v)) {
this.trigger.options.tipType = "success"; this.trigger.options.tipType = "success";
this.element.removeClass("combo-error"); this.element.removeClass("combo-error");
} else { } else {
v = BI.isArray(v) ? v : [v]; v = isArray(v) ? v : [v];
var result = BI.find(this.options.items, function (idx, item) { const result = find(this.options.items, (idx, item) => contains(v, item.value));
return BI.contains(v, item.value); if (isNull(result)) {
});
if (BI.isNull(result)) {
this.element.removeClass("combo-error").addClass("combo-error"); this.element.removeClass("combo-error").addClass("combo-error");
this.trigger.attr("tipType", "warning"); this.trigger.attr("tipType", "warning");
} else { } else {
@ -130,24 +168,21 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
this.trigger.attr("tipType", "success"); this.trigger.attr("tipType", "success");
} }
} }
}, }
populate: function (items) { populate(items) {
this.options.items = items; this.options.items = items;
this.combo.populate(items); this.combo.populate(items);
}, }
setValue: function (v) { setValue(v) {
this.combo.setValue(v); this.combo.setValue(v);
this._checkError(v); this._checkError(v);
}, }
getValue: function () { getValue() {
var value = this.combo.getValue(); const value = this.combo.getValue();
return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
return isNull(value) ? [] : isArray(value) ? value : [value];
} }
}); }
BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.SearchTextValueCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"
BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo);

142
src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js

@ -1,76 +1,100 @@
/** import {
* Created by Windy on 2018/2/5. shortcut,
*/ Controller,
BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, { Events,
VerticalLayout,
map,
extend,
concat
} from "@/core";
import { ButtonGroup, Pane } from "@/base";
import { SingleSelectItem } from "../../button";
props: { @shortcut()
baseCls: "bi-search-text-value-popup" export class SearchTextValueComboPopup extends Pane {
}, static xtype = "bi.search_text_value_combo_popup";
render: function () { props = { baseCls: "bi-search-text-value-popup" };
var self = this, o = this.options;
static EVENT_CHANGE = "EVENT_CHANGE";
render() {
const o = this.options;
return { return {
type: "bi.vertical", type: VerticalLayout.xtype,
vgap: 5, vgap: 5,
items: [{ items: [
type: "bi.button_group", {
ref: function () { type: ButtonGroup.xtype,
self.popup = this; ref: _ref => {
}, this.popup = _ref;
items: this._formatItems(o.items), },
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, items: this._formatItems(o.items),
layouts: [{ chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
type: "bi.vertical" layouts: [
}], {
behaviors: { type: VerticalLayout.xtype,
redmark: function () { }
return true; ],
} behaviors: {
}, redmark () {
value: o.value, return true;
listeners: [{ },
eventName: BI.Controller.EVENT_CHANGE, },
action: function (type, val, obj) { value: o.value,
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); listeners: [
if (type === BI.Events.CLICK) { {
self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj); eventName: Controller.EVENT_CHANGE,
action: (...args) => {
const [type, val, obj] = args;
this.fireEvent(
Controller.EVENT_CHANGE,
...args
);
if (type === Events.CLICK) {
this.fireEvent(
SearchTextValueComboPopup.EVENT_CHANGE,
val,
obj
);
}
},
} }
} ],
}] }
}] ],
}; };
}, }
_formatItems: function (items) { _formatItems(items) {
var o = this.options; const o = this.options;
return BI.map(items, function (i, item) {
return BI.extend({ return map(items, (i, item) => extend(
type: "bi.single_select_item", {
type: SingleSelectItem.xtype,
textAlign: o.textAlign, textAlign: o.textAlign,
title: item.title || item.text title: item.title || item.text,
}, item); },
}); item
}, ));
}
// mounted之后做check mounted() {
mounted: function() {
this.check(); this.check();
}, }
populate: function (find, match, keyword) { populate(find, match, keyword) {
var items = BI.concat(find, match); const items = concat(find, match);
BI.SearchTextValueComboPopup.superclass.populate.apply(this, items); super.populate.apply(this, items);
this.popup.populate(this._formatItems(items), keyword); this.popup.populate(this._formatItems(items), keyword);
}, }
getValue: function () { getValue() {
return this.popup.getValue(); return this.popup.getValue();
}, }
setValue: function (v) { setValue(v) {
this.popup.setValue(v); this.popup.setValue(v);
} }
}
});
BI.SearchTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_combo_popup", BI.SearchTextValueComboPopup);

202
src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js

@ -1,32 +1,53 @@
/** import {
* Created by Windy on 2018/2/2. shortcut,
*/ find,
BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { i18nText,
isNotEmptyString,
VerticalAdaptLayout
} from "@/core";
import {
ButtonGroup,
Trigger,
Searcher,
IconButton
} from "@/base";
import { TriggerIconButton } from "../../button";
import { DefaultTextEditor } from "../../editor";
props: function () { @shortcut()
export class SearchTextValueTrigger extends Trigger {
static xtype = "bi.search_text_value_trigger";
static EVENT_SEARCHING = "EVENT_SEARCHING";
static EVENT_STOP = "EVENT_STOP";
static EVENT_START = "EVENT_START";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_CLEAR = "EVENT_CLEAR";
props() {
return { return {
baseCls: "bi-search-text-value-trigger", baseCls: "bi-search-text-value-trigger",
height: 24, height: 24,
watermark: BI.i18nText("BI-Basic_Search"), watermark: i18nText("BI-Basic_Search"),
allowClear: false, allowClear: false,
title: () => this.editor.getText(), title: () => this.editor.getText(),
}; };
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
var triggerButton = { const triggerButton = {
type: "bi.trigger_icon_button", type: TriggerIconButton.xtype,
cls: "trigger-icon-button", cls: "trigger-icon-button",
ref: function () { ref: _ref => {
self.triggerBtn = this; this.triggerBtn = _ref;
}, },
width: o.height, width: o.height,
height: o.height, height: o.height,
}; };
var stateText = this._digest(o.value, o.items) || o.text; const stateText = this._digest(o.value, o.items) || o.text;
return { return {
type: "bi.horizontal_fill", type: "bi.horizontal_fill",
@ -34,15 +55,15 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
items: [ items: [
{ {
el: { el: {
type: "bi.searcher", type: Searcher.xtype,
ref: function () { ref: _ref => {
self.searcher = this; this.searcher = this;
}, },
isAutoSearch: false, isAutoSearch: false,
el: { el: {
type: "bi.default_text_editor", type: DefaultTextEditor.xtype,
ref: function () { ref: _ref => {
self.editor = this; this.editor = _ref;
}, },
watermark: o.watermark, watermark: o.watermark,
defaultText: o.defaultText, defaultText: o.defaultText,
@ -53,90 +74,103 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
popup: { popup: {
type: "bi.search_text_value_combo_popup", type: "bi.search_text_value_combo_popup",
cls: "bi-card", cls: "bi-card",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
tipText: BI.i18nText("BI-No_Select"), tipText: i18nText("BI-No_Select"),
}, },
onSearch: function (obj, callback) { onSearch (obj, callback) {
var keyword = obj.keyword; const keyword = obj.keyword;
var finding = BI.Func.getSearchResult(o.items, keyword); const finding = BI.Func.getSearchResult(
var matched = finding.match, find = finding.find; o.items,
keyword
);
const matched = finding.match,
find = finding.find;
callback(matched, find); callback(matched, find);
}, },
listeners: [{ listeners: [
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.SearchTextValueTrigger.EVENT_CHANGE);
}
}]
}
}, {
el: o.allowClear ? {
type: "bi.vertical_adapt",
horizontalAlign: "left",
scrollable: false,
items: [
{ {
el: { eventName: Searcher.EVENT_CHANGE,
type: "bi.icon_button", action: () => {
ref: function (_ref) { this.fireEvent(
self.clearBtn = _ref; SearchTextValueTrigger.EVENT_CHANGE
}, );
cls: "close-h-font " + (o.allowClear ? "clear-button" : ""),
stopPropagation: true,
invisible: !BI.isNotEmptyString(stateText),
width: o.height,
height: o.height,
handler: function () {
self.fireEvent(BI.SearchTextValueTrigger.EVENT_CLEAR);
},
}, },
}, {
el: triggerButton,
} }
] ],
} : triggerButton, },
width: 24 },
{
el: o.allowClear
? {
type: VerticalAdaptLayout.xtype,
horizontalAlign: "left",
scrollable: false,
items: [
{
el: {
type: IconButton.xtype,
ref: _ref => {
this.clearBtn = _ref;
},
cls:
`close-h-font ${
o.allowClear
? "clear-button"
: ""}`,
stopPropagation: true,
invisible:
!isNotEmptyString(stateText),
width: o.height,
height: o.height,
handler: () => {
this.fireEvent(
SearchTextValueTrigger.EVENT_CLEAR
);
},
},
},
{
el: triggerButton,
}
],
}
: triggerButton,
width: 24,
} }
] ],
}; };
}, }
_setState: function (v) { _setState(v) {
this.editor.setState(v); this.editor.setState(v);
}, }
_digest: function (value, items) { _digest(value, items) {
var result = BI.find(items, function (i, item) { const result = find(items, (i, item) => item.value === value);
return item.value === value;
});
return result?.text; return result?.text;
}, }
stopEditing: function () { stopEditing() {
this.searcher.stopSearch(); this.searcher.stopSearch();
}, }
getSearcher: function () { getSearcher() {
return this.searcher; return this.searcher;
}, }
populate: function (items) { populate(items) {
this.options.items = items; this.options.items = items;
}, }
setValue: function (vals) { setValue(vals) {
var digestText = this._digest(vals, this.options.items); const digestText = this._digest(vals, this.options.items);
this._setState(digestText); this._setState(digestText);
this.options.allowClear && this.clearBtn.setVisible(BI.isNotEmptyString(digestText)); this.options.allowClear &&
}, this.clearBtn.setVisible(isNotEmptyString(digestText));
}
getValue: function () { getValue() {
return this.searcher.getValue(); return this.searcher.getValue();
} }
}); }
BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP";
BI.SearchTextValueTrigger.EVENT_START = "EVENT_START";
BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.SearchTextValueTrigger.EVENT_CLEAR = "EVENT_CLEAR";
BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger);

131
src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js

@ -1,92 +1,113 @@
/** import {
* @class BI.TextValueCheckCombo shortcut,
* @extend BI.Widget Widget,
* combo : text + icon, popup : check + text extend,
*/ isFunction,
BI.TextValueCheckCombo = BI.inherit(BI.Widget, { createWidget,
_defaultConfig: function (config) { toPix,
return BI.extend(BI.TextValueCheckCombo.superclass._defaultConfig.apply(this, arguments), { Controller,
baseCls: "bi-text-value-check-combo " + (config.simple ? "bi-border-bottom" : "bi-border"), isKey,
isNull,
isArray
} from "@/core";
import { ButtonGroup, Combo } from "@/base";
import { TextValueCheckComboPopup } from "./popup.textvaluecheck";
import { SelectTextTrigger } from "../../trigger";
@shortcut()
export class TextValueCheckCombo extends Widget {
static xtype = "bi.text_value_check_combo";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig(config) {
return extend(super._defaultConfig(...arguments), {
baseCls:
`bi-text-value-check-combo ${
config.simple ? "bi-border-bottom" : "bi-border"}`,
width: 100, width: 100,
height: 24, height: 24,
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
value: "", value: "",
}); });
}, }
_init: function () { _init() {
var self = this, o = this.options; const o = this.options;
o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { o.value = isFunction(o.value)
self.setValue(newValue); ? this.__watch(o.value, (context, newValue) => {
}) : o.value; this.setValue(newValue);
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { })
self.populate(newValue); : o.value;
}) : o.items; o.items = isFunction(o.items)
BI.TextValueCheckCombo.superclass._init.apply(this, arguments); ? this.__watch(o.items, (context, newValue) => {
this.trigger = BI.createWidget({ this.populate(newValue);
type: "bi.select_text_trigger", })
: o.items;
super._init(...arguments);
this.trigger = createWidget({
type: SelectTextTrigger.xtype,
cls: "text-value-trigger", cls: "text-value-trigger",
items: o.items, items: o.items,
height: BI.toPix(o.height, 2), height: toPix(o.height, 2),
text: o.text, text: o.text,
value: o.value value: o.value,
}); });
this.popup = BI.createWidget({ this.popup = createWidget({
type: "bi.text_value_check_combo_popup", type: TextValueCheckComboPopup.xtype,
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items, items: o.items,
value: o.value value: o.value,
}); });
this.popup.on(BI.TextValueCheckComboPopup.EVENT_CHANGE, function () { this.popup.on(TextValueCheckComboPopup.EVENT_CHANGE, () => {
self.setValue(self.popup.getValue()); this.setValue(this.popup.getValue());
self.textIconCheckCombo.hideView(); this.textIconCheckCombo.hideView();
self.fireEvent(BI.TextValueCheckCombo.EVENT_CHANGE); this.fireEvent(TextValueCheckCombo.EVENT_CHANGE);
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function () { this.popup.on(Controller.EVENT_CHANGE, ...args => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(Controller.EVENT_CHANGE, ...args);
}); });
this.textIconCheckCombo = BI.createWidget({ this.textIconCheckCombo = createWidget({
type: "bi.combo", type: Combo.xtype,
container: o.container, container: o.container,
direction: o.direction, direction: o.direction,
element: this, element: this,
width: BI.toPix(o.width, 2), width: toPix(o.width, 2),
height: BI.toPix(o.height, 2), height: toPix(o.height, 2),
adjustLength: 2, adjustLength: 2,
el: this.trigger, el: this.trigger,
popup: { popup: {
el: this.popup, el: this.popup,
maxHeight: 300 maxHeight: 300,
} },
}); });
if (BI.isKey(o.value)) { if (isKey(o.value)) {
this.setValue(o.value); this.setValue(o.value);
} }
}, }
setTitle: function (title) { setTitle(title) {
this.trigger.setTitle(title); this.trigger.setTitle(title);
}, }
setValue: function (v) { setValue(v) {
this.trigger.setValue(v); this.trigger.setValue(v);
this.popup.setValue(v); this.popup.setValue(v);
}, }
setWarningTitle: function (title) { setWarningTitle(title) {
this.trigger.setWarningTitle(title); this.trigger.setWarningTitle(title);
}, }
getValue: function () { getValue() {
var value = this.popup.getValue(); const value = this.popup.getValue();
return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
}, return isNull(value) ? [] : isArray(value) ? value : [value];
}
populate: function (items) { populate(items) {
this.options.items = items; this.options.items = items;
this.textIconCheckCombo.populate(items); this.textIconCheckCombo.populate(items);
} }
}); }
BI.TextValueCheckCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_value_check_combo", BI.TextValueCheckCombo);

101
src/case/combo/textvaluecheckcombo/popup.textvaluecheck.js

@ -1,64 +1,83 @@
BI.TextValueCheckComboPopup = BI.inherit(BI.Pane, { import {
_defaultConfig: function () { shortcut,
return BI.extend(BI.TextValueCheckComboPopup.superclass._defaultConfig.apply(this, arguments), { extend,
createWidget,
Controller,
Events,
VerticalLayout,
map
} from "@/core";
import { Pane, ButtonGroup } from "@/base";
import { SingleSelectItem } from "../../button";
@shortcut()
export class TextValueCheckComboPopup extends Pane {
static xtype = "bi.text_value_check_combo_popup";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-text-icon-popup", baseCls: "bi-text-icon-popup",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
}); });
}, }
_init: function () { _init() {
BI.TextValueCheckComboPopup.superclass._init.apply(this, arguments); super._init(...arguments);
var o = this.options, self = this; const o = this.options;
this.popup = BI.createWidget({ this.popup = createWidget({
type: "bi.button_group", type: ButtonGroup.xtype,
items: this._formatItems(o.items), items: this._formatItems(o.items),
chooseType: o.chooseType, chooseType: o.chooseType,
layouts: [{ layouts: [
type: "bi.vertical" {
}], type: VerticalLayout.xtype,
value: o.value }
],
value: o.value,
}); });
this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { this.popup.on(Controller.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); const [type, val, obj] = args;
if (type === BI.Events.CLICK) { this.fireEvent(Controller.EVENT_CHANGE, ...args);
self.fireEvent(BI.TextValueCheckComboPopup.EVENT_CHANGE, val, obj); if (type === Events.CLICK) {
this.fireEvent(TextValueCheckComboPopup.EVENT_CHANGE, val, obj);
} }
}); });
BI.createWidget({ createWidget({
type: "bi.vertical", type: VerticalLayout.xtype,
element: this, element: this,
vgap: 5, vgap: 5,
items: [this.popup] items: [this.popup],
}); });
}, }
_formatItems: function (items) { _formatItems(items) {
var o = this.options; const o = this.options;
return BI.map(items, function (i, item) {
return BI.extend({ return map(items, (i, item) => extend(
type: "bi.single_select_item", {
type: SingleSelectItem.xtype,
cls: "bi-list-item", cls: "bi-list-item",
textAlign: o.textAlign, textAlign: o.textAlign,
title: item.title || item.text title: item.title || item.text,
}, item); },
}); item
}, ));
}
populate: function (items) { populate(items) {
BI.TextValueCheckComboPopup.superclass.populate.apply(this, arguments); super.populate(...arguments);
this.popup.populate(this._formatItems(items)); this.popup.populate(this._formatItems(items));
}, }
getValue: function () { getValue() {
return this.popup.getValue(); return this.popup.getValue();
}, }
setValue: function (v) { setValue(v) {
this.popup.setValue(v); this.popup.setValue(v);
} }
}
});
BI.TextValueCheckComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_value_check_combo_popup", BI.TextValueCheckComboPopup);

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

@ -1,15 +1,37 @@
/** import {
* @class BI.TextValueCombo shortcut,
* @extend BI.Widget Widget,
* combo : text + icon, popup : text extend,
* 参见场景dashboard布局方式选择 isFunction,
*/ toPix,
BI.TextValueCombo = BI.inherit(BI.Widget, { isEmptyArray,
_defaultConfig: function (config) { Controller,
return BI.extend(BI.TextValueCombo.superclass._defaultConfig.apply(this, arguments), { isKey,
baseCls: "bi-text-value-combo " + (config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), isObject,
isNull,
isArray,
intersection,
map
} from "@/core";
import { ButtonGroup, Combo } from "@/base";
import { SelectTextTrigger } from "../../trigger";
import { TextValueComboPopup } from "./popup.textvalue";
@shortcut()
export class TextValueCombo extends Widget {
static xtype = "bi.text_value_combo";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig(config) {
return extend(super._defaultConfig(...arguments), {
baseCls:
`bi-text-value-combo ${
config.simple
? "bi-border-bottom"
: "bi-border bi-border-radius"}`,
height: 24, height: 24,
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
text: "", text: "",
value: "", value: "",
defaultText: "", defaultText: "",
@ -19,44 +41,48 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
title: null, title: null,
allowSelectAll: true, allowSelectAll: true,
}); });
}, }
_init: function () {
var self = this, o = this.options;
o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) {
self.setValue(newValue);
}) : o.value;
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) {
self.populate(newValue);
}) : o.items;
BI.TextValueCombo.superclass._init.apply(this, arguments);
},
render: function () { _init() {
const o = this.options;
o.value = isFunction(o.value)
? this.__watch(o.value, (context, newValue) => {
this.setValue(newValue);
})
: o.value;
o.items = isFunction(o.items)
? this.__watch(o.items, (context, newValue) => {
this.populate(newValue);
})
: o.items;
super._init(...arguments);
}
render() {
const o = this.options; const o = this.options;
const title = () => { const title = () => {
if (BI.isFunction(o.title)) { if (isFunction(o.title)) {
return o.title(); return o.title();
} }
if (this.options.status === "error") { if (this.options.status === "error") {
return { return {
level: "warning", level: "warning",
text: o.warningTitle text: o.warningTitle,
}; };
} }
return { return {
level: "success" level: "success",
}; };
}; };
const trigger = { const trigger = {
type: "bi.select_text_trigger", type: SelectTextTrigger.xtype,
ref: ref => this.trigger = ref, ref: ref => (this.trigger = ref),
cls: "text-value-trigger", cls: "text-value-trigger",
items: o.items, items: o.items,
height: BI.toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
text: o.text, text: o.text,
value: o.value, value: o.value,
title, title,
@ -64,150 +90,169 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
defaultText: o.defaultText, defaultText: o.defaultText,
listeners: [ listeners: [
{ {
eventName: BI.SelectTextTrigger.EVENT_CLEAR, eventName: SelectTextTrigger.EVENT_CLEAR,
action: () => { action: () => {
this._clear(); this._clear();
this.fireEvent(BI.TextValueCombo.EVENT_CHANGE); this.fireEvent(TextValueCombo.EVENT_CHANGE);
} },
} }
], ],
...o.el ...o.el,
}; };
let changeTag = false; 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),
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items, items: o.items,
allowSelectAll: o.allowSelectAll, allowSelectAll: o.allowSelectAll,
listeners: [ listeners: [
{ {
eventName: BI.TextValueComboPopup.EVENT_CHANGE, eventName: TextValueComboPopup.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
changeTag = true; changeTag = true;
const value = this.popup.getValue(); const value = this.popup.getValue();
this.setValue(value); this.setValue(value);
if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) { if (o.chooseType === ButtonGroup.CHOOSE_TYPE_SINGLE) {
this.combo.hideView(...args); this.combo.hideView(...args);
this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); this.fireEvent(
TextValueCombo.EVENT_CHANGE,
...args
);
} }
if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_MULTI && BI.isEmptyArray(value)) { if (
o.chooseType === ButtonGroup.CHOOSE_TYPE_MULTI &&
isEmptyArray(value)
) {
this._clear(); this._clear();
} }
} },
}, { },
eventName: BI.Controller.EVENT_CHANGE, {
eventName: Controller.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
this.fireEvent(BI.Controller.EVENT_CHANGE, ...args); this.fireEvent(Controller.EVENT_CHANGE, ...args);
} },
}, { },
eventName: BI.TextValueComboPopup.EVENT_CLEAR, {
eventName: TextValueComboPopup.EVENT_CLEAR,
action: (...args) => { action: (...args) => {
changeTag = true; changeTag = true;
this._clear(); this._clear();
this.combo.hideView(); this.combo.hideView();
} },
}, { },
eventName: BI.TextValueComboPopup.EVENT_CONFIRM, {
eventName: TextValueComboPopup.EVENT_CONFIRM,
action: (...args) => { action: (...args) => {
this.combo.hideView(); this.combo.hideView();
} },
} }
] ],
}; };
return { return {
type: "bi.combo", type: Combo.xtype,
height: BI.toPix(o.height, 2), height: toPix(o.height, 2),
width: BI.toPix(o.width, 2), width: toPix(o.width, 2),
ref: ref => this.combo = ref, ref: ref => (this.combo = ref),
container: o.container, container: o.container,
direction: o.direction, direction: o.direction,
adjustLength: 2, adjustLength: 2,
el: trigger, el: trigger,
listeners: [ listeners: [
{ {
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => { action: () => {
changeTag = false; changeTag = false;
} },
}, { },
eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, {
eventName: Combo.EVENT_AFTER_HIDEVIEW,
action: (...args) => { action: (...args) => {
if (o.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_SINGLE && changeTag) { if (
this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); o.chooseType !== ButtonGroup.CHOOSE_TYPE_SINGLE &&
changeTag
) {
this.fireEvent(
TextValueCombo.EVENT_CHANGE,
...args
);
} }
} },
} }
], ],
popup: { popup: {
el: popup, el: popup,
value: o.value, value: o.value,
maxHeight: 240, maxHeight: 240,
minHeight: (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_MULTI && o.allowSelectAll) ? 55 : 25 minHeight:
} o.chooseType === ButtonGroup.CHOOSE_TYPE_MULTI &&
o.allowSelectAll
? 55
: 25,
},
}; };
}, }
mounted: function () { mounted() {
const o = this.options; const o = this.options;
if (BI.isKey(o.value) || BI.isObject(o.value)) { if (isKey(o.value) || isObject(o.value)) {
this._checkError(o.value); this._checkError(o.value);
} }
}, }
_clear: function () { _clear() {
this.trigger.setText(""); this.trigger.setText("");
this.combo.setValue(); this.combo.setValue();
this.setStatus("success"); this.setStatus("success");
}, }
_checkError: function (v) {
if (BI.isNull(v)) { _checkError(v) {
if (isNull(v)) {
this.setStatus("success"); this.setStatus("success");
return; return;
} }
var vals = BI.isArray(v) ? v : [v]; const vals = isArray(v) ? v : [v];
var result = BI.intersection(BI.map(this.options.items, "value"), vals); const result = intersection(map(this.options.items, "value"), vals);
if (result.length !== vals.length) { if (result.length !== vals.length) {
this.setStatus("error"); this.setStatus("error");
} else { } else {
this.setStatus("success"); this.setStatus("success");
} }
}, }
clear: function () { clear() {
this._clear(); this._clear();
}, }
setText: function (text) { setText(text) {
this.trigger.setText(text); this.trigger.setText(text);
}, }
setValue: function (v) { setValue(v) {
this.combo.setValue(v); this.combo.setValue(v);
this._checkError(v); this._checkError(v);
}, }
setStatus: function (status) { setStatus(status) {
this.element.removeClass(`bi-status-${this.options.status}`); this.element.removeClass(`bi-status-${this.options.status}`);
this.element.addClass(`bi-status-${status}`); this.element.addClass(`bi-status-${status}`);
this.options.status = status; this.options.status = status;
}, }
getValue: function () { getValue() {
var value = this.combo.getValue(); const value = this.combo.getValue();
return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
}, return isNull(value) ? [] : isArray(value) ? value : [value];
}
populate: function (items) { populate(items) {
this.options.items = items; this.options.items = items;
this.combo.populate(items); this.combo.populate(items);
} }
}); }
BI.TextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_value_combo", BI.TextValueCombo);

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

@ -1,32 +1,41 @@
/** import {
* @class BI.SmallTextValueCombo shortcut,
* @extend BI.Widget Widget,
* combo : text + icon, popup : text extend
* 参见场景dashboard布局方式选择 } from "@/core";
*/ import { ButtonGroup } from "@/base";
BI.SmallTextValueCombo = BI.inherit(BI.Widget, { import { SmallSelectTextTrigger } from "../../trigger";
_defaultConfig: function () { import { TextValueCombo } from "./combo.textvalue";
return BI.extend(BI.SmallTextValueCombo.superclass._defaultConfig.apply(this, arguments), {
@shortcut()
export class SmallTextValueCombo extends Widget {
static xtype = "bi.small_text_value_combo";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
width: 100, width: 100,
height: 20, height: 20,
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
el: {}, el: {},
text: "" text: "",
}); });
}, }
render: function () { render() {
var o = this.options; const o = this.options;
return { return {
type: "bi.text_value_combo", type: "bi.text_value_combo",
ref: (_ref) => { ref: _ref => {
this.combo = _ref; this.combo = _ref;
}, },
height: o.height, height: o.height,
chooseType: o.chooseType, chooseType: o.chooseType,
el: { el: {
type: "bi.small_select_text_trigger", type: SmallSelectTextTrigger.xtype,
...o.el ...o.el,
}, },
text: o.text, text: o.text,
value: o.value, value: o.value,
@ -34,26 +43,29 @@ BI.SmallTextValueCombo = BI.inherit(BI.Widget, {
allowClear: o.allowClear, allowClear: o.allowClear,
status: o.status, status: o.status,
title: o.title, title: o.title,
listeners: [{ listeners: [
eventName: BI.TextValueCombo.EVENT_CHANGE, {
action: (...args) => { eventName: TextValueCombo.EVENT_CHANGE,
this.fireEvent(BI.SmallTextValueCombo.EVENT_CHANGE, ...args); action: (...args) => {
this.fireEvent(
SmallTextValueCombo.EVENT_CHANGE,
...args
);
},
} }
}] ],
} };
}, }
setValue: function (v) { setValue(v) {
this.combo.setValue(v); this.combo.setValue(v);
}, }
getValue: function () { getValue() {
return this.combo.getValue(); return this.combo.getValue();
}, }
populate: function (items) { populate(items) {
this.combo.populate(items); this.combo.populate(items);
} }
}); }
BI.SmallTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo);

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

@ -1,190 +1,240 @@
BI.TextValueComboPopup = BI.inherit(BI.Pane, { import {
_defaultConfig: function () { shortcut,
return BI.extend(BI.TextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { extend,
Controller,
map,
Events,
VerticalAlign,
createItems,
i18nText,
VerticalLayout,
CenterLayout
} from "@/core";
import { ButtonGroup, Pane, TextButton } from "@/base";
import { SelectList } from "../../list/list.select";
import { ListPane } from "../../layer";
import { SingleSelectItem, MultiSelectItem } from "../../button";
@shortcut()
export class TextValueComboPopup extends Pane {
static xtype = "bi.text_value_combo_popup";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_CLEAR = "EVENT_CLEAR";
static EVENT_CONFIRM = "EVENT_CONFIRM";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-text-icon-popup", baseCls: "bi-text-icon-popup",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
allowSelectAll: true, allowSelectAll: true,
}); });
}, }
render() { render() {
var o = this.options, self = this; const o = this.options;
if (o.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { if (o.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI) {
return { return {
type: "bi.vertical", type: VerticalLayout.xtype,
vgap: 5, vgap: 5,
items: [ items: [
{ {
type: "bi.button_group", type: ButtonGroup.xtype,
ref: (_ref) => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
}, },
items: this._formatItems(o.items), items: this._formatItems(o.items),
chooseType: o.chooseType, chooseType: o.chooseType,
layouts: [ layouts: [
{ {
type: "bi.vertical" type: VerticalLayout.xtype,
} }
], ],
value: o.value, value: o.value,
listeners: [ listeners: [
{ {
eventName: BI.Controller.EVENT_CHANGE, eventName: Controller.EVENT_CHANGE,
action: function (type, val, obj) { action: (type, val, obj) => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(
if (type === BI.Events.CLICK) { Controller.EVENT_CHANGE,
self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); arguments
);
if (type === Events.CLICK) {
this.fireEvent(
TextValueComboPopup.EVENT_CHANGE,
val,
obj
);
} }
} },
} }
] ],
} }
] ],
}; };
} }
return { return {
type: "bi.vertical", type: VerticalLayout.xtype,
verticalAlign: BI.VerticalAlign.Stretch, verticalAlign: VerticalAlign.Stretch,
items: o.allowSelectAll ? [ items: o.allowSelectAll
{ ? [
type: "bi.select_list", {
logic: { type: SelectList.xtype,
dynamic: true, logic: {
innerVgap: 5, dynamic: true,
rowSize: ["", "fill"], innerVgap: 5,
verticalAlign: BI.VerticalAlign.Stretch rowSize: ["", "fill"],
}, verticalAlign: VerticalAlign.Stretch,
ref: (_ref) => { },
this.popup = _ref; ref: _ref => {
}, this.popup = _ref;
el: { },
el: { el: {
chooseType: o.chooseType, el: {
} chooseType: o.chooseType,
}, },
items: this._formatItems(o.items), },
value: { items: this._formatItems(o.items),
type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, value: {
value: o.value type: ButtonGroup.CHOOSE_TYPE_MULTI,
}, value: o.value,
height: "fill", },
listeners: [ height: "fill",
{ listeners: [
eventName: BI.SelectList.EVENT_CHANGE, {
action: function (val) { eventName: SelectList.EVENT_CHANGE,
self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); action (val) {
} this.fireEvent(
} TextValueComboPopup.EVENT_CHANGE,
] val
}, { );
type: "bi.center", },
cls: "list-view-toolbar bi-high-light bi-split-top",
height: 24,
items: BI.createItems([
{
type: "bi.text_button",
text: BI.i18nText("BI-Basic_Clears"),
handler: function () {
self.fireEvent(BI.TextValueComboPopup.EVENT_CLEAR);
}
}, {
type: "bi.text_button",
text: BI.i18nText("BI-Basic_OK"),
handler: function () {
self.fireEvent(BI.TextValueComboPopup.EVENT_CONFIRM);
} }
} ],
], {
once: false,
shadow: true,
isShadowShowingOnSelected: true
})
}
] : [
{
type: "bi.list_pane",
logic: {
dynamic: true,
innerVgap: 5,
rowSize: ["", "fill"],
verticalAlign: BI.VerticalAlign.Stretch
},
ref: (_ref) => {
this.popup = _ref;
},
el: {
chooseType: o.chooseType,
}, },
items: this._formatItems(o.items), {
value: o.value, type: CenterLayout.xtype,
height: "fill", cls: "list-view-toolbar bi-high-light bi-split-top",
listeners: [ height: 24,
{ items: createItems(
eventName: BI.ListPane.EVENT_CHANGE, [
action: function (val) { {
self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); type: TextButton.xtype,
text: i18nText("BI-Basic_Clears"),
handler: () => {
this.fireEvent(
TextValueComboPopup.EVENT_CLEAR
);
},
},
{
type: TextButton.xtype,
text: i18nText("BI-Basic_OK"),
handler: () => {
this.fireEvent(
TextValueComboPopup.EVENT_CONFIRM
);
},
}
],
{
once: false,
shadow: true,
isShadowShowingOnSelected: true,
}
),
}
]
: [
{
type: ListPane.xtype,
logic: {
dynamic: true,
innerVgap: 5,
rowSize: ["", "fill"],
verticalAlign: VerticalAlign.Stretch,
},
ref: _ref => {
this.popup = _ref;
},
el: {
chooseType: o.chooseType,
},
items: this._formatItems(o.items),
value: o.value,
height: "fill",
listeners: [
{
eventName: ListPane.EVENT_CHANGE,
action: val => {
this.fireEvent(
TextValueComboPopup.EVENT_CHANGE,
val
);
},
} }
} ],
] }
} ],
],
}; };
}, }
beforeMount: function () { beforeMount() {
if (this.options.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { if (this.options.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI) {
this.check(); this.check();
} }
}, }
_formatItems: function (items) { _formatItems(items) {
var o = this.options; const o = this.options;
return BI.map(items, function (i, item) {
return BI.extend({ return map(items, (i, item) => extend(
type: o.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI ? "bi.single_select_item" : "bi.multi_select_item", {
type:
o.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI
? SingleSelectItem.xtype
: MultiSelectItem.xtype,
iconWrapperWidth: 36, iconWrapperWidth: 36,
textAlign: o.textAlign, textAlign: o.textAlign,
title: item.title || item.text title: item.title || item.text,
}, item); },
}); item
}, ));
}
populate: function (items) { populate(items) {
BI.TextValueComboPopup.superclass.populate.apply(this, arguments); super.populate(...arguments);
this.popup.populate(this._formatItems(items)); this.popup.populate(this._formatItems(items));
}, }
getValue: function () { getValue() {
if (this.options.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { if (this.options.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI) {
return this.popup.getValue(); return this.popup.getValue();
} }
var val = this.popup.getValue(); const val = this.popup.getValue();
if (!this.options.allowSelectAll) { if (!this.options.allowSelectAll) {
return val; return val;
} }
if (val.type === BI.ButtonGroup.CHOOSE_TYPE_MULTI) { if (val.type === ButtonGroup.CHOOSE_TYPE_MULTI) {
return val.value; return val.value;
} else { } else {
return val.assist; return val.assist;
} }
}, }
setValue: function (v) { setValue(v) {
if (this.options.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { if (this.options.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI) {
return this.popup.setValue(v); return this.popup.setValue(v);
} }
if (!this.options.allowSelectAll) { if (!this.options.allowSelectAll) {
this.popup.setValue(v); this.popup.setValue(v);
return; return;
} }
this.popup.setValue({ this.popup.setValue({
type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, type: ButtonGroup.CHOOSE_TYPE_MULTI,
value: v value: v,
}); });
} }
}
});
BI.TextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.TextValueComboPopup.EVENT_CLEAR = "EVENT_CLEAR";
BI.TextValueComboPopup.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.text_value_combo_popup", BI.TextValueComboPopup);

3
src/case/index.js

@ -11,8 +11,10 @@ import { MultiSelectBar } from "./toolbar/toolbar.multiselect";
import * as layer from "./layer"; import * as layer from "./layer";
import * as linearSegment from "./linearsegment"; import * as linearSegment from "./linearsegment";
import { SelectList } from "./list/list.select"; import { SelectList } from "./list/list.select";
import * as combo from "./combo";
Object.assign(BI, { Object.assign(BI, {
...combo,
...button, ...button,
...calendarItem, ...calendarItem,
...pager, ...pager,
@ -28,6 +30,7 @@ Object.assign(BI, {
SelectList, SelectList,
}); });
export * from "./combo";
export * from "./button"; export * from "./button";
export * from "./calendar"; export * from "./calendar";
export * from "./pager"; export * from "./pager";

Loading…
Cancel
Save