mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 16:42:17 +03:00
85d7932e45
refs https://github.com/TryGhost/Team/issues/559
refs 054a5f15f5
- with the update of `ember-promise-modals` we started to get deprecation warnings when using `modals.open('modal-component-name')`
- upcoming Ember build updates will introduce tree shaking but using run-time lookup of modal components by name works against that because it's not statically analysable
- switched to importing components and passing the component class directly, eg. `modals.open(ModalComponent)`
- standardized modal component class names with a `MyModal` style to get better behaviour in code editors when it auto generates imports
- dropped the modal defaults from the modals service because we can now use a static `modalOptions` property on the modal components themselves when we want to override the defaults
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {resetQueryParams} from 'ghost-admin/helpers/reset-query-params';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default class CustomViewFormModal extends Component {
|
|
@service customViews;
|
|
@service router;
|
|
|
|
static modalOptions = {
|
|
className: 'fullscreen-modal-action fullscreen-modal-narrow'
|
|
};
|
|
|
|
@action
|
|
changeColor(event) {
|
|
const color = event.target.value;
|
|
this.args.data.customView.set('color', color);
|
|
}
|
|
|
|
@action
|
|
validate(property) {
|
|
return this.args.data.customView.validate({property});
|
|
}
|
|
|
|
@task
|
|
*saveTask() {
|
|
const view = yield this.customViews.saveViewTask.perform(this.args.data.customView);
|
|
this.args.close();
|
|
return view;
|
|
}
|
|
|
|
@task
|
|
*deleteTask() {
|
|
const view = yield this.customViews.deleteViewTask.perform(this.args.data.customView);
|
|
|
|
const routeName = this.router.currentRouteName;
|
|
this.router.transitionTo(routeName, {queryParams: resetQueryParams(routeName)});
|
|
|
|
this.args.close();
|
|
return view;
|
|
}
|
|
}
|