change engine mount point and base path in jsapp

This commit is contained in:
Rimian Perkins 2019-12-03 10:29:44 +11:00
parent 382fd4ac41
commit 08cbff0c1c
23 changed files with 29 additions and 28 deletions

View File

@ -3,7 +3,7 @@ import { ajax } from "discourse/lib/ajax";
export default Ember.Controller.extend({ export default Ember.Controller.extend({
actions: { actions: {
stripePaymentHandler(data) { stripePaymentHandler(data) {
return ajax("/patrons/patrons", { return ajax("/s/patrons", {
data, data,
method: "post" method: "post"
}).catch(() => { }).catch(() => {

View File

@ -25,7 +25,7 @@ export default Ember.Controller.extend({
source: result.token.id source: result.token.id
}; };
return ajax("/patrons/customers", { return ajax("/s/customers", {
method: "post", method: "post",
data: customerData data: customerData
}).then(customer => { }).then(customer => {

View File

@ -20,7 +20,7 @@ const AdminPlan = Plan.extend({
}, },
destroy() { destroy() {
return ajax(`/patrons/admin/plans/${this.id}`, { method: "delete" }); return ajax(`/s/admin/plans/${this.id}`, { method: "delete" });
}, },
save() { save() {
@ -35,7 +35,7 @@ const AdminPlan = Plan.extend({
active: this.active active: this.active
}; };
return ajax("/patrons/admin/plans", { method: "post", data }); return ajax("/s/admin/plans", { method: "post", data });
}, },
update() { update() {
@ -46,19 +46,19 @@ const AdminPlan = Plan.extend({
active: this.active active: this.active
}; };
return ajax(`/patrons/admin/plans/${this.id}`, { method: "patch", data }); return ajax(`/s/admin/plans/${this.id}`, { method: "patch", data });
} }
}); });
AdminPlan.reopenClass({ AdminPlan.reopenClass({
findAll(data) { findAll(data) {
return ajax("/patrons/admin/plans", { method: "get", data }).then(result => return ajax("/s/admin/plans", { method: "get", data }).then(result =>
result.map(plan => AdminPlan.create(plan)) result.map(plan => AdminPlan.create(plan))
); );
}, },
find(id) { find(id) {
return ajax(`/patrons/admin/plans/${id}`, { method: "get" }).then(plan => return ajax(`/s/admin/plans/${id}`, { method: "get" }).then(plan =>
AdminPlan.create(plan) AdminPlan.create(plan)
); );
} }

View File

@ -5,7 +5,7 @@ const AdminProduct = Discourse.Model.extend({
metadata: {}, metadata: {},
destroy() { destroy() {
return ajax(`/patrons/admin/products/${this.id}`, { method: "delete" }); return ajax(`/s/admin/products/${this.id}`, { method: "delete" });
}, },
save() { save() {
@ -16,7 +16,7 @@ const AdminProduct = Discourse.Model.extend({
active: this.active active: this.active
}; };
return ajax("/patrons/admin/products", { return ajax("/s/admin/products", {
method: "post", method: "post",
data data
}).then(product => AdminProduct.create(product)); }).then(product => AdminProduct.create(product));
@ -30,7 +30,7 @@ const AdminProduct = Discourse.Model.extend({
active: this.active active: this.active
}; };
return ajax(`/patrons/admin/products/${this.id}`, { return ajax(`/s/admin/products/${this.id}`, {
method: "patch", method: "patch",
data data
}); });
@ -39,13 +39,13 @@ const AdminProduct = Discourse.Model.extend({
AdminProduct.reopenClass({ AdminProduct.reopenClass({
findAll() { findAll() {
return ajax("/patrons/admin/products", { method: "get" }).then(result => return ajax("/s/admin/products", { method: "get" }).then(result =>
result.map(product => AdminProduct.create(product)) result.map(product => AdminProduct.create(product))
); );
}, },
find(id) { find(id) {
return ajax(`/patrons/admin/products/${id}`, { return ajax(`/s/admin/products/${id}`, {
method: "get" method: "get"
}).then(product => AdminProduct.create(product)); }).then(product => AdminProduct.create(product));
} }

View File

@ -20,7 +20,7 @@ const AdminSubscription = Discourse.Model.extend({
}, },
destroy() { destroy() {
return ajax(`/patrons/admin/subscriptions/${this.id}`, { return ajax(`/s/admin/subscriptions/${this.id}`, {
method: "delete" method: "delete"
}).then(result => AdminSubscription.create(result)); }).then(result => AdminSubscription.create(result));
} }
@ -28,7 +28,7 @@ const AdminSubscription = Discourse.Model.extend({
AdminSubscription.reopenClass({ AdminSubscription.reopenClass({
find() { find() {
return ajax("/patrons/admin/subscriptions", { return ajax("/s/admin/subscriptions", {
method: "get" method: "get"
}).then(result => }).then(result =>
result.data.map(subscription => AdminSubscription.create(subscription)) result.data.map(subscription => AdminSubscription.create(subscription))

View File

@ -4,7 +4,7 @@ const Invoice = Discourse.Model.extend({});
Invoice.reopenClass({ Invoice.reopenClass({
findAll() { findAll() {
return ajax("/patrons/invoices", { method: "get" }).then(result => return ajax("/s/invoices", { method: "get" }).then(result =>
result.map(invoice => Invoice.create(invoice)) result.map(invoice => Invoice.create(invoice))
); );
} }

View File

@ -21,7 +21,7 @@ const Plan = Discourse.Model.extend({
Plan.reopenClass({ Plan.reopenClass({
findAll(data) { findAll(data) {
return ajax("/patrons/plans", { method: "get", data }).then(result => return ajax("/s/plans", { method: "get", data }).then(result =>
result.map(plan => Plan.create(plan)) result.map(plan => Plan.create(plan))
); );
} }

View File

@ -4,13 +4,13 @@ const Product = Discourse.Model.extend({});
Product.reopenClass({ Product.reopenClass({
findAll() { findAll() {
return ajax("/patrons/products", { method: "get" }).then(result => return ajax("/s/products", { method: "get" }).then(result =>
result.map(product => Product.create(product)) result.map(product => Product.create(product))
); );
}, },
find(id) { find(id) {
return ajax(`/patrons/products/${id}`, { method: "get" }).then(product => return ajax(`/s/products/${id}`, { method: "get" }).then(product =>
Product.create(product) Product.create(product)
); );
} }

View File

@ -13,13 +13,13 @@ const Subscription = Discourse.Model.extend({
plan: this.plan plan: this.plan
}; };
return ajax("/patrons/subscriptions", { method: "post", data }); return ajax("/s/subscriptions", { method: "post", data });
} }
}); });
Subscription.reopenClass({ Subscription.reopenClass({
findAll() { findAll() {
return ajax("/patrons/subscriptions", { method: "get" }).then(result => return ajax("/s/subscriptions", { method: "get" }).then(result =>
result.map(subscription => Subscription.create(subscription)) result.map(subscription => Subscription.create(subscription))
); );
} }

View File

@ -9,7 +9,7 @@ const UserSubscription = Discourse.Model.extend({
}, },
destroy() { destroy() {
return ajax(`/patrons/user/subscriptions/${this.id}`, { return ajax(`/s/user/subscriptions/${this.id}`, {
method: "delete" method: "delete"
}).then(result => UserSubscription.create(result)); }).then(result => UserSubscription.create(result));
} }
@ -17,7 +17,7 @@ const UserSubscription = Discourse.Model.extend({
UserSubscription.reopenClass({ UserSubscription.reopenClass({
findAll() { findAll() {
return ajax("/patrons/user/subscriptions", { method: "get" }).then(result => return ajax("/s/user/subscriptions", { method: "get" }).then(result =>
result.map(subscription => { result.map(subscription => {
subscription.plan = Plan.create(subscription.plan); subscription.plan = Plan.create(subscription.plan);
return UserSubscription.create(subscription); return UserSubscription.create(subscription);

View File

@ -1,5 +1,5 @@
export default function() { export default function() {
this.route("patrons", function() { this.route("s", function() {
this.route("subscribe", function() { this.route("subscribe", function() {
this.route("show", { path: "/:subscription-id" }); this.route("show", { path: "/:subscription-id" });
}); });

View File

@ -8,7 +8,7 @@ export default Discourse.Route.extend({
phone: "" phone: ""
}); });
return ajax("/patrons", { return ajax("/s", {
method: "get" method: "get"
}) })
.then(result => { .then(result => {

View File

@ -9,7 +9,7 @@
{{#if currentUser}} {{#if currentUser}}
<div class="pull-right"> <div class="pull-right">
{{#link-to "patrons.subscribe.show" product.id disabled=product.subscribed class="btn btn-primary"}} {{#link-to "s.subscribe.show" product.id disabled=product.subscribed class="btn btn-primary"}}
{{i18n 'discourse_patrons.subscribe.title'}} {{i18n 'discourse_patrons.subscribe.title'}}
{{/link-to}} {{/link-to}}
</div> </div>

View File

@ -1,5 +1,5 @@
{{#if (show-extra-nav)}} {{#if (show-extra-nav)}}
{{#link-to 'patrons.subscribe' class='discourse-patrons-subscribe'}} {{#link-to 's.subscribe' class='discourse-patrons-subscribe'}}
{{i18n 'discourse_patrons.navigation.subscribe'}} {{i18n 'discourse_patrons.navigation.subscribe'}}
{{/link-to}} {{/link-to}}
{{/if}} {{/if}}

View File

@ -16,6 +16,7 @@ en:
js: js:
discourse_patrons: discourse_patrons:
title: Discourse Subscriptions title: Discourse Subscriptions
admin_navigation: Subscriptions
optional: Optional optional: Optional
transactions: transactions:
payment: payment:

View File

@ -24,7 +24,7 @@ extend_content_security_policy(
script_src: ['https://js.stripe.com/v3/'] script_src: ['https://js.stripe.com/v3/']
) )
add_admin_route 'discourse_patrons.title', 'discourse-subscriptions.products' add_admin_route 'discourse_patrons.admin_navigation', 'discourse-subscriptions.products'
Discourse::Application.routes.append do Discourse::Application.routes.append do
get '/admin/plugins/discourse-subscriptions' => 'admin/plugins#index' get '/admin/plugins/discourse-subscriptions' => 'admin/plugins#index'
@ -69,6 +69,6 @@ after_initialize do
].each { |path| require File.expand_path(path, __FILE__) } ].each { |path| require File.expand_path(path, __FILE__) }
Discourse::Application.routes.append do Discourse::Application.routes.append do
mount ::DiscoursePatrons::Engine, at: 'patrons' mount ::DiscoursePatrons::Engine, at: 's'
end end
end end