diff --git a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 index 654fea42..f5d85a48 100644 --- a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 @@ -65,4 +65,14 @@ export default Ember.Component.extend({ return options; }, + + actions: { + imageUploadDone(upload) { + this.set("field.image", upload.url); + }, + + imageUploadDeleted() { + this.set("field.image", null); + } + } }); diff --git a/assets/javascripts/discourse/components/wizard-custom-step.js.es6 b/assets/javascripts/discourse/components/wizard-custom-step.js.es6 index c8945b80..066deff2 100644 --- a/assets/javascripts/discourse/components/wizard-custom-step.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-step.js.es6 @@ -67,4 +67,14 @@ export default Ember.Component.extend({ return fields; }, + + actions: { + bannerUploadDone(upload) { + this.set("step.banner", upload.url); + }, + + bannerUploadDeleted() { + this.set("step.banner", null); + } + } }); diff --git a/assets/javascripts/discourse/components/wizard-links.js.es6 b/assets/javascripts/discourse/components/wizard-links.js.es6 index e7113c17..5a351296 100644 --- a/assets/javascripts/discourse/components/wizard-links.js.es6 +++ b/assets/javascripts/discourse/components/wizard-links.js.es6 @@ -1,15 +1,16 @@ import { default as computed, on, observes } from 'discourse-common/utils/decorators'; import { notEmpty } from "@ember/object/computed"; +import { scheduleOnce } from "@ember/runloop"; export default Ember.Component.extend({ - classNames: 'wizard-links', + classNameBindings: [':wizard-links', 'type'], items: Ember.A(), anyLinks: notEmpty('links'), @on('didInsertElement') @observes('links.@each') didInsertElement() { - Ember.run.scheduleOnce('afterRender', () => (this.applySortable())); + scheduleOnce('afterRender', () => (this.applySortable())); }, applySortable() { @@ -25,7 +26,7 @@ export default Ember.Component.extend({ const item = items.findBy('id', itemId); items.removeObject(item); items.insertAt(newIndex, item); - Ember.run.scheduleOnce('afterRender', this, () => this.applySortable()); + scheduleOnce('afterRender', this, () => this.applySortable()); }, @computed('type') diff --git a/assets/javascripts/discourse/components/wizard-text-editor.js.es6 b/assets/javascripts/discourse/components/wizard-text-editor.js.es6 index 2a24cd0b..7335f75f 100644 --- a/assets/javascripts/discourse/components/wizard-text-editor.js.es6 +++ b/assets/javascripts/discourse/components/wizard-text-editor.js.es6 @@ -1,8 +1,24 @@ -import { default as discourseComputed } from 'discourse-common/utils/decorators'; +import { + default as discourseComputed, + on +} from 'discourse-common/utils/decorators'; import { profileFields } from '../lib/custom-wizard'; +import { scheduleOnce } from "@ember/runloop"; export default Ember.Component.extend({ classNames: 'wizard-text-editor', + barEnabled: true, + previewEnabled: true, + fieldsEnabled: true, + + didReceiveAttrs() { + this._super(...arguments); + if (!this.barEnabled) { + scheduleOnce('afterRender', () => { + $(this.element).find('.d-editor-button-bar').addClass('hidden'); + }); + } + }, @discourseComputed('forcePreview') previewLabel(forcePreview) { diff --git a/assets/javascripts/discourse/controllers/admin-wizard.js.es6 b/assets/javascripts/discourse/controllers/admin-wizard.js.es6 index acd25f95..f9960371 100644 --- a/assets/javascripts/discourse/controllers/admin-wizard.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizard.js.es6 @@ -1,10 +1,22 @@ -import { default as computed } from 'discourse-common/utils/decorators'; +import { default as computed, observes } from 'discourse-common/utils/decorators'; +import { notEmpty } from "@ember/object/computed"; import showModal from 'discourse/lib/show-modal'; +import { generateId } from '../lib/custom-wizard'; +import { dasherize } from "@ember/string"; export default Ember.Controller.extend({ - @computed('model.id', 'model.name') + hasName: notEmpty('model.name'), + + @computed('model.id') wizardUrl(wizardId) { - return window.location.origin + '/w/' + Ember.String.dasherize(wizardId); + return window.location.origin + '/w/' + dasherize(wizardId); + }, + + @observes('model.name') + setId() { + if (!this.model.existingId) { + this.set('model.id', generateId(this.model.name)); + } }, @computed('model.after_time_scheduled') diff --git a/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 b/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 index 9e925b26..592de089 100644 --- a/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 +++ b/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 @@ -1,4 +1,5 @@ import { default as computed } from 'discourse-common/utils/decorators'; +import { scheduleOnce } from "@ember/runloop"; export default Ember.Controller.extend({ title: 'admin.wizard.after_time_modal.title', @@ -14,7 +15,7 @@ export default Ember.Controller.extend({ this.setProperties({ date, time }); - Ember.run.scheduleOnce('afterRender', this, () => { + scheduleOnce('afterRender', this, () => { const $timePicker = $("#time-picker"); $timePicker.timepicker({ timeFormat: 'H:i' }); $timePicker.timepicker('setTime', time); diff --git a/assets/javascripts/discourse/lib/custom-wizard.js.es6 b/assets/javascripts/discourse/lib/custom-wizard.js.es6 index 90c7036c..8ffdcd97 100644 --- a/assets/javascripts/discourse/lib/custom-wizard.js.es6 +++ b/assets/javascripts/discourse/lib/custom-wizard.js.es6 @@ -121,6 +121,12 @@ function newPair(options = {}) { return Ember.Object.create(params); } +function generateId(name) { + return name.replace(/[^\w ]/g, '') + .replace(/ /g,"_") + .toLowerCase(); +} + export { generateSelectKitContent, profileFields, @@ -130,5 +136,6 @@ export { defaultSelectionType, connectors, newInput, - newPair + newPair, + generateId }; \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/admin-wizard.hbs b/assets/javascripts/discourse/templates/admin-wizard.hbs index 87265cc2..31064780 100644 --- a/assets/javascripts/discourse/templates/admin-wizard.hbs +++ b/assets/javascripts/discourse/templates/admin-wizard.hbs @@ -1,30 +1,19 @@