plans are child of product
This commit is contained in:
parent
2179e3d280
commit
c26ce1fc80
|
@ -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" });
|
||||
});
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -21,5 +21,5 @@ export default Discourse.Route.extend({
|
|||
const groups = Group.findAll({ ignore_automatic: true });
|
||||
|
||||
return Ember.RSVP.hash({ plans, product, groups });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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}}
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
// TODO: This gets overridden somewhere. It is defined in common/base/discourse.scss
|
||||
input[disabled], input[readonly], select[disabled], select[readonly], textarea[disabled], textarea[readonly] {
|
||||
cursor: not-allowed;
|
||||
background-color: #e9e9e9;
|
||||
border-color: #e9e9e9;
|
||||
}
|
||||
|
||||
.discourse-patrons-section-columns {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
.donations-category-header .donations-category-metadata {
|
||||
flex-flow: wrap;
|
||||
padding: 0 10px;
|
||||
|
||||
div {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ en:
|
|||
js:
|
||||
discourse_patrons:
|
||||
title: Discourse Patrons
|
||||
optional: Optional
|
||||
navigation:
|
||||
subscribe: Subscribe
|
||||
subscribe:
|
||||
|
@ -70,28 +71,29 @@ en:
|
|||
product:
|
||||
product_id: Product ID
|
||||
name: Product Name
|
||||
statement_descriptor:
|
||||
title: Statement Descriptor
|
||||
description: Extra information about a product which will appear on your customer’s credit card statement.
|
||||
group:
|
||||
title: User Group
|
||||
description: This is the discourse user group the customer gets added to when the subscription is created.
|
||||
statement_descriptor: Statement Descriptor
|
||||
statement_descriptor_help: Extra information about a product which will appear on your customer’s credit card statement.
|
||||
group: User Group
|
||||
group_help: This is the discourse user group the customer gets added to when the subscription is created.
|
||||
active: Active
|
||||
plans:
|
||||
title: Pricing Plans
|
||||
operations:
|
||||
add: Add New Plan
|
||||
create: Create Plan
|
||||
create_help: Once a pricing plan is created, only its nickname and trial period can be updated.
|
||||
new: New Plan
|
||||
destroy:
|
||||
confirm: Are you sure you want to destroy this plan?
|
||||
plan:
|
||||
nickname:
|
||||
title: Plan Nickname
|
||||
description: This won't be visible to customers, but will help you find this plan later.
|
||||
nickname: Plan Nickname
|
||||
nickname_help: This won't be visible to customers, but will help you find this plan later.
|
||||
plan_id: Plan ID
|
||||
product: Product
|
||||
interval: Interval
|
||||
interval: Billing Interval
|
||||
amount: Amount
|
||||
trial: Trial Period Days
|
||||
trial_help: Subscriptions to this plan will automatically start with a free trial of this length
|
||||
subscriptions:
|
||||
title: Subscriptions
|
||||
subscription:
|
||||
|
|
Loading…
Reference in New Issue