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";
|
2020-05-22 12:20:05 -04:00
|
|
|
import I18n from "I18n";
|
2022-01-06 06:32:09 -05:00
|
|
|
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
|
|
|
},
|
|
|
|
|
2022-01-06 06:32:09 -05:00
|
|
|
@action
|
|
|
|
destroyProduct(product) {
|
2022-10-17 14:42:40 -04:00
|
|
|
this.dialog.yesNoConfirm({
|
|
|
|
message: I18n.t(
|
2022-01-06 06:32:09 -05:00
|
|
|
"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
|
|
|
});
|