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"; |
||||
|
||||
constants = { height: 12, lgap: 10, tgap: 10, bgap: 5 }; |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.MultiSelectCheckPane.superclass._defaultConfig.apply(this, arguments), { |
||||
_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: [{ |
||||
items: [ |
||||
{ |
||||
height: this.constants.height, |
||||
el: { |
||||
type: "bi.vertical_adapt", |
||||
type: VerticalAdaptLayout.xtype, |
||||
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") |
||||
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 |
||||
}] |
||||
hgap: this.constants.lgap, |
||||
} |
||||
], |
||||
}, |
||||
tgap: this.constants.tgap |
||||
}, { |
||||
tgap: this.constants.tgap, |
||||
}, |
||||
{ |
||||
height: "fill", |
||||
el: this.display, |
||||
tgap: this.constants.bgap |
||||
}] |
||||
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"; |
||||
|
||||
constants = { height: 24, lgap: 10 }; |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), { |
||||
_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", |
||||
this.button_group = createWidget( |
||||
extend( |
||||
{ |
||||
type: ListPane.xtype, |
||||
onLoaded: opts.onLoaded, |
||||
el: { |
||||
type: "bi.loader", |
||||
type: Loader.xtype, |
||||
isDefaultInit: false, |
||||
logic: { |
||||
dynamic: true, |
||||
scrolly: true |
||||
scrolly: true, |
||||
}, |
||||
el: { |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
chooseType: ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
behaviors: { |
||||
redmark: function () { |
||||
redmark() { |
||||
return true; |
||||
} |
||||
}, |
||||
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 |
||||
layouts: [ |
||||
{ |
||||
type: VerticalLayout.xtype, |
||||
} |
||||
], |
||||
}, |
||||
}, |
||||
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, function (ob) { |
||||
opts.itemsCreator(op, ob => { |
||||
hasNext = ob.hasNext; |
||||
var firstItems = []; |
||||
let firstItems = []; |
||||
if (op.times === 1 && self.storeValue) { |
||||
var json = BI.map(self.storeValue.value, function (i, v) { |
||||
var txt = opts.valueFormatter(v) || v; |
||||
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 === BI.Selection.Multi |
||||
selected: |
||||
self.storeValue.type === |
||||
Selection.Multi, |
||||
}; |
||||
}); |
||||
if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { |
||||
var txt = opts.valueFormatter(startValue) || startValue; |
||||
} |
||||
); |
||||
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 |
||||
selected: true, |
||||
}); |
||||
} |
||||
firstItems = self._createItems(json); |
||||
} |
||||
callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); |
||||
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)); |
||||
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(); |
||||
op.times === 1 && self._scrollToTop(); |
||||
}); |
||||
}, |
||||
hasNext: function () { |
||||
hasNext() { |
||||
return hasNext; |
||||
}, |
||||
value: this.storeValue |
||||
}, opts.el)); |
||||
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) { |
||||
this.popupView.on( |
||||
MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, |
||||
index => { |
||||
switch (index) { |
||||
case 0: |
||||
self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR); |
||||
self.fireEvent(MultiSelectPopupView.EVENT_CLICK_CLEAR); |
||||
break; |
||||
case 1: |
||||
self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM); |
||||
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) { |
||||
this.popupView.on( |
||||
MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, |
||||
index => { |
||||
switch (index) { |
||||
case 0: |
||||
self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR); |
||||
self.fireEvent( |
||||
MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR |
||||
); |
||||
break; |
||||
case 1: |
||||
self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM); |
||||
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) { |
||||
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: [{ |
||||
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 }; |
||||
|
||||
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.MultiSelectSearchPane.superclass._defaultConfig.apply(this, arguments), { |
||||
_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) { |
||||
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: [{ |
||||
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); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue