2019-10-13 21:36:46 -04:00
|
|
|
import AdminSubscription from "discourse/plugins/discourse-patrons/discourse/models/admin-subscription";
|
2019-09-23 03:53:05 -04:00
|
|
|
|
|
|
|
export default Discourse.Route.extend({
|
2019-09-26 19:42:32 -04:00
|
|
|
model() {
|
2019-10-13 21:36:46 -04:00
|
|
|
return AdminSubscription.find();
|
2019-11-13 18:51:04 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
cancelSubscription(subscription) {
|
|
|
|
bootbox.confirm(
|
|
|
|
I18n.t(
|
|
|
|
"discourse_patrons.user.subscriptions.operations.destroy.confirm"
|
|
|
|
),
|
|
|
|
I18n.t("no_value"),
|
|
|
|
I18n.t("yes_value"),
|
|
|
|
confirmed => {
|
|
|
|
if (confirmed) {
|
2019-11-13 22:07:45 -05:00
|
|
|
subscription.set("loading", true);
|
|
|
|
|
2019-11-13 18:51:04 -05:00
|
|
|
subscription
|
|
|
|
.destroy()
|
|
|
|
.then(result => subscription.set("status", result.status))
|
|
|
|
.catch(data =>
|
|
|
|
bootbox.alert(data.jqXHR.responseJSON.errors.join("\n"))
|
2019-11-13 22:07:45 -05:00
|
|
|
)
|
|
|
|
.finally(() => {
|
|
|
|
subscription.set("loading", false);
|
|
|
|
});
|
2019-11-13 18:51:04 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2019-09-24 21:18:11 -04:00
|
|
|
}
|
2019-09-23 03:53:05 -04:00
|
|
|
});
|