mirror of
https://github.com/TryGhost/Ghost-Admin.git
synced 2023-12-14 02:33:04 +01:00
7bd38066f7
closes TryGhost/Ghost#9477 - remove ember-invoke-action in favor of straight function calls
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
import Component from '@ember/component';
|
|
import RSVP from 'rsvp';
|
|
import {computed} from '@ember/object';
|
|
import {A as emberA} from '@ember/array';
|
|
import {isBlank} from '@ember/utils';
|
|
import {run} from '@ember/runloop';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
const FullScreenModalComponent = Component.extend({
|
|
dropdown: service(),
|
|
|
|
model: null,
|
|
modifier: null,
|
|
|
|
modalPath: computed('modal', function () {
|
|
return `modal-${this.get('modal') || 'unknown'}`;
|
|
}),
|
|
|
|
modalClasses: computed('modifiers', function () {
|
|
let modalClass = 'fullscreen-modal';
|
|
let modifiers = (this.get('modifier') || '').split(' ');
|
|
let modalClasses = emberA([modalClass]);
|
|
|
|
modifiers.forEach((modifier) => {
|
|
if (!isBlank(modifier)) {
|
|
let className = `${modalClass}-${modifier}`;
|
|
modalClasses.push(className);
|
|
}
|
|
});
|
|
|
|
return modalClasses.join(' ');
|
|
}),
|
|
|
|
didInsertElement() {
|
|
run.schedule('afterRender', this, function () {
|
|
this.get('dropdown').closeDropdowns();
|
|
});
|
|
},
|
|
|
|
actions: {
|
|
close() {
|
|
return this.close();
|
|
},
|
|
|
|
confirm() {
|
|
return this.confirm();
|
|
},
|
|
|
|
clickOverlay() {
|
|
this.send('close');
|
|
}
|
|
},
|
|
|
|
// Allowed actions
|
|
close: () => RSVP.resolve(),
|
|
confirm: () => RSVP.resolve()
|
|
});
|
|
|
|
FullScreenModalComponent.reopenClass({
|
|
positionalParams: ['modal']
|
|
});
|
|
|
|
export default FullScreenModalComponent;
|