diff --git a/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 b/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 index af48e1e6909..a067838bb3e 100644 --- a/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 +++ b/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 @@ -24,6 +24,7 @@ export default Controller.extend(ModalFunctionality, { pollType: REGULAR_POLL_TYPE, pollTitle: "", pollOptions: null, + pollOptionsText: null, pollMin: 1, pollMax: 2, pollStep: 1, @@ -39,6 +40,7 @@ export default Controller.extend(ModalFunctionality, { pollType: REGULAR_POLL_TYPE, pollTitle: null, pollOptions: [EmberObject.create({ value: "" })], + pollOptionsText: "", pollMin: 1, pollMax: 2, pollStep: 1, @@ -337,6 +339,17 @@ export default Controller.extend(ModalFunctionality, { })); }, + @action + onOptionsTextChange(e) { + let idx = 0; + this.set( + "pollOptions", + e.target.value + .split("\n") + .map((value) => EmberObject.create({ idx: idx++, value })) + ); + }, + @action insertPoll() { this.toolbarEvent.addText(this.pollOutput); @@ -346,6 +359,12 @@ export default Controller.extend(ModalFunctionality, { @action toggleAdvanced() { this.toggleProperty("showAdvanced"); + if (this.showAdvanced) { + this.set( + "pollOptionsText", + this.pollOptions.map((x) => x.value).join("\n") + ); + } }, @action diff --git a/plugins/poll/assets/javascripts/discourse/templates/modal/poll-ui-builder.hbs b/plugins/poll/assets/javascripts/discourse/templates/modal/poll-ui-builder.hbs index 0f2f4479922..6c464e8a3e2 100644 --- a/plugins/poll/assets/javascripts/discourse/templates/modal/poll-ui-builder.hbs +++ b/plugins/poll/assets/javascripts/discourse/templates/modal/poll-ui-builder.hbs @@ -26,23 +26,30 @@