templates and routes for subscriptions
This commit is contained in:
parent
8b61747fbd
commit
e004a18071
|
@ -8,6 +8,10 @@ module DiscoursePatrons
|
|||
render_serialized(payments, PaymentSerializer)
|
||||
end
|
||||
|
||||
def subscriptions
|
||||
head 200
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def payments_order
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
export default Ember.Controller.extend({
|
||||
queryParams: ["order", "descending"],
|
||||
order: null,
|
||||
descending: true,
|
||||
|
||||
actions: {
|
||||
loadMore() {},
|
||||
|
||||
orderPayments(order) {
|
||||
if (order === this.get("order")) {
|
||||
this.toggleProperty("descending");
|
||||
}
|
||||
|
||||
this.set("order", order);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -1,17 +1,3 @@
|
|||
|
||||
export default Ember.Controller.extend({
|
||||
queryParams: ["order", "descending"],
|
||||
order: null,
|
||||
descending: true,
|
||||
|
||||
actions: {
|
||||
loadMore() {},
|
||||
|
||||
orderPayments(order) {
|
||||
if (order === this.get("order")) {
|
||||
this.toggleProperty("descending");
|
||||
}
|
||||
|
||||
this.set("order", order);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,6 +2,8 @@ export default {
|
|||
resource: "admin.adminPlugins",
|
||||
path: "/plugins",
|
||||
map() {
|
||||
this.route("discourse-patrons");
|
||||
this.route("discourse-patrons", function() {
|
||||
this.route("subscriptions");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import { ajax } from "discourse/lib/ajax";
|
||||
|
||||
export default Discourse.Route.extend({
|
||||
queryParams: {
|
||||
order: {
|
||||
refreshModel: true
|
||||
},
|
||||
descending: {
|
||||
refreshModel: true
|
||||
}
|
||||
},
|
||||
|
||||
model(params) {
|
||||
return ajax("/patrons/admin", {
|
||||
method: "get",
|
||||
data: {
|
||||
order: params.order,
|
||||
descending: params.descending
|
||||
}
|
||||
}).then(results => results);
|
||||
}
|
||||
});
|
|
@ -1,22 +1,3 @@
|
|||
import { ajax } from "discourse/lib/ajax";
|
||||
|
||||
export default Discourse.Route.extend({
|
||||
queryParams: {
|
||||
order: {
|
||||
refreshModel: true
|
||||
},
|
||||
descending: {
|
||||
refreshModel: true
|
||||
}
|
||||
},
|
||||
|
||||
model(params) {
|
||||
return ajax("/patrons/admin", {
|
||||
method: "get",
|
||||
data: {
|
||||
order: params.order,
|
||||
descending: params.descending
|
||||
}
|
||||
}).then(results => results);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<h3>Payments</h3>
|
||||
|
||||
{{#load-more selector=".discourse-patrons-admin tr" action=(action "loadMore")}}
|
||||
{{#if model}}
|
||||
<table class="table discourse-patrons-admin">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{i18n 'discourse_patrons.admin.payment_history.table.head.user'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.payment_history.table.head.payment_intent'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.payment_history.table.head.receipt_email'}}</th>
|
||||
<th onclick={{action "orderPayments" "created_at"}} class="sortable">{{i18n 'created'}}</th>
|
||||
<th class="amount" onclick={{action "orderPayments" "amount"}} class="sortable amount">{{i18n 'discourse_patrons.admin.payment_history.table.head.amount'}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{{#each model as |payment|}}
|
||||
<tr>
|
||||
<td>
|
||||
{{#link-to "adminUser.index" payment.user_id payment.username}}
|
||||
{{payment.username}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>
|
||||
{{#link-to "patrons.show" payment.payment_intent_id}}
|
||||
{{{payment.payment_intent_id}}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>{{payment.receipt_email}}</td>
|
||||
<td>{{{format-duration payment.created_at_age}}}</td>
|
||||
<td class="amount">{{payment.amount_currency}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{/if}}
|
||||
{{/load-more}}
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
|
||||
<h3>Subscriptions</h3>
|
|
@ -1,35 +1,13 @@
|
|||
|
||||
<h2>{{i18n 'discourse_patrons.title' site_name=siteSettings.title}}</h2>
|
||||
|
||||
{{#load-more selector=".discourse-patrons-admin tr" action=(action "loadMore")}}
|
||||
{{#if model}}
|
||||
<table class="table discourse-patrons-admin">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{i18n 'discourse_patrons.admin.payment_history.table.head.user'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.payment_history.table.head.payment_intent'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.payment_history.table.head.receipt_email'}}</th>
|
||||
<th onclick={{action "orderPayments" "created_at"}} class="sortable">{{i18n 'created'}}</th>
|
||||
<th class="amount" onclick={{action "orderPayments" "amount"}} class="sortable amount">{{i18n 'discourse_patrons.admin.payment_history.table.head.amount'}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{{#each model as |payment|}}
|
||||
<tr>
|
||||
<td>
|
||||
{{#link-to "adminUser.index" payment.user_id payment.username}}
|
||||
{{payment.username}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>
|
||||
{{#link-to "patrons.show" payment.payment_intent_id}}
|
||||
{{{payment.payment_intent_id}}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>{{payment.receipt_email}}</td>
|
||||
<td>{{{format-duration payment.created_at_age}}}</td>
|
||||
<td class="amount">{{payment.amount_currency}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{/if}}
|
||||
{{/load-more}}
|
||||
{{#link-to 'adminPlugins.discourse-patrons'}}
|
||||
Payments
|
||||
{{/link-to}}
|
||||
{{#link-to 'adminPlugins.discourse-patrons.subscriptions'}}
|
||||
Subscriptions
|
||||
{{/link-to}}
|
||||
|
||||
<hr>
|
||||
|
||||
{{outlet}}
|
||||
|
|
|
@ -4,6 +4,5 @@ DiscoursePatrons::Engine.routes.draw do
|
|||
get '/admin' => 'admin#index'
|
||||
get '/' => 'patrons#index'
|
||||
get '/:pid' => 'patrons#show'
|
||||
|
||||
resources :patrons, only: [:index, :create]
|
||||
end
|
||||
|
|
|
@ -25,6 +25,7 @@ add_admin_route 'discourse_patrons.title', 'discourse-patrons'
|
|||
|
||||
Discourse::Application.routes.append do
|
||||
get '/admin/plugins/discourse-patrons' => 'admin/plugins#index'
|
||||
get '/admin/plugins/discourse-patrons/subscriptions' => 'admin/plugins#index'
|
||||
end
|
||||
|
||||
after_initialize do
|
||||
|
|
Loading…
Reference in New Issue