forked from fanruan/fineui
Browse Source
Merge in VISUAL/fineui from ~DAILER/fineui:es6 to es6 * commit '2bfd07879c342edab49b6a714a5972eb15a5c9de': KERNEL-14086 feat: widget/singletree、selecttreees6
Dailer-刘荣歆
2 years ago
32 changed files with 3098 additions and 2457 deletions
@ -1,113 +1,121 @@
|
||||
/** |
||||
* |
||||
* @class BI.MultiSelectCheckPane |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.MultiSelectCheckPane = BI.inherit(BI.Widget, { |
||||
import { |
||||
shortcut, |
||||
Widget, |
||||
extend, |
||||
emptyFn, |
||||
createWidget, |
||||
map, |
||||
i18nText, |
||||
VerticalAdaptLayout, VTapeLayout |
||||
} from "@/core"; |
||||
import { TextButton, Label } from "@/base"; |
||||
import { DisplaySelectedList } from "./multiselect.display"; |
||||
|
||||
constants: { |
||||
height: 12, |
||||
lgap: 10, |
||||
tgap: 10, |
||||
bgap: 5 |
||||
}, |
||||
@shortcut() |
||||
export class MultiSelectCheckPane extends Widget { |
||||
static xtype = "bi.multi_select_check_pane"; |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.MultiSelectCheckPane.superclass._defaultConfig.apply(this, arguments), { |
||||
constants = { height: 12, lgap: 10, tgap: 10, bgap: 5 }; |
||||
|
||||
_defaultConfig() { |
||||
return extend(super._defaultConfig(...arguments), { |
||||
baseCls: "bi-multi-select-check-pane bi-background", |
||||
items: [], |
||||
itemsCreator: BI.emptyFn, |
||||
valueFormatter: BI.emptyFn, |
||||
onClickContinueSelect: BI.emptyFn |
||||
itemsCreator: emptyFn, |
||||
valueFormatter: emptyFn, |
||||
onClickContinueSelect: emptyFn, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.MultiSelectCheckPane.superclass._init.apply(this, arguments); |
||||
_init() { |
||||
super._init(...arguments); |
||||
|
||||
var self = this, opts = this.options; |
||||
const self = this, |
||||
opts = this.options; |
||||
|
||||
this.storeValue = opts.value || {}; |
||||
this.display = BI.createWidget({ |
||||
type: "bi.display_selected_list", |
||||
this.display = createWidget({ |
||||
type: DisplaySelectedList.xtype, |
||||
items: opts.items, |
||||
itemsCreator: function (op, callback) { |
||||
op = BI.extend(op || {}, { |
||||
selectedValues: self.storeValue.value |
||||
itemsCreator(op, callback) { |
||||
op = extend(op || {}, { |
||||
selectedValues: self.storeValue.value, |
||||
}); |
||||
if (self.storeValue.type === BI.Selection.Multi) { |
||||
callback({ |
||||
items: BI.map(self.storeValue.value, function (i, v) { |
||||
var txt = opts.valueFormatter(v) || v; |
||||
items: map(self.storeValue.value, (i, v) => { |
||||
const txt = opts.valueFormatter(v) || v; |
||||
|
||||
return { |
||||
text: txt, |
||||
value: v, |
||||
title: txt |
||||
title: txt, |
||||
}; |
||||
}) |
||||
}), |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
opts.itemsCreator(op, callback); |
||||
} |
||||
}, |
||||
}); |
||||
|
||||
this.continueSelect = BI.createWidget({ |
||||
type: "bi.text_button", |
||||
title: BI.i18nText("BI-Continue_Select"), |
||||
text: BI.i18nText("BI-Continue_Select"), |
||||
cls: "multi-select-check-selected bi-high-light" |
||||
this.continueSelect = createWidget({ |
||||
type: TextButton.xtype, |
||||
title: i18nText("BI-Continue_Select"), |
||||
text: i18nText("BI-Continue_Select"), |
||||
cls: "multi-select-check-selected bi-high-light", |
||||
}); |
||||
|
||||
this.continueSelect.on(BI.TextButton.EVENT_CHANGE, function () { |
||||
this.continueSelect.on(TextButton.EVENT_CHANGE, () => { |
||||
opts.onClickContinueSelect(); |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
type: "bi.vtape", |
||||
createWidget({ |
||||
type: VTapeLayout.xtype, |
||||
element: this, |
||||
items: [{ |
||||
height: this.constants.height, |
||||
el: { |
||||
type: "bi.vertical_adapt", |
||||
columnSize: ["auto", "auto"], |
||||
cls: "multi-select-continue-select", |
||||
items: [ |
||||
{ |
||||
el: { |
||||
type: "bi.label", |
||||
title: BI.i18nText("BI-Selected_Data"), |
||||
text: BI.i18nText("BI-Selected_Data") |
||||
items: [ |
||||
{ |
||||
height: this.constants.height, |
||||
el: { |
||||
type: VerticalAdaptLayout.xtype, |
||||
columnSize: ["auto", "auto"], |
||||
cls: "multi-select-continue-select", |
||||
items: [ |
||||
{ |
||||
el: { |
||||
type: Label.xtype, |
||||
title: i18nText("BI-Selected_Data"), |
||||
text: i18nText("BI-Selected_Data"), |
||||
}, |
||||
lgap: this.constants.lgap, |
||||
}, |
||||
lgap: this.constants.lgap |
||||
}, |
||||
{ |
||||
el: this.continueSelect, |
||||
hgap: this.constants.lgap |
||||
}] |
||||
{ |
||||
el: this.continueSelect, |
||||
hgap: this.constants.lgap, |
||||
} |
||||
], |
||||
}, |
||||
tgap: this.constants.tgap, |
||||
}, |
||||
tgap: this.constants.tgap |
||||
}, { |
||||
height: "fill", |
||||
el: this.display, |
||||
tgap: this.constants.bgap |
||||
}] |
||||
{ |
||||
height: "fill", |
||||
el: this.display, |
||||
tgap: this.constants.bgap, |
||||
} |
||||
], |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.storeValue = v || {}; |
||||
}, |
||||
} |
||||
|
||||
empty: function () { |
||||
empty() { |
||||
this.display.empty(); |
||||
}, |
||||
|
||||
populate: function () { |
||||
this.display.populate.apply(this.display, arguments); |
||||
} |
||||
}); |
||||
|
||||
BI.shortcut("bi.multi_select_check_pane", BI.MultiSelectCheckPane); |
||||
populate() { |
||||
this.display.populate(...arguments); |
||||
} |
||||
} |
||||
|
@ -1,106 +1,112 @@
|
||||
/** |
||||
* |
||||
* |
||||
* 查看已选弹出层的展示面板 |
||||
* @class BI.DisplaySelectedList |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.DisplaySelectedList = BI.inherit(BI.Pane, { |
||||
import { |
||||
shortcut, |
||||
extend, |
||||
emptyFn, |
||||
createWidget, |
||||
VerticalLayout, |
||||
createItems |
||||
} from "@/core"; |
||||
import { Pane, ButtonGroup, Loader, IconTextItem } from "@/base"; |
||||
import { ListPane } from "@/case"; |
||||
|
||||
constants: { |
||||
height: 24, |
||||
lgap: 10 |
||||
}, |
||||
@shortcut() |
||||
export class DisplaySelectedList extends Pane { |
||||
static xtype = "bi.display_selected_list"; |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), { |
||||
constants = { height: 24, lgap: 10 }; |
||||
|
||||
_defaultConfig() { |
||||
return extend(super._defaultConfig(...arguments), { |
||||
baseCls: "bi-display-list", |
||||
itemsCreator: BI.emptyFn, |
||||
items: [] |
||||
itemsCreator: emptyFn, |
||||
items: [], |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.DisplaySelectedList.superclass._init.apply(this, arguments); |
||||
_init() { |
||||
super._init(...arguments); |
||||
|
||||
var self = this, opts = this.options; |
||||
const self = this, |
||||
opts = this.options; |
||||
|
||||
this.hasNext = false; |
||||
var cacheItems = []; |
||||
let cacheItems = []; |
||||
|
||||
this.button_group = BI.createWidget({ |
||||
type: "bi.list_pane", |
||||
this.button_group = createWidget({ |
||||
type: ListPane.xtype, |
||||
element: this, |
||||
el: { |
||||
type: "bi.loader", |
||||
type: Loader.xtype, |
||||
isDefaultInit: false, |
||||
logic: { |
||||
dynamic: true, |
||||
scrolly: true |
||||
scrolly: true, |
||||
}, |
||||
items: this._createItems(opts.items), |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
chooseType: ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
layouts: [ |
||||
{ |
||||
type: "bi.vertical", |
||||
lgap: 10 |
||||
type: VerticalLayout.xtype, |
||||
lgap: 10, |
||||
} |
||||
] |
||||
], |
||||
}, |
||||
itemsCreator: function (options, callback) { |
||||
itemsCreator (options, callback) { |
||||
if (options.times === 1) { |
||||
cacheItems = []; |
||||
} |
||||
|
||||
if (cacheItems.length > 0) { |
||||
var renderedItems = cacheItems.slice(0, 100); |
||||
const renderedItems = cacheItems.slice(0, 100); |
||||
cacheItems = cacheItems.slice(100); |
||||
self.hasNext = cacheItems.length > 0; |
||||
callback(self._createItems(renderedItems)); |
||||
|
||||
return; |
||||
} |
||||
|
||||
opts.itemsCreator(options, function (ob) { |
||||
opts.itemsCreator(options, ob => { |
||||
self.hasNext = !!ob.hasNext; |
||||
var firstItemsCount = 100 + ob.items.length % 100; |
||||
const firstItemsCount = 100 + (ob.items.length % 100); |
||||
if (ob.items.length > 100) { |
||||
cacheItems = ob.items.slice(firstItemsCount); |
||||
self.hasNext = (firstItemsCount === ob.items.length) ? false : true; |
||||
self.hasNext = |
||||
firstItemsCount !== ob.items.length; |
||||
} |
||||
callback(self._createItems(ob.items.slice(0, firstItemsCount))); |
||||
callback( |
||||
self._createItems(ob.items.slice(0, firstItemsCount)) |
||||
); |
||||
}); |
||||
}, |
||||
hasNext: function () { |
||||
hasNext () { |
||||
return self.hasNext; |
||||
} |
||||
}, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_createItems: function (items) { |
||||
return BI.createItems(items, { |
||||
type: "bi.icon_text_item", |
||||
_createItems(items) { |
||||
return createItems(items, { |
||||
type: IconTextItem.xtype, |
||||
cls: "cursor-default check-font icon-size-12 display-list-item bi-tips", |
||||
once: true, |
||||
invalid: true, |
||||
selected: true, |
||||
height: this.constants.height, |
||||
logic: { |
||||
dynamic: true |
||||
} |
||||
dynamic: true, |
||||
}, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
empty: function () { |
||||
empty() { |
||||
this.button_group.empty(); |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
populate(items) { |
||||
if (arguments.length === 0) { |
||||
this.button_group.populate(); |
||||
} else { |
||||
this.button_group.populate(this._createItems(items)); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
BI.shortcut("bi.display_selected_list", BI.DisplaySelectedList); |
||||
} |
||||
|
@ -1,185 +1,242 @@
|
||||
/** |
||||
* 多选加载数据面板 |
||||
* Created by guy on 15/11/2. |
||||
* @class BI.MultiSelectNoBarLoader |
||||
* @extends Widget |
||||
*/ |
||||
BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.MultiSelectNoBarLoader.superclass._defaultConfig.apply(this, arguments), { |
||||
import { |
||||
shortcut, |
||||
Widget, |
||||
extend, |
||||
emptyFn, |
||||
createWidget, |
||||
isKey, |
||||
map, |
||||
contains, |
||||
remove, |
||||
Controller, |
||||
VerticalLayout, |
||||
delay, |
||||
isNotNull, |
||||
toPix, |
||||
Selection, |
||||
pushDistinct |
||||
} from "@/core"; |
||||
import { ButtonGroup, Loader } from "@/base"; |
||||
import { SelectList, ListPane, MultiSelectItem } from "@/case"; |
||||
|
||||
@shortcut() |
||||
export class MultiSelectNoBarLoader extends Widget { |
||||
static xtype = "bi.multi_select_no_bar_loader"; |
||||
|
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
|
||||
_defaultConfig() { |
||||
return extend(super._defaultConfig(...arguments), { |
||||
baseCls: "bi-multi-select-loader", |
||||
logic: { |
||||
dynamic: true |
||||
dynamic: true, |
||||
}, |
||||
el: { |
||||
height: 400 |
||||
height: 400, |
||||
}, |
||||
valueFormatter: BI.emptyFn, |
||||
itemsCreator: BI.emptyFn, |
||||
valueFormatter: emptyFn, |
||||
itemsCreator: emptyFn, |
||||
itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
||||
onLoaded: BI.emptyFn, |
||||
itemFormatter: BI.emptyFn, |
||||
onLoaded: emptyFn, |
||||
itemFormatter: emptyFn, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.MultiSelectNoBarLoader.superclass._init.apply(this, arguments); |
||||
_init() { |
||||
super._init(...arguments); |
||||
|
||||
var self = this, opts = this.options; |
||||
var hasNext = false; |
||||
const self = this, |
||||
opts = this.options; |
||||
let hasNext = false; |
||||
|
||||
this.storeValue = opts.value || {}; |
||||
this._assertValue(this.storeValue); |
||||
|
||||
this.button_group = BI.createWidget(BI.extend({ |
||||
type: "bi.list_pane", |
||||
onLoaded: opts.onLoaded, |
||||
el: { |
||||
type: "bi.loader", |
||||
isDefaultInit: false, |
||||
logic: { |
||||
dynamic: true, |
||||
scrolly: true |
||||
}, |
||||
el: { |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
behaviors: { |
||||
redmark: function () { |
||||
return true; |
||||
} |
||||
this.button_group = createWidget( |
||||
extend( |
||||
{ |
||||
type: ListPane.xtype, |
||||
onLoaded: opts.onLoaded, |
||||
el: { |
||||
type: Loader.xtype, |
||||
isDefaultInit: false, |
||||
logic: { |
||||
dynamic: true, |
||||
scrolly: true, |
||||
}, |
||||
el: { |
||||
chooseType: ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
behaviors: { |
||||
redmark() { |
||||
return true; |
||||
}, |
||||
}, |
||||
layouts: [ |
||||
{ |
||||
type: VerticalLayout.xtype, |
||||
} |
||||
], |
||||
}, |
||||
}, |
||||
layouts: [{ |
||||
type: "bi.vertical" |
||||
}] |
||||
} |
||||
}, |
||||
itemsCreator: function (op, callback) { |
||||
var startValue = self._startValue; |
||||
self.storeValue && (op = BI.extend(op || {}, { |
||||
selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi |
||||
? self.storeValue.value.concat(startValue) : self.storeValue.value |
||||
})); |
||||
opts.itemsCreator(op, function (ob) { |
||||
hasNext = ob.hasNext; |
||||
var firstItems = []; |
||||
if (op.times === 1 && self.storeValue) { |
||||
var json = BI.map(self.storeValue.value, function (i, v) { |
||||
var txt = opts.valueFormatter(v) || v; |
||||
return { |
||||
text: txt, |
||||
value: v, |
||||
title: txt, |
||||
selected: self.storeValue.type === BI.Selection.Multi |
||||
}; |
||||
itemsCreator(op, callback) { |
||||
const startValue = self._startValue; |
||||
self.storeValue && |
||||
(op = extend(op || {}, { |
||||
selectedValues: |
||||
isKey(startValue) && |
||||
self.storeValue.type === Selection.Multi |
||||
? self.storeValue.value.concat( |
||||
startValue |
||||
) |
||||
: self.storeValue.value, |
||||
})); |
||||
opts.itemsCreator(op, ob => { |
||||
hasNext = ob.hasNext; |
||||
let firstItems = []; |
||||
if (op.times === 1 && self.storeValue) { |
||||
const json = map( |
||||
self.storeValue.value, |
||||
(i, v) => { |
||||
const txt = opts.valueFormatter(v) || v; |
||||
|
||||
return { |
||||
text: txt, |
||||
value: v, |
||||
title: txt, |
||||
selected: |
||||
self.storeValue.type === |
||||
Selection.Multi, |
||||
}; |
||||
} |
||||
); |
||||
if ( |
||||
isKey(self._startValue) && |
||||
!contains( |
||||
self.storeValue.value, |
||||
self._startValue |
||||
) |
||||
) { |
||||
const txt = |
||||
opts.valueFormatter(startValue) || |
||||
startValue; |
||||
json.unshift({ |
||||
text: txt, |
||||
value: startValue, |
||||
title: txt, |
||||
selected: true, |
||||
}); |
||||
} |
||||
firstItems = self._createItems(json); |
||||
} |
||||
callback( |
||||
firstItems.concat(self._createItems(ob.items)), |
||||
ob.keyword || "" |
||||
); |
||||
if (op.times === 1 && self.storeValue) { |
||||
isKey(startValue) && |
||||
(self.storeValue.type === Selection.All |
||||
? remove( |
||||
self.storeValue.value, |
||||
startValue |
||||
) |
||||
: pushDistinct( |
||||
self.storeValue.value, |
||||
startValue |
||||
)); |
||||
self.setValue(self.storeValue); |
||||
} |
||||
op.times === 1 && self._scrollToTop(); |
||||
}); |
||||
if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { |
||||
var txt = opts.valueFormatter(startValue) || startValue; |
||||
json.unshift({ |
||||
text: txt, |
||||
value: startValue, |
||||
title: txt, |
||||
selected: true |
||||
}); |
||||
} |
||||
firstItems = self._createItems(json); |
||||
} |
||||
callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); |
||||
if (op.times === 1 && self.storeValue) { |
||||
BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); |
||||
self.setValue(self.storeValue); |
||||
} |
||||
(op.times === 1) && self._scrollToTop(); |
||||
}); |
||||
}, |
||||
hasNext: function () { |
||||
return hasNext; |
||||
}, |
||||
value: this.storeValue |
||||
}, opts.el)); |
||||
}, |
||||
hasNext() { |
||||
return hasNext; |
||||
}, |
||||
value: this.storeValue, |
||||
}, |
||||
opts.el |
||||
) |
||||
); |
||||
|
||||
BI.createWidget({ |
||||
type: "bi.vertical", |
||||
createWidget({ |
||||
type: VerticalLayout.xtype, |
||||
element: this, |
||||
items: [this.button_group], |
||||
vgap: 5 |
||||
vgap: 5, |
||||
}); |
||||
|
||||
this.button_group.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
this.button_group.on(Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.MultiSelectNoBarLoader.EVENT_CHANGE, arguments); |
||||
this.button_group.on(SelectList.EVENT_CHANGE, function () { |
||||
self.fireEvent(MultiSelectNoBarLoader.EVENT_CHANGE, arguments); |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_createItems: function (items) { |
||||
return BI.map(items, (index, item) => { |
||||
_createItems(items) { |
||||
return map(items, (index, item) => { |
||||
return { |
||||
type: "bi.multi_select_item", |
||||
type: MultiSelectItem.xtype, |
||||
cls: "bi-list-item-active", |
||||
logic: this.options.logic, |
||||
height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
||||
height: |
||||
this.options.itemHeight || |
||||
BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
||||
iconWrapperWidth: 36, |
||||
...item, |
||||
...this.options.itemFormatter(item), |
||||
}; |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_scrollToTop: function () { |
||||
var self = this; |
||||
BI.delay(function () { |
||||
_scrollToTop() { |
||||
const self = this; |
||||
delay(() => { |
||||
self.button_group.element.scrollTop(0); |
||||
}, 30); |
||||
}, |
||||
} |
||||
|
||||
_assertValue: function (val) { |
||||
_assertValue(val) { |
||||
val || (val = {}); |
||||
val.type || (val.type = BI.Selection.Multi); |
||||
val.type || (val.type = Selection.Multi); |
||||
val.value || (val.value = []); |
||||
}, |
||||
} |
||||
|
||||
setStartValue: function (v) { |
||||
setStartValue(v) { |
||||
this._startValue = v; |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.storeValue = v || {}; |
||||
this._assertValue(this.storeValue); |
||||
this.button_group.setValue(this.storeValue.value); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return { |
||||
type: BI.Selection.Multi, |
||||
value: this.button_group.getValue() |
||||
type: Selection.Multi, |
||||
value: this.button_group.getValue(), |
||||
}; |
||||
}, |
||||
} |
||||
|
||||
getAllButtons: function () { |
||||
getAllButtons() { |
||||
return this.button_group.getAllButtons(); |
||||
}, |
||||
} |
||||
|
||||
empty: function () { |
||||
empty() { |
||||
this.button_group.empty(); |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
if (BI.isNotNull(items)) { |
||||
populate(items) { |
||||
if (isNotNull(items)) { |
||||
arguments[0] = this._createItems(items); |
||||
} |
||||
this.button_group.populate.apply(this.button_group, arguments); |
||||
}, |
||||
|
||||
resetHeight: function (h) { |
||||
this.button_group.element.css({ "max-height": BI.toPix(h) }); |
||||
}, |
||||
|
||||
resetWidth: function () { |
||||
this.button_group.populate(...arguments); |
||||
} |
||||
|
||||
resetHeight(h) { |
||||
this.button_group.element.css({ "max-height": toPix(h) }); |
||||
} |
||||
}); |
||||
|
||||
BI.MultiSelectNoBarLoader.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.multi_select_no_bar_loader", BI.MultiSelectNoBarLoader); |
||||
resetWidth() { |
||||
} |
||||
} |
||||
|
@ -1,100 +1,113 @@
|
||||
/** |
||||
* 带加载的多选下拉面板 |
||||
* @class BI.MultiSelectPopupView |
||||
* @extends Widget |
||||
*/ |
||||
BI.MultiSelectPopupView = BI.inherit(BI.Widget, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.MultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), { |
||||
import { |
||||
shortcut, |
||||
Widget, |
||||
extend, |
||||
emptyFn, |
||||
createWidget, |
||||
i18nText |
||||
} from "@/core"; |
||||
import { MultiPopupView } from "@/case"; |
||||
import { MultiSelectLoader } from "./multiselect.loader"; |
||||
|
||||
@shortcut() |
||||
export class MultiSelectPopupView extends Widget { |
||||
static xtype = "bi.multi_select_popup_view"; |
||||
|
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
static EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; |
||||
static EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; |
||||
|
||||
_defaultConfig() { |
||||
return extend(super._defaultConfig(...arguments), { |
||||
baseCls: "bi-multi-select-popup-view", |
||||
maxWidth: "auto", |
||||
minWidth: 135, |
||||
maxHeight: 400, |
||||
valueFormatter: BI.emptyFn, |
||||
itemsCreator: BI.emptyFn, |
||||
onLoaded: BI.emptyFn, |
||||
valueFormatter: emptyFn, |
||||
itemsCreator: emptyFn, |
||||
onLoaded: emptyFn, |
||||
itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.MultiSelectPopupView.superclass._init.apply(this, arguments); |
||||
var self = this, opts = this.options; |
||||
_init() { |
||||
super._init(...arguments); |
||||
const self = this, |
||||
opts = this.options; |
||||
|
||||
this.loader = BI.createWidget({ |
||||
type: "bi.multi_select_loader", |
||||
this.loader = createWidget({ |
||||
type: MultiSelectLoader.xtype, |
||||
itemsCreator: opts.itemsCreator, |
||||
itemHeight: opts.itemHeight, |
||||
valueFormatter: opts.valueFormatter, |
||||
itemFormatter: opts.itemFormatter, |
||||
onLoaded: opts.onLoaded, |
||||
value: opts.value |
||||
value: opts.value, |
||||
}); |
||||
|
||||
this.popupView = BI.createWidget({ |
||||
type: "bi.multi_popup_view", |
||||
this.popupView = createWidget({ |
||||
type: MultiPopupView.xtype, |
||||
stopPropagation: false, |
||||
maxWidth: opts.maxWidth, |
||||
minWidth: opts.minWidth, |
||||
maxHeight: opts.maxHeight, |
||||
element: this, |
||||
buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_OK")], |
||||
buttons: [i18nText("BI-Basic_Clears"), i18nText("BI-Basic_OK")], |
||||
el: this.loader, |
||||
value: opts.value |
||||
value: opts.value, |
||||
}); |
||||
|
||||
this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE); |
||||
this.popupView.on(MultiPopupView.EVENT_CHANGE, () => { |
||||
self.fireEvent(MultiSelectPopupView.EVENT_CHANGE); |
||||
}); |
||||
this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { |
||||
switch (index) { |
||||
case 0: |
||||
self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR); |
||||
break; |
||||
case 1: |
||||
self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM); |
||||
break; |
||||
this.popupView.on( |
||||
MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, |
||||
index => { |
||||
switch (index) { |
||||
case 0: |
||||
self.fireEvent(MultiSelectPopupView.EVENT_CLICK_CLEAR); |
||||
break; |
||||
case 1: |
||||
self.fireEvent( |
||||
MultiSelectPopupView.EVENT_CLICK_CONFIRM |
||||
); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
}); |
||||
}, |
||||
); |
||||
} |
||||
|
||||
isAllSelected: function () { |
||||
isAllSelected() { |
||||
return this.loader.isAllSelected(); |
||||
}, |
||||
} |
||||
|
||||
setStartValue: function (v) { |
||||
setStartValue(v) { |
||||
this.loader.setStartValue(v); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.popupView.setValue(v); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.popupView.getValue(); |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
this.popupView.populate.apply(this.popupView, arguments); |
||||
}, |
||||
populate(items) { |
||||
this.popupView.populate(...arguments); |
||||
} |
||||
|
||||
resetHeight: function (h) { |
||||
resetHeight(h) { |
||||
this.popupView.resetHeight(h); |
||||
}, |
||||
} |
||||
|
||||
resetWidth: function (w) { |
||||
resetWidth(w) { |
||||
this.popupView.resetWidth(w); |
||||
}, |
||||
} |
||||
|
||||
setDirection: function (direction, position) { |
||||
setDirection(direction, position) { |
||||
this.popupView.setDirection(direction, position); |
||||
}, |
||||
}); |
||||
|
||||
BI.MultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; |
||||
BI.MultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; |
||||
|
||||
|
||||
BI.shortcut("bi.multi_select_popup_view", BI.MultiSelectPopupView); |
||||
} |
||||
} |
||||
|
@ -1,96 +1,109 @@
|
||||
/** |
||||
* 带加载的多选下拉面板 |
||||
* @class BI.MultiSelectPopupView |
||||
* @extends Widget |
||||
*/ |
||||
BI.MultiSelectNoBarPopupView = BI.inherit(BI.Widget, { |
||||
import { |
||||
shortcut, |
||||
Widget, |
||||
extend, |
||||
emptyFn, |
||||
createWidget, |
||||
i18nText |
||||
} from "@/core"; |
||||
import { MultiPopupView } from "@/case"; |
||||
import { MultiSelectNoBarLoader } from "./multiselect.loader.nobar"; |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.MultiSelectNoBarPopupView.superclass._defaultConfig.apply(this, arguments), { |
||||
@shortcut() |
||||
export class MultiSelectNoBarPopupView extends Widget { |
||||
static xtype = "bi.multi_select_no_bar_popup_view"; |
||||
|
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
static EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; |
||||
static EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; |
||||
|
||||
_defaultConfig() { |
||||
return extend(super._defaultConfig(...arguments), { |
||||
baseCls: "bi-multi-select-popup-view", |
||||
maxWidth: "auto", |
||||
minWidth: 135, |
||||
maxHeight: 400, |
||||
valueFormatter: BI.emptyFn, |
||||
itemsCreator: BI.emptyFn, |
||||
valueFormatter: emptyFn, |
||||
itemsCreator: emptyFn, |
||||
itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
||||
onLoaded: BI.emptyFn |
||||
onLoaded: emptyFn, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.MultiSelectNoBarPopupView.superclass._init.apply(this, arguments); |
||||
var self = this, opts = this.options; |
||||
_init() { |
||||
super._init(...arguments); |
||||
const self = this, |
||||
opts = this.options; |
||||
|
||||
this.loader = BI.createWidget({ |
||||
type: "bi.multi_select_no_bar_loader", |
||||
this.loader = createWidget({ |
||||
type: MultiSelectNoBarLoader.xtype, |
||||
itemsCreator: opts.itemsCreator, |
||||
itemHeight: opts.itemHeight, |
||||
valueFormatter: opts.valueFormatter, |
||||
itemFormatter: opts.itemFormatter, |
||||
onLoaded: opts.onLoaded, |
||||
value: opts.value |
||||
value: opts.value, |
||||
}); |
||||
|
||||
this.popupView = BI.createWidget({ |
||||
type: "bi.multi_popup_view", |
||||
this.popupView = createWidget({ |
||||
type: MultiPopupView.xtype, |
||||
stopPropagation: false, |
||||
maxWidth: opts.maxWidth, |
||||
minWidth: opts.minWidth, |
||||
maxHeight: opts.maxHeight, |
||||
element: this, |
||||
buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_OK")], |
||||
buttons: [i18nText("BI-Basic_Clears"), i18nText("BI-Basic_OK")], |
||||
el: this.loader, |
||||
value: opts.value |
||||
value: opts.value, |
||||
}); |
||||
|
||||
this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CHANGE); |
||||
this.popupView.on(MultiPopupView.EVENT_CHANGE, () => { |
||||
self.fireEvent(MultiSelectNoBarPopupView.EVENT_CHANGE); |
||||
}); |
||||
this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { |
||||
switch (index) { |
||||
case 0: |
||||
self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR); |
||||
break; |
||||
case 1: |
||||
self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM); |
||||
break; |
||||
this.popupView.on( |
||||
MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, |
||||
index => { |
||||
switch (index) { |
||||
case 0: |
||||
self.fireEvent( |
||||
MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR |
||||
); |
||||
break; |
||||
case 1: |
||||
self.fireEvent( |
||||
MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM |
||||
); |
||||
break; |
||||
} |
||||
} |
||||
}); |
||||
}, |
||||
); |
||||
} |
||||
|
||||
setStartValue: function (v) { |
||||
setStartValue(v) { |
||||
this.loader.setStartValue(v); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.popupView.setValue(v); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.popupView.getValue(); |
||||
}, |
||||
} |
||||
|
||||
populate: function (items) { |
||||
this.popupView.populate.apply(this.popupView, arguments); |
||||
}, |
||||
populate(items) { |
||||
this.popupView.populate(...arguments); |
||||
} |
||||
|
||||
resetHeight: function (h) { |
||||
resetHeight(h) { |
||||
this.popupView.resetHeight(h); |
||||
}, |
||||
} |
||||
|
||||
resetWidth: function (w) { |
||||
resetWidth(w) { |
||||
this.popupView.resetWidth(w); |
||||
}, |
||||
} |
||||
|
||||
setDirection: function (direction, position) { |
||||
setDirection(direction, position) { |
||||
this.popupView.setDirection(direction, position); |
||||
}, |
||||
}); |
||||
|
||||
BI.MultiSelectNoBarPopupView.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; |
||||
BI.MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; |
||||
|
||||
|
||||
BI.shortcut("bi.multi_select_no_bar_popup_view", BI.MultiSelectNoBarPopupView); |
||||
} |
||||
} |
||||
|
@ -1,99 +1,109 @@
|
||||
/** |
||||
* |
||||
* 在搜索框中输入文本弹出的面板 |
||||
* @class BI.MultiSelectSearchInsertPane |
||||
* @extends Widget |
||||
*/ |
||||
|
||||
BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, { |
||||
|
||||
constants: { |
||||
height: 24, |
||||
lgap: 10, |
||||
tgap: 5 |
||||
}, |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.MultiSelectSearchInsertPane.superclass._defaultConfig.apply(this, arguments), { |
||||
import { |
||||
shortcut, |
||||
Widget, |
||||
extend, |
||||
emptyFn, |
||||
createWidget, |
||||
i18nText, |
||||
Controller, VerticalFillLayout |
||||
} from "@/core"; |
||||
import { Label } from "@/base"; |
||||
import { MultiSelectSearchLoader } from "./multiselect.search.loader"; |
||||
|
||||
@shortcut() |
||||
export class MultiSelectSearchInsertPane extends Widget { |
||||
static xtype = "bi.multi_select_search_insert_pane"; |
||||
|
||||
constants = { height: 24, lgap: 10, tgap: 5 }; |
||||
|
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
|
||||
_defaultConfig() { |
||||
return extend(super._defaultConfig(...arguments), { |
||||
baseCls: "bi-multi-select-search-pane bi-card", |
||||
itemsCreator: BI.emptyFn, |
||||
valueFormatter: BI.emptyFn, |
||||
keywordGetter: BI.emptyFn, |
||||
itemHeight: 24 |
||||
itemsCreator: emptyFn, |
||||
valueFormatter: emptyFn, |
||||
keywordGetter: emptyFn, |
||||
itemHeight: 24, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.MultiSelectSearchInsertPane.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
_init() { |
||||
super._init(...arguments); |
||||
const self = this, |
||||
o = this.options; |
||||
|
||||
this.addNotMatchTip = BI.createWidget({ |
||||
type: "bi.label", |
||||
text: BI.i18nText("BI-Basic_Press_Enter_To_Add_Text", ""), |
||||
this.addNotMatchTip = createWidget({ |
||||
type: Label.xtype, |
||||
text: i18nText("BI-Basic_Press_Enter_To_Add_Text", ""), |
||||
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
||||
cls: "bi-keyword-red-mark", |
||||
hgap: 5, |
||||
}); |
||||
|
||||
this.loader = BI.createWidget({ |
||||
type: "bi.multi_select_search_loader", |
||||
this.loader = createWidget({ |
||||
type: MultiSelectSearchLoader.xtype, |
||||
keywordGetter: o.keywordGetter, |
||||
valueFormatter: o.valueFormatter, |
||||
itemFormatter: o.itemFormatter, |
||||
itemsCreator: function (op, callback) { |
||||
o.itemsCreator.apply(self, [op, function (res) { |
||||
callback(res); |
||||
self.setKeyword(o.keywordGetter()); |
||||
}]); |
||||
itemsCreator(op, callback) { |
||||
o.itemsCreator.apply(self, [ |
||||
op, |
||||
function (res) { |
||||
callback(res); |
||||
self.setKeyword(o.keywordGetter()); |
||||
} |
||||
]); |
||||
}, |
||||
itemHeight: o.itemHeight, |
||||
value: o.value |
||||
value: o.value, |
||||
}); |
||||
this.loader.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
this.loader.on(Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
|
||||
this.resizer = BI.createWidget({ |
||||
type: "bi.vertical_fill", |
||||
this.resizer = createWidget({ |
||||
type: VerticalFillLayout.xtype, |
||||
rowSize: ["", "fill"], |
||||
element: this, |
||||
items: [{ |
||||
el: this.addNotMatchTip, |
||||
}, { |
||||
el: this.loader, |
||||
}], |
||||
items: [ |
||||
{ |
||||
el: this.addNotMatchTip, |
||||
}, |
||||
{ |
||||
el: this.loader, |
||||
} |
||||
], |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
setKeyword: function (keyword) { |
||||
this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Press_Enter_To_Add_Text", keyword)); |
||||
}, |
||||
setKeyword(keyword) { |
||||
this.addNotMatchTip.setText( |
||||
i18nText("BI-Basic_Press_Enter_To_Add_Text", keyword) |
||||
); |
||||
} |
||||
|
||||
isAllSelected: function () { |
||||
isAllSelected() { |
||||
return this.loader.isAllSelected(); |
||||
}, |
||||
} |
||||
|
||||
hasMatched: function () { |
||||
hasMatched() { |
||||
return false; |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.loader.setValue(v); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.loader.getValue(); |
||||
}, |
||||
} |
||||
|
||||
empty: function () { |
||||
empty() { |
||||
this.loader.empty(); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.loader.populate.apply(this.loader, arguments); |
||||
} |
||||
}); |
||||
|
||||
BI.MultiSelectSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
|
||||
BI.shortcut("bi.multi_select_search_insert_pane", BI.MultiSelectSearchInsertPane); |
||||
populate(items) { |
||||
this.loader.populate(...arguments); |
||||
} |
||||
} |
||||
|
@ -1,86 +1,92 @@
|
||||
/** |
||||
* |
||||
* 在搜索框中输入文本弹出的面板 |
||||
* @class BI.MultiSelectSearchPane |
||||
* @extends Widget |
||||
*/ |
||||
import { |
||||
shortcut, |
||||
Widget, |
||||
extend, |
||||
emptyFn, |
||||
createWidget, |
||||
Controller, |
||||
AbsoluteLayout |
||||
} from "@/core"; |
||||
import { MultiSelectSearchLoader } from "./multiselect.search.loader"; |
||||
|
||||
BI.MultiSelectSearchPane = BI.inherit(BI.Widget, { |
||||
@shortcut() |
||||
export class MultiSelectSearchPane extends Widget { |
||||
static xtype = "bi.multi_select_search_pane"; |
||||
|
||||
constants: { |
||||
height: 24, |
||||
lgap: 10, |
||||
tgap: 5 |
||||
}, |
||||
constants = { height: 24, lgap: 10, tgap: 5 }; |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.MultiSelectSearchPane.superclass._defaultConfig.apply(this, arguments), { |
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
|
||||
_defaultConfig() { |
||||
return extend(super._defaultConfig(...arguments), { |
||||
baseCls: "bi-multi-select-search-pane bi-card", |
||||
itemsCreator: BI.emptyFn, |
||||
valueFormatter: BI.emptyFn, |
||||
keywordGetter: BI.emptyFn, |
||||
itemsCreator: emptyFn, |
||||
valueFormatter: emptyFn, |
||||
keywordGetter: emptyFn, |
||||
itemHeight: 24, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_init: function () { |
||||
BI.MultiSelectSearchPane.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
_init() { |
||||
super._init(...arguments); |
||||
const self = this, |
||||
o = this.options; |
||||
|
||||
this.loader = BI.createWidget({ |
||||
type: "bi.multi_select_search_loader", |
||||
this.loader = createWidget({ |
||||
type: MultiSelectSearchLoader.xtype, |
||||
keywordGetter: o.keywordGetter, |
||||
valueFormatter: o.valueFormatter, |
||||
itemFormatter: o.itemFormatter, |
||||
itemsCreator: function (op, callback) { |
||||
o.itemsCreator.apply(self, [op, function (res) { |
||||
callback(res); |
||||
}]); |
||||
itemsCreator(op, callback) { |
||||
o.itemsCreator.apply(self, [ |
||||
op, |
||||
function (res) { |
||||
callback(res); |
||||
} |
||||
]); |
||||
}, |
||||
itemHeight: o.itemHeight, |
||||
value: o.value |
||||
value: o.value, |
||||
}); |
||||
this.loader.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
this.loader.on(Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
|
||||
this.resizer = BI.createWidget({ |
||||
type: "bi.absolute", |
||||
this.resizer = createWidget({ |
||||
type: AbsoluteLayout.xtype, |
||||
element: this, |
||||
items: [{ |
||||
el: this.loader, |
||||
left: 0, |
||||
right: 0, |
||||
bottom: 0, |
||||
top: 0, |
||||
}], |
||||
items: [ |
||||
{ |
||||
el: this.loader, |
||||
left: 0, |
||||
right: 0, |
||||
bottom: 0, |
||||
top: 0, |
||||
} |
||||
], |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
isAllSelected: function () { |
||||
isAllSelected() { |
||||
return this.loader.isAllSelected(); |
||||
}, |
||||
} |
||||
|
||||
hasMatched: function () { |
||||
}, |
||||
hasMatched() { |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.loader.setValue(v); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.loader.getValue(); |
||||
}, |
||||
} |
||||
|
||||
empty: function () { |
||||
empty() { |
||||
this.loader.empty(); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.loader.populate.apply(this.loader, arguments); |
||||
} |
||||
}); |
||||
|
||||
BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
|
||||
BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane); |
||||
populate(items) { |
||||
this.loader.populate(...arguments); |
||||
} |
||||
} |
||||
|
@ -1,214 +1,248 @@
|
||||
/** |
||||
* @author windy |
||||
* @version 2.0 |
||||
* Created by windy on 2021/5/18 |
||||
*/ |
||||
BI.SelectPatchEditor = BI.inherit(BI.Widget, { |
||||
|
||||
props: { |
||||
baseCls: "bi-patch-select-editor", |
||||
height: 24, |
||||
}, |
||||
|
||||
render: function () { |
||||
var self = this, o = this.options; |
||||
|
||||
var debounceInputChange = BI.debounce(BI.bind(this._dealChange, this), 300); |
||||
|
||||
return BI.extend({ |
||||
type: "bi.state_editor", |
||||
ref: function (_ref) { |
||||
self.editor = _ref; |
||||
}, |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
height: o.height, |
||||
watermark: o.watermark, |
||||
allowBlank: true, |
||||
value: o.value, |
||||
defaultText: o.defaultText, |
||||
text: o.text, |
||||
tipType: o.tipType, |
||||
warningTitle: o.warningTitle, |
||||
el: { |
||||
type: 'bi.textarea_editor', |
||||
scrolly: false, |
||||
validationChecker: function () { |
||||
return true; |
||||
import { |
||||
shortcut, |
||||
Widget, |
||||
debounce, |
||||
bind, |
||||
extend, |
||||
Controller, |
||||
contains, |
||||
isKey, |
||||
Events, |
||||
trim, replaceAll |
||||
} from "@/core"; |
||||
import { Editor, TextAreaEditor } from "@/base"; |
||||
import { StateEditor } from "@/case"; |
||||
|
||||
@shortcut() |
||||
export class SelectPatchEditor extends Widget { |
||||
static xtype = "bi.select_patch_editor"; |
||||
|
||||
props = { baseCls: "bi-patch-select-editor", height: 24 }; |
||||
|
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
static EVENT_FOCUS = "EVENT_FOCUS"; |
||||
static EVENT_BLUR = "EVENT_BLUR"; |
||||
|
||||
render() { |
||||
const self = this, |
||||
o = this.options; |
||||
|
||||
const debounceInputChange = debounce(bind(this._dealChange, this), 300); |
||||
|
||||
return extend( |
||||
{ |
||||
type: StateEditor.xtype, |
||||
ref(_ref) { |
||||
self.editor = _ref; |
||||
}, |
||||
throttle: true, |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.Controller.EVENT_CHANGE, |
||||
action: function (type, v) { |
||||
if (BI.contains(v, "\n")) { |
||||
self._dealChange(type, v); |
||||
} else { |
||||
debounceInputChange(type, v); |
||||
} |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
height: o.height, |
||||
watermark: o.watermark, |
||||
allowBlank: true, |
||||
value: o.value, |
||||
defaultText: o.defaultText, |
||||
text: o.text, |
||||
tipType: o.tipType, |
||||
warningTitle: o.warningTitle, |
||||
el: { |
||||
type: TextAreaEditor.xtype, |
||||
scrolly: false, |
||||
validationChecker() { |
||||
return true; |
||||
}, |
||||
throttle: true, |
||||
}, |
||||
}, { |
||||
eventName: BI.Editor.EVENT_KEY_DOWN, |
||||
action: function (keyCode) { |
||||
if (keyCode === BI.KeyCode.ENTER) { |
||||
self._clearSplitValue(); |
||||
listeners: [ |
||||
{ |
||||
eventName: Controller.EVENT_CHANGE, |
||||
action(type, v) { |
||||
if (contains(v, "\n")) { |
||||
self._dealChange(type, v); |
||||
} else { |
||||
debounceInputChange(type, v); |
||||
} |
||||
}, |
||||
}, |
||||
{ |
||||
eventName: Editor.EVENT_KEY_DOWN, |
||||
action(keyCode) { |
||||
if (keyCode === BI.KeyCode.ENTER) { |
||||
self._clearSplitValue(); |
||||
} |
||||
}, |
||||
}, |
||||
{ |
||||
eventName: Editor.EVENT_FOCUS, |
||||
action() { |
||||
self.fireEvent( |
||||
SelectPatchEditor.EVENT_FOCUS, |
||||
arguments |
||||
); |
||||
}, |
||||
}, |
||||
{ |
||||
eventName: Editor.EVENT_BLUR, |
||||
action() { |
||||
self._start = false; |
||||
self.fireEvent( |
||||
SelectPatchEditor.EVENT_BLUR, |
||||
arguments |
||||
); |
||||
}, |
||||
} |
||||
}, |
||||
}, { |
||||
eventName: BI.Editor.EVENT_FOCUS, |
||||
action: function () { |
||||
self.fireEvent(BI.SelectPatchEditor.EVENT_FOCUS, arguments); |
||||
}, |
||||
}, { |
||||
eventName: BI.Editor.EVENT_BLUR, |
||||
action: function () { |
||||
self._start = false; |
||||
self.fireEvent(BI.SelectPatchEditor.EVENT_BLUR, arguments); |
||||
}, |
||||
}], |
||||
}, o.el); |
||||
}, |
||||
], |
||||
}, |
||||
o.el |
||||
); |
||||
} |
||||
|
||||
_clearSplitValue: function () { |
||||
_clearSplitValue() { |
||||
this.editor.setValue(""); |
||||
}, |
||||
} |
||||
|
||||
_dealChange: function (type, v) { |
||||
var value = ""; |
||||
_dealChange(type, v) { |
||||
let value = ""; |
||||
if (v !== this.editor.getValue()) { |
||||
return; |
||||
} |
||||
if (BI.isKey(v)) { |
||||
if (isKey(v)) { |
||||
value = this._formatText(v); |
||||
} |
||||
if (type === BI.Events.CHANGE) { |
||||
if (type === Events.CHANGE) { |
||||
this._setValue(value); |
||||
if (this._trimValue(value) !== "") { |
||||
if (!this._start || !BI.isKey(this._lastValue) || (this._pause === true && this._trimValue(this._lastValue) !== this._trimValue(value))) { |
||||
if ( |
||||
!this._start || |
||||
!isKey(this._lastValue) || |
||||
(this._pause === true && |
||||
this._trimValue(this._lastValue) !== |
||||
this._trimValue(value)) |
||||
) { |
||||
this._start = true; |
||||
this._pause = false; |
||||
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.STARTEDIT, this.getValue(), this); |
||||
this.fireEvent( |
||||
Controller.EVENT_CHANGE, |
||||
Events.STARTEDIT, |
||||
this.getValue(), |
||||
this |
||||
); |
||||
} |
||||
} |
||||
if (this._trimValue(this._lastValue) !== this._trimValue(value)) { |
||||
this.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
this.fireEvent(Controller.EVENT_CHANGE, arguments); |
||||
} |
||||
if (BI.endWith(value, BI.BlankSplitChar)) { |
||||
this._pause = true; |
||||
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.PAUSE, "", this); |
||||
this.fireEvent(Controller.EVENT_CHANGE, Events.PAUSE, "", this); |
||||
} |
||||
} |
||||
if (type === BI.Events.EMPTY || type === BI.Events.STOPEDIT) { |
||||
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY); |
||||
if (type === Events.EMPTY || type === Events.STOPEDIT) { |
||||
this.fireEvent(Controller.EVENT_CHANGE, Events.EMPTY); |
||||
} |
||||
this._lastValue = value; |
||||
}, |
||||
} |
||||
|
||||
_trimValue: function (v) { |
||||
return BI.trim(BI.replaceAll(v || "", BI.BlankSplitChar, "")); |
||||
}, |
||||
_trimValue(v) { |
||||
return trim(replaceAll(v || "", BI.BlankSplitChar, "")); |
||||
} |
||||
|
||||
_formatText: function (v) { |
||||
return BI.replaceAll(v || "", "\n", BI.BlankSplitChar); |
||||
}, |
||||
_formatText(v) { |
||||
return replaceAll(v || "", "\n", BI.BlankSplitChar); |
||||
} |
||||
|
||||
setWaterMark: function (v) { |
||||
setWaterMark(v) { |
||||
this.editor.setWaterMark(v); |
||||
}, |
||||
} |
||||
|
||||
doRedMark: function () { |
||||
this.editor.doRedMark.apply(this.editor, arguments); |
||||
}, |
||||
doRedMark() { |
||||
this.editor.doRedMark(...arguments); |
||||
} |
||||
|
||||
unRedMark: function () { |
||||
this.editor.unRedMark.apply(this.editor, arguments); |
||||
}, |
||||
unRedMark() { |
||||
this.editor.unRedMark(...arguments); |
||||
} |
||||
|
||||
doHighLight: function () { |
||||
this.editor.doHighLight.apply(this.editor, arguments); |
||||
}, |
||||
doHighLight() { |
||||
this.editor.doHighLight(...arguments); |
||||
} |
||||
|
||||
unHighLight: function () { |
||||
this.text.unHighLight.apply(this.text, arguments); |
||||
}, |
||||
unHighLight() { |
||||
this.text.unHighLight(...arguments); |
||||
} |
||||
|
||||
focus: function () { |
||||
focus() { |
||||
this.editor.focus(); |
||||
}, |
||||
} |
||||
|
||||
blur: function () { |
||||
blur() { |
||||
this.editor.blur(); |
||||
}, |
||||
} |
||||
|
||||
_setValue: function (v) { |
||||
_setValue(v) { |
||||
this.editor.setValue(this._formatText(v)); |
||||
}, |
||||
} |
||||
|
||||
_showInput: function () { |
||||
_showInput() { |
||||
this.editor.visible(); |
||||
this.text.invisible(); |
||||
}, |
||||
} |
||||
|
||||
_showHint: function () { |
||||
_showHint() { |
||||
this.editor.invisible(); |
||||
this.text.visible(); |
||||
}, |
||||
} |
||||
|
||||
isValid: function () { |
||||
isValid() { |
||||
return this.editor.isValid(); |
||||
}, |
||||
} |
||||
|
||||
setErrorText: function (text) { |
||||
setErrorText(text) { |
||||
this.editor.setErrorText(text); |
||||
}, |
||||
} |
||||
|
||||
getErrorText: function () { |
||||
getErrorText() { |
||||
return this.editor.getErrorText(); |
||||
}, |
||||
} |
||||
|
||||
isEditing: function () { |
||||
isEditing() { |
||||
return this.editor.isEditing(); |
||||
}, |
||||
} |
||||
|
||||
getLastValidValue: function () { |
||||
getLastValidValue() { |
||||
return this.editor.getLastValidValue(); |
||||
}, |
||||
} |
||||
|
||||
getLastChangedValue: function () { |
||||
getLastChangedValue() { |
||||
return this.editor.getLastChangedValue(); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this._setValue(v); |
||||
this._lastValue = this._trimValue(v); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
return BI.trim(this.editor.getValue()); |
||||
}, |
||||
getValue() { |
||||
return trim(this.editor.getValue()); |
||||
} |
||||
|
||||
getState: function () { |
||||
getState() { |
||||
return this.editor.getState(); |
||||
}, |
||||
} |
||||
|
||||
setState: function (v) { |
||||
setState(v) { |
||||
this.editor.setState(v); |
||||
}, |
||||
} |
||||
|
||||
setTipType: function (v) { |
||||
setTipType(v) { |
||||
this.editor.setTipType(v); |
||||
}, |
||||
} |
||||
|
||||
getText: function () { |
||||
getText() { |
||||
return this.editor.getText(); |
||||
}, |
||||
}); |
||||
BI.SelectPatchEditor.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.SelectPatchEditor.EVENT_FOCUS = "EVENT_FOCUS"; |
||||
BI.SelectPatchEditor.EVENT_BLUR = "EVENT_BLUR"; |
||||
|
||||
BI.shortcut("bi.select_patch_editor", BI.SelectPatchEditor); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue