Zhenfei.Li
2 years ago
17 changed files with 1204 additions and 1114 deletions
@ -0,0 +1,9 @@ |
|||||||
|
export { SingleSelectCombo } from "./singleselect.combo"; |
||||||
|
export { SingleSelectInsertCombo } from "./singleselect.insert.combo"; |
||||||
|
export { SingleSelectList } from "./singleselect.list"; |
||||||
|
export { SingleSelectLoader } from "./singleselect.loader"; |
||||||
|
export { SingleSelectPopupView } from "./singleselect.popup.view"; |
||||||
|
export { SingleSelectTrigger } from "./singleselect.trigger"; |
||||||
|
export { SingleSelectInsertList } from "./singleselectlist.insert"; |
||||||
|
export * from "./trigger"; |
||||||
|
export * from "./search"; |
@ -0,0 +1,3 @@ |
|||||||
|
export { SingleSelectSearchLoader } from "./singleselect.search.loader"; |
||||||
|
export { SingleSelectSearchPane } from "./singleselect.search.pane"; |
||||||
|
export { SingleSelectSearchInsertPane } from "./singleselect.search.pane.insert"; |
@ -1,96 +1,96 @@ |
|||||||
/** |
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText, Controller, VerticalFillLayout, VerticalLayout } from "@/core"; |
||||||
* |
import { Label } from "@/base"; |
||||||
* 在搜索框中输入文本弹出的面板 |
import { SingleSelectSearchLoader } from "./singleselect.search.loader"; |
||||||
* @class BI.SingleSelectSearchInsertPane |
|
||||||
* @extends Widget |
|
||||||
*/ |
|
||||||
|
|
||||||
BI.SingleSelectSearchInsertPane = BI.inherit(BI.Widget, { |
@shortcut() |
||||||
|
export class SingleSelectSearchInsertPane extends Widget { |
||||||
|
static xtype = "bi.single_select_search_insert_pane"; |
||||||
|
|
||||||
constants: { |
constants = { height: 25, lgap: 10, tgap: 5 }; |
||||||
height: 25, |
|
||||||
lgap: 10, |
|
||||||
tgap: 5 |
|
||||||
}, |
|
||||||
|
|
||||||
_defaultConfig: function () { |
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
return BI.extend(BI.SingleSelectSearchInsertPane.superclass._defaultConfig.apply(this, arguments), { |
|
||||||
|
_defaultConfig() { |
||||||
|
return extend(super._defaultConfig(...arguments), { |
||||||
baseCls: "bi-single-select-search-pane-insert bi-card", |
baseCls: "bi-single-select-search-pane-insert bi-card", |
||||||
allowNoSelect: false, |
allowNoSelect: false, |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
valueFormatter: BI.emptyFn, |
valueFormatter: emptyFn, |
||||||
keywordGetter: BI.emptyFn |
keywordGetter: emptyFn, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_init: function () { |
_init() { |
||||||
BI.SingleSelectSearchInsertPane.superclass._init.apply(this, arguments); |
super._init(...arguments); |
||||||
var self = this, o = this.options; |
const self = this, |
||||||
|
o = this.options; |
||||||
|
|
||||||
this.addNotMatchTip = BI.createWidget({ |
this.addNotMatchTip = createWidget({ |
||||||
type: "bi.label", |
type: Label.xtype, |
||||||
text: BI.i18nText("BI-Basic_Press_Enter_To_Add_Text", ""), |
text: i18nText("BI-Basic_Press_Enter_To_Add_Text", ""), |
||||||
height: this.constants.height, |
height: this.constants.height, |
||||||
cls: "bi-keyword-red-mark", |
cls: "bi-keyword-red-mark", |
||||||
hgap: 5, |
hgap: 5, |
||||||
}); |
}); |
||||||
|
|
||||||
this.loader = BI.createWidget({ |
this.loader = createWidget({ |
||||||
type: "bi.single_select_search_loader", |
type: SingleSelectSearchLoader.xtype, |
||||||
allowNoSelect: o.allowNoSelect, |
allowNoSelect: o.allowNoSelect, |
||||||
keywordGetter: o.keywordGetter, |
keywordGetter: o.keywordGetter, |
||||||
valueFormatter: o.valueFormatter, |
valueFormatter: o.valueFormatter, |
||||||
itemsCreator: function (op, callback) { |
itemsCreator (op, callback) { |
||||||
o.itemsCreator.apply(self, [op, function (res) { |
o.itemsCreator.apply(self, [ |
||||||
callback(res); |
op, |
||||||
self.setKeyword(o.keywordGetter()); |
function (res) { |
||||||
}]); |
callback(res); |
||||||
|
self.setKeyword(o.keywordGetter()); |
||||||
|
} |
||||||
|
]); |
||||||
}, |
}, |
||||||
value: o.value |
value: o.value, |
||||||
}); |
}); |
||||||
this.loader.on(BI.Controller.EVENT_CHANGE, function () { |
this.loader.on(Controller.EVENT_CHANGE, function () { |
||||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
||||||
}); |
}); |
||||||
|
|
||||||
this.resizer = BI.createWidget({ |
this.resizer = createWidget({ |
||||||
type: "bi.vertical_fill", |
type: VerticalFillLayout.xtype, |
||||||
rowSize: ["", "fill"], |
rowSize: ["", "fill"], |
||||||
element: this, |
element: this, |
||||||
items: [{ |
items: [ |
||||||
type: "bi.vertical", |
{ |
||||||
items: [this.addNotMatchTip], |
type: VerticalLayout.xtype, |
||||||
height: this.constants.height |
items: [this.addNotMatchTip], |
||||||
}, { |
height: this.constants.height, |
||||||
el: this.loader |
}, |
||||||
}] |
{ |
||||||
|
el: this.loader, |
||||||
|
} |
||||||
|
], |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
setKeyword: function (keyword) { |
setKeyword(keyword) { |
||||||
this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Press_Enter_To_Add_Text", keyword)); |
this.addNotMatchTip.setText(i18nText("BI-Basic_Press_Enter_To_Add_Text", keyword)); |
||||||
}, |
} |
||||||
|
|
||||||
hasMatched: function () { |
hasMatched() { |
||||||
return false; |
return false; |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
this.loader.setValue(v); |
this.loader.setValue(v); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.loader.getValue(); |
return this.loader.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
empty: function () { |
empty() { |
||||||
this.loader.empty(); |
this.loader.empty(); |
||||||
}, |
|
||||||
|
|
||||||
populate: function (items) { |
|
||||||
this.loader.populate.apply(this.loader, arguments); |
|
||||||
} |
} |
||||||
}); |
|
||||||
|
|
||||||
BI.SingleSelectSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE"; |
populate(items) { |
||||||
|
this.loader.populate(...arguments); |
||||||
BI.shortcut("bi.single_select_search_insert_pane", BI.SingleSelectSearchInsertPane); |
} |
||||||
|
} |
||||||
|
@ -1,101 +1,105 @@ |
|||||||
/** |
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText, Controller, VerticalFillLayout } from "@/core"; |
||||||
* |
import { Label } from "@/base"; |
||||||
* 在搜索框中输入文本弹出的面板 |
import { SingleSelectSearchLoader } from "./singleselect.search.loader"; |
||||||
* @class BI.SingleSelectSearchPane |
|
||||||
* @extends Widget |
|
||||||
*/ |
|
||||||
|
|
||||||
BI.SingleSelectSearchPane = BI.inherit(BI.Widget, { |
@shortcut() |
||||||
|
export class SingleSelectSearchPane extends Widget { |
||||||
|
static xtype = "bi.single_select_search_pane"; |
||||||
|
|
||||||
constants: { |
constants = { height: 25, lgap: 10, tgap: 5 }; |
||||||
height: 25, |
|
||||||
lgap: 10, |
|
||||||
tgap: 5 |
|
||||||
}, |
|
||||||
|
|
||||||
_defaultConfig: function () { |
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
return BI.extend(BI.SingleSelectSearchPane.superclass._defaultConfig.apply(this, arguments), { |
|
||||||
|
_defaultConfig() { |
||||||
|
return extend(super._defaultConfig(...arguments), { |
||||||
baseCls: "bi-single-select-search-pane bi-card", |
baseCls: "bi-single-select-search-pane bi-card", |
||||||
allowNoSelect: false, |
allowNoSelect: false, |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
valueFormatter: BI.emptyFn, |
valueFormatter: emptyFn, |
||||||
keywordGetter: BI.emptyFn |
keywordGetter: emptyFn, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_init: function () { |
_init() { |
||||||
BI.SingleSelectSearchPane.superclass._init.apply(this, arguments); |
super._init(...arguments); |
||||||
var self = this, o = this.options; |
const self = this, |
||||||
|
o = this.options; |
||||||
|
|
||||||
this.tooltipClick = BI.createWidget({ |
this.tooltipClick = createWidget({ |
||||||
type: "bi.label", |
type: Label.xtype, |
||||||
invisible: true, |
invisible: true, |
||||||
text: BI.i18nText("BI-Click_Blank_To_Select"), |
text: i18nText("BI-Click_Blank_To_Select"), |
||||||
cls: "single-select-toolbar", |
cls: "single-select-toolbar", |
||||||
height: this.constants.height |
height: this.constants.height, |
||||||
}); |
}); |
||||||
|
|
||||||
this.loader = BI.createWidget({ |
this.loader = createWidget({ |
||||||
type: "bi.single_select_search_loader", |
type: SingleSelectSearchLoader.xtype, |
||||||
allowNoSelect: o.allowNoSelect, |
allowNoSelect: o.allowNoSelect, |
||||||
keywordGetter: o.keywordGetter, |
keywordGetter: o.keywordGetter, |
||||||
valueFormatter: o.valueFormatter, |
valueFormatter: o.valueFormatter, |
||||||
itemsCreator: function (op, callback) { |
itemsCreator (op, callback) { |
||||||
o.itemsCreator.apply(self, [op, function (res) { |
o.itemsCreator.apply(self, [ |
||||||
callback(res); |
op, |
||||||
self.setKeyword(o.keywordGetter()); |
function (res) { |
||||||
}]); |
callback(res); |
||||||
|
self.setKeyword(o.keywordGetter()); |
||||||
|
} |
||||||
|
]); |
||||||
}, |
}, |
||||||
value: o.value |
value: o.value, |
||||||
}); |
}); |
||||||
this.loader.on(BI.Controller.EVENT_CHANGE, function () { |
this.loader.on(Controller.EVENT_CHANGE, function () { |
||||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
||||||
}); |
}); |
||||||
|
|
||||||
this.resizer = BI.createWidget({ |
this.resizer = createWidget({ |
||||||
type: "bi.vertical_fill", |
type: VerticalFillLayout.xtype, |
||||||
rowSize: ["", "fill"], |
rowSize: ["", "fill"], |
||||||
element: this, |
element: this, |
||||||
items: [{ |
items: [ |
||||||
el: this.tooltipClick, |
{ |
||||||
}, { |
el: this.tooltipClick, |
||||||
el: this.loader |
}, |
||||||
}] |
{ |
||||||
|
el: this.loader, |
||||||
|
} |
||||||
|
], |
||||||
}); |
}); |
||||||
this.tooltipClick.setVisible(false); |
this.tooltipClick.setVisible(false); |
||||||
}, |
} |
||||||
|
|
||||||
setKeyword: function (keyword) { |
setKeyword(keyword) { |
||||||
var btn, o = this.options; |
let btn; |
||||||
var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === (o.valueFormatter(btn.getValue()) || btn.getValue())); |
const o = this.options; |
||||||
|
const isVisible = |
||||||
|
this.loader.getAllButtons().length > 0 && |
||||||
|
(btn = this.loader.getAllButtons()[0]) && |
||||||
|
keyword === (o.valueFormatter(btn.getValue()) || btn.getValue()); |
||||||
if (isVisible !== this.tooltipClick.isVisible()) { |
if (isVisible !== this.tooltipClick.isVisible()) { |
||||||
this.tooltipClick.setVisible(isVisible); |
this.tooltipClick.setVisible(isVisible); |
||||||
this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0); |
this.resizer.attr("items")[0].height = isVisible ? this.constants.height : 0; |
||||||
this.resizer.resize(); |
this.resizer.resize(); |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
hasMatched: function () { |
hasMatched() { |
||||||
return this.tooltipClick.isVisible(); |
return this.tooltipClick.isVisible(); |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
this.loader.setValue(v); |
this.loader.setValue(v); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.loader.getValue(); |
return this.loader.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
empty: function () { |
empty() { |
||||||
this.loader.empty(); |
this.loader.empty(); |
||||||
}, |
|
||||||
|
|
||||||
populate: function (items) { |
|
||||||
this.loader.populate.apply(this.loader, arguments); |
|
||||||
} |
} |
||||||
}); |
|
||||||
|
|
||||||
BI.SingleSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; |
populate(items) { |
||||||
|
this.loader.populate(...arguments); |
||||||
BI.shortcut("bi.single_select_search_pane", BI.SingleSelectSearchPane); |
} |
||||||
|
} |
||||||
|
@ -1,178 +1,187 @@ |
|||||||
/** |
import { shortcut, Widget, extend, emptyFn, createWidget, isUndefined, map, isKey, Controller, VerticalLayout, delay } from "@/core"; |
||||||
* 单选加载数据面板 |
import { ButtonGroup, Loader } from "@/base"; |
||||||
* Created by guy on 15/11/2. |
import { SingleSelectList } from "./singleselect.list"; |
||||||
* @class BI.SingleSelectLoader |
import { SingleSelectItem, SingleSelectRadioItem } from "@/case"; |
||||||
* @extends Widget |
|
||||||
*/ |
@shortcut() |
||||||
BI.SingleSelectLoader = BI.inherit(BI.Widget, { |
export class SingleSelectLoader extends Widget { |
||||||
|
static xtype = "bi.single_select_loader"; |
||||||
_constants: { |
|
||||||
itemVgap: 5 |
_constants = { itemVgap: 5 }; |
||||||
}, |
|
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
_defaultConfig: function () { |
|
||||||
return BI.extend(BI.SingleSelectLoader.superclass._defaultConfig.apply(this, arguments), { |
_defaultConfig() { |
||||||
|
return extend(super._defaultConfig(...arguments), { |
||||||
baseCls: "bi-single-select-loader", |
baseCls: "bi-single-select-loader", |
||||||
logic: { |
logic: { |
||||||
dynamic: true |
dynamic: true, |
||||||
}, |
}, |
||||||
el: { |
el: { |
||||||
height: 400 |
height: 400, |
||||||
}, |
}, |
||||||
allowNoSelect: false, |
allowNoSelect: false, |
||||||
valueFormatter: BI.emptyFn, |
valueFormatter: emptyFn, |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
itemWrapper: BI.emptyFn, |
itemWrapper: emptyFn, |
||||||
onLoaded: BI.emptyFn |
onLoaded: emptyFn, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_init: function () { |
_init() { |
||||||
BI.SingleSelectLoader.superclass._init.apply(this, arguments); |
super._init(...arguments); |
||||||
|
|
||||||
var self = this, opts = this.options; |
const self = this, |
||||||
var hasNext = false; |
opts = this.options; |
||||||
|
let hasNext = false; |
||||||
this.storeValue = opts.value; |
this.storeValue = opts.value; |
||||||
this.button_group = BI.createWidget({ |
this.button_group = createWidget({ |
||||||
type: "bi.single_select_list", |
type: SingleSelectList.xtype, |
||||||
allowNoSelect: opts.allowNoSelect, |
allowNoSelect: opts.allowNoSelect, |
||||||
logic: opts.logic, |
logic: opts.logic, |
||||||
el: BI.extend({ |
el: extend( |
||||||
onLoaded: opts.onLoaded, |
{ |
||||||
el: { |
onLoaded: opts.onLoaded, |
||||||
type: "bi.loader", |
|
||||||
isDefaultInit: false, |
|
||||||
logic: { |
|
||||||
dynamic: true, |
|
||||||
scrolly: true |
|
||||||
}, |
|
||||||
el: { |
el: { |
||||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, |
type: Loader.xtype, |
||||||
behaviors: { |
isDefaultInit: false, |
||||||
redmark: function () { |
logic: { |
||||||
return true; |
dynamic: true, |
||||||
} |
scrolly: true, |
||||||
}, |
}, |
||||||
layouts: [{ |
el: { |
||||||
type: "bi.vertical" |
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||||
}] |
behaviors: { |
||||||
} |
redmark () { |
||||||
} |
return true; |
||||||
}, opts.el), |
}, |
||||||
itemsCreator: function (op, callback) { |
}, |
||||||
var startValue = self._startValue; |
layouts: [ |
||||||
!BI.isUndefined(self.storeValue) && (op = BI.extend(op || {}, { |
{ |
||||||
selectedValues: [self.storeValue] |
type: VerticalLayout.xtype, |
||||||
})); |
} |
||||||
opts.itemsCreator(op, function (ob) { |
], |
||||||
|
}, |
||||||
|
}, |
||||||
|
}, |
||||||
|
opts.el |
||||||
|
), |
||||||
|
itemsCreator (op, callback) { |
||||||
|
const startValue = self._startValue; |
||||||
|
!isUndefined(self.storeValue) && |
||||||
|
(op = extend(op || {}, { |
||||||
|
selectedValues: [self.storeValue], |
||||||
|
})); |
||||||
|
opts.itemsCreator(op, ob => { |
||||||
hasNext = ob.hasNext; |
hasNext = ob.hasNext; |
||||||
var firstItems = []; |
let firstItems = []; |
||||||
if (op.times === 1 && !BI.isUndefined(self.storeValue)) { |
if (op.times === 1 && !isUndefined(self.storeValue)) { |
||||||
var json = BI.map([self.storeValue], function (i, v) { |
const json = map([self.storeValue], (i, v) => { |
||||||
var txt = opts.valueFormatter(v) || v; |
const txt = opts.valueFormatter(v) || v; |
||||||
return opts.itemWrapper({ |
|
||||||
text: txt, |
return ( |
||||||
value: v, |
opts.itemWrapper({ |
||||||
title: txt, |
text: txt, |
||||||
selected: true |
value: v, |
||||||
}) || { |
title: txt, |
||||||
text: txt, |
selected: true, |
||||||
value: v, |
}) || { |
||||||
title: txt, |
text: txt, |
||||||
selected: true |
value: v, |
||||||
}; |
title: txt, |
||||||
|
selected: true, |
||||||
|
} |
||||||
|
); |
||||||
}); |
}); |
||||||
firstItems = self._createItems(json); |
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) { |
if (op.times === 1 && self.storeValue) { |
||||||
BI.isKey(startValue) && (self.storeValue = startValue); |
isKey(startValue) && (self.storeValue = startValue); |
||||||
self.setValue(self.storeValue); |
self.setValue(self.storeValue); |
||||||
} |
} |
||||||
(op.times === 1) && self._scrollToTop(); |
op.times === 1 && self._scrollToTop(); |
||||||
}); |
}); |
||||||
}, |
}, |
||||||
hasNext: function () { |
hasNext () { |
||||||
return hasNext; |
return hasNext; |
||||||
}, |
}, |
||||||
value: this.storeValue |
value: this.storeValue, |
||||||
}); |
}); |
||||||
|
|
||||||
BI.createWidget({ |
createWidget({ |
||||||
type: "bi.vertical", |
type: VerticalLayout.xtype, |
||||||
element: this, |
element: this, |
||||||
items: [this.button_group], |
items: [this.button_group], |
||||||
vgap: this._constants.itemVgap |
vgap: this._constants.itemVgap, |
||||||
}); |
}); |
||||||
|
|
||||||
this.button_group.on(BI.Controller.EVENT_CHANGE, function () { |
this.button_group.on(Controller.EVENT_CHANGE, function () { |
||||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
||||||
}); |
}); |
||||||
this.button_group.on(BI.SingleSelectList.EVENT_CHANGE, function () { |
this.button_group.on(SingleSelectList.EVENT_CHANGE, function () { |
||||||
self.fireEvent(BI.SingleSelectLoader.EVENT_CHANGE, arguments); |
self.fireEvent(SingleSelectLoader.EVENT_CHANGE, arguments); |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_createItems: function (items) { |
_createItems(items) { |
||||||
var o = this.options; |
const o = this.options; |
||||||
return BI.map(items, function (i, item) { |
|
||||||
return BI.extend({ |
return map(items, (i, item) => extend( |
||||||
type: o.allowNoSelect ? "bi.single_select_item" : "bi.single_select_radio_item", |
{ |
||||||
|
type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype, |
||||||
logic: o.logic, |
logic: o.logic, |
||||||
cls: "bi-list-item-active", |
cls: "bi-list-item-active", |
||||||
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
||||||
selected: false, |
selected: false, |
||||||
iconWrapperWidth: 26, |
iconWrapperWidth: 26, |
||||||
textHgap: o.allowNoSelect ? 10 : 0, |
textHgap: o.allowNoSelect ? 10 : 0, |
||||||
title: item.title || item.text |
title: item.title || item.text, |
||||||
}, item); |
}, |
||||||
}); |
item |
||||||
}, |
)); |
||||||
|
} |
||||||
|
|
||||||
_scrollToTop: function () { |
_scrollToTop() { |
||||||
var self = this; |
const self = this; |
||||||
BI.delay(function () { |
delay(() => { |
||||||
self.button_group.element.scrollTop(0); |
self.button_group.element.scrollTop(0); |
||||||
}, 30); |
}, 30); |
||||||
}, |
} |
||||||
|
|
||||||
_assertValue: function (val) { |
_assertValue(val) {} |
||||||
}, |
|
||||||
|
|
||||||
setStartValue: function (v) { |
setStartValue(v) { |
||||||
this._startValue = v; |
this._startValue = v; |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
this.storeValue = v; |
this.storeValue = v; |
||||||
this._assertValue(this.storeValue); |
this._assertValue(this.storeValue); |
||||||
this.button_group.setValue(this.storeValue); |
this.button_group.setValue(this.storeValue); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.button_group.getValue(); |
return this.button_group.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
getAllButtons: function () { |
getAllButtons() { |
||||||
return this.button_group.getAllButtons(); |
return this.button_group.getAllButtons(); |
||||||
}, |
} |
||||||
|
|
||||||
empty: function () { |
empty() { |
||||||
this.button_group.empty(); |
this.button_group.empty(); |
||||||
}, |
} |
||||||
|
|
||||||
populate: function (items) { |
populate(items) { |
||||||
this.button_group.populate.apply(this.button_group, arguments); |
this.button_group.populate(...arguments); |
||||||
}, |
} |
||||||
|
|
||||||
resetHeight: function (h) { |
resetHeight(h) { |
||||||
this.button_group.resetHeight(h - this._constants.itemVgap * 2); |
this.button_group.resetHeight(h - this._constants.itemVgap * 2); |
||||||
}, |
} |
||||||
|
|
||||||
resetWidth: function (w) { |
resetWidth(w) { |
||||||
this.button_group.resetWidth(w); |
this.button_group.resetWidth(w); |
||||||
} |
} |
||||||
}); |
} |
||||||
|
|
||||||
BI.SingleSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.shortcut("bi.single_select_loader", BI.SingleSelectLoader); |
|
||||||
|
@ -1,84 +1,82 @@ |
|||||||
/** |
import { shortcut, Widget, extend, emptyFn, createWidget } from "@/core"; |
||||||
* 带加载的单选下拉面板 |
import { MultiPopupView } from "@/case"; |
||||||
* @class BI.SingleSelectPopupView |
import { PopupView } from "@/base"; |
||||||
* @extends Widget |
|
||||||
*/ |
|
||||||
BI.SingleSelectPopupView = BI.inherit(BI.Widget, { |
|
||||||
|
|
||||||
_defaultConfig: function () { |
@shortcut() |
||||||
return BI.extend(BI.SingleSelectPopupView.superclass._defaultConfig.apply(this, arguments), { |
export class SingleSelectPopupView extends Widget { |
||||||
|
static xtype = "bi.single_select_popup_view"; |
||||||
|
|
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
|
||||||
|
_defaultConfig() { |
||||||
|
return extend(super._defaultConfig(...arguments), { |
||||||
baseCls: "bi-single-select-popup-view", |
baseCls: "bi-single-select-popup-view", |
||||||
allowNoSelect: false, |
allowNoSelect: false, |
||||||
maxWidth: "auto", |
maxWidth: "auto", |
||||||
minWidth: 135, |
minWidth: 135, |
||||||
maxHeight: 400, |
maxHeight: 400, |
||||||
valueFormatter: BI.emptyFn, |
valueFormatter: emptyFn, |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
itemWrapper: BI.emptyFn, |
itemWrapper: emptyFn, |
||||||
onLoaded: BI.emptyFn |
onLoaded: emptyFn, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_init: function () { |
_init() { |
||||||
BI.SingleSelectPopupView.superclass._init.apply(this, arguments); |
super._init(...arguments); |
||||||
var self = this, opts = this.options; |
const opts = this.options; |
||||||
|
|
||||||
this.loader = BI.createWidget({ |
this.loader = createWidget({ |
||||||
type: "bi.single_select_loader", |
type: "bi.single_select_loader", |
||||||
allowNoSelect: opts.allowNoSelect, |
allowNoSelect: opts.allowNoSelect, |
||||||
itemsCreator: opts.itemsCreator, |
itemsCreator: opts.itemsCreator, |
||||||
itemWrapper: opts.itemWrapper, |
itemWrapper: opts.itemWrapper, |
||||||
valueFormatter: opts.valueFormatter, |
valueFormatter: opts.valueFormatter, |
||||||
onLoaded: opts.onLoaded, |
onLoaded: opts.onLoaded, |
||||||
value: opts.value |
value: opts.value, |
||||||
}); |
}); |
||||||
|
|
||||||
this.popupView = BI.createWidget({ |
this.popupView = createWidget({ |
||||||
type: "bi.popup_view", |
type: PopupView.xtype, |
||||||
stopPropagation: false, |
stopPropagation: false, |
||||||
maxWidth: opts.maxWidth, |
maxWidth: opts.maxWidth, |
||||||
minWidth: opts.minWidth, |
minWidth: opts.minWidth, |
||||||
maxHeight: opts.maxHeight, |
maxHeight: opts.maxHeight, |
||||||
element: this, |
element: this, |
||||||
el: this.loader, |
el: this.loader, |
||||||
value: opts.value |
value: opts.value, |
||||||
}); |
}); |
||||||
|
|
||||||
this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { |
this.popupView.on(MultiPopupView.EVENT_CHANGE, () => { |
||||||
self.fireEvent(BI.SingleSelectPopupView.EVENT_CHANGE); |
this.fireEvent(SingleSelectPopupView.EVENT_CHANGE); |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
setStartValue: function (v) { |
setStartValue(v) { |
||||||
this.loader.setStartValue(v); |
this.loader.setStartValue(v); |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
this.popupView.setValue(v); |
this.popupView.setValue(v); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.popupView.getValue(); |
return this.popupView.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
populate: function (items) { |
populate(items) { |
||||||
this.popupView.populate.apply(this.popupView, arguments); |
this.popupView.populate(...arguments); |
||||||
}, |
} |
||||||
|
|
||||||
resetHeight: function (h) { |
resetHeight(h) { |
||||||
this.popupView.resetHeight(h); |
this.popupView.resetHeight(h); |
||||||
}, |
} |
||||||
|
|
||||||
resetWidth: function (w) { |
resetWidth(w) { |
||||||
this.popupView.resetWidth(w); |
this.popupView.resetWidth(w); |
||||||
}, |
} |
||||||
|
|
||||||
setDirection: function (direction, position) { |
setDirection(direction, position) { |
||||||
this.popupView.setDirection(direction, position); |
this.popupView.setDirection(direction, position); |
||||||
}, |
} |
||||||
}); |
} |
||||||
|
|
||||||
BI.SingleSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
|
|
||||||
|
|
||||||
BI.shortcut("bi.single_select_popup_view", BI.SingleSelectPopupView); |
|
||||||
|
@ -0,0 +1,2 @@ |
|||||||
|
export { SingleSelectEditor } from "./editor.singleselect"; |
||||||
|
export { SingleSelectSearcher } from "./searcher.singleselect"; |
@ -1,162 +1,161 @@ |
|||||||
/** |
import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, isUndefined, Selection } from "@/core"; |
||||||
* searcher |
import { SingleSelectEditor } from "./editor.singleselect"; |
||||||
* Created by guy on 15/11/3. |
import { Searcher } from "@/base"; |
||||||
* @class BI.SingleSelectSearcher |
|
||||||
* @extends Widget |
@shortcut() |
||||||
*/ |
export class SingleSelectSearcher extends Widget { |
||||||
BI.SingleSelectSearcher = BI.inherit(BI.Widget, { |
static xtype = "bi.single_select_searcher"; |
||||||
|
|
||||||
_defaultConfig: function () { |
static EVENT_FOCUS = "EVENT_FOCUS"; |
||||||
return BI.extend(BI.SingleSelectSearcher.superclass._defaultConfig.apply(this, arguments), { |
static EVENT_BLUR = "EVENT_BLUR"; |
||||||
|
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
static EVENT_START = "EVENT_START"; |
||||||
|
static EVENT_STOP = "EVENT_STOP"; |
||||||
|
static EVENT_PAUSE = "EVENT_PAUSE"; |
||||||
|
static EVENT_SEARCHING = "EVENT_SEARCHING"; |
||||||
|
|
||||||
|
_defaultConfig() { |
||||||
|
return extend(super._defaultConfig(...arguments), { |
||||||
baseCls: "bi-single-select-searcher", |
baseCls: "bi-single-select-searcher", |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
el: {}, |
el: {}, |
||||||
popup: {}, |
popup: {}, |
||||||
valueFormatter: BI.emptyFn, |
valueFormatter: emptyFn, |
||||||
adapter: null, |
adapter: null, |
||||||
masker: {}, |
masker: {}, |
||||||
allowNoSelect: false |
allowNoSelect: false, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_init: function () { |
_init() { |
||||||
BI.SingleSelectSearcher.superclass._init.apply(this, arguments); |
super._init(...arguments); |
||||||
var self = this, o = this.options; |
const self = this, |
||||||
this.editor = BI.createWidget(o.el, { |
o = this.options; |
||||||
|
this.editor = createWidget(o.el, { |
||||||
type: "bi.single_select_editor", |
type: "bi.single_select_editor", |
||||||
height: o.height, |
height: o.height, |
||||||
watermark: o.watermark, |
watermark: o.watermark, |
||||||
text: o.text, |
text: o.text, |
||||||
listeners: [{ |
listeners: [{ |
||||||
eventName: BI.SingleSelectEditor.EVENT_FOCUS, |
eventName: SingleSelectEditor.EVENT_FOCUS, |
||||||
action: function () { |
action: () => { |
||||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_FOCUS); |
this.fireEvent(SingleSelectSearcher.EVENT_FOCUS); |
||||||
} |
}, |
||||||
}, { |
}, |
||||||
eventName: BI.SingleSelectEditor.EVENT_BLUR, |
{ |
||||||
action: function () { |
eventName: SingleSelectEditor.EVENT_BLUR, |
||||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_BLUR); |
action: () => { |
||||||
} |
this.fireEvent(SingleSelectSearcher.EVENT_BLUR); |
||||||
}] |
}, |
||||||
|
} |
||||||
|
], |
||||||
}); |
}); |
||||||
|
|
||||||
this.searcher = BI.createWidget({ |
this.searcher = createWidget({ |
||||||
type: "bi.searcher", |
type: Searcher.xtype, |
||||||
element: this, |
element: this, |
||||||
height: o.height, |
height: o.height, |
||||||
isAutoSearch: false, |
isAutoSearch: false, |
||||||
isAutoSync: false, |
isAutoSync: false, |
||||||
onSearch: function (op, callback) { |
onSearch(op, callback) { |
||||||
callback(); |
callback(); |
||||||
}, |
}, |
||||||
el: this.editor, |
el: this.editor, |
||||||
|
|
||||||
popup: BI.extend({ |
popup: extend({ |
||||||
type: "bi.single_select_search_pane", |
type: "bi.single_select_search_pane", |
||||||
allowNoSelect: o.allowNoSelect, |
allowNoSelect: o.allowNoSelect, |
||||||
valueFormatter: o.valueFormatter, |
valueFormatter: o.valueFormatter, |
||||||
keywordGetter: function () { |
keywordGetter: () => this.editor.getValue(), |
||||||
return self.editor.getValue(); |
itemsCreator(op, callback) { |
||||||
}, |
const keyword = self.editor.getValue(); |
||||||
itemsCreator: function (op, callback) { |
|
||||||
var keyword = self.editor.getValue(); |
|
||||||
op.keywords = [keyword]; |
op.keywords = [keyword]; |
||||||
this.setKeyword(keyword); |
this.setKeyword(keyword); |
||||||
o.itemsCreator(op, callback); |
o.itemsCreator(op, callback); |
||||||
}, |
}, |
||||||
value: o.value |
value: o.value, |
||||||
}, o.popup), |
}, |
||||||
|
o.popup |
||||||
|
), |
||||||
|
|
||||||
adapter: o.adapter, |
adapter: o.adapter, |
||||||
masker: o.masker |
masker: o.masker, |
||||||
}); |
}); |
||||||
this.searcher.on(BI.Searcher.EVENT_START, function () { |
this.searcher.on(Searcher.EVENT_START, () => { |
||||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_START); |
this.fireEvent(SingleSelectSearcher.EVENT_START); |
||||||
}); |
}); |
||||||
this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { |
this.searcher.on(Searcher.EVENT_PAUSE, () => { |
||||||
if (this.hasMatched()) { |
this.fireEvent(SingleSelectSearcher.EVENT_PAUSE); |
||||||
|
|
||||||
} |
|
||||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_PAUSE); |
|
||||||
}); |
}); |
||||||
this.searcher.on(BI.Searcher.EVENT_STOP, function () { |
this.searcher.on(Searcher.EVENT_STOP, () => { |
||||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_STOP); |
this.fireEvent(SingleSelectSearcher.EVENT_STOP); |
||||||
}); |
}); |
||||||
this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { |
this.searcher.on(Searcher.EVENT_CHANGE, (...args) => { |
||||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_CHANGE, arguments); |
this.fireEvent(SingleSelectSearcher.EVENT_CHANGE, ...args); |
||||||
}); |
}); |
||||||
this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { |
this.searcher.on(Searcher.EVENT_SEARCHING, () => { |
||||||
var keywords = this.getKeywords(); |
const keywords = this.searcher.getKeywords(); |
||||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_SEARCHING, keywords); |
this.fireEvent(SingleSelectSearcher.EVENT_SEARCHING, keywords); |
||||||
}); |
}); |
||||||
|
|
||||||
if(BI.isNotNull(o.value)){ |
if (isNotNull(o.value)) { |
||||||
this.setState(o.value); |
this.setState(o.value); |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
adjustView: function () { |
adjustView() { |
||||||
this.searcher.adjustView(); |
this.searcher.adjustView(); |
||||||
}, |
} |
||||||
|
|
||||||
isSearching: function () { |
isSearching() { |
||||||
return this.searcher.isSearching(); |
return this.searcher.isSearching(); |
||||||
}, |
} |
||||||
|
|
||||||
stopSearch: function () { |
stopSearch() { |
||||||
this.searcher.stopSearch(); |
this.searcher.stopSearch(); |
||||||
}, |
} |
||||||
|
|
||||||
getKeyword: function () { |
getKeyword() { |
||||||
return this.editor.getKeyword(); |
return this.editor.getKeyword(); |
||||||
}, |
} |
||||||
|
|
||||||
hasMatched: function () { |
hasMatched() { |
||||||
return this.searcher.hasMatched(); |
return this.searcher.hasMatched(); |
||||||
}, |
} |
||||||
|
|
||||||
hasChecked: function () { |
hasChecked() { |
||||||
return this.searcher.getView() && this.searcher.getView().hasChecked(); |
return this.searcher.getView() && this.searcher.getView().hasChecked(); |
||||||
}, |
} |
||||||
|
|
||||||
setAdapter: function (adapter) { |
setAdapter(adapter) { |
||||||
this.searcher.setAdapter(adapter); |
this.searcher.setAdapter(adapter); |
||||||
}, |
} |
||||||
|
|
||||||
setState: function (v) { |
setState(v) { |
||||||
var o = this.options; |
const o = this.options; |
||||||
if (BI.isUndefined(v)) { |
if (isUndefined(v)) { |
||||||
this.editor.setState(BI.Selection.None); |
this.editor.setState(Selection.None); |
||||||
} else { |
} else { |
||||||
v = v ?? ""; |
v = v ?? ""; |
||||||
this.editor.setState(o.valueFormatter(v + "") || (v + "")); |
this.editor.setState(o.valueFormatter(`${v}`) || `${v}`); |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (ob) { |
setValue(ob) { |
||||||
this.setState(ob); |
this.setState(ob); |
||||||
this.searcher.setValue(ob); |
this.searcher.setValue(ob); |
||||||
}, |
} |
||||||
|
|
||||||
getKey: function () { |
getKey() { |
||||||
return this.editor.getValue(); |
return this.editor.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.searcher.getValue(); |
return this.searcher.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
populate: function (items) { |
populate(items) { |
||||||
this.searcher.populate.apply(this.searcher, arguments); |
this.searcher.populate(...arguments); |
||||||
} |
} |
||||||
}); |
} |
||||||
|
|
||||||
BI.SingleSelectSearcher.EVENT_FOCUS = "EVENT_FOCUS"; |
|
||||||
BI.SingleSelectSearcher.EVENT_BLUR = "EVENT_BLUR"; |
|
||||||
BI.SingleSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
|
||||||
BI.SingleSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.SingleSelectSearcher.EVENT_START = "EVENT_START"; |
|
||||||
BI.SingleSelectSearcher.EVENT_STOP = "EVENT_STOP"; |
|
||||||
BI.SingleSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; |
|
||||||
BI.SingleSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; |
|
||||||
BI.shortcut("bi.single_select_searcher", BI.SingleSelectSearcher); |
|
||||||
|
Loading…
Reference in new issue