0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-27 03:20:27 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-subscription.js.es6

56 Zeilen
1,5 KiB
Text

import Component from "@ember/component";
2021-09-24 11:58:42 +02:00
import CustomWizardSubscription from "../models/custom-wizard-subscription";
import { notEmpty } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators";
2021-09-07 14:15:04 +02:00
import I18n from "I18n";
export default Component.extend({
2021-09-07 14:13:01 +02:00
classNameBindings: [
2021-09-24 11:58:42 +02:00
":custom-wizard-subscription",
2021-09-07 14:13:01 +02:00
"subscription.active:active:inactive",
],
subscribed: notEmpty("subscription"),
2021-09-07 14:13:01 +02:00
@discourseComputed("subscription.type")
title(type) {
2021-09-07 14:13:01 +02:00
return type
2021-09-24 11:58:42 +02:00
? I18n.t(`admin.wizard.subscription.subscription.title.${type}`)
: I18n.t("admin.wizard.subscription.not_subscribed");
},
2021-09-07 14:13:01 +02:00
@discourseComputed("subscription.active")
stateClass(active) {
2021-09-07 14:13:01 +02:00
return active ? "active" : "inactive";
},
2021-09-07 14:13:01 +02:00
@discourseComputed("stateClass")
stateLabel(stateClass) {
2021-10-19 14:49:06 +02:00
return I18n.t(
`admin.wizard.subscription.subscription.status.${stateClass}`
);
},
actions: {
update() {
2021-09-07 14:13:01 +02:00
this.set("updating", true);
2021-09-24 11:58:42 +02:00
CustomWizardSubscription.update()
2021-09-07 14:13:01 +02:00
.then((result) => {
if (result.success) {
this.setProperties({
updateIcon: "check",
subscription: result.subscription,
});
} else {
this.set("updateIcon", "times");
}
})
.finally(() => {
this.set("updating", false);
setTimeout(() => {
this.set("updateIcon", null);
}, 7000);
});
},
},
});