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

28 lines
778 B
Plaintext
Raw Normal View History

2019-10-14 22:18:25 -04:00
import AdminProduct from "discourse/plugins/discourse-patrons/discourse/models/admin-product";
export default Discourse.Route.extend({
model() {
2019-10-15 08:14:04 -04:00
return AdminProduct.findAll();
2019-10-14 22:18:25 -04:00
},
actions: {
destroyProduct(product) {
bootbox.confirm(
I18n.t("discourse_patrons.admin.products.operations.destroy.confirm"),
I18n.t("no_value"),
I18n.t("yes_value"),
confirmed => {
if (confirmed) {
2019-10-15 08:14:04 -04:00
product.destroy().then(() => {
this.controllerFor("adminPluginsDiscoursePatronsProductsIndex")
.get("model")
.removeObject(product);
})
.catch(data => bootbox.alert(data.jqXHR.responseJSON.errors.join("\n")));
2019-10-14 22:18:25 -04:00
}
}
);
}
}
});