discourse-subscriptions/assets/javascripts/discourse/routes/admin-plugins-discourse-pat...

36 lines
1001 B
Plaintext
Raw Normal View History

2019-10-21 00:28:45 -04:00
import AdminPlan from "discourse/plugins/discourse-patrons/discourse/models/admin-plan";
2019-10-22 20:50:54 -04:00
import Group from "discourse/models/group";
2019-10-21 00:28:45 -04:00
export default Discourse.Route.extend({
model(params) {
2019-10-24 23:00:59 -04:00
const id = params["plan-id"];
const product = this.modelFor(
"adminPlugins.discourse-patrons.products.show"
).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,
2019-11-30 00:39:28 -05:00
currency: Discourse.SiteSettings.discourse_patrons_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 });
return Ember.RSVP.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-10-24 23:00:59 -04:00
this.render("adminPlugins.discourse-patrons.products.show.plans.show", {
into: "adminPlugins.discourse-patrons.products",
outlet: "main",
controller: "adminPlugins.discourse-patrons.products.show.plans.show"
2019-10-22 00:45:51 -04:00
});
2019-10-24 23:00:59 -04:00
}
2019-10-21 00:28:45 -04:00
});