plan can be active or not

This commit is contained in:
Rimian Perkins
2019-10-24 10:02:31 +11:00
parent 922dee581c
commit 603ddc354b
7 changed files with 20 additions and 2 deletions
@@ -36,6 +36,7 @@ const AdminPlan = Discourse.Model.extend({
trial_period_days: this.parseTrialPeriodDays,
product: this.product,
metadata: this.metadata,
active: this.active
};
return ajax("/patrons/admin/plans", { method: "post", data });
@@ -46,6 +47,7 @@ const AdminPlan = Discourse.Model.extend({
nickname: this.nickname,
trial_period_days: this.parseTrialPeriodDays,
metadata: this.metadata,
active: this.active
};
return ajax(`/patrons/admin/plans/${this.id}`, { method: "patch", data });
@@ -8,7 +8,7 @@ export default Discourse.Route.extend({
let plan;
if(id === 'new') {
plan = AdminPlan.create({ isNew: true, product: product.get('id') });
plan = AdminPlan.create({ active: true, isNew: true, product: product.get('id') });
}
else {
plan = AdminPlan.find(id);
@@ -40,6 +40,12 @@
</label>
{{combo-box valueAttribute="value" content=model.plan.intervals value=model.plan.interval}}
</p>
<p>
<label for="active">
{{i18n 'discourse_patrons.admin.plans.plan.active'}}
</label>
{{input type="checkbox" name="active" checked=model.plan.active}}
</p>
</form>
<section>
@@ -30,6 +30,7 @@
<th>{{i18n 'discourse_patrons.admin.plans.plan.interval'}}</th>
<th>{{i18n 'discourse_patrons.admin.plans.plan.created_at'}}</th>
<th>{{i18n 'discourse_patrons.admin.plans.plan.group'}}</th>
<th>{{i18n 'discourse_patrons.admin.plans.plan.active'}}</th>
<th class="td-right">{{i18n 'discourse_patrons.admin.plans.plan.amount'}}</th>
<th class="td-right">
{{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id "new" class="btn"}}
@@ -43,6 +44,7 @@
<td>{{plan.interval}}</td>
<td>{{format-date plan.createdFormatted}}</td>
<td>{{plan.metadata.group_name}}</td>
<td>{{plan.active}}</td>
<td class="td-right">{{plan.amount}}</td>
<td class="td-right">
{{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id plan.id class="btn no-text btn-icon"}}
@@ -58,7 +60,7 @@
{{/each}}
<tr>
<td colspan="6">
<td colspan="7">
{{#unless model.plans}}
<hr>
{{i18n 'discourse_patrons.admin.products.product.plan_help'}}