From e004a18071c9fd9a617248cb597d2c1f48a3b923 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 23 Sep 2019 15:01:03 +1000 Subject: [PATCH] templates and routes for subscriptions --- app/controllers/admin_controller.rb | 4 ++ ...min-plugins-discourse-patrons-index.js.es6 | 18 ++++++++ .../admin-plugins-discourse-patrons.js.es6 | 16 +------ .../discourse-patrons-route-map.js.es6 | 4 +- ...min-plugins-discourse-patrons-index.js.es6 | 22 ++++++++++ .../admin-plugins-discourse-patrons.js.es6 | 19 --------- .../admin/plugins-discourse-patrons-index.hbs | 34 +++++++++++++++ ...lugins-discourse-patrons-subscriptions.hbs | 3 ++ .../admin/plugins-discourse-patrons.hbs | 42 +++++-------------- config/routes.rb | 1 - plugin.rb | 1 + 11 files changed, 96 insertions(+), 68 deletions(-) create mode 100644 assets/javascripts/discourse/controllers/admin-plugins-discourse-patrons-index.js.es6 create mode 100644 assets/javascripts/discourse/routes/admin-plugins-discourse-patrons-index.js.es6 create mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-index.hbs create mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-subscriptions.hbs diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 2c1c46a..0025b5f 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -8,6 +8,10 @@ module DiscoursePatrons render_serialized(payments, PaymentSerializer) end + def subscriptions + head 200 + end + private def payments_order diff --git a/assets/javascripts/discourse/controllers/admin-plugins-discourse-patrons-index.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-discourse-patrons-index.js.es6 new file mode 100644 index 0000000..16b4a9a --- /dev/null +++ b/assets/javascripts/discourse/controllers/admin-plugins-discourse-patrons-index.js.es6 @@ -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); + } + } +}); diff --git a/assets/javascripts/discourse/controllers/admin-plugins-discourse-patrons.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-discourse-patrons.js.es6 index eeaf139..b969276 100644 --- a/assets/javascripts/discourse/controllers/admin-plugins-discourse-patrons.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-plugins-discourse-patrons.js.es6 @@ -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); - } - } }); diff --git a/assets/javascripts/discourse/discourse-patrons-route-map.js.es6 b/assets/javascripts/discourse/discourse-patrons-route-map.js.es6 index 1f0a813..e95822b 100644 --- a/assets/javascripts/discourse/discourse-patrons-route-map.js.es6 +++ b/assets/javascripts/discourse/discourse-patrons-route-map.js.es6 @@ -2,6 +2,8 @@ export default { resource: "admin.adminPlugins", path: "/plugins", map() { - this.route("discourse-patrons"); + this.route("discourse-patrons", function() { + this.route("subscriptions"); + }); } }; diff --git a/assets/javascripts/discourse/routes/admin-plugins-discourse-patrons-index.js.es6 b/assets/javascripts/discourse/routes/admin-plugins-discourse-patrons-index.js.es6 new file mode 100644 index 0000000..275e792 --- /dev/null +++ b/assets/javascripts/discourse/routes/admin-plugins-discourse-patrons-index.js.es6 @@ -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); + } +}); diff --git a/assets/javascripts/discourse/routes/admin-plugins-discourse-patrons.js.es6 b/assets/javascripts/discourse/routes/admin-plugins-discourse-patrons.js.es6 index 275e792..da78be9 100644 --- a/assets/javascripts/discourse/routes/admin-plugins-discourse-patrons.js.es6 +++ b/assets/javascripts/discourse/routes/admin-plugins-discourse-patrons.js.es6 @@ -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); - } }); diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-index.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-index.hbs new file mode 100644 index 0000000..2e7dd22 --- /dev/null +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-index.hbs @@ -0,0 +1,34 @@ +

Payments

+ +{{#load-more selector=".discourse-patrons-admin tr" action=(action "loadMore")}} + {{#if model}} + + + + + + + + + + + {{#each model as |payment|}} + + + + + + + + {{/each}} +
{{i18n 'discourse_patrons.admin.payment_history.table.head.user'}}{{i18n 'discourse_patrons.admin.payment_history.table.head.payment_intent'}}{{i18n 'discourse_patrons.admin.payment_history.table.head.receipt_email'}}{{i18n 'created'}}{{i18n 'discourse_patrons.admin.payment_history.table.head.amount'}}
+ {{#link-to "adminUser.index" payment.user_id payment.username}} + {{payment.username}} + {{/link-to}} + + {{#link-to "patrons.show" payment.payment_intent_id}} + {{{payment.payment_intent_id}}} + {{/link-to}} + {{payment.receipt_email}}{{{format-duration payment.created_at_age}}}{{payment.amount_currency}}
+ {{/if}} +{{/load-more}} diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-subscriptions.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-subscriptions.hbs new file mode 100644 index 0000000..b460fbe --- /dev/null +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-subscriptions.hbs @@ -0,0 +1,3 @@ + + +

Subscriptions

diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs index 37fdd2f..090b192 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs @@ -1,35 +1,13 @@

{{i18n 'discourse_patrons.title' site_name=siteSettings.title}}

-{{#load-more selector=".discourse-patrons-admin tr" action=(action "loadMore")}} - {{#if model}} - - - - - - - - - - - {{#each model as |payment|}} - - - - - - - - {{/each}} -
{{i18n 'discourse_patrons.admin.payment_history.table.head.user'}}{{i18n 'discourse_patrons.admin.payment_history.table.head.payment_intent'}}{{i18n 'discourse_patrons.admin.payment_history.table.head.receipt_email'}}{{i18n 'created'}}{{i18n 'discourse_patrons.admin.payment_history.table.head.amount'}}
- {{#link-to "adminUser.index" payment.user_id payment.username}} - {{payment.username}} - {{/link-to}} - - {{#link-to "patrons.show" payment.payment_intent_id}} - {{{payment.payment_intent_id}}} - {{/link-to}} - {{payment.receipt_email}}{{{format-duration payment.created_at_age}}}{{payment.amount_currency}}
- {{/if}} -{{/load-more}} +{{#link-to 'adminPlugins.discourse-patrons'}} + Payments +{{/link-to}} +{{#link-to 'adminPlugins.discourse-patrons.subscriptions'}} + Subscriptions +{{/link-to}} + +
+ +{{outlet}} diff --git a/config/routes.rb b/config/routes.rb index 226e348..650751e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/plugin.rb b/plugin.rb index 681e598..b04daa3 100644 --- a/plugin.rb +++ b/plugin.rb @@ -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