2017-08-22 10:53:26 +03:00
|
|
|
import Component from '@ember/component';
|
2016-06-30 21:14:25 +03:00
|
|
|
import RSVP from 'rsvp';
|
2017-08-22 10:53:26 +03:00
|
|
|
import {computed} from '@ember/object';
|
|
|
|
import {A as emberA} from '@ember/array';
|
|
|
|
import {isBlank} from '@ember/utils';
|
|
|
|
import {run} from '@ember/runloop';
|
2017-10-30 12:38:01 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2015-11-18 13:50:48 +03:00
|
|
|
|
2016-10-07 16:27:39 +03:00
|
|
|
const FullScreenModalComponent = Component.extend({
|
2018-01-11 20:43:23 +03:00
|
|
|
dropdown: service(),
|
2015-11-18 13:50:48 +03:00
|
|
|
|
2016-10-07 16:27:39 +03:00
|
|
|
model: null,
|
|
|
|
modifier: null,
|
2015-11-18 13:50:48 +03:00
|
|
|
|
2016-10-07 16:27:39 +03:00
|
|
|
modalPath: computed('modal', function () {
|
2019-03-06 16:53:54 +03:00
|
|
|
return `modal-${this.modal || 'unknown'}`;
|
2016-10-07 16:27:39 +03:00
|
|
|
}),
|
2015-11-18 13:50:48 +03:00
|
|
|
|
2021-05-17 18:14:38 +03:00
|
|
|
modalClasses: computed('modifier', function () {
|
2016-10-07 16:27:39 +03:00
|
|
|
let modalClass = 'fullscreen-modal';
|
2019-03-06 16:53:54 +03:00
|
|
|
let modifiers = (this.modifier || '').split(' ');
|
2016-10-07 16:27:39 +03:00
|
|
|
let modalClasses = emberA([modalClass]);
|
2015-11-18 13:50:48 +03:00
|
|
|
|
|
|
|
modifiers.forEach((modifier) => {
|
|
|
|
if (!isBlank(modifier)) {
|
2016-10-07 16:27:39 +03:00
|
|
|
let className = `${modalClass}-${modifier}`;
|
|
|
|
modalClasses.push(className);
|
2015-11-18 13:50:48 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-10-07 16:27:39 +03:00
|
|
|
return modalClasses.join(' ');
|
2015-11-18 13:50:48 +03:00
|
|
|
}),
|
|
|
|
|
2017-01-10 14:49:15 +03:00
|
|
|
didInsertElement() {
|
2021-07-15 17:27:29 +03:00
|
|
|
this._super(...arguments);
|
2015-11-18 13:50:48 +03:00
|
|
|
run.schedule('afterRender', this, function () {
|
2019-03-06 16:53:54 +03:00
|
|
|
this.dropdown.closeDropdowns();
|
2015-11-18 13:50:48 +03:00
|
|
|
});
|
2017-01-10 14:49:15 +03:00
|
|
|
},
|
2015-11-18 13:50:48 +03:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
close() {
|
2020-07-23 16:14:50 +03:00
|
|
|
return this.close(...arguments);
|
2015-11-18 13:50:48 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
confirm() {
|
2020-07-23 16:14:50 +03:00
|
|
|
return this.confirm(...arguments);
|
2015-11-18 13:50:48 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
clickOverlay() {
|
|
|
|
this.send('close');
|
|
|
|
}
|
2018-03-20 17:57:59 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
// Allowed actions
|
|
|
|
close: () => RSVP.resolve(),
|
|
|
|
confirm: () => RSVP.resolve()
|
2015-11-18 13:50:48 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
export default FullScreenModalComponent;
|