mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-03 03:55:26 +03:00
ed48cd6e3a
refs https://github.com/TryGhost/Team/issues/559 refs https://github.com/TryGhost/Admin/pull/2227 - updated modal component to use newer ember-promise-modals modals implementation - removed use of "delayedColor" properties as the workaround for liquid-fire based animation is no longer required - added `validate` action to remove need for `{{action}}` - we can't call the `validate()` method directly from the template because it's not bound correctly with `@action` and binding it breaks other code that expects `_super()` for the validate method to work via the mixin (eg, staff invite modal) - removed `customViews.toggleFormModal()`` and changed `customViews.editView()` to open the modal directly - updated templates to use `{{on "click" this.customViews.editView}}` in place of toggling the "showFormModal" property
40 lines
1.1 KiB
JavaScript
40 lines
1.1 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-decorators';
|
|
|
|
export default class CustomViewFormModal extends Component {
|
|
@service customViews;
|
|
@service router;
|
|
|
|
@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;
|
|
}
|
|
}
|