DEV: Call onClose for closing modals.

This commit is contained in:
Dan Ungureanu 2018-11-20 18:02:07 +02:00 committed by Sam
parent 0005bded6c
commit d657ce844b
2 changed files with 8 additions and 0 deletions

View File

@ -39,6 +39,7 @@ export default function(name, opts) {
modalController.set("modalClass", opts.modalClass);
const controllerName = opts.admin ? `modals/${name}` : name;
modalController.set("name", controllerName);
let controller = container.lookup("controller:" + controllerName);
const templateName = opts.templateName || Ember.String.dasherize(name);

View File

@ -144,6 +144,13 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
// Close the current modal, and destroy its state.
closeModal() {
this.render("hide-modal", { into: "modal", outlet: "modalBody" });
const route = getOwner(this).lookup("route:application");
const name = route.controllerFor("modal").get("name");
const controller = getOwner(this).lookup(`controller:${name}`);
if (controller && controller.onClose) {
controller.onClose();
}
},
/**