branch feature/multi-ui updated (bd632735 -> dc869a4f)
This is an automated email from the git hooks/post-receive script. New change to branch feature/multi-ui in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git from bd632735 Merge branch 'feature/multi-ui' of gitlab.nuiton.org:chorem/pollen into feature/multi-ui new dc869a4f Can now create a multi question poll (still ugly and not perfect, but it works \o/ ). Still need: - Good navigation between question at creation going back and forth - Per question options - Summary (after saving) - First summary renaming (before saving) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit dc869a4fa4abc190711920f8110c6c13bd303e1b Author: jcouteau <couteau@codelutin.com> Date: Sat Aug 17 08:03:39 2019 +0200 Can now create a multi question poll (still ugly and not perfect, but it works \o/ ). Still need: - Good navigation between question at creation going back and forth - Per question options - Summary (after saving) - First summary renaming (before saving) After that, need to vote multi-question Summary of changes: pollen-ui-riot-js/src/main/web/i18n/en.json | 6 + pollen-ui-riot-js/src/main/web/i18n/fr.json | 8 ++ pollen-ui-riot-js/src/main/web/js/PollForm.js | 34 ++++- pollen-ui-riot-js/src/main/web/js/PollService.js | 34 +++-- pollen-ui-riot-js/src/main/web/js/Question.js | 10 ++ .../src/main/web/tag/poll/Choices.tag.html | 23 +++- .../src/main/web/tag/poll/Description.tag.html | 4 + .../src/main/web/tag/poll/EditPoll.tag.html | 54 +++++++- .../src/main/web/tag/poll/EditQuestions.tag.html | 101 +++++++++++++++ .../src/main/web/tag/poll/SummaryMulti.tag.html | 144 +++++++++++++++++++++ .../src/main/web/tag/poll/SummaryQuestion.tag.html | 137 ++++++++++++++++++++ 11 files changed, 527 insertions(+), 28 deletions(-) create mode 100644 pollen-ui-riot-js/src/main/web/js/Question.js create mode 100644 pollen-ui-riot-js/src/main/web/tag/poll/EditQuestions.tag.html create mode 100644 pollen-ui-riot-js/src/main/web/tag/poll/SummaryMulti.tag.html create mode 100644 pollen-ui-riot-js/src/main/web/tag/poll/SummaryQuestion.tag.html -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/multi-ui in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit dc869a4fa4abc190711920f8110c6c13bd303e1b Author: jcouteau <couteau@codelutin.com> Date: Sat Aug 17 08:03:39 2019 +0200 Can now create a multi question poll (still ugly and not perfect, but it works \o/ ). Still need: - Good navigation between question at creation going back and forth - Per question options - Summary (after saving) - First summary renaming (before saving) After that, need to vote multi-question --- pollen-ui-riot-js/src/main/web/i18n/en.json | 6 + pollen-ui-riot-js/src/main/web/i18n/fr.json | 8 ++ pollen-ui-riot-js/src/main/web/js/PollForm.js | 34 ++++- pollen-ui-riot-js/src/main/web/js/PollService.js | 34 +++-- pollen-ui-riot-js/src/main/web/js/Question.js | 10 ++ .../src/main/web/tag/poll/Choices.tag.html | 23 +++- .../src/main/web/tag/poll/Description.tag.html | 4 + .../src/main/web/tag/poll/EditPoll.tag.html | 54 +++++++- .../src/main/web/tag/poll/EditQuestions.tag.html | 101 +++++++++++++++ .../src/main/web/tag/poll/SummaryMulti.tag.html | 144 +++++++++++++++++++++ .../src/main/web/tag/poll/SummaryQuestion.tag.html | 137 ++++++++++++++++++++ 11 files changed, 527 insertions(+), 28 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/i18n/en.json b/pollen-ui-riot-js/src/main/web/i18n/en.json index 8a233d84..d8244173 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/en.json +++ b/pollen-ui-riot-js/src/main/web/i18n/en.json @@ -299,6 +299,12 @@ "poll_description_email": "Your email", "poll_description_emailPlaceHolder": "Enter your email", "poll_description_multiQuestion": "Multi-questions poll", + "poll_editQuestions_info": "Information", + "poll_editQuestions_title": "Title", + "poll_editQuestions_titlePlaceHolder": "Enter question title", + "poll_editQuestions_titleNotBlank": "Title must be not blank", + "poll_editQuestions_description": "Description", + "poll_editQuestions_descriptionPlaceHolder": "Enter question description", "poll_settings_pollType": "Poll opening", "poll_settings_pollType_FREE": "Open to all", "poll_settings_pollType_FREE_help": "Anyone with the poll link can vote.", diff --git a/pollen-ui-riot-js/src/main/web/i18n/fr.json b/pollen-ui-riot-js/src/main/web/i18n/fr.json index b460506b..b5341a0c 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/fr.json +++ b/pollen-ui-riot-js/src/main/web/i18n/fr.json @@ -299,6 +299,14 @@ "poll_description_email": "Votre adresse électronique", "poll_description_emailPlaceHolder": "Renseignez votre adresse électronique", "poll_description_multiQuestion": "Sondage à plusieurs questions", + "poll_editQuestions_info": "Informations", + "poll_editQuestions_title": "Titre", + "poll_editQuestions_titlePlaceHolder": "Renseignez le titre de la question", + "poll_editQuestions_titleNotBlank": "Le titre ne doit pas être blanc", + "poll_editQuestions_description": "Description", + "poll_editQuestions_descriptionPlaceHolder": "Renseignez la description de la question", + "poll_editQuestions_newQuestion": "Question suivante", + "poll_editQuestions_previousQuestion": "Question précédente", "poll_settings_pollType": "Ouverture du sondage", "poll_settings_pollType_FREE": "Ouvert à tous", "poll_settings_pollType_FREE_help": "Toutes les personnes ayant le lien du sondage peuvent voter.", diff --git a/pollen-ui-riot-js/src/main/web/js/PollForm.js b/pollen-ui-riot-js/src/main/web/js/PollForm.js index 376318a2..a0e074ed 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollForm.js +++ b/pollen-ui-riot-js/src/main/web/js/PollForm.js @@ -20,6 +20,7 @@ */ import singleton from "./Singleton"; import Choice from "./Choice"; +import Question from "./Question"; import voteCountingTypeService from "./VoteCountingTypeService"; import resourceService from "./ResourceService"; import pollService from "./PollService"; @@ -34,15 +35,13 @@ class PollForm { this.stepsNoMulti = [ "general", "choices", - "options", - "voters" + "options" ]; this.stepsMulti = [ "general", "options", "questions", - "summary", - "voters" + "summary" ]; this.types = ["FREE", "RESTRICTED", "REGISTERED"]; @@ -68,11 +67,17 @@ class PollForm { } getSteps(multi){ + let steps; if (multi) { - return this.stepsMulti; + steps = this.stepsMulti; } else { - return this.stepsNoMulti; + steps = this.stepsNoMulti; + } + if (this.model.pollType === "RESTRICTED") { + steps.push("voters"); } + this.steps = steps; + return steps; } reloadVoteCountingTypes() { @@ -164,6 +169,7 @@ class PollForm { this.isInit = true; this._updateSteps(); this.setStep(0); + this.questionEdited=0; }); } @@ -221,6 +227,14 @@ class PollForm { this.setStep(this.step + 1); } + addNewQuestion() { + let newQuestion = new Question("", "", ""); + this.setQuestionDefaultSettings(newQuestion); + this.questionEdited = this.questionEdited+1; + this.model.questions.push(newQuestion); + bus.trigger("questionEditedChanged", this.questionEdited); + } + addNewChoice(questionId) { this.model.questions.forEach((question) => { if (question.id === questionId || question.id === null) { @@ -275,6 +289,9 @@ class PollForm { } setQuestionDefaultSettings(question) { + + question.choices = [new Choice("TEXT"), new Choice("TEXT"), new Choice("TEXT")]; + question.choices.forEach((c, index) => {c.choiceOrder = index;}); question.addChoices = false; question.voteCountingType = 1; question.voteCountingConfig = {}; @@ -294,6 +311,11 @@ class PollForm { } } + setMulti(multi) { + if (multi) { + } + } + _updateSteps() { let steps = ["general", "choices", "options"]; if (this.model.pollType === "RESTRICTED") { diff --git a/pollen-ui-riot-js/src/main/web/js/PollService.js b/pollen-ui-riot-js/src/main/web/js/PollService.js index c644cc8b..cf6b3f44 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollService.js +++ b/pollen-ui-riot-js/src/main/web/js/PollService.js @@ -43,12 +43,17 @@ class PollService extends FetchService { let poll2 = Object.assign({}, poll); delete poll2.participant; delete poll2.votePeriod; - delete poll2.questions[0].addChoices; - delete poll2.questions[0].voteVisibility; - delete poll2.questions[0].anonymousVote; - delete poll2.questions[0].resultVisibility; - delete poll2.questions[0].continuousResults; - delete poll2.questions[0].commentVisibility; + poll2.questions.forEach(function(question) { + delete question.addChoices; + delete question.voteVisibility; + delete question.anonymousVote; + delete question.resultVisibility; + delete question.continuousResults; + delete question.commentVisibility; + if (question.id==="") { + delete question.id; + }; + }); delete poll2.voteCountingType; delete poll2.alreadyParticipants; delete poll2.limitChoices; @@ -60,12 +65,17 @@ class PollService extends FetchService { let poll2 = Object.assign({}, poll); delete poll2.participant; delete poll2.votePeriod; - delete poll2.questions[0].addChoices; - delete poll2.questions[0].voteVisibility; - delete poll2.questions[0].anonymousVote; - delete poll2.questions[0].resultVisibility; - delete poll2.questions[0].continuousResults; - delete poll2.questions[0].commentVisibility; + poll2.questions.forEach(function(question) { + delete question.addChoices; + delete question.voteVisibility; + delete question.anonymousVote; + delete question.resultVisibility; + delete question.continuousResults; + delete question.commentVisibility; + if (question.id==="") { + delete question.id; + }; + }); delete poll2.voteCountingType; delete poll2.alreadyParticipants; delete poll2.limitChoices; diff --git a/pollen-ui-riot-js/src/main/web/js/Question.js b/pollen-ui-riot-js/src/main/web/js/Question.js new file mode 100644 index 00000000..114d8a86 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/js/Question.js @@ -0,0 +1,10 @@ +class Question { + + constructor(title, description, id) { + this.description = description; + this.id = id; + this.title = title; + } +} + +export default Question; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag.html index 88bca7a7..69022e74 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag.html @@ -22,7 +22,7 @@ <Choices> <h4>{_t.title}</h4> <div class="choicesList" ref="choicesList"></div> - <Draggable each={choice, index in form.model.questions[0].choices} + <Draggable each={choice, index in form.model.questions[form.questionEdited].choices} on-drop={dropChoice} ref="choicesDrag" class="choice-draggable"> @@ -74,12 +74,24 @@ this.choiceType = this.form.choiceType || "TEXT"; this.installBundle(this.session, "poll_choices", this.opts.emitter); - this.on("mount", () => { + this.loadChoices = () => { let choices = (this.refs.choicesDrag || []) .sort((c1, c2) => Math.sign(c1.choice.choiceOrder - c2.choice.choiceOrder)) .map(c => c.refs.choice); choices[0] && choices[0].focus(); this.placeChoices(true); + }; + + this.on("mount", this.loadChoices); + this.on("updated", () =>{ + if (this.updateChoices) { + this.loadChoices(); + this.updateChoices = false; + } + }); + + this.listen("questionEditedChanged", () => { + this.updateChoices = true; }); this.getChoicesDragTab = () => { @@ -108,6 +120,7 @@ .sort((c1, c2) => Math.sign(c1.choice.choiceOrder - c2.choice.choiceOrder)); for (let index = 0, l = choicesDrag.length; index < l; index++) { + console.log("Try setting position", currentY); let choiceDrag = choicesDrag[index]; choiceDrag.setPosition(0, currentY); currentY += choiceDrag.root.offsetHeight; @@ -163,7 +176,7 @@ setTimeout(() => { choiceElt.root.style["z-index"] = ""; this.submit(); - this.form.choices.sort((c1, c2) => Math.sign(c1.choiceOrder - c2.choiceOrder)); + this.form.model.questions[this.form.questionEdited].choices.sort((c1, c2) => Math.sign(c1.choiceOrder - c2.choiceOrder)); this.update(); this.getChoicesDragTab() .map(cd => cd.refs.choice) @@ -176,7 +189,7 @@ this.addOneChoice = () => { if (!this.form.hasVotes) { this.submit(); - this.form.addNewChoice(0); + this.form.addNewChoice(this.form.questionEdited); this.update(); this.placeChoices(true); let choices = this.getChoicesDragTab() @@ -188,7 +201,7 @@ this.removeChoice = index => () => { if (!this.form.hasVotes) { - this.form.removeChoice(0, index); + this.form.removeChoice(this.form.questionEdited, index); this.compatChoiceOrders(); this.update(); this.placeChoices(true); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Description.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Description.tag.html index d658f085..ef257d72 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Description.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Description.tag.html @@ -113,6 +113,10 @@ this.form.model.creatorName = this.refs.name.value; this.form.model.creatorEmail = this.refs.email.value; this.form.multi = this.refs.multi.checked; + if (this.form.multi) { + //TODO ???? + this.form.model + } }; </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html index 8115a75e..cada45c7 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html @@ -24,6 +24,8 @@ import "./Description.tag.html"; import "./Choices.tag.html"; import "./Settings.tag.html"; import "./VoteSettings.tag.html"; +import "./EditQuestions.tag.html"; +import "./SummaryMulti.tag.html"; import "../voterList/VoterList.tag.html"; import "./Summary.tag.html"; import "../components/HumanInput.tag.html"; @@ -62,12 +64,14 @@ import "./CheckEmails.tag.html"; <Description if={!showSummary && form.step === 0} form={form} ref="description"/> <Choices if={!showSummary && form.step === 1 && !form.multi} form={form} ref="choices"/> <Settings if={!showSummary && form.step === 2 && !form.multi} form={form} ref="settings"/> - <VoterList if={!showSummary && form.step === 3 && ! form.multi && form.model.pollType === "RESTRICTED"} form={form} ref="voters"/> + <VoterList if={!showSummary && ((form.step === 3 && ! form.multi) || (form.step === 4 && form.multi)) && form.model.pollType === "RESTRICTED"} form={form} ref="voters"/> <VoteSettings if={!showSummary && form.step === 1 && form.multi} form={form} ref="voteSettings"/> + <EditQuestions if={!showSummary && form.step === 2 && form.multi} form={form} ref="editQuestions"/> + <SummaryMulti if={!showSummary && form.step === 3 && form.multi} form={form} ref="summaryMulti"/> <Summary if={showSummary} form={form}/> <div class="form-footer"> - <GtuValidation if={!form.model.gtuValidated && !showSummary && (!form.creation || form.step === form.steps.length - 1)} + <GtuValidation if={!form.model.gtuValidated && !showSummary && (!form.creation || form.step === form.getSteps(form.multi).length - 1)} ref="gtuValidation"/> <div class="actions" if={!showSummary}> @@ -84,7 +88,26 @@ import "./CheckEmails.tag.html"; <i class="fa fa-chevron-left" aria-hidden="true"></i> {_t.previous} </button> - <button if={form.step < form.steps.length - 1} + + <button if={form.step === 2 && form.multi && form.questionEdited !== 0} + type={form.creation || form.model.closed ? "button" : "submit"} + class="c-button c-button--info" + tabindex="1" + onclick={previousQuestion}> + <i class="fa fa-chevron-left " aria-hidden="true"></i> + {_t.previousQuestion} BBB + </button> + + <button if={form.step === 2 && form.multi} + type="submit" + class="c-button c-button--info" + tabindex="1" + onclick={newQuestion}> + {_t.newQuestion} AAA + <i class="fa fa-chevron-right " aria-hidden="true"></i> + </button> + + <button if={form.step < form.getSteps(form.multi).length - 1} type="submit" class="c-button c-button--info" tabindex="1" @@ -95,7 +118,7 @@ import "./CheckEmails.tag.html"; <button type="submit" tabindex="1" - if={!form.creation || form.step === form.steps.length - 1} + if={!form.creation || form.step === form.getSteps(form.multi).length - 1} class="c-button c-button--info" show={!form.model.closed} disabled={savePollWaiting} @@ -146,14 +169,22 @@ import "./CheckEmails.tag.html"; e.stopPropagation(); if (this.form.step === 0) { this.refs.description.submit(); + } else if (this.form.step === 1 && this.form.multi) { + this.refs.voteSettings.submit(); } else if (this.form.step === 1) { this.refs.choices.submit(); + } else if (this.form.step === 2 && this.form.multi) { + this.refs.editQuestions.submit(); } else if (this.form.step === 2) { this.refs.settings.submit(); + } else if (this.form.step === 3 && this.form.multi) { + this.refs.summaryMulti.submit(); } else if (this.form.step === 3) { this.refs.voters.submit(); + } else if (this.form.step === 4) { + this.refs.voters.submit(); } - if (!this.form.model.gtuValidated && !this.showSummary && (!this.form.creation || this.form.step === this.form.steps.length - 1)) { + if (!this.form.model.gtuValidated && !this.showSummary && (!this.form.creation || this.form.step === this.form.getSteps(form.multi).length - 1)) { this.form.model.gtuValidated = this.refs.gtuValidation.value(); } if (this.callAfterSubmit) { @@ -166,6 +197,15 @@ import "./CheckEmails.tag.html"; this.callAfterSubmit = () => this.form.nextStep(); }; + this.newQuestion = () => { + this.callAfterSubmit = () => this.refs.editQuestions.newQuestion(); + }; + + this.previousQuestion = (e) => { + this.callAfterSubmit = () => this.refs.editQuestions.previousQuestion(); + this.submitStep(e); + }; + this.doShowSummary = () => { this.showSummary = true; }; @@ -205,6 +245,10 @@ import "./CheckEmails.tag.html"; this.update(); }); + this.listen("questionEditedChanged", () => { + this.update(); + }); + </script> <style> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/EditQuestions.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/EditQuestions.tag.html new file mode 100644 index 00000000..6adc9c1e --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/poll/EditQuestions.tag.html @@ -0,0 +1,101 @@ +import "./Choices.tag.html"; + +<EditQuestions> + + <h2>Question {form.questionEdited + 1}</h2> + + <div class="editQuestion-part"> + <h4><i class="fa fa-info-circle" aria-hidden="true"></i> {_t.info}</h4> + + <div class="o-form-element"> + <label class="c-label" for="title">{_t.title}</label> + <input id="title" + ref="title" + tabindex="1" + type="text" + class="c-field c-field--label" + required + pattern=".*[^\s]+.*" + maxlength="255" + title={_t.titleNotBlank} + name="title" + value="{question.title}" + disabled={opts.form.model.closed} + placeholder="{_t.titlePlaceHolder}"/> + </div> + <div class="o-form-element"> + <label class="c-label" for="description">{_t.description}</label> + <textarea id="description" + ref="description" + tabindex="1" + class="c-field c-field--label" + name="description" + disabled={opts.form.model.closed} + placeholder="{_t.descriptionPlaceHolder}">{question.description}</textarea> + </div> + </div> + + <div class="editQuestion-part"> + <Choices form={form} ref="choices"></Choices> + </div> + + <!--TODO JC190814 - Ici faut mettre les options de la question--> + + <script type="es6"> + import "./Choices.tag.html"; + + import session from "../../js/Session"; + + this.session = session; + this.form = this.opts.form; + this.question = this.form.model.questions[this.form.questionEdited]; + this.installBundle(this.session, "poll_editQuestions", this.opts.emitter); + + this.newQuestion = () => { + //gérer le cas ou on navigue en avant et en arrière + if (!this.form.hasVotes) { + this.submit(); + this.form.addNewQuestion(); + this.question = this.form.model.questions[this.form.questionEdited]; + this.refs.title.value = this.question.title; + this.refs.description.value = this.question.description; + this.update(); + } + }; + + this.previousQuestion = () => { + if (!this.form.hasVotes) { + this.submit(); + this.form.questionEdited = this.form.questionEdited - 1; + this.bus.trigger("questionEditedChanged", this.questionEdited); + this.question = this.form.model.questions[this.form.questionEdited]; + this.refs.title.value = this.question.title; + this.refs.description.value = this.question.description; + this.update(); + } + }; + + this.submit = () => { + this.refs.choices.submit(); + this.question.title = this.refs.title.value; + this.question.description = this.refs.description.value; + this.form.model.questions[this.form.questionEdited] = this.question; + }; + </script> + + <style> + + editQuestion { + display: flex; + flex-wrap: wrap; + justify-content: space-around; + } + + .editQuestion-part { + flex-grow: 1; + padding: 0 5px; + } + + </style> + +</EditQuestions> \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/SummaryMulti.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/SummaryMulti.tag.html new file mode 100644 index 00000000..eb72eafd --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/poll/SummaryMulti.tag.html @@ -0,0 +1,144 @@ +<SummaryMulti> + + <div if={successMessage} class="c-alert c-alert--success">{successMessage}</div> + + <div class="summary-part"> + <h2> + {opts.form.model.title} + </h2> + + <p if="{opts.form.model.description}"> + <MultiLineLabel class="italic" + label="{opts.form.model.description}"> + </MultiLineLabel> + </p> + + <div class="summary-part"> + <div each={question, index in opts.form.model.questions}> + <SummaryQuestion question={question} showdescription="true" hidereport="true"/> + </div> + </div> + </div> + + + <script type="es6"> + import "./SummaryQuestion.tag.html"; + import "../components/MultiLineLabel.tag.html"; + + import session from "../../js/Session"; + + this.session = session; + this.installBundle(this.session, "summary"); + + this.showVoteCountingTypeHelper = false; + this.on("update", () => { + this.voteUrl = window.location.origin + window.location.pathname + "#poll/" + this.opts.form.model.id + "/vote"; + }); + + this.getMembersWarningLabel = () => { + let label; + if (this.opts.form.model.participantInvitedCount === 0) { + label = this._t.membersNoInvited_all; + } else { + let noInvited = this.opts.form.model.participantCount - this.opts.form.model.participantInvitedCount; + if (noInvited > 1) { + label = this._l("membersNoInvited_many", noInvited); + } else { + label = this._t.membersNoInvited_one; + } + } + return label; + }; + + this.getSendInvitationsLabel = () => { + let label; + let noInvited = this.opts.form.model.participantCount - this.opts.form.model.participantInvitedCount; + if (noInvited > 1) { + label = this._l("sendInvitations", noInvited); + } else { + label = this._t.sendInvitation; + } + return label; + }; + + this.copyUrl = (refInputUrl) => () => { + this.refs[refInputUrl].select(); + document.execCommand("copy"); + }; + + this.listen("successMessage", (successMessage) => { + this.successMessage = successMessage; + this.update(); + }); + + this.closePoll = (e) => { + e.preventDefault(); + e.stopPropagation(); + this.opts.form.close().then(() => { + this.update(); + }); + }; + + this.reopenPoll = (e) => { + e.preventDefault(); + e.stopPropagation(); + this.opts.form.reopen().then(() => { + this.update(); + }); + }; + + this.copy = (refInput) => () => { + this.refs[refInput].select(); + document.execCommand("copy"); + }; + + this.sendInvitations = () => { + this.opts.form.sendInvitations() + .then(nbInvitation => { + let message = nbInvitation > 1 ? this._l("sendInvitations_success", nbInvitation) : this._t.sendInvitation_success; + this.bus.trigger("message", message, "info"); + this.update(); + }); + }; + + + + this.submit = () => { + }; + + </script> + + <style> + + .summary-part { + margin-bottom: 20px; + line-height: 25px; + } + + .odd-row { + background-color: #eee; + } + + .summary-part-actions { + margin-top: 5px; + display: flex; + } + + .summary-part-actions > .c-input-group { + flex-grow: 0.5; + } + + .summary-part-actions > * { + margin-right: 5px; + } + + .invitations-warning { + font-size: 1em; + } + + ul.suffixes { + margin-left: 2em; + } + + </style> +</SummaryMulti> \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/SummaryQuestion.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/SummaryQuestion.tag.html new file mode 100644 index 00000000..9026c828 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/poll/SummaryQuestion.tag.html @@ -0,0 +1,137 @@ +<SummaryQuestion> + + <div class="summary-part"> + <h2> + {opts.question.title} + </h2> + + <p if="{opts.question.description}"> + <MultiLineLabel class="italic" + label="{opts.question.description}"> + </MultiLineLabel> + </p> + </div> + + <div class="summary-part"> + <h3>{_t.choices}</h3> + <div each={choice, index in opts.question.choices} class="{odd-row: index % 2 > 0}"> + <ChoiceView choice={choice} showdescription="true" hidereport="true"/> + </div> + </div> + + <script type="es6"> + import "./ChoiceView.tag.html"; + import "../components/MultiLineLabel.tag.html"; + + import session from "../../js/Session"; + + this.session = session; + this.installBundle(this.session, "summary"); + + this.showVoteCountingTypeHelper = false; + this.on("update", () => { + this.voteUrl = window.location.origin + window.location.pathname + "#poll/" + this.opts.form.model.id + "/vote"; + }); + + this.getMembersWarningLabel = () => { + let label; + if (this.opts.form.model.participantInvitedCount === 0) { + label = this._t.membersNoInvited_all; + } else { + let noInvited = this.opts.form.model.participantCount - this.opts.form.model.participantInvitedCount; + if (noInvited > 1) { + label = this._l("membersNoInvited_many", noInvited); + } else { + label = this._t.membersNoInvited_one; + } + } + return label; + }; + + this.getSendInvitationsLabel = () => { + let label; + let noInvited = this.opts.form.model.participantCount - this.opts.form.model.participantInvitedCount; + if (noInvited > 1) { + label = this._l("sendInvitations", noInvited); + } else { + label = this._t.sendInvitation; + } + return label; + }; + + this.copyUrl = (refInputUrl) => () => { + this.refs[refInputUrl].select(); + document.execCommand("copy"); + }; + + this.listen("successMessage", (successMessage) => { + this.successMessage = successMessage; + this.update(); + }); + + this.closePoll = (e) => { + e.preventDefault(); + e.stopPropagation(); + this.opts.form.close().then(() => { + this.update(); + }); + }; + + this.reopenPoll = (e) => { + e.preventDefault(); + e.stopPropagation(); + this.opts.form.reopen().then(() => { + this.update(); + }); + }; + + this.copy = (refInput) => () => { + this.refs[refInput].select(); + document.execCommand("copy"); + }; + + this.sendInvitations = () => { + this.opts.form.sendInvitations() + .then(nbInvitation => { + let message = nbInvitation > 1 ? this._l("sendInvitations_success", nbInvitation) : this._t.sendInvitation_success; + this.bus.trigger("message", message, "info"); + this.update(); + }); + }; + + </script> + + <style> + + .summary-part { + margin-bottom: 20px; + line-height: 25px; + } + + .odd-row { + background-color: #eee; + } + + .summary-part-actions { + margin-top: 5px; + display: flex; + } + + .summary-part-actions > .c-input-group { + flex-grow: 0.5; + } + + .summary-part-actions > * { + margin-right: 5px; + } + + .invitations-warning { + font-size: 1em; + } + + ul.suffixes { + margin-left: 2em; + } + + </style> +</SummaryQuestion> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm