2019-12-12 19:54:32 -05:00
|
|
|
import Route from "@ember/routing/route";
|
2019-12-02 02:58:14 -05:00
|
|
|
import AdminPlan from "discourse/plugins/discourse-subscriptions/discourse/models/admin-plan";
|
2019-10-22 20:50:54 -04:00
|
|
|
import Group from "discourse/models/group";
|
2020-05-28 11:32:57 -04:00
|
|
|
import { hash } from "rsvp";
|
2019-10-21 00:28:45 -04:00
|
|
|
|
2019-12-12 19:54:32 -05:00
|
|
|
export default Route.extend({
|
2019-10-21 00:28:45 -04:00
|
|
|
model(params) {
|
2019-10-24 23:00:59 -04:00
|
|
|
const id = params["plan-id"];
|
|
|
|
const product = this.modelFor(
|
2019-12-02 02:58:14 -05:00
|
|
|
"adminPlugins.discourse-subscriptions.products.show"
|
2019-10-24 23:00:59 -04:00
|
|
|
).product;
|
2019-10-22 00:45:51 -04:00
|
|
|
let plan;
|
|
|
|
|
2019-10-24 23:00:59 -04:00
|
|
|
if (id === "new") {
|
|
|
|
plan = AdminPlan.create({
|
|
|
|
active: true,
|
|
|
|
isNew: true,
|
2020-05-28 11:32:57 -04:00
|
|
|
interval: "month",
|
2019-12-03 19:53:05 -05:00
|
|
|
currency: Discourse.SiteSettings.discourse_subscriptions_currency,
|
2019-10-24 23:00:59 -04:00
|
|
|
product: product.get("id")
|
|
|
|
});
|
|
|
|
} else {
|
2019-10-22 00:45:51 -04:00
|
|
|
plan = AdminPlan.find(id);
|
|
|
|
}
|
|
|
|
|
2019-10-22 20:50:54 -04:00
|
|
|
const groups = Group.findAll({ ignore_automatic: true });
|
|
|
|
|
2020-05-28 11:32:57 -04:00
|
|
|
return hash({ plan, product, groups });
|
2019-10-22 00:45:51 -04:00
|
|
|
},
|
2019-10-21 00:28:45 -04:00
|
|
|
|
2019-10-22 19:36:12 -04:00
|
|
|
renderTemplate() {
|
2019-12-02 18:52:46 -05:00
|
|
|
this.render(
|
|
|
|
"adminPlugins.discourse-subscriptions.products.show.plans.show",
|
|
|
|
{
|
|
|
|
into: "adminPlugins.discourse-subscriptions.products",
|
|
|
|
outlet: "main",
|
|
|
|
controller:
|
|
|
|
"adminPlugins.discourse-subscriptions.products.show.plans.show"
|
|
|
|
}
|
|
|
|
);
|
2019-10-24 23:00:59 -04:00
|
|
|
}
|
2019-10-21 00:28:45 -04:00
|
|
|
});
|