Browse Source
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
20 changed files with 1361 additions and 1074 deletions
@ -1,133 +1,37 @@
|
||||
/** |
||||
* Created by GUY on 2017/2/8. |
||||
* |
||||
* @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 |
||||
}); |
||||
}, |
||||
import { shortcut, extend } from "@/core"; |
||||
import { PopupView, Label } from "@/base"; |
||||
|
||||
_createContent: function () { |
||||
return this.options.el; |
||||
}, |
||||
@shortcut() |
||||
export class BubblePopupView extends PopupView { |
||||
static xtype = "bi.text_bubble_bar_popup_view"; |
||||
|
||||
_createView: function () { |
||||
var o = this.options; |
||||
static EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON"; |
||||
static EVENT_CHANGE = "EVENT_CLICK_TOOLBAR_BUTTON"; |
||||
|
||||
var view = BI.createWidget({ |
||||
type: "bi.vertical", |
||||
items: [this._createContent()], |
||||
cls: "bar-popup-container", |
||||
hgap: o.innerHgap, |
||||
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", |
||||
_defaultConfig() { |
||||
const config = super._defaultConfig(...arguments); |
||||
|
||||
return extend(config, { |
||||
baseCls: `${config.baseCls} bi-text-bubble-bar-popup-view`, |
||||
text: "", |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_createContent: function () { |
||||
var self = this, o = this.options; |
||||
_createContent() { |
||||
const o = this.options; |
||||
|
||||
return { |
||||
type: "bi.label", |
||||
type: Label.xtype, |
||||
text: o.text, |
||||
whiteSpace: "normal", |
||||
textAlign: "left", |
||||
ref: function () { |
||||
self.text = this; |
||||
} |
||||
ref: _ref => { |
||||
this.text = _ref; |
||||
}, |
||||
}; |
||||
}, |
||||
} |
||||
|
||||
populate: function (v) { |
||||
populate(v) { |
||||
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); |
||||
} |
||||
|
@ -1,63 +1,74 @@
|
||||
/** |
||||
* Created by GUY on 2016/2/2. |
||||
* |
||||
* @class BI.IconComboPopup |
||||
* @extend BI.Pane |
||||
*/ |
||||
BI.IconComboPopup = BI.inherit(BI.Pane, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.IconComboPopup.superclass._defaultConfig.apply(this, arguments), { |
||||
import { |
||||
shortcut, |
||||
extend, |
||||
createWidget, |
||||
createItems, |
||||
Controller, |
||||
Events, |
||||
VerticalLayout |
||||
} 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", |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE |
||||
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||
}); |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.IconComboPopup.superclass._init.apply(this, arguments); |
||||
var o = this.options, self = this; |
||||
this.popup = BI.createWidget({ |
||||
type: "bi.button_group", |
||||
items: BI.createItems(o.items, { |
||||
type: "bi.single_select_icon_text_item", |
||||
} |
||||
|
||||
_init() { |
||||
super._init(...arguments); |
||||
const o = this.options; |
||||
this.popup = createWidget({ |
||||
type: ButtonGroup.xtype, |
||||
items: createItems(o.items, { |
||||
type: SingleSelectIconTextItem.xtype, |
||||
}), |
||||
chooseType: o.chooseType, |
||||
layouts: [{ |
||||
type: "bi.vertical" |
||||
}], |
||||
value: o.value |
||||
layouts: [ |
||||
{ |
||||
type: VerticalLayout.xtype, |
||||
} |
||||
], |
||||
value: o.value, |
||||
}); |
||||
|
||||
this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
if (type === BI.Events.CLICK) { |
||||
self.fireEvent(BI.IconComboPopup.EVENT_CHANGE, val, obj); |
||||
this.popup.on(Controller.EVENT_CHANGE, (...args) => { |
||||
const [type, val, obj] = args; |
||||
this.fireEvent(Controller.EVENT_CHANGE, ...args); |
||||
if (type === Events.CLICK) { |
||||
this.fireEvent(IconComboPopup.EVENT_CHANGE, val, obj); |
||||
} |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
type: "bi.vertical", |
||||
createWidget({ |
||||
type: VerticalLayout.xtype, |
||||
element: this, |
||||
vgap: 5, |
||||
items: [this.popup] |
||||
items: [this.popup], |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.IconComboPopup.superclass.populate.apply(this, arguments); |
||||
items = BI.createItems(items, { |
||||
type: "bi.single_select_icon_text_item", |
||||
populate(items) { |
||||
super.populate(...arguments); |
||||
items = createItems(items, { |
||||
type: SingleSelectIconTextItem.xtype, |
||||
}); |
||||
this.popup.populate(items); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.popup.getValue(); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.popup.setValue(v); |
||||
} |
||||
|
||||
}); |
||||
BI.IconComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.icon_combo_popup", BI.IconComboPopup); |
||||
} |
||||
|
@ -1,74 +1,88 @@
|
||||
/** |
||||
* Created by Windy on 2017/12/12. |
||||
*/ |
||||
BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.IconTextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { |
||||
import { |
||||
shortcut, |
||||
extend, |
||||
createWidget, |
||||
createItems, |
||||
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", |
||||
behaviors: { |
||||
redmark: function () { |
||||
redmark () { |
||||
return true; |
||||
} |
||||
} |
||||
}, |
||||
}, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.IconTextValueComboPopup.superclass._init.apply(this, arguments); |
||||
var o = this.options, self = this; |
||||
this.popup = BI.createWidget({ |
||||
type: "bi.button_group", |
||||
items: BI.createItems(o.items, { |
||||
type: "bi.single_select_icon_text_item", |
||||
_init() { |
||||
super._init(...arguments); |
||||
const o = this.options; |
||||
this.popup = createWidget({ |
||||
type: ButtonGroup.xtype, |
||||
items: createItems(o.items, { |
||||
type: SingleSelectIconTextItem.xtype, |
||||
iconHeight: o.iconHeight, |
||||
iconWidth: o.iconWidth, |
||||
iconWrapperWidth: o.iconWrapperWidth |
||||
iconWrapperWidth: o.iconWrapperWidth, |
||||
}), |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||
layouts: [{ |
||||
type: "bi.vertical" |
||||
}], |
||||
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||
layouts: [ |
||||
{ |
||||
type: VerticalLayout.xtype, |
||||
} |
||||
], |
||||
behaviors: o.behaviors, |
||||
value: o.value |
||||
value: o.value, |
||||
}); |
||||
|
||||
this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
if (type === BI.Events.CLICK) { |
||||
self.fireEvent(BI.IconTextValueComboPopup.EVENT_CHANGE, val, obj); |
||||
this.popup.on(Controller.EVENT_CHANGE, (...args) => { |
||||
const [type, val, obj] = args; |
||||
this.fireEvent(Controller.EVENT_CHANGE, ...args); |
||||
if (type === Events.CLICK) { |
||||
this.fireEvent(IconTextValueComboPopup.EVENT_CHANGE, val, obj); |
||||
} |
||||
}); |
||||
|
||||
this.check(); |
||||
|
||||
BI.createWidget({ |
||||
type: "bi.vertical", |
||||
createWidget({ |
||||
type: VerticalLayout.xtype, |
||||
element: this, |
||||
vgap: 5, |
||||
items: [this.popup] |
||||
items: [this.popup], |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
populate: function (items, keyword) { |
||||
BI.IconTextValueComboPopup.superclass.populate.apply(this, arguments); |
||||
var o = this.options; |
||||
items = BI.createItems(items, { |
||||
type: "bi.single_select_icon_text_item", |
||||
populate(items, keyword) { |
||||
super.populate(...arguments); |
||||
const o = this.options; |
||||
items = createItems(items, { |
||||
type: SingleSelectIconTextItem.xtype, |
||||
iconWrapperWidth: o.iconWrapperWidth, |
||||
iconHeight: o.iconHeight, |
||||
iconWidth: o.iconWidth, |
||||
}); |
||||
this.popup.populate(items, keyword); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.popup.getValue(); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.popup.setValue(v); |
||||
} |
||||
|
||||
}); |
||||
BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup); |
||||
} |
||||
|
@ -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"; |
@ -1,76 +1,100 @@
|
||||
/** |
||||
* Created by Windy on 2018/2/5. |
||||
*/ |
||||
BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, { |
||||
import { |
||||
shortcut, |
||||
Controller, |
||||
Events, |
||||
VerticalLayout, |
||||
map, |
||||
extend, |
||||
concat |
||||
} from "@/core"; |
||||
import { ButtonGroup, Pane } from "@/base"; |
||||
import { SingleSelectItem } from "../../button"; |
||||
|
||||
props: { |
||||
baseCls: "bi-search-text-value-popup" |
||||
}, |
||||
@shortcut() |
||||
export class SearchTextValueComboPopup extends Pane { |
||||
static xtype = "bi.search_text_value_combo_popup"; |
||||
|
||||
render: function () { |
||||
var self = this, o = this.options; |
||||
props = { baseCls: "bi-search-text-value-popup" }; |
||||
|
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
|
||||
render() { |
||||
const o = this.options; |
||||
|
||||
return { |
||||
type: "bi.vertical", |
||||
type: VerticalLayout.xtype, |
||||
vgap: 5, |
||||
items: [{ |
||||
type: "bi.button_group", |
||||
ref: function () { |
||||
self.popup = this; |
||||
}, |
||||
items: this._formatItems(o.items), |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||
layouts: [{ |
||||
type: "bi.vertical" |
||||
}], |
||||
behaviors: { |
||||
redmark: function () { |
||||
return true; |
||||
} |
||||
}, |
||||
value: o.value, |
||||
listeners: [{ |
||||
eventName: BI.Controller.EVENT_CHANGE, |
||||
action: function (type, val, obj) { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
if (type === BI.Events.CLICK) { |
||||
self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj); |
||||
items: [ |
||||
{ |
||||
type: ButtonGroup.xtype, |
||||
ref: _ref => { |
||||
this.popup = _ref; |
||||
}, |
||||
items: this._formatItems(o.items), |
||||
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||
layouts: [ |
||||
{ |
||||
type: VerticalLayout.xtype, |
||||
} |
||||
], |
||||
behaviors: { |
||||
redmark () { |
||||
return true; |
||||
}, |
||||
}, |
||||
value: o.value, |
||||
listeners: [ |
||||
{ |
||||
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) { |
||||
var o = this.options; |
||||
return BI.map(items, function (i, item) { |
||||
return BI.extend({ |
||||
type: "bi.single_select_item", |
||||
_formatItems(items) { |
||||
const o = this.options; |
||||
|
||||
return map(items, (i, item) => extend( |
||||
{ |
||||
type: SingleSelectItem.xtype, |
||||
textAlign: o.textAlign, |
||||
title: item.title || item.text |
||||
}, item); |
||||
}); |
||||
}, |
||||
title: item.title || item.text, |
||||
}, |
||||
item |
||||
)); |
||||
} |
||||
|
||||
// mounted之后做check
|
||||
mounted: function() { |
||||
mounted() { |
||||
this.check(); |
||||
}, |
||||
} |
||||
|
||||
populate: function (find, match, keyword) { |
||||
var items = BI.concat(find, match); |
||||
BI.SearchTextValueComboPopup.superclass.populate.apply(this, items); |
||||
populate(find, match, keyword) { |
||||
const items = concat(find, match); |
||||
super.populate.apply(this, items); |
||||
this.popup.populate(this._formatItems(items), keyword); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.popup.getValue(); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.popup.setValue(v); |
||||
} |
||||
|
||||
}); |
||||
BI.SearchTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.search_text_value_combo_popup", BI.SearchTextValueComboPopup); |
||||
} |
||||
|
@ -1,92 +1,113 @@
|
||||
/** |
||||
* @class BI.TextValueCheckCombo |
||||
* @extend BI.Widget |
||||
* combo : text + icon, popup : check + text |
||||
*/ |
||||
BI.TextValueCheckCombo = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function (config) { |
||||
return BI.extend(BI.TextValueCheckCombo.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-text-value-check-combo " + (config.simple ? "bi-border-bottom" : "bi-border"), |
||||
import { |
||||
shortcut, |
||||
Widget, |
||||
extend, |
||||
isFunction, |
||||
createWidget, |
||||
toPix, |
||||
Controller, |
||||
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, |
||||
height: 24, |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||
value: "", |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_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.TextValueCheckCombo.superclass._init.apply(this, arguments); |
||||
this.trigger = BI.createWidget({ |
||||
type: "bi.select_text_trigger", |
||||
_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); |
||||
this.trigger = createWidget({ |
||||
type: SelectTextTrigger.xtype, |
||||
cls: "text-value-trigger", |
||||
items: o.items, |
||||
height: BI.toPix(o.height, 2), |
||||
height: toPix(o.height, 2), |
||||
text: o.text, |
||||
value: o.value |
||||
value: o.value, |
||||
}); |
||||
this.popup = BI.createWidget({ |
||||
type: "bi.text_value_check_combo_popup", |
||||
this.popup = createWidget({ |
||||
type: TextValueCheckComboPopup.xtype, |
||||
chooseType: o.chooseType, |
||||
items: o.items, |
||||
value: o.value |
||||
value: o.value, |
||||
}); |
||||
this.popup.on(BI.TextValueCheckComboPopup.EVENT_CHANGE, function () { |
||||
self.setValue(self.popup.getValue()); |
||||
self.textIconCheckCombo.hideView(); |
||||
self.fireEvent(BI.TextValueCheckCombo.EVENT_CHANGE); |
||||
this.popup.on(TextValueCheckComboPopup.EVENT_CHANGE, () => { |
||||
this.setValue(this.popup.getValue()); |
||||
this.textIconCheckCombo.hideView(); |
||||
this.fireEvent(TextValueCheckCombo.EVENT_CHANGE); |
||||
}); |
||||
this.popup.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
this.popup.on(Controller.EVENT_CHANGE, ...args => { |
||||
this.fireEvent(Controller.EVENT_CHANGE, ...args); |
||||
}); |
||||
this.textIconCheckCombo = BI.createWidget({ |
||||
type: "bi.combo", |
||||
this.textIconCheckCombo = createWidget({ |
||||
type: Combo.xtype, |
||||
container: o.container, |
||||
direction: o.direction, |
||||
element: this, |
||||
width: BI.toPix(o.width, 2), |
||||
height: BI.toPix(o.height, 2), |
||||
width: toPix(o.width, 2), |
||||
height: toPix(o.height, 2), |
||||
adjustLength: 2, |
||||
el: this.trigger, |
||||
popup: { |
||||
el: this.popup, |
||||
maxHeight: 300 |
||||
} |
||||
maxHeight: 300, |
||||
}, |
||||
}); |
||||
|
||||
if (BI.isKey(o.value)) { |
||||
if (isKey(o.value)) { |
||||
this.setValue(o.value); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setTitle: function (title) { |
||||
setTitle(title) { |
||||
this.trigger.setTitle(title); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.trigger.setValue(v); |
||||
this.popup.setValue(v); |
||||
}, |
||||
} |
||||
|
||||
setWarningTitle: function (title) { |
||||
setWarningTitle(title) { |
||||
this.trigger.setWarningTitle(title); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
var value = this.popup.getValue(); |
||||
return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); |
||||
}, |
||||
getValue() { |
||||
const value = this.popup.getValue(); |
||||
|
||||
return isNull(value) ? [] : isArray(value) ? value : [value]; |
||||
} |
||||
|
||||
populate: function (items) { |
||||
populate(items) { |
||||
this.options.items = items; |
||||
this.textIconCheckCombo.populate(items); |
||||
} |
||||
}); |
||||
BI.TextValueCheckCombo.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.text_value_check_combo", BI.TextValueCheckCombo); |
||||
} |
||||
|
@ -1,64 +1,83 @@
|
||||
BI.TextValueCheckComboPopup = BI.inherit(BI.Pane, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.TextValueCheckComboPopup.superclass._defaultConfig.apply(this, arguments), { |
||||
import { |
||||
shortcut, |
||||
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", |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE |
||||
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.TextValueCheckComboPopup.superclass._init.apply(this, arguments); |
||||
var o = this.options, self = this; |
||||
this.popup = BI.createWidget({ |
||||
type: "bi.button_group", |
||||
_init() { |
||||
super._init(...arguments); |
||||
const o = this.options; |
||||
this.popup = createWidget({ |
||||
type: ButtonGroup.xtype, |
||||
items: this._formatItems(o.items), |
||||
chooseType: o.chooseType, |
||||
layouts: [{ |
||||
type: "bi.vertical" |
||||
}], |
||||
value: o.value |
||||
layouts: [ |
||||
{ |
||||
type: VerticalLayout.xtype, |
||||
} |
||||
], |
||||
value: o.value, |
||||
}); |
||||
|
||||
this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
if (type === BI.Events.CLICK) { |
||||
self.fireEvent(BI.TextValueCheckComboPopup.EVENT_CHANGE, val, obj); |
||||
this.popup.on(Controller.EVENT_CHANGE, (...args) => { |
||||
const [type, val, obj] = args; |
||||
this.fireEvent(Controller.EVENT_CHANGE, ...args); |
||||
if (type === Events.CLICK) { |
||||
this.fireEvent(TextValueCheckComboPopup.EVENT_CHANGE, val, obj); |
||||
} |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
type: "bi.vertical", |
||||
createWidget({ |
||||
type: VerticalLayout.xtype, |
||||
element: this, |
||||
vgap: 5, |
||||
items: [this.popup] |
||||
items: [this.popup], |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_formatItems: function (items) { |
||||
var o = this.options; |
||||
return BI.map(items, function (i, item) { |
||||
return BI.extend({ |
||||
type: "bi.single_select_item", |
||||
_formatItems(items) { |
||||
const o = this.options; |
||||
|
||||
return map(items, (i, item) => extend( |
||||
{ |
||||
type: SingleSelectItem.xtype, |
||||
cls: "bi-list-item", |
||||
textAlign: o.textAlign, |
||||
title: item.title || item.text |
||||
}, item); |
||||
}); |
||||
}, |
||||
title: item.title || item.text, |
||||
}, |
||||
item |
||||
)); |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.TextValueCheckComboPopup.superclass.populate.apply(this, arguments); |
||||
populate(items) { |
||||
super.populate(...arguments); |
||||
this.popup.populate(this._formatItems(items)); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.popup.getValue(); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.popup.setValue(v); |
||||
} |
||||
|
||||
}); |
||||
BI.TextValueCheckComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.text_value_check_combo_popup", BI.TextValueCheckComboPopup); |
||||
} |
||||
|
@ -1,190 +1,240 @@
|
||||
BI.TextValueComboPopup = BI.inherit(BI.Pane, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.TextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { |
||||
import { |
||||
shortcut, |
||||
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", |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||
allowSelectAll: true, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
render() { |
||||
var o = this.options, self = this; |
||||
if (o.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { |
||||
const o = this.options; |
||||
if (o.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI) { |
||||
return { |
||||
type: "bi.vertical", |
||||
type: VerticalLayout.xtype, |
||||
vgap: 5, |
||||
items: [ |
||||
{ |
||||
type: "bi.button_group", |
||||
ref: (_ref) => { |
||||
type: ButtonGroup.xtype, |
||||
ref: _ref => { |
||||
this.popup = _ref; |
||||
}, |
||||
items: this._formatItems(o.items), |
||||
chooseType: o.chooseType, |
||||
layouts: [ |
||||
{ |
||||
type: "bi.vertical" |
||||
type: VerticalLayout.xtype, |
||||
} |
||||
], |
||||
value: o.value, |
||||
listeners: [ |
||||
{ |
||||
eventName: BI.Controller.EVENT_CHANGE, |
||||
action: function (type, val, obj) { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
if (type === BI.Events.CLICK) { |
||||
self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); |
||||
eventName: Controller.EVENT_CHANGE, |
||||
action: (type, val, obj) => { |
||||
this.fireEvent( |
||||
Controller.EVENT_CHANGE, |
||||
arguments |
||||
); |
||||
if (type === Events.CLICK) { |
||||
this.fireEvent( |
||||
TextValueComboPopup.EVENT_CHANGE, |
||||
val, |
||||
obj |
||||
); |
||||
} |
||||
} |
||||
}, |
||||
} |
||||
] |
||||
], |
||||
} |
||||
] |
||||
], |
||||
}; |
||||
} |
||||
|
||||
return { |
||||
type: "bi.vertical", |
||||
verticalAlign: BI.VerticalAlign.Stretch, |
||||
items: o.allowSelectAll ? [ |
||||
{ |
||||
type: "bi.select_list", |
||||
logic: { |
||||
dynamic: true, |
||||
innerVgap: 5, |
||||
rowSize: ["", "fill"], |
||||
verticalAlign: BI.VerticalAlign.Stretch |
||||
}, |
||||
ref: (_ref) => { |
||||
this.popup = _ref; |
||||
}, |
||||
el: { |
||||
type: VerticalLayout.xtype, |
||||
verticalAlign: VerticalAlign.Stretch, |
||||
items: o.allowSelectAll |
||||
? [ |
||||
{ |
||||
type: SelectList.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: { |
||||
type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
value: o.value |
||||
}, |
||||
height: "fill", |
||||
listeners: [ |
||||
{ |
||||
eventName: BI.SelectList.EVENT_CHANGE, |
||||
action: function (val) { |
||||
self.fireEvent(BI.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); |
||||
el: { |
||||
chooseType: o.chooseType, |
||||
}, |
||||
}, |
||||
items: this._formatItems(o.items), |
||||
value: { |
||||
type: ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
value: o.value, |
||||
}, |
||||
height: "fill", |
||||
listeners: [ |
||||
{ |
||||
eventName: SelectList.EVENT_CHANGE, |
||||
action (val) { |
||||
this.fireEvent( |
||||
TextValueComboPopup.EVENT_CHANGE, |
||||
val |
||||
); |
||||
}, |
||||
} |
||||
} |
||||
], { |
||||
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, |
||||
height: "fill", |
||||
listeners: [ |
||||
{ |
||||
eventName: BI.ListPane.EVENT_CHANGE, |
||||
action: function (val) { |
||||
self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); |
||||
{ |
||||
type: CenterLayout.xtype, |
||||
cls: "list-view-toolbar bi-high-light bi-split-top", |
||||
height: 24, |
||||
items: createItems( |
||||
[ |
||||
{ |
||||
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 () { |
||||
if (this.options.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { |
||||
beforeMount() { |
||||
if (this.options.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI) { |
||||
this.check(); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
_formatItems: function (items) { |
||||
var o = this.options; |
||||
return BI.map(items, function (i, item) { |
||||
return BI.extend({ |
||||
type: o.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI ? "bi.single_select_item" : "bi.multi_select_item", |
||||
_formatItems(items) { |
||||
const o = this.options; |
||||
|
||||
return map(items, (i, item) => extend( |
||||
{ |
||||
type: |
||||
o.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI |
||||
? SingleSelectItem.xtype |
||||
: MultiSelectItem.xtype, |
||||
iconWrapperWidth: 36, |
||||
textAlign: o.textAlign, |
||||
title: item.title || item.text |
||||
}, item); |
||||
}); |
||||
}, |
||||
title: item.title || item.text, |
||||
}, |
||||
item |
||||
)); |
||||
} |
||||
|
||||
populate: function (items) { |
||||
BI.TextValueComboPopup.superclass.populate.apply(this, arguments); |
||||
populate(items) { |
||||
super.populate(...arguments); |
||||
this.popup.populate(this._formatItems(items)); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
if (this.options.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { |
||||
getValue() { |
||||
if (this.options.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI) { |
||||
return this.popup.getValue(); |
||||
} |
||||
var val = this.popup.getValue(); |
||||
const val = this.popup.getValue(); |
||||
if (!this.options.allowSelectAll) { |
||||
return val; |
||||
} |
||||
if (val.type === BI.ButtonGroup.CHOOSE_TYPE_MULTI) { |
||||
if (val.type === ButtonGroup.CHOOSE_TYPE_MULTI) { |
||||
return val.value; |
||||
} else { |
||||
return val.assist; |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
if (this.options.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { |
||||
setValue(v) { |
||||
if (this.options.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI) { |
||||
return this.popup.setValue(v); |
||||
} |
||||
if (!this.options.allowSelectAll) { |
||||
this.popup.setValue(v); |
||||
|
||||
return; |
||||
} |
||||
this.popup.setValue({ |
||||
type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
value: v |
||||
type: ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
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); |
||||
} |
||||
|
Loading…
Reference in new issue