mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-07 23:12:33 +00:00
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("products", function() {
|
||||||
this.route("show", { path: "/:product-id" }, function() {
|
this.route("show", { path: "/:product-id" }, function() {
|
||||||
// this.route("plans");
|
|
||||||
this.route("plans", function() {
|
this.route("plans", function() {
|
||||||
this.route("show", { path: "/:plan-id" });
|
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";
|
import AdminProduct from "discourse/plugins/discourse-patrons/discourse/models/admin-product";
|
||||||
|
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
templateName: 'admin-plugins-discourse-patrons-plans-show',
|
|
||||||
|
|
||||||
model(params) {
|
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'];
|
if(id === 'new') {
|
||||||
// let plan;
|
plan = AdminPlan.create({ product_id: product.get('id') });
|
||||||
//
|
}
|
||||||
// if(id === 'new') {
|
else {
|
||||||
// plan = AdminPlan.create();
|
plan = AdminPlan.find(id);
|
||||||
// }
|
}
|
||||||
// else {
|
|
||||||
// plan = AdminPlan.find(id);
|
return Ember.RSVP.hash({ plan, product });
|
||||||
// }
|
},
|
||||||
//
|
|
||||||
// const products = AdminProduct.findAll();
|
renderTemplate(controller, model) {
|
||||||
//
|
this.render('adminPlugins.discourse-patrons.products.show.plans.show', {
|
||||||
// return Ember.RSVP.hash({ plan, products });
|
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 });
|
const groups = Group.findAll({ ignore_automatic: true });
|
||||||
|
|
||||||
return Ember.RSVP.hash({ plans, product, groups });
|
return Ember.RSVP.hash({ plans, product, groups });
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<th>{{i18n 'discourse_patrons.admin.products.product.product_id'}}</th>
|
<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.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>{{i18n 'discourse_patrons.admin.products.product.active'}}</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -3,10 +3,14 @@
|
|||||||
|
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
<p>
|
<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}}
|
{{input type="text" name="name" value=model.plan.nickname}}
|
||||||
<div class="control-instructions">
|
<div class="control-instructions">
|
||||||
{{i18n 'discourse_patrons.admin.plans.plan.nickname.description'}}
|
{{i18n 'discourse_patrons.admin.plans.plan.nickname_help'}}
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@ -14,15 +18,33 @@
|
|||||||
{{input type="text" name="name" value=model.plan.amount}}
|
{{input type="text" name="name" value=model.plan.amount}}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="product">{{i18n 'discourse_patrons.admin.plans.plan.product'}}</label>
|
<label for="trial">
|
||||||
{{combo-box valueAttribute="id" content=model.products value=model.plan.product_id}}
|
{{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>
|
||||||
<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}}
|
{{combo-box valueAttribute="value" content=model.plan.intervals value=model.plan.interval}}
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="buttons">
|
<section>
|
||||||
{{d-button label="discourse_patrons.admin.plans.operations.create" action="createPlan" icon="plus"}}
|
<hr>
|
||||||
</div>
|
|
||||||
|
<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>
|
<h4>{{i18n 'discourse_patrons.admin.products.title'}}</h4>
|
||||||
|
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
@ -8,18 +7,18 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="statement_descriptor">
|
<label for="statement_descriptor">
|
||||||
{{i18n 'discourse_patrons.admin.products.product.statement_descriptor.title'}}
|
{{i18n 'discourse_patrons.admin.products.product.statement_descriptor'}}
|
||||||
</label>
|
</label>
|
||||||
{{input type="text" name="statement_descriptor" value=model.product.statement_descriptor}}
|
{{input type="text" name="statement_descriptor" value=model.product.statement_descriptor}}
|
||||||
<div class="control-instructions">
|
<div class="control-instructions">
|
||||||
{{i18n 'discourse_patrons.admin.products.product.statement_descriptor.description'}}
|
{{i18n 'discourse_patrons.admin.products.product.statement_descriptor_help'}}
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
<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}}
|
{{combo-box valueAttribute="name" content=model.groups value=model.product.metadata.group_name}}
|
||||||
<div class="control-instructions">
|
<div class="control-instructions">
|
||||||
{{i18n 'discourse_patrons.admin.products.product.group.description'}}
|
{{i18n 'discourse_patrons.admin.products.product.group_help'}}
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@ -34,8 +33,9 @@
|
|||||||
<table class="table discourse-patrons-admin">
|
<table class="table discourse-patrons-admin">
|
||||||
<thead>
|
<thead>
|
||||||
<th>{{i18n 'discourse_patrons.admin.plans.plan.plan_id'}}</th>
|
<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.interval'}}</th>
|
||||||
|
<th>{{i18n 'discourse_patrons.admin.plans.plan.amount'}}</th>
|
||||||
<th class="td-right">
|
<th class="td-right">
|
||||||
{{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id "new" class="btn"}}
|
{{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id "new" class="btn"}}
|
||||||
{{i18n 'discourse_patrons.admin.plans.operations.add'}}
|
{{i18n 'discourse_patrons.admin.plans.operations.add'}}
|
||||||
@ -48,12 +48,21 @@
|
|||||||
<td>{{plan.nickname}}</td>
|
<td>{{plan.nickname}}</td>
|
||||||
<td>{{plan.interval}}</td>
|
<td>{{plan.interval}}</td>
|
||||||
<td>{{plan.amount}}</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>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</table>
|
</table>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
@ -66,3 +75,5 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</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 {
|
.discourse-patrons-section-columns {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
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:
|
js:
|
||||||
discourse_patrons:
|
discourse_patrons:
|
||||||
title: Discourse Patrons
|
title: Discourse Patrons
|
||||||
|
optional: Optional
|
||||||
navigation:
|
navigation:
|
||||||
subscribe: Subscribe
|
subscribe: Subscribe
|
||||||
subscribe:
|
subscribe:
|
||||||
@ -70,28 +71,29 @@ en:
|
|||||||
product:
|
product:
|
||||||
product_id: Product ID
|
product_id: Product ID
|
||||||
name: Product Name
|
name: Product Name
|
||||||
statement_descriptor:
|
statement_descriptor: Statement Descriptor
|
||||||
title: Statement Descriptor
|
statement_descriptor_help: Extra information about a product which will appear on your customer’s credit card statement.
|
||||||
description: Extra information about a product which will appear on your customer’s credit card statement.
|
group: User Group
|
||||||
group:
|
group_help: This is the discourse user group the customer gets added to when the subscription is created.
|
||||||
title: User Group
|
|
||||||
description: This is the discourse user group the customer gets added to when the subscription is created.
|
|
||||||
active: Active
|
active: Active
|
||||||
plans:
|
plans:
|
||||||
title: Pricing Plans
|
title: Pricing Plans
|
||||||
operations:
|
operations:
|
||||||
add: Add New Plan
|
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
|
new: New Plan
|
||||||
destroy:
|
destroy:
|
||||||
confirm: Are you sure you want to destroy this plan?
|
confirm: Are you sure you want to destroy this plan?
|
||||||
plan:
|
plan:
|
||||||
nickname:
|
nickname: Plan Nickname
|
||||||
title: Plan Nickname
|
nickname_help: This won't be visible to customers, but will help you find this plan later.
|
||||||
description: This won't be visible to customers, but will help you find this plan later.
|
|
||||||
plan_id: Plan ID
|
plan_id: Plan ID
|
||||||
product: Product
|
product: Product
|
||||||
interval: Interval
|
interval: Billing Interval
|
||||||
amount: Amount
|
amount: Amount
|
||||||
|
trial: Trial Period Days
|
||||||
|
trial_help: Subscriptions to this plan will automatically start with a free trial of this length
|
||||||
subscriptions:
|
subscriptions:
|
||||||
title: Subscriptions
|
title: Subscriptions
|
||||||
subscription:
|
subscription:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user