0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-23 09:50:28 +01:00
discourse-custom-wizard/assets/javascripts/wizard/controllers/wizard-index.js.es6

25 Zeilen
660 B
Text

2022-03-16 12:33:34 +01:00
import Controller from "@ember/controller";
import { or } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators";
const reasons = {
noWizard: "none",
requiresLogin: "requires_login",
notPermitted: "not_permitted",
2022-06-15 08:59:09 +02:00
completed: "completed",
};
2022-03-16 12:33:34 +01:00
export default Controller.extend({
2022-06-15 08:59:09 +02:00
noAccess: or("noWizard", "requiresLogin", "notPermitted", "completed"),
2022-03-16 12:33:34 +01:00
2022-06-15 08:59:09 +02:00
@discourseComputed("noAccessReason")
2022-03-16 12:33:34 +01:00
noAccessI18nKey(reason) {
2022-06-15 08:59:09 +02:00
return reason ? `wizard.${reasons[reason]}` : "wizard.none";
2022-03-16 12:33:34 +01:00
},
@discourseComputed
noAccessReason() {
2022-06-15 08:59:09 +02:00
return Object.keys(reasons).find((reason) => this.get(reason));
},
2022-03-16 12:33:34 +01:00
});