0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2025-02-02 11:27:01 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-text-editor.js.es6

57 Zeilen
1,5 KiB
Text

2020-04-05 11:37:09 +10:00
import { default as discourseComputed, on } from 'discourse-common/utils/decorators';
2020-04-14 15:46:06 +10:00
import { notEmpty } from "@ember/object/computed";
2020-04-10 17:57:49 +10:00
import { userProperties } from '../lib/wizard';
2020-03-30 10:53:28 +11:00
import { scheduleOnce } from "@ember/runloop";
2020-04-05 11:37:09 +10:00
import Component from "@ember/component";
2020-03-29 18:49:33 +11:00
2020-04-05 11:37:09 +10:00
export default Component.extend({
2020-03-29 18:49:33 +11:00
classNames: 'wizard-text-editor',
2020-03-30 10:53:28 +11:00
barEnabled: true,
previewEnabled: true,
fieldsEnabled: true,
2020-04-14 15:46:06 +10:00
hasWizardFields: notEmpty('wizardFieldList'),
2020-03-30 10:53:28 +11:00
didReceiveAttrs() {
this._super(...arguments);
2020-04-14 15:46:06 +10:00
2020-03-30 10:53:28 +11:00
if (!this.barEnabled) {
scheduleOnce('afterRender', () => {
$(this.element).find('.d-editor-button-bar').addClass('hidden');
});
}
},
2020-03-29 18:49:33 +11:00
@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()
userFieldList() {
2020-04-10 17:57:49 +10:00
return userProperties.map((f) => ` u{${f}}`);
2020-03-29 18:49:33 +11:00
},
@discourseComputed('wizardFields')
wizardFieldList(wizardFields) {
return wizardFields.map((f) => ` w{${f.id}}`);
},
actions: {
togglePreview() {
this.toggleProperty('forcePreview');
},
togglePopover() {
this.toggleProperty('showPopover');
}
}
});