2021-04-08 15:38:42 +03:00
|
|
|
import Controller from '@ember/controller';
|
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
import {task} from 'ember-concurrency-decorators';
|
|
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
|
|
|
|
export default class ProductController extends Controller {
|
|
|
|
@service settings;
|
|
|
|
|
|
|
|
@tracked showLeaveSettingsModal = false;
|
2021-04-09 14:00:41 +03:00
|
|
|
@tracked showPriceModal = false;
|
2021-04-08 15:38:42 +03:00
|
|
|
|
|
|
|
leaveRoute(transition) {
|
|
|
|
if (this.settings.get('hasDirtyAttributes')) {
|
|
|
|
transition.abort();
|
|
|
|
this.leaveSettingsTransition = transition;
|
|
|
|
this.showLeaveSettingsModal = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
async confirmLeave() {
|
|
|
|
this.settings.rollbackAttributes();
|
|
|
|
this.showLeaveSettingsModal = false;
|
|
|
|
this.leaveSettingsTransition.retry();
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
cancelLeave() {
|
|
|
|
this.showLeaveSettingsModal = false;
|
|
|
|
this.leaveSettingsTransition = null;
|
|
|
|
}
|
|
|
|
|
2021-04-09 14:00:41 +03:00
|
|
|
@action
|
|
|
|
closePriceModal() {
|
|
|
|
this.showPriceModal = false;
|
|
|
|
}
|
|
|
|
|
2021-04-08 15:38:42 +03:00
|
|
|
@task({drop: true})
|
|
|
|
*saveTask() {
|
|
|
|
return yield this.settings.save();
|
|
|
|
}
|
|
|
|
}
|