mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-08 15:22:46 +00:00
order the payments in admin
This commit is contained in:
parent
85a90b091c
commit
ca62cad04e
@ -3,9 +3,19 @@
|
|||||||
module DiscoursePatrons
|
module DiscoursePatrons
|
||||||
class AdminController < ::Admin::AdminController
|
class AdminController < ::Admin::AdminController
|
||||||
def index
|
def index
|
||||||
payments = Payment.all
|
payments = Payment.all.order(payments_order)
|
||||||
|
|
||||||
render_serialized(payments, PaymentSerializer)
|
render_serialized(payments, PaymentSerializer)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def payments_order
|
||||||
|
if %w(created_at amount).include?(params[:order])
|
||||||
|
params[:order].to_sym
|
||||||
|
else
|
||||||
|
:created_at
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
|
queryParams: ["order"],
|
||||||
|
order: null,
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
loadMore() {}
|
loadMore() {},
|
||||||
|
|
||||||
|
orderPayments(order) {
|
||||||
|
this.set("order", order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
model() {
|
queryParams: {
|
||||||
|
order: {
|
||||||
|
refreshModel: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
model(params) {
|
||||||
return ajax("/patrons/admin", {
|
return ajax("/patrons/admin", {
|
||||||
method: "get"
|
method: "get",
|
||||||
|
data: { order: params.order }
|
||||||
}).then(results => results);
|
}).then(results => results);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
<th>{{i18n 'discourse_patrons.admin.table.head.user'}}</th>
|
<th>{{i18n 'discourse_patrons.admin.table.head.user'}}</th>
|
||||||
<th>{{i18n 'discourse_patrons.admin.table.head.payment_intent'}}</th>
|
<th>{{i18n 'discourse_patrons.admin.table.head.payment_intent'}}</th>
|
||||||
<th>{{i18n 'discourse_patrons.admin.table.head.receipt_email'}}</th>
|
<th>{{i18n 'discourse_patrons.admin.table.head.receipt_email'}}</th>
|
||||||
<th>{{i18n 'created'}}</th>
|
<th onclick={{action "orderPayments" "created_at"}} class="sortable">{{i18n 'created'}}</th>
|
||||||
<th class="amount">{{i18n 'discourse_patrons.admin.table.head.amount'}}</th>
|
<th class="amount" onclick={{action "orderPayments" "amount"}} class="sortable amount">{{i18n 'discourse_patrons.admin.table.head.amount'}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{{#each model as |payment|}}
|
{{#each model as |payment|}}
|
||||||
|
@ -9,8 +9,5 @@ module DiscoursePatrons
|
|||||||
it 'is a subclass of AdminController' do
|
it 'is a subclass of AdminController' do
|
||||||
expect(DiscoursePatrons::AdminController < Admin::AdminController).to eq(true)
|
expect(DiscoursePatrons::AdminController < Admin::AdminController).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO authenticate
|
|
||||||
it 'has payments'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user