0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-text-editor.js.es6
Angus McLeod cf50a7deb3
Apply prettier 💄 (#80)
* Apply prettier

* applied prettier for similar-topics-validator

Co-authored-by: Faizaan Gagan <fzngagan@gmail.com>
2021-03-28 14:36:49 +05:30

75 Zeilen
1,8 KiB
JavaScript

import {
default as discourseComputed,
on,
} from "discourse-common/utils/decorators";
import { notEmpty } from "@ember/object/computed";
import { userProperties } from "../lib/wizard";
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import I18n from "I18n";
const excludedUserProperties = [
"avatar",
"profile_background",
"card_background",
];
export default Component.extend({
classNames: "wizard-text-editor",
barEnabled: true,
previewEnabled: true,
fieldsEnabled: true,
hasWizardFields: notEmpty("wizardFieldList"),
hasWizardActions: notEmpty("wizardActionList"),
didReceiveAttrs() {
this._super(...arguments);
if (!this.barEnabled) {
scheduleOnce("afterRender", () => {
$(this.element).find(".d-editor-button-bar").addClass("hidden");
});
}
},
@discourseComputed("forcePreview")
previewLabel(forcePreview) {
return I18n.t("admin.wizard.editor.preview", {
action: I18n.t(`admin.wizard.editor.${forcePreview ? "hide" : "show"}`),
});
},
@discourseComputed("showPopover")
popoverLabel(showPopover) {
return I18n.t("admin.wizard.editor.popover", {
action: I18n.t(`admin.wizard.editor.${showPopover ? "hide" : "show"}`),
});
},
@discourseComputed()
userPropertyList() {
return userProperties
.filter((f) => !excludedUserProperties.includes(f))
.map((f) => ` u{${f}}`);
},
@discourseComputed("wizardFields")
wizardFieldList(wizardFields) {
return wizardFields.map((f) => ` w{${f.id}}`);
},
@discourseComputed("wizardActions")
wizardActionList(wizardActions) {
return wizardActions.map((a) => ` w{${a.id}}`);
},
actions: {
togglePreview() {
this.toggleProperty("forcePreview");
},
togglePopover() {
this.toggleProperty("showPopover");
},
},
});