2020-05-28 10:32:57 -05:00
|
|
|
import Controller from "@ember/controller";
|
2023-12-01 18:30:36 +00:00
|
|
|
import { inject as service } from "@ember/service";
|
2024-01-16 17:51:44 +01:00
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2019-10-15 09:40:49 +11:00
|
|
|
|
2020-05-28 10:32:57 -05:00
|
|
|
export default Controller.extend({
|
2023-12-01 18:30:36 +00:00
|
|
|
router: service(),
|
|
|
|
|
|
2019-10-15 09:40:49 +11:00
|
|
|
actions: {
|
2019-10-22 16:35:41 +11:00
|
|
|
cancelProduct() {
|
2023-12-01 18:30:36 +00:00
|
|
|
this.router.transitionTo("adminPlugins.discourse-subscriptions.products");
|
2019-10-22 16:35:41 +11:00
|
|
|
},
|
|
|
|
|
|
2019-10-15 21:50:30 +11:00
|
|
|
createProduct() {
|
|
|
|
|
this.get("model.product")
|
2019-10-15 09:40:49 +11:00
|
|
|
.save()
|
2020-09-16 09:53:50 -05:00
|
|
|
.then((product) => {
|
2023-12-01 18:30:36 +00:00
|
|
|
this.router.transitionTo(
|
2019-12-02 18:58:14 +11:00
|
|
|
"adminPlugins.discourse-subscriptions.products.show",
|
2019-10-25 14:00:59 +11:00
|
|
|
product.id
|
|
|
|
|
);
|
2019-10-23 15:55:06 +11:00
|
|
|
})
|
2019-10-15 09:40:49 +11:00
|
|
|
.catch(popupAjaxError);
|
2019-10-16 14:15:01 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updateProduct() {
|
|
|
|
|
this.get("model.product")
|
|
|
|
|
.update()
|
2019-10-23 15:55:06 +11:00
|
|
|
.then(() => {
|
2023-12-01 18:30:36 +00:00
|
|
|
this.router.transitionTo(
|
2019-12-03 10:52:46 +11:00
|
|
|
"adminPlugins.discourse-subscriptions.products"
|
|
|
|
|
);
|
2019-10-23 15:55:06 +11:00
|
|
|
})
|
2019-10-16 14:15:01 +11:00
|
|
|
.catch(popupAjaxError);
|
2020-09-16 09:53:50 -05:00
|
|
|
},
|
|
|
|
|
},
|
2019-10-15 09:40:49 +11:00
|
|
|
});
|