mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
cb59388c5b
no issue - adds `eslint-plugin-sort-imports-es6-autofix` dependency - implements ESLint's base `sort-imports` rule but has a distinction in that `import {foo} from 'bar';` is considered `multiple` rather than `single` - fixes ESLint's autofix behaviour so `eslint --fix` will actually fix the sort order - updates all unordered import rules by using `eslint --fix` With the increased number of `import` statements since Ember+ecosystem started moving towards es6 modules I've found it frustrating at times trying to search through randomly ordered import statements. Recently I've been sorting imports manually when I've added new code or touched old code so I thought I'd add an ESLint rule to codify it.
72 lines
1.8 KiB
JavaScript
72 lines
1.8 KiB
JavaScript
import Component from 'ember-component';
|
|
import RSVP from 'rsvp';
|
|
import computed from 'ember-computed';
|
|
import injectService from 'ember-service/inject';
|
|
import run from 'ember-runloop';
|
|
import {A as emberA} from 'ember-array/utils';
|
|
import {invokeAction} from 'ember-invoke-action';
|
|
import {isBlank} from 'ember-utils';
|
|
|
|
const FullScreenModalComponent = Component.extend({
|
|
|
|
model: null,
|
|
modifier: null,
|
|
|
|
dropdown: injectService(),
|
|
|
|
modalPath: computed('modal', function () {
|
|
return `modals/${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() {
|
|
// Because we return the promise from invokeAction, we have
|
|
// to check if "close" exists first
|
|
if (this.get('close')) {
|
|
return invokeAction(this, 'close');
|
|
}
|
|
|
|
return RSVP.resolve();
|
|
},
|
|
|
|
confirm() {
|
|
if (this.get('confirm')) {
|
|
return invokeAction(this, 'confirm');
|
|
}
|
|
|
|
return RSVP.resolve();
|
|
},
|
|
|
|
clickOverlay() {
|
|
this.send('close');
|
|
}
|
|
}
|
|
});
|
|
|
|
FullScreenModalComponent.reopenClass({
|
|
positionalParams: ['modal']
|
|
});
|
|
|
|
export default FullScreenModalComponent;
|