mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Added handling for active prices
refs https://github.com/TryGhost/Team/issues/665 - Allows (un)archiving of prices - Filters Portal settings on active prices only
This commit is contained in:
parent
998d42fc33
commit
c53e0fce77
3 changed files with 33 additions and 7 deletions
|
@ -332,6 +332,9 @@ export default ModalComponent.extend({
|
|||
const products = yield this.store.query('product', {include: 'stripe_prices'});
|
||||
const product = products.firstObject;
|
||||
const prices = product.get('stripePrices');
|
||||
this.set('prices', prices);
|
||||
const activePrices = prices.filter((d) => {
|
||||
return !!d.active;
|
||||
});
|
||||
this.set('prices', activePrices);
|
||||
}).drop()
|
||||
});
|
||||
|
|
|
@ -80,6 +80,18 @@ export default class ProductController extends Controller {
|
|||
this.showPriceModal = true;
|
||||
}
|
||||
|
||||
@action
|
||||
async archivePrice(price) {
|
||||
price.active = false;
|
||||
this.send('savePrice', price);
|
||||
}
|
||||
|
||||
@action
|
||||
async activatePrice(price) {
|
||||
price.active = true;
|
||||
this.send('savePrice', price);
|
||||
}
|
||||
|
||||
@action
|
||||
async confirmLeave() {
|
||||
this.settings.rollbackAttributes();
|
||||
|
@ -102,12 +114,21 @@ export default class ProductController extends Controller {
|
|||
savePrice(price) {
|
||||
const stripePrices = this.product.stripePrices.map((d) => {
|
||||
if (d.id === price.id) {
|
||||
return EmberObject.create(price);
|
||||
return EmberObject.create({
|
||||
...price,
|
||||
active: !!price.active
|
||||
});
|
||||
}
|
||||
return d;
|
||||
return {
|
||||
...d,
|
||||
active: !!d.active
|
||||
};
|
||||
});
|
||||
if (!price.id) {
|
||||
stripePrices.push(EmberObject.create(price));
|
||||
stripePrices.push(EmberObject.create({
|
||||
...price,
|
||||
active: !!price.active
|
||||
}));
|
||||
}
|
||||
this.product.set('stripePrices', stripePrices);
|
||||
this.saveTask.perform();
|
||||
|
@ -128,7 +149,7 @@ export default class ProductController extends Controller {
|
|||
return this._validateSignupRedirect(this.paidSignupRedirect, 'membersPaidSignupRedirect');
|
||||
}
|
||||
|
||||
@task({drop: true})
|
||||
@task({restartable: true})
|
||||
*saveTask() {
|
||||
this.send('validatePaidSignupRedirect');
|
||||
if (this.settings.get('errors').length !== 0) {
|
||||
|
|
|
@ -105,11 +105,13 @@
|
|||
<span>Edit</span>
|
||||
</button>
|
||||
{{#if price.active}}
|
||||
<button class="gh-btn gh-btn-link archived">
|
||||
<button class="gh-btn gh-btn-link archived" {{action "archivePrice" price}}>
|
||||
<span>Archive</span>
|
||||
</button>
|
||||
{{else}}
|
||||
<button class="gh-btn gh-btn-link"><span>Activate</span></button>
|
||||
<button class="gh-btn gh-btn-link" {{action "activatePrice" price}}>
|
||||
<span>Activate</span>
|
||||
</button>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue