This is an automated email from the git hooks/post-receive script. New commit to branch feature/149-jugement-majoritaire in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit d989f50e4b1039112096b458b6abc5c1376a1875 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Oct 9 11:00:59 2017 +0200 Configuration du jugement majoritaire a l'edition du sondage ref #149 --- .../converter/VoteCountingConfigDeserializer.java | 17 +++++ pollen-ui-riot-js/src/main/web/i18n/en.json | 5 ++ pollen-ui-riot-js/src/main/web/i18n/fr.json | 5 ++ .../src/main/web/tag/poll/Settings.tag.html | 5 ++ .../MajorityJudgmentConfig.tag.html | 84 ++++++++++++++++++++++ 5 files changed, 116 insertions(+) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/converter/VoteCountingConfigDeserializer.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/converter/VoteCountingConfigDeserializer.java index 504c5b32..0ab65d5c 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/converter/VoteCountingConfigDeserializer.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/converter/VoteCountingConfigDeserializer.java @@ -26,6 +26,7 @@ import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import org.chorem.pollen.votecounting.BordaConfig; import org.chorem.pollen.votecounting.CumulativeConfig; +import org.chorem.pollen.votecounting.MajorityJudgmentConfig; import org.chorem.pollen.votecounting.model.EmptyVoteCountingConfig; import org.chorem.pollen.votecounting.model.MaxChoicesNumberConfig; import org.chorem.pollen.votecounting.model.VoteCountingConfig; @@ -66,6 +67,12 @@ public class VoteCountingConfigDeserializer extends JsonDeserializer<VoteCountin cumulativeConfig.setPoints(configTemp.getPoints()); config = cumulativeConfig; + } else if (configTemp.getGrades() != null) { + + MajorityJudgmentConfig majorityJudgmentConfig = new MajorityJudgmentConfig(); + majorityJudgmentConfig.setGrades(configTemp.getGrades()); + config = majorityJudgmentConfig; + } else { config = new EmptyVoteCountingConfig(); @@ -84,6 +91,8 @@ public class VoteCountingConfigDeserializer extends JsonDeserializer<VoteCountin protected Integer points; + protected List<String> grades; + public Integer getMaxChoiceNumber() { return maxChoiceNumber; } @@ -107,5 +116,13 @@ public class VoteCountingConfigDeserializer extends JsonDeserializer<VoteCountin public void setPoints(Integer points) { this.points = points; } + + public List<String> getGrades() { + return grades; + } + + public void setGrades(List<String> grades) { + this.grades = grades; + } } } 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 6d73063a..4af6687c 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/en.json +++ b/pollen-ui-riot-js/src/main/web/i18n/en.json @@ -320,6 +320,11 @@ "poll_settings_voteCountingConfig_rank": "Rank", "poll_settings_voteCountingConfig_points": "points", "poll_settings_voteCountingConfig_cumulativePoints": "number of points to allocate", + "poll_settings_voteCountingConfig_grades": "Grades list", + "poll_settings_voteCountingConfig_addGradAfter": "Add grad after", + "poll_settings_voteCountingConfig_removeGrad": "Remove this grade", + "poll_settings_voteCountingConfig_grades_default": "Default grades", + "poll_settings_voteCountingConfig_grades_default_values": "To reject,Poor,Fair,Fairly well,Well,Very well,Excellent", "poll_settings_votesConfiguration": "Votes configuration", "poll_settings_voteCountingType": "Vote counting type used to compute poll's results.", "poll_settings_voteCountingType_normal": "Normal", 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 0049ddb5..6abf5ff2 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/fr.json +++ b/pollen-ui-riot-js/src/main/web/i18n/fr.json @@ -320,6 +320,11 @@ "poll_settings_voteCountingConfig_rank": "Rang", "poll_settings_voteCountingConfig_points": "points", "poll_settings_voteCountingConfig_cumulativePoints": "Nombre de points à distribuer", + "poll_settings_voteCountingConfig_grades": "Liste des mentions", + "poll_settings_voteCountingConfig_addGradAfter": "Ajouter une mention après", + "poll_settings_voteCountingConfig_removeGrad": "Supprimer la mention", + "poll_settings_voteCountingConfig_grades_default": "Mentions par défaut", + "poll_settings_voteCountingConfig_grades_default_values": "A rejeter,Insuffisant,Passable,Assez bien,Bien,Très bien,Excellent", "poll_settings_votesConfiguration": "Configuration des votes", "poll_settings_voteCountingType": "Type de scrutin pour effectuer le dépouillement du sondage", "poll_settings_voteCountingType_normal": "Normal", diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Settings.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Settings.tag.html index 40bfec72..1659c242 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Settings.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Settings.tag.html @@ -25,6 +25,7 @@ require("../components/Checkbox.tag.html"); require("../voteCountingType/MaxChoicesNumberConfig.tag.html"); require("../voteCountingType/BordaConfig.tag.html"); require("../voteCountingType/CumulativeConfig.tag.html"); +require("../voteCountingType/MajorityJudgmentConfig.tag.html"); <Settings> <div class="form-section" show={form.creation}> @@ -154,6 +155,10 @@ require("../voteCountingType/CumulativeConfig.tag.html"); ref="config" config={form.model.voteCountingConfig} disabled={form.hasVotes || form.model.closed}/> + <MajorityJudgmentConfig if={opts.form.model.voteCountingType == 8} + ref="config" + config={form.model.voteCountingConfig} + disabled={form.hasVotes || form.model.closed}/> </div> </div> diff --git a/pollen-ui-riot-js/src/main/web/tag/voteCountingType/MajorityJudgmentConfig.tag.html b/pollen-ui-riot-js/src/main/web/tag/voteCountingType/MajorityJudgmentConfig.tag.html new file mode 100644 index 00000000..024a133b --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/voteCountingType/MajorityJudgmentConfig.tag.html @@ -0,0 +1,84 @@ +<MajorityJudgmentConfig> + + <div class="o-form-element"> + <label class="c-label"> + {__.grades} + </label> + <div class="grades"> + <div class="c-input-group c-field--label" each={value, index in opts.config.grades}> + <div class="o-field"> + <input name="grade-{index}" + tabindex="1" + id="grade-{index}" + ref="grades" + class="c-field" + disabled={parent.opts.disabled} + value={value} + onChange={parent.gradeChange(index)} + required + type="text"> + </div> + <button class="c-button c-button--success" + title={parent.__.addGradAfter} + onclick={addGradAfter(index)}> + <i class="fa fa-plus" aria-hidden="true"></i> + </button> + <button class="c-button c-button--error" + title={parent.__.removeGrad} + disabled={parent.opts.config.grades.length <= 3} + onclick={removeGrad(index)}> + <i class="fa fa-trash" aria-hidden="true"></i> + </button> + </div> + </div> + <button class="c-button c-button--info default-grades" + onclick={setDefaultGrades}> + {__.grades_default} + </button> + </div> + + <script type="es6"> + let session = require("../../js/Session"); + this.installBundle(session, "poll_settings_voteCountingConfig"); + + this.setDefaultGrades = () => { + this.opts.config.grades = this.__.grades_default_values.split(","); + }; + + if (this.opts.config.grades === undefined) { + this.setDefaultGrades(); + } + + this.gradeChange = index => e => { + this.opts.config.grades[index] = e.target.value; + }; + + this.addGradAfter = index => () => { + this.opts.config.grades.splice(index, 0, ""); + }; + + this.removeGrad = index => () => { + this.opts.config.grades.splice(index, 1); + }; + + this.getConfig = () => { + let config = { + grades: this.refs.grades.map(input => input.value) + }; + return config; + }; + </script> + + <style> + .grades { + display: flex; + flex-direction: column-reverse + } + + .default-grades { + margin-top: 0.5em; + + } + </style> + +</MajorityJudgmentConfig> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.