MODAL: Untangle `onSelectPanel`

Previously modal-tab component would call on click the onSelectPanel callback with itself (modal-tab) as `this` which severely limited its usefulness. Now showModal binds the callback to its controller.
This commit is contained in:
Jarek Radosz 2020-07-04 14:09:55 +02:00
parent 126a1f550a
commit b7f6ec60c5
3 changed files with 9 additions and 6 deletions

View File

@ -20,6 +20,10 @@ export default Component.extend({
}, },
click() { click() {
this.onSelectPanel(this.panel); this.set("selectedPanel", this.panel);
if (this.onSelectPanel) {
this.onSelectPanel(this.panel);
}
} }
}); });

View File

@ -50,7 +50,10 @@ export default function(name, opts) {
}); });
if (controller.actions.onSelectPanel) { if (controller.actions.onSelectPanel) {
modalController.set("onSelectPanel", controller.actions.onSelectPanel); modalController.set(
"onSelectPanel",
controller.actions.onSelectPanel.bind(controller)
);
} }
modalController.set( modalController.set(

View File

@ -18,10 +18,6 @@ export default Mixin.create({
closeModal() { closeModal() {
this.modal.send("closeModal"); this.modal.send("closeModal");
this.set("panels", []); this.set("panels", []);
},
onSelectPanel(panel) {
this.set("selectedPanel", panel);
} }
} }
}); });