1
0
Fork 0
discourse-custom-wizard-unl.../assets/javascripts/discourse/components/wizard-text-editor.js.es6

56 Zeilen
1,3 KiB
Text

2020-03-30 01:53:28 +02:00
import {
default as discourseComputed,
on
} from 'discourse-common/utils/decorators';
2020-04-02 07:21:57 +02:00
import { profileFields } from '../lib/wizard';
2020-03-30 01:53:28 +02:00
import { scheduleOnce } from "@ember/runloop";
2020-03-29 09:49:33 +02:00
export default Ember.Component.extend({
classNames: 'wizard-text-editor',
2020-03-30 01:53:28 +02:00
barEnabled: true,
previewEnabled: true,
fieldsEnabled: true,
didReceiveAttrs() {
this._super(...arguments);
if (!this.barEnabled) {
scheduleOnce('afterRender', () => {
$(this.element).find('.d-editor-button-bar').addClass('hidden');
});
}
},
2020-03-29 09:49:33 +02: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() {
return profileFields.map((f) => ` u{${f}}`);
},
@discourseComputed('wizardFields')
wizardFieldList(wizardFields) {
return wizardFields.map((f) => ` w{${f.id}}`);
},
actions: {
togglePreview() {
this.toggleProperty('forcePreview');
},
togglePopover() {
this.toggleProperty('showPopover');
}
}
});