mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-08 07:12:46 +00:00
format dates for plan and product list
This commit is contained in:
parent
c26ce1fc80
commit
5cce5f2b84
@ -1,7 +1,15 @@
|
|||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
|
redirect() {
|
||||||
|
this.transitionToRoute("adminPlugins.discourse-patrons.products");
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
cancelProduct() {
|
||||||
|
this.redirect();
|
||||||
|
},
|
||||||
|
|
||||||
createProduct() {
|
createProduct() {
|
||||||
// TODO: set default group name beforehand
|
// TODO: set default group name beforehand
|
||||||
if (this.get("model.product.metadata.group_name") === undefined) {
|
if (this.get("model.product.metadata.group_name") === undefined) {
|
||||||
@ -13,18 +21,14 @@ export default Ember.Controller.extend({
|
|||||||
|
|
||||||
this.get("model.product")
|
this.get("model.product")
|
||||||
.save()
|
.save()
|
||||||
.then(() => {
|
.then(() => this.redirect())
|
||||||
this.transitionToRoute("adminPlugins.discourse-patrons.products");
|
|
||||||
})
|
|
||||||
.catch(popupAjaxError);
|
.catch(popupAjaxError);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateProduct() {
|
updateProduct() {
|
||||||
this.get("model.product")
|
this.get("model.product")
|
||||||
.update()
|
.update()
|
||||||
.then(() => {
|
.then(() => this.redirect())
|
||||||
this.transitionToRoute("adminPlugins.discourse-patrons.products");
|
|
||||||
})
|
|
||||||
.catch(popupAjaxError);
|
.catch(popupAjaxError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
|
||||||
const AdminPlan = Discourse.Model.extend({
|
const AdminPlan = Discourse.Model.extend({
|
||||||
@ -6,6 +7,11 @@ const AdminPlan = Discourse.Model.extend({
|
|||||||
amount: 0,
|
amount: 0,
|
||||||
intervals: ["day", "week", "month", "year"],
|
intervals: ["day", "week", "month", "year"],
|
||||||
|
|
||||||
|
@computed("created")
|
||||||
|
createdFormatted(created) {
|
||||||
|
return moment.unix(created).format();
|
||||||
|
},
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
return ajax(`/patrons/admin/plans/${this.id}`, { method: "delete" });
|
return ajax(`/patrons/admin/plans/${this.id}`, { method: "delete" });
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
|
||||||
const AdminProduct = Discourse.Model.extend({
|
const AdminProduct = Discourse.Model.extend({
|
||||||
isNew: false,
|
isNew: false,
|
||||||
metadata: {},
|
metadata: {},
|
||||||
|
|
||||||
|
@computed("created")
|
||||||
|
createdFormatted(created) {
|
||||||
|
return moment.unix(created).format();
|
||||||
|
},
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
return ajax(`/patrons/admin/products/${this.id}`, { method: "delete" });
|
return ajax(`/patrons/admin/products/${this.id}`, { method: "delete" });
|
||||||
},
|
},
|
||||||
|
@ -1,17 +1,24 @@
|
|||||||
|
|
||||||
|
<p class="btn-right">
|
||||||
|
{{#link-to 'adminPlugins.discourse-patrons.products.show' 'new' class="btn btn-primary"}}
|
||||||
|
{{d-icon "plus"}}
|
||||||
|
<span>{{i18n 'discourse_patrons.admin.products.operations.new'}}</span>
|
||||||
|
{{/link-to}}
|
||||||
|
</p>
|
||||||
|
|
||||||
<table class="table discourse-patrons-admin">
|
<table class="table discourse-patrons-admin">
|
||||||
<thead>
|
<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.name'}}</th>
|
||||||
<th>{{i18n 'discourse_patrons.admin.products.product.group'}}</th>
|
<th>{{i18n 'discourse_patrons.admin.products.product.group'}}</th>
|
||||||
|
<th>{{i18n 'discourse_patrons.admin.products.product.created_at'}}</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>
|
||||||
{{#each model as |product|}}
|
{{#each model as |product|}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{product.id}}</td>
|
|
||||||
<td>{{product.name}}</td>
|
<td>{{product.name}}</td>
|
||||||
<td>{{product.metadata.group_name}}</td>
|
<td>{{product.metadata.group_name}}</td>
|
||||||
|
<td>{{format-date product.createdFormatted}}</td>
|
||||||
<td>{{product.active}}</td>
|
<td>{{product.active}}</td>
|
||||||
<td class="td-right">
|
<td class="td-right">
|
||||||
{{#link-to "adminPlugins.discourse-patrons.products.show" product.id class="btn no-text btn-icon"}}
|
{{#link-to "adminPlugins.discourse-patrons.products.show" product.id class="btn no-text btn-icon"}}
|
||||||
|
@ -32,9 +32,9 @@
|
|||||||
<p>
|
<p>
|
||||||
<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.nickname'}}</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.created_at'}}</th>
|
||||||
<th>{{i18n 'discourse_patrons.admin.plans.plan.amount'}}</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"}}
|
||||||
@ -44,9 +44,9 @@
|
|||||||
</thead>
|
</thead>
|
||||||
{{#each model.plans as |plan|}}
|
{{#each model.plans as |plan|}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{plan.id}}</td>
|
|
||||||
<td>{{plan.nickname}}</td>
|
<td>{{plan.nickname}}</td>
|
||||||
<td>{{plan.interval}}</td>
|
<td>{{plan.interval}}</td>
|
||||||
|
<td>{{format-date plan.createdFormatted}}</td>
|
||||||
<td>{{plan.amount}}</td>
|
<td>{{plan.amount}}</td>
|
||||||
<td class="td-right">
|
<td class="td-right">
|
||||||
{{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id plan.id class="btn no-text btn-icon"}}
|
{{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id plan.id class="btn no-text btn-icon"}}
|
||||||
@ -67,6 +67,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
|
{{d-button label="cancel" action=(action "cancelProduct") icon="times"}}
|
||||||
{{#if model.product.isNew}}
|
{{#if model.product.isNew}}
|
||||||
{{d-button label="discourse_patrons.admin.products.operations.create" action="createProduct" icon="plus"}}
|
{{d-button label="discourse_patrons.admin.products.operations.create" action="createProduct" icon="plus"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
@ -1,9 +1,2 @@
|
|||||||
|
|
||||||
<p class="btn-right">
|
|
||||||
{{#link-to 'adminPlugins.discourse-patrons.products.show' 'new' class="btn btn-primary"}}
|
|
||||||
{{d-icon "plus"}}
|
|
||||||
<span>{{i18n 'discourse_patrons.admin.products.operations.new'}}</span>
|
|
||||||
{{/link-to}}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{{outlet}}
|
{{outlet}}
|
||||||
|
@ -76,6 +76,7 @@ en:
|
|||||||
group: User Group
|
group: User Group
|
||||||
group_help: This is the discourse user group the customer gets added to when the subscription is created.
|
group_help: This is the discourse user group the customer gets added to when the subscription is created.
|
||||||
active: Active
|
active: Active
|
||||||
|
created_at: Created
|
||||||
plans:
|
plans:
|
||||||
title: Pricing Plans
|
title: Pricing Plans
|
||||||
operations:
|
operations:
|
||||||
@ -94,6 +95,7 @@ en:
|
|||||||
amount: Amount
|
amount: Amount
|
||||||
trial: Trial Period Days
|
trial: Trial Period Days
|
||||||
trial_help: Subscriptions to this plan will automatically start with a free trial of this length
|
trial_help: Subscriptions to this plan will automatically start with a free trial of this length
|
||||||
|
created_at: Created
|
||||||
subscriptions:
|
subscriptions:
|
||||||
title: Subscriptions
|
title: Subscriptions
|
||||||
subscription:
|
subscription:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user