FEATURE: Show a textarea in advanced mode (#12806)

When switching to advanced mode, show a textarea instead of individual
inputs. Every line of the textarea is equivalent with an input.
This commit is contained in:
Bianca Nenciu
2021-04-23 16:54:53 +03:00
committed by GitHub
parent e53b474557
commit a97e3e249d
3 changed files with 41 additions and 15 deletions
@@ -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