mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 18:52:05 +03:00
8cc4c6c4a1
no issue - since `ember-concurrency@2.0` it's possible to use the standard imports as decorators removing the need for the extra `ember-concurrency-decorators` dependency and imports
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';
|
|
|
|
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;
|
|
}
|
|
}
|