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

37 lines
965 B
JavaScript
Raw Normal View History

2019-12-12 19:54:32 -05:00
import Route from "@ember/routing/route";
2019-12-02 02:58:14 -05:00
import AdminProduct from "discourse/plugins/discourse-subscriptions/discourse/models/admin-product";
import I18n from "I18n";
import { action } from "@ember/object";
2022-10-17 14:42:40 -04:00
import { inject as service } from "@ember/service";
2019-10-14 22:18:25 -04:00
2019-12-12 19:54:32 -05:00
export default Route.extend({
2022-10-17 14:42:40 -04:00
dialog: service(),
2019-10-14 22:18:25 -04:00
model() {
2019-10-15 08:14:04 -04:00
return AdminProduct.findAll();
2019-10-14 22:18:25 -04:00
},
@action
destroyProduct(product) {
2022-10-17 14:42:40 -04:00
this.dialog.yesNoConfirm({
message: I18n.t(
"discourse_subscriptions.admin.products.operations.destroy.confirm"
),
2022-10-17 14:42:40 -04:00
didConfirm: () => {
return product
.destroy()
.then(() => {
this.controllerFor(
"adminPluginsDiscourseSubscriptionsProductsIndex"
)
.get("model")
.removeObject(product);
})
.catch((data) =>
this.dialog.alert(data.jqXHR.responseJSON.errors.join("\n"))
);
},
});
2020-09-16 10:53:50 -04:00
},
2019-10-14 22:18:25 -04:00
});