ember-promise-modals
Version:
The better way to handle modals in your Ember.js apps.
35 lines (32 loc) • 858 B
JavaScript
import Helper from '@ember/component/helper';
import { inject } from '@ember/service';
import { g, i } from 'decorator-transforms/runtime';
class OpenModalHelper extends Helper {
static {
g(this.prototype, "modals", [inject]);
}
#modals = (i(this, "modals"), void 0);
modal = null;
compute([modalComponent, data, options], {
close
}) {
this.showModal(modalComponent, data, options, close);
}
async showModal(modalComponent, data, options, close) {
this.modal = this.modals.open(modalComponent, data, options);
let success = await this.modal;
this.modal = null;
if (close) {
close(success);
}
}
hideModal() {
this.modal?.close();
}
willDestroy() {
this.hideModal();
super.willDestroy(...arguments);
}
}
export { OpenModalHelper as default };
//# sourceMappingURL=open-modal.js.map