Zhenfei.Li
2 years ago
20 changed files with 1361 additions and 1074 deletions
@ -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 = []; |
@shortcut() |
||||||
BI.each(o.buttons, function (i, buttonOpt) { |
export class BubblePopupView extends PopupView { |
||||||
if (BI.isWidget(buttonOpt)) { |
static xtype = "bi.text_bubble_bar_popup_view"; |
||||||
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 () { |
static EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON"; |
||||||
return this.options.el; |
static EVENT_CHANGE = "EVENT_CLICK_TOOLBAR_BUTTON"; |
||||||
}, |
|
||||||
|
|
||||||
_createView: function () { |
_defaultConfig() { |
||||||
var o = this.options; |
const config = super._defaultConfig(...arguments); |
||||||
|
|
||||||
var view = BI.createWidget({ |
return extend(config, { |
||||||
type: "bi.vertical", |
baseCls: `${config.baseCls} bi-text-bubble-bar-popup-view`, |
||||||
items: [this._createContent()], |
text: "", |
||||||
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); |
|
||||||
|
|
||||||
/** |
_createContent() { |
||||||
* Created by Windy on 2018/2/2. |
const o = this.options; |
||||||
* |
|
||||||
* @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: "", |
|
||||||
}); |
|
||||||
}, |
|
||||||
|
|
||||||
_createContent: function () { |
|
||||||
var self = this, 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); |
|
||||||
|
@ -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); |
|
||||||
|
@ -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); |
|
||||||
|
@ -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 @@ |
|||||||
/** |
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"; |
||||||
|
|
||||||
|
props = { baseCls: "bi-search-text-value-popup" }; |
||||||
|
|
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
|
||||||
|
render() { |
||||||
|
const o = this.options; |
||||||
|
|
||||||
render: function () { |
|
||||||
var self = this, 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), |
items: this._formatItems(o.items), |
||||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, |
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||||
layouts: [{ |
layouts: [ |
||||||
type: "bi.vertical" |
{ |
||||||
}], |
type: VerticalLayout.xtype, |
||||||
|
} |
||||||
|
], |
||||||
behaviors: { |
behaviors: { |
||||||
redmark: function () { |
redmark () { |
||||||
return true; |
return true; |
||||||
} |
}, |
||||||
}, |
}, |
||||||
value: o.value, |
value: o.value, |
||||||
listeners: [{ |
listeners: [ |
||||||
eventName: BI.Controller.EVENT_CHANGE, |
{ |
||||||
action: function (type, val, obj) { |
eventName: Controller.EVENT_CHANGE, |
||||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
action: (...args) => { |
||||||
if (type === BI.Events.CLICK) { |
const [type, val, obj] = args; |
||||||
self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj); |
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); |
|
||||||
|
@ -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); |
|
||||||
|
@ -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(items) { |
||||||
|
const o = this.options; |
||||||
|
|
||||||
_formatItems: function (items) { |
return map(items, (i, item) => extend( |
||||||
var o = this.options; |
{ |
||||||
return BI.map(items, function (i, item) { |
type: SingleSelectItem.xtype, |
||||||
return BI.extend({ |
|
||||||
type: "bi.single_select_item", |
|
||||||
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); |
|
||||||
|
Loading…
Reference in new issue