list subscriptions
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
|
||||
const Subscription = Discourse.Model.extend({
|
||||
@computed("created")
|
||||
createdFormatted(created) {
|
||||
return moment.unix(created).format();
|
||||
},
|
||||
|
||||
save() {
|
||||
const data = {
|
||||
customer: this.customer,
|
||||
@@ -11,4 +17,12 @@ const Subscription = Discourse.Model.extend({
|
||||
}
|
||||
});
|
||||
|
||||
Subscription.reopenClass({
|
||||
findAll() {
|
||||
return ajax("/patrons/subscriptions", { method: "get" }).then(result =>
|
||||
result.map(subscription => Subscription.create(subscription))
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
export default Subscription;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import Subscription from "discourse/plugins/discourse-patrons/discourse/models/subscription";
|
||||
|
||||
export default Discourse.Route.extend({
|
||||
model() {
|
||||
return Subscription.findAll();
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
if (this.currentUser.id !== this.modelFor("user").id) {
|
||||
this.replaceWith("userActivity");
|
||||
} else {
|
||||
controller.setProperties({ model });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{{#if (user-viewing-self model)}}
|
||||
{{#link-to 'user.billing'}}{{d-icon "credit-card"}}{{I18n 'discourse_patrons.navigation.billing'}}{{/link-to}}
|
||||
{{/if}}
|
||||
@@ -0,0 +1,3 @@
|
||||
{{#if (user-viewing-self model)}}
|
||||
{{#link-to 'user.subscriptions'}}{{d-icon "credit-card"}}{{I18n 'discourse_patrons.navigation.subscriptions'}}{{/link-to}}
|
||||
{{/if}}
|
||||
@@ -2,13 +2,6 @@
|
||||
<h3>{{i18n 'discourse_patrons.user.billing.title'}}</h3>
|
||||
|
||||
{{#if model}}
|
||||
<p class="btn-right">
|
||||
{{#link-to 'user.subscriptions' class="btn btn-primary"}}
|
||||
{{d-icon "credit-card"}}
|
||||
<span>{{i18n 'discourse_patrons.user.subscriptions.title'}}</span>
|
||||
{{/link-to}}
|
||||
</p>
|
||||
|
||||
<table class="topic-list">
|
||||
<thead>
|
||||
<th>{{i18n 'discourse_patrons.user.billing.invoices.amount'}}</th>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
<h3>{{i18n 'discourse_patrons.user.billing.title'}}</h3>
|
||||
|
||||
{{#if model}}
|
||||
<table class="topic-list">
|
||||
<thead>
|
||||
<th>{{i18n 'discourse_patrons.user.billing.invoices.amount'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.user.billing.invoices.number'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.user.billing.invoices.created_at'}}</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
{{#each model as |invoice|}}
|
||||
<tr>
|
||||
<td>{{invoice.amount_paid}}</td>
|
||||
<td>{{invoice.number}}</td>
|
||||
<td>{{format-date invoice.createdFormatted}}</td>
|
||||
<td class="td-right">
|
||||
<a href="{{invoice.invoice_pdf}}" class="btn btn-icon">
|
||||
{{d-icon "download"}}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{else}}
|
||||
<p>{{i18n 'discourse_patrons.user.billing_help'}}</p>
|
||||
{{/if}}
|
||||
@@ -1,2 +1,21 @@
|
||||
{{#d-section class="user-secondary-navigation" pageClass="user-subscriptions"}}
|
||||
|
||||
<h3>{{i18n 'discourse_patrons.user.subscriptions.title'}}</h3>
|
||||
<h3>{{i18n 'discourse_patrons.user.subscriptions.title'}}</h3>
|
||||
|
||||
{{#if model}}
|
||||
<table class="topic-list">
|
||||
<thead>
|
||||
<th>{{i18n 'discourse_patrons.user.billing.subscriptions.created_at'}}</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
{{#each model as |subscription|}}
|
||||
<tr>
|
||||
<td>{{format-date subscription.createdFormatted}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{else}}
|
||||
<p>{{i18n 'discourse_patrons.user.subscriptions_help'}}</p>
|
||||
{{/if}}
|
||||
|
||||
{{/d-section}}
|
||||
|
||||
Reference in New Issue
Block a user