mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
89b9f6cfc6
no issue Unsaved changes handling hadn't been moved across fully to the payments screen when settings were re-jigged meaning changes on the payments screen would make settings dirty and show unsaved changes modal unexpectedly on other screens. - refactored `members-payments` route to use native classes - used same unsaved changes pattern as `members-access` route/controller
55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
/* eslint-disable ghost/ember/alias-model-in-controller */
|
|
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 MembersPaymentsController extends Controller {
|
|
@service settings;
|
|
|
|
@tracked showLeaveSettingsModal = false;
|
|
|
|
@action
|
|
setDefaultContentVisibility(value) {
|
|
this.settings.set('defaultContentVisibility', value);
|
|
}
|
|
|
|
@action
|
|
setStripeConnectIntegrationTokenSetting(stripeConnectIntegrationToken) {
|
|
this.settings.set('stripeConnectIntegrationToken', stripeConnectIntegrationToken);
|
|
}
|
|
|
|
@task({drop: true})
|
|
*saveSettings() {
|
|
return yield this.settings.save();
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
reset() {
|
|
// stripeConnectIntegrationToken is not a persisted value so we don't want
|
|
// to keep it around across transitions
|
|
this.settings.set('stripeConnectIntegrationToken', undefined);
|
|
}
|
|
}
|