mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Fixed checkbox state not persisted in wizard
closes https://github.com/TryGhost/Team/issues/676 The checkbox state for portal plans was not stored between wizard pages and kept switching back to original state.
This commit is contained in:
parent
724cbc6123
commit
052c5f62a9
3 changed files with 39 additions and 9 deletions
|
@ -23,11 +23,11 @@ export default class GhLaunchWizardFinaliseComponent extends Component {
|
|||
const yearlyPrice = updatedProduct.get('stripePrices').find(d => d.nickname === 'Yearly');
|
||||
const portalPlans = this.settings.get('portalPlans') || [];
|
||||
let allowedPlans = [...portalPlans];
|
||||
if (data.isMonthlyChecked && monthlyPrice) {
|
||||
if (data.isMonthlyChecked && monthlyPrice && !allowedPlans.includes(monthlyPrice.id)) {
|
||||
allowedPlans.push(monthlyPrice.id);
|
||||
}
|
||||
|
||||
if (data.isYearlyChecked && yearlyPrice) {
|
||||
if (data.isYearlyChecked && yearlyPrice && !allowedPlans.includes(yearlyPrice.id)) {
|
||||
allowedPlans.push(yearlyPrice.id);
|
||||
}
|
||||
this.settings.set('portalPlans', allowedPlans);
|
||||
|
|
|
@ -127,7 +127,7 @@
|
|||
{{/if}}
|
||||
|
||||
<div class="gh-launch-wizard-nav-buttons">
|
||||
<button type="button" class="gh-btn gh-btn-outline gh-btn-icon-dark gh-btn-large w-30" {{on "click" @backStep}}><span>{{svg-jar "arrow-left-tail"}}</span></button>
|
||||
<button type="button" class="gh-btn gh-btn-outline gh-btn-icon-dark gh-btn-large w-30" {{on "click" this.backStep}}><span>{{svg-jar "arrow-left-tail"}}</span></button>
|
||||
|
||||
{{!-- TODO: reset "failed" state automatically --}}
|
||||
<GhTaskButton
|
||||
|
|
|
@ -64,12 +64,23 @@ export default class GhLaunchWizardSetPricingComponent extends Component {
|
|||
constructor() {
|
||||
super(...arguments);
|
||||
const storedData = this.args.getData();
|
||||
if (storedData && storedData.product) {
|
||||
if (storedData) {
|
||||
if (storedData.product) {
|
||||
this.updatePricesFromProduct(storedData.product);
|
||||
} else {
|
||||
this.stripeMonthlyAmount = 5;
|
||||
this.stripeYearlyAmount = 50;
|
||||
}
|
||||
if (storedData.isMonthlyChecked !== undefined) {
|
||||
this.isMonthlyChecked = storedData.isMonthlyChecked;
|
||||
}
|
||||
if (storedData.isYearlyChecked !== undefined) {
|
||||
this.isYearlyChecked = storedData.isYearlyChecked;
|
||||
}
|
||||
if (storedData.isFreeChecked !== undefined) {
|
||||
this.isFreeChecked = storedData.isFreeChecked;
|
||||
}
|
||||
}
|
||||
this.updatePreviewUrl();
|
||||
this.loadingProduct = true;
|
||||
this.fetchDefaultProduct();
|
||||
|
@ -95,6 +106,22 @@ export default class GhLaunchWizardSetPricingComponent extends Component {
|
|||
this.args.updatePreview('');
|
||||
}
|
||||
|
||||
@action
|
||||
backStep() {
|
||||
const product = this.getProduct();
|
||||
const data = this.args.getData() || {};
|
||||
this.args.storeData({
|
||||
...data,
|
||||
product,
|
||||
isFreeChecked: this.isFreeChecked,
|
||||
isMonthlyChecked: this.isMonthlyChecked,
|
||||
isYearlyChecked: this.isYearlyChecked,
|
||||
monthlyAmount: this.stripeMonthlyAmount,
|
||||
yearlyAmount: this.stripeYearlyAmount
|
||||
});
|
||||
this.args.backStep();
|
||||
}
|
||||
|
||||
@action
|
||||
setStripePlansCurrency(event) {
|
||||
const newCurrency = event.value;
|
||||
|
@ -150,8 +177,11 @@ export default class GhLaunchWizardSetPricingComponent extends Component {
|
|||
this.args.storeData({
|
||||
...data,
|
||||
product,
|
||||
isFreeChecked: this.isFreeChecked,
|
||||
isMonthlyChecked: this.isMonthlyChecked,
|
||||
isYearlyChecked: this.isYearlyChecked
|
||||
isYearlyChecked: this.isYearlyChecked,
|
||||
monthlyAmount: this.stripeMonthlyAmount,
|
||||
yearlyAmount: this.stripeYearlyAmount
|
||||
});
|
||||
this.args.nextStep();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue