plans are child of product
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
redirect(product_id) {
|
||||
DiscourseURL.redirectTo(`/admin/plugins/discourse-patrons/products/${product_id}`);
|
||||
},
|
||||
|
||||
actions: {
|
||||
cancelPlan(product_id) {
|
||||
this.redirect(product_id);
|
||||
},
|
||||
|
||||
createPlan() {
|
||||
const product_id = this.get('model.plan.product_id');
|
||||
this.get('model.plan').save().then(result => this.redirect(product_id));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -15,7 +15,6 @@ export default {
|
||||
|
||||
this.route("products", function() {
|
||||
this.route("show", { path: "/:product-id" }, function() {
|
||||
// this.route("plans");
|
||||
this.route("plans", function() {
|
||||
this.route("show", { path: "/:plan-id" });
|
||||
});
|
||||
|
||||
+20
-17
@@ -2,23 +2,26 @@ import AdminPlan from "discourse/plugins/discourse-patrons/discourse/models/admi
|
||||
import AdminProduct from "discourse/plugins/discourse-patrons/discourse/models/admin-product";
|
||||
|
||||
export default Discourse.Route.extend({
|
||||
templateName: 'admin-plugins-discourse-patrons-plans-show',
|
||||
|
||||
model(params) {
|
||||
console.log('product plans', params);
|
||||
const id = params['plan-id'];
|
||||
const product = this.modelFor('adminPlugins.discourse-patrons.products.show').product;
|
||||
let plan;
|
||||
|
||||
// const id = params['plan-id'];
|
||||
// let plan;
|
||||
//
|
||||
// if(id === 'new') {
|
||||
// plan = AdminPlan.create();
|
||||
// }
|
||||
// else {
|
||||
// plan = AdminPlan.find(id);
|
||||
// }
|
||||
//
|
||||
// const products = AdminProduct.findAll();
|
||||
//
|
||||
// return Ember.RSVP.hash({ plan, products });
|
||||
}
|
||||
if(id === 'new') {
|
||||
plan = AdminPlan.create({ product_id: product.get('id') });
|
||||
}
|
||||
else {
|
||||
plan = AdminPlan.find(id);
|
||||
}
|
||||
|
||||
return Ember.RSVP.hash({ plan, product });
|
||||
},
|
||||
|
||||
renderTemplate(controller, model) {
|
||||
this.render('adminPlugins.discourse-patrons.products.show.plans.show', {
|
||||
into: 'adminPlugins.discourse-patrons.products',
|
||||
outlet: 'main',
|
||||
controller: 'adminPlugins.discourse-patrons.products.show.plans.show',
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
+1
-1
@@ -21,5 +21,5 @@ export default Discourse.Route.extend({
|
||||
const groups = Group.findAll({ ignore_automatic: true });
|
||||
|
||||
return Ember.RSVP.hash({ plans, product, groups });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<thead>
|
||||
<th>{{i18n 'discourse_patrons.admin.products.product.product_id'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.products.product.name'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.products.product.group.title'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.products.product.group'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.products.product.active'}}</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
|
||||
+30
-8
@@ -3,10 +3,14 @@
|
||||
|
||||
<form class="form-horizontal">
|
||||
<p>
|
||||
<label for="name">{{i18n 'discourse_patrons.admin.plans.plan.nickname.title'}}</label>
|
||||
<label for="product">{{i18n 'discourse_patrons.admin.products.product.name'}}</label>
|
||||
{{input type="text" name="product_name" value=model.product.name disabled=true}}
|
||||
</p>
|
||||
<p>
|
||||
<label for="name">{{i18n 'discourse_patrons.admin.plans.plan.nickname'}}</label>
|
||||
{{input type="text" name="name" value=model.plan.nickname}}
|
||||
<div class="control-instructions">
|
||||
{{i18n 'discourse_patrons.admin.plans.plan.nickname.description'}}
|
||||
{{i18n 'discourse_patrons.admin.plans.plan.nickname_help'}}
|
||||
</div>
|
||||
</p>
|
||||
<p>
|
||||
@@ -14,15 +18,33 @@
|
||||
{{input type="text" name="name" value=model.plan.amount}}
|
||||
</p>
|
||||
<p>
|
||||
<label for="product">{{i18n 'discourse_patrons.admin.plans.plan.product'}}</label>
|
||||
{{combo-box valueAttribute="id" content=model.products value=model.plan.product_id}}
|
||||
<label for="trial">
|
||||
{{i18n 'discourse_patrons.admin.plans.plan.trial'}}
|
||||
({{i18n 'discourse_patrons.optional'}})
|
||||
</label>
|
||||
{{input type="text" name="trial" value=model.plan.trial}}
|
||||
<div class="control-instructions">
|
||||
{{i18n 'discourse_patrons.admin.plans.plan.trial_help'}}
|
||||
</div>
|
||||
</p>
|
||||
<p>
|
||||
<label for="interval">{{i18n 'discourse_patrons.admin.plans.plan.interval'}}</label>
|
||||
<label for="interval">
|
||||
{{i18n 'discourse_patrons.admin.plans.plan.interval'}}
|
||||
</label>
|
||||
{{combo-box valueAttribute="value" content=model.plan.intervals value=model.plan.interval}}
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<div class="buttons">
|
||||
{{d-button label="discourse_patrons.admin.plans.operations.create" action="createPlan" icon="plus"}}
|
||||
</div>
|
||||
<section>
|
||||
<hr>
|
||||
|
||||
<div class="control-instructions">
|
||||
{{i18n 'discourse_patrons.admin.plans.operations.create_help'}}
|
||||
</div>
|
||||
|
||||
<div class="pull-right">
|
||||
{{d-button label="cancel" action=(action "cancelPlan" model.plan.product_id) icon="times"}}
|
||||
{{d-button label="discourse_patrons.admin.plans.operations.create" action="createPlan" icon="plus" class="btn btn-primary"}}
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
+18
-7
@@ -1,4 +1,3 @@
|
||||
|
||||
<h4>{{i18n 'discourse_patrons.admin.products.title'}}</h4>
|
||||
|
||||
<form class="form-horizontal">
|
||||
@@ -8,18 +7,18 @@
|
||||
</p>
|
||||
<p>
|
||||
<label for="statement_descriptor">
|
||||
{{i18n 'discourse_patrons.admin.products.product.statement_descriptor.title'}}
|
||||
{{i18n 'discourse_patrons.admin.products.product.statement_descriptor'}}
|
||||
</label>
|
||||
{{input type="text" name="statement_descriptor" value=model.product.statement_descriptor}}
|
||||
<div class="control-instructions">
|
||||
{{i18n 'discourse_patrons.admin.products.product.statement_descriptor.description'}}
|
||||
{{i18n 'discourse_patrons.admin.products.product.statement_descriptor_help'}}
|
||||
</div>
|
||||
</p>
|
||||
<p>
|
||||
<label for="interval">{{i18n 'discourse_patrons.admin.products.product.group.title'}}</label>
|
||||
<label for="interval">{{i18n 'discourse_patrons.admin.products.product.group'}}</label>
|
||||
{{combo-box valueAttribute="name" content=model.groups value=model.product.metadata.group_name}}
|
||||
<div class="control-instructions">
|
||||
{{i18n 'discourse_patrons.admin.products.product.group.description'}}
|
||||
{{i18n 'discourse_patrons.admin.products.product.group_help'}}
|
||||
</div>
|
||||
</p>
|
||||
<p>
|
||||
@@ -34,8 +33,9 @@
|
||||
<table class="table discourse-patrons-admin">
|
||||
<thead>
|
||||
<th>{{i18n 'discourse_patrons.admin.plans.plan.plan_id'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.plans.plan.nickname.title'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.plans.plan.nickname'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.plans.plan.interval'}}</th>
|
||||
<th>{{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"}}
|
||||
{{i18n 'discourse_patrons.admin.plans.operations.add'}}
|
||||
@@ -48,12 +48,21 @@
|
||||
<td>{{plan.nickname}}</td>
|
||||
<td>{{plan.interval}}</td>
|
||||
<td>{{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"}}
|
||||
{{d-icon "far-edit"}}
|
||||
{{/link-to}}
|
||||
{{!-- {{d-button
|
||||
action=(route-action "destroyPlan")
|
||||
actionParam=plan
|
||||
icon="trash-alt"
|
||||
class="btn-danger btn no-text btn-icon"}} --}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
</p>
|
||||
|
||||
|
||||
<section>
|
||||
<hr>
|
||||
|
||||
@@ -66,3 +75,5 @@
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
{{outlet}}
|
||||
|
||||
Reference in New Issue
Block a user