Browse Source

无JIRA任务 fix: 修复pane.list的bug

es6
Zhenfei.Li 2 years ago
parent
commit
80db0a5eee
  1. 51
      src/base/combination/group.button.js
  2. 3
      src/case/layer/pane.list.js

51
src/base/combination/group.button.js

@ -31,7 +31,7 @@ export class ButtonGroup extends Widget {
const behaviors = {}; const behaviors = {};
each(optionsBehaviors, (key, rule) => { each(optionsBehaviors, (key, rule) => {
behaviors[key] = BI.BehaviorFactory.createBehavior(key, { behaviors[key] = BI.BehaviorFactory.createBehavior(key, {
rule: rule, rule,
}); });
}); });
this.behaviors = behaviors; this.behaviors = behaviors;
@ -65,25 +65,26 @@ export class ButtonGroup extends Widget {
args[0] = buttons; args[0] = buttons;
each(this.behaviors, (i, behavior) => { each(this.behaviors, (i, behavior) => {
behavior.doBehavior.apply(behavior, args); behavior.doBehavior(...args);
}); });
each(buttons, (i, btn) => { each(buttons, (i, btn) => {
btn.on(Controller.EVENT_CHANGE, (type, value, obj, ...arg) => { btn.on(Controller.EVENT_CHANGE, (...arg) => {
const [type, value, obj] = arg;
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
switch (chooseType) { switch (chooseType) {
case ButtonGroup.CHOOSE_TYPE_SINGLE: case ButtonGroup.CHOOSE_TYPE_SINGLE:
this.setValue(btn.getValue()); this.setValue(btn.getValue());
break; break;
case ButtonGroup.CHOOSE_TYPE_NONE: case ButtonGroup.CHOOSE_TYPE_NONE:
this.setValue([]); this.setValue([]);
break; break;
default: default:
break; break;
} }
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...arg); this.fireEvent(Controller.EVENT_CHANGE, ...arg);
this.fireEvent(ButtonGroup.EVENT_CHANGE, value, obj); this.fireEvent(ButtonGroup.EVENT_CHANGE, value, obj);
} else { } else {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...arg); this.fireEvent(Controller.EVENT_CHANGE, ...arg);
} }
}); });
btn.on(BI.Events.DESTROY, () => { btn.on(BI.Events.DESTROY, () => {
@ -98,15 +99,13 @@ export class ButtonGroup extends Widget {
const { layouts: optionsLayouts } = this.options; const { layouts: optionsLayouts } = this.options;
const layouts = isArray(optionsLayouts) ? optionsLayouts : [optionsLayouts]; const layouts = isArray(optionsLayouts) ? optionsLayouts : [optionsLayouts];
for (let i = layouts.length - 1; i > 0; i--) { for (let i = layouts.length - 1; i > 0; i--) {
btns = map(btns, (k, it) => { btns = map(btns, (k, it) => extend({}, layouts[i], {
return extend({}, layouts[i], { items: [
items: [ extend({}, layouts[i].el, {
extend({}, layouts[i].el, { el: it,
el: it, })
}) ],
], }));
});
});
} }
return btns; return btns;
@ -154,12 +153,12 @@ export class ButtonGroup extends Widget {
const args = Array.prototype.slice.call(arguments); const args = Array.prototype.slice.call(arguments);
args.unshift(this.buttons); args.unshift(this.buttons);
each(this.behaviors, (i, behavior) => { each(this.behaviors, (i, behavior) => {
behavior.doBehavior.apply(behavior, args); behavior.doBehavior(...args);
}); });
} }
prependItems(items) { prependItems(items) {
const btns = this._btnsCreator.apply(this, arguments); const btns = this._btnsCreator(...arguments);
this.buttons = concat(btns, this.buttons); this.buttons = concat(btns, this.buttons);
if (this._isSimpleLayout() && this.layouts && this.layouts.prependItems) { if (this._isSimpleLayout() && this.layouts && this.layouts.prependItems) {
@ -173,7 +172,7 @@ export class ButtonGroup extends Widget {
} }
addItems(items) { addItems(items) {
const btns = this._btnsCreator.apply(this, arguments); const btns = this._btnsCreator(...arguments);
this.buttons = concat(this.buttons, btns); this.buttons = concat(this.buttons, btns);
// 如果是一个简单的layout // 如果是一个简单的layout
@ -209,7 +208,7 @@ export class ButtonGroup extends Widget {
this.empty(); this.empty();
this.options.items = items; this.options.items = items;
this.buttons = this._btnsCreator.apply(this, arguments); this.buttons = this._btnsCreator(...arguments);
if (this._isSimpleLayout()) { if (this._isSimpleLayout()) {
items = this._packageSimpleItems(this.buttons); items = this._packageSimpleItems(this.buttons);
} else { } else {

3
src/case/layer/pane.list.js

@ -69,7 +69,8 @@ export class ListPane extends Pane {
}], }],
}); });
this.button_group.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => { this.button_group.on(Controller.EVENT_CHANGE, (...args) => {
const [type, value, obj] = args;
this.fireEvent(Controller.EVENT_CHANGE, ...args); this.fireEvent(Controller.EVENT_CHANGE, ...args);
if (type === Events.CLICK) { if (type === Events.CLICK) {
this.fireEvent(ListPane.EVENT_CHANGE, value, obj); this.fireEvent(ListPane.EVENT_CHANGE, value, obj);

Loading…
Cancel
Save