branch feature/pollen-riot-js updated (c802d85 -> b08b3c6)
This is an automated email from the git hooks/post-receive script. New change to branch feature/pollen-riot-js in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git from c802d85 Ajout des votes new e92f3d3 ajout de nombre de votes sur un sondage new 9ca5676 Ajout des résultats + ... new b08b3c6 Utilisation de moment pour afficher les dates + continue le dev sur les sondages The 3 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 b08b3c683ea47e6e94648f84b1288df0d50cc51c Author: Tony CHEMIT <dev@tchemit.fr> Date: Wed Jan 25 00:17:49 2017 +0100 Utilisation de moment pour afficher les dates + continue le dev sur les sondages commit 9ca567693008a1ab49c2e348aba93e4157782939 Author: Tony CHEMIT <dev@tchemit.fr> Date: Tue Jan 24 20:08:49 2017 +0100 Ajout des résultats + ... commit e92f3d3084889032fafe76b7f6f22d2aeda1ed0f Author: Tony CHEMIT <dev@tchemit.fr> Date: Tue Jan 24 20:08:34 2017 +0100 ajout de nombre de votes sur un sondage Summary of changes: .../org/chorem/pollen/services/bean/PollBean.java | 10 +++ .../pollen/services/service/PollService.java | 3 +- .../pollen/services/service/VoteService.java | 8 ++ pollen-ui-riot-js/src/main/web/i18n.json | 18 ++++ .../web/js/{ChoiceText.js => ResultService.js} | 22 +++-- pollen-ui-riot-js/src/main/web/tag/Pollen.tag | 6 ++ pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag | 56 +++++++++---- .../src/main/web/tag/poll/PollComments.tag | 10 ++- .../src/main/web/tag/poll/PollResults.tag | 95 ++++++++++++++++++++++ .../src/main/web/tag/poll/PollVotes.tag | 8 +- .../tag/{polls/CreatedPolls.tag => poll/Polls.tag} | 7 +- 11 files changed, 204 insertions(+), 39 deletions(-) copy pollen-ui-riot-js/src/main/web/js/{ChoiceText.js => ResultService.js} (65%) create mode 100644 pollen-ui-riot-js/src/main/web/tag/poll/PollResults.tag rename pollen-ui-riot-js/src/main/web/tag/{polls/CreatedPolls.tag => poll/Polls.tag} (97%) -- 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/pollen-riot-js in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit e92f3d3084889032fafe76b7f6f22d2aeda1ed0f Author: Tony CHEMIT <dev@tchemit.fr> Date: Tue Jan 24 20:08:34 2017 +0100 ajout de nombre de votes sur un sondage --- .../main/java/org/chorem/pollen/services/bean/PollBean.java | 10 ++++++++++ .../java/org/chorem/pollen/services/service/PollService.java | 3 ++- .../java/org/chorem/pollen/services/service/VoteService.java | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java index 80c7099..c9efced 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java @@ -46,6 +46,8 @@ import java.util.Set; */ public class PollBean extends PollenBean<Poll> { + private long voteCount; + public PollBean() { super(Poll.class); } @@ -386,4 +388,12 @@ public class PollBean extends PollenBean<Poll> { public void setParticipants(Set<String> participants) { this.participants = participants; } + + public void setVoteCount(long voteCount) { + this.voteCount = voteCount; + } + + public long getVoteCount() { + return voteCount; + } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java index dc79560..540d341 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java @@ -80,8 +80,9 @@ public class PollService extends PollenServiceSupport { input.setCanVote(canVote); long commentCount = getCommentService().getCommentCount(input.getEntityId()); - input.setCommentCount(commentCount); + long voteVount = getVoteService().getVoteCount(input.getEntityId()); + input.setVoteCount(voteVount); return input; }; diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java index 47fbdcc..571ded5 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java @@ -399,4 +399,12 @@ public class VoteService extends PollenServiceSupport { return result; } + + public long getVoteCount(String pollId) { + checkNotNull(pollId); + + Poll poll = getPollService().getPoll0(pollId); + + return getVoteDao().forPollEquals(poll).count(); + } } -- 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/pollen-riot-js in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 9ca567693008a1ab49c2e348aba93e4157782939 Author: Tony CHEMIT <dev@tchemit.fr> Date: Tue Jan 24 20:08:49 2017 +0100 Ajout des résultats + ... --- pollen-ui-riot-js/src/main/web/i18n.json | 18 ++++ pollen-ui-riot-js/src/main/web/js/ResultService.js | 36 ++++++++ pollen-ui-riot-js/src/main/web/tag/Pollen.tag | 6 ++ pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag | 56 +++++++++---- .../src/main/web/tag/poll/PollComments.tag | 10 ++- .../src/main/web/tag/poll/PollResults.tag | 95 ++++++++++++++++++++++ .../src/main/web/tag/poll/PollVotes.tag | 8 +- 7 files changed, 202 insertions(+), 27 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/i18n.json b/pollen-ui-riot-js/src/main/web/i18n.json index 7cfb62e..48ce6f6 100644 --- a/pollen-ui-riot-js/src/main/web/i18n.json +++ b/pollen-ui-riot-js/src/main/web/i18n.json @@ -1,5 +1,14 @@ { "fr": { + "poll_votes":"Votes", + "poll_results":"Résultats", + "poll_results_title":"Résultats", + "poll_results_noResult":"Les résultats ne sont pas encore disponibles.", + "poll_results_voter":"votant.", + "poll_results_voters":"votants.", + "poll_results_rank":"Rang :", + "poll_results_votesCount":"Nombre de votes :", + "poll_comments":"Commentaires", "poll_comments_noComment":"Pas de commentaire.", "poll_comments_title":"Commentaires", "poll_comments_addComment":"Ajouter un commentaire", @@ -150,6 +159,15 @@ "": "" }, "en": { + "poll_votes":"Votes", + "poll_results":"Results", + "poll_results_noResult":"Results are not yet available.", + "poll_results_title":"Results", + "poll_results_voter":"voter.", + "poll_results_voters":"voters.", + "poll_results_rank":"Rank:", + "poll_results_votesCount":"Votes count:", + "poll_comments":"Comments", "poll_comments_noComment":"No comment.", "poll_comments_title":"Comments", "poll_comments_addComment":"Add a comment", diff --git a/pollen-ui-riot-js/src/main/web/js/ResultService.js b/pollen-ui-riot-js/src/main/web/js/ResultService.js new file mode 100644 index 0000000..74b88b3 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/js/ResultService.js @@ -0,0 +1,36 @@ +/*- + * #%L + * Pollen :: UI (Riot Js) + * %% + * Copyright (C) 2009 - 2017 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +let singleton = require("./Singleton"); +let FetchService = require("./FetchService"); + +class ResultService extends FetchService { + + getResults(pollId, permission) { + let args = {}; + if (permission) { + args.permission = permission; + } + return this.getWithParams("/v1/polls/" + pollId + "/results", args); + } + +} + +module.exports = singleton(ResultService); diff --git a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag index b9fed83..ca631b2 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag @@ -70,6 +70,12 @@ require("./polls/CreatedPolls.tag"); route("/poll/*/comment/*", (pollId, permission) => { riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'comments', permission: permission}); }); + route("/poll/*/result", (pollId) => { + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'results'}); + }); + route("/poll/*/result/*", (pollId, permission) => { + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'results', permission: permission}); + }); route("/user/profile", () => { riot.mount(this.refs.content, "userprofile"); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag index 690326d..883f08f 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag @@ -1,5 +1,6 @@ require('./PollVotes.tag'); require('./PollComments.tag'); +require('./PollResults.tag'); <Poll> <div class="container"> @@ -11,12 +12,18 @@ require('./PollComments.tag'); <div class="tab-header"> <div class="{selectedTab=='votes'?'tab-selected':'tab-not-selected'}"> <a href="#poll/{pollId}/vote{permission?'/' + permission : ''}"> - <i class="fa fa-thumbs-o-up fa-flip-horizontal"></i>Votes + <i class="fa fa-thumbs-o-up fa-flip-horizontal"></i>{__.votes} ({votesCount}) </a> </div> <div class="{selectedTab=='comments'?'tab-selected':'tab-not-selected'}"> <a href="#poll/{pollId}/comment{permission?'/' + permission : ''}"> - <i class="fa fa-comments-o"></i>Comments + <i class="fa fa-comments-o"></i>{__.comments} ({commentsCount}) + </a> + </div> + <div class="{selectedTab=='results'?'tab-selected':'tab-not-selected'}"> + <a class="{withResults ? '' : 'block'}" + href="{withResults?'#poll/' + pollId + '/result' + (permission? '/' + permission : ''):''}"> + <i class="fa fa-bar-chart-o"></i><span>{__.results}</span> </a> </div> @@ -29,40 +36,53 @@ require('./PollComments.tag'); this.pollId = opts.pollId; this.selectedTab = opts.tabName; this.permission = opts.permission; + this.commentsCount = ' '; + this.votesCount = ' '; + this.withResults = true; let session = require("../../js/Session"); this.installBundle(session, "poll"); - this.on('mount', () => { let pollService = require('../../js/PollService'); pollService.getPoll(this.pollId).then(result => { this.poll = result; + this.withResults = this.poll.continiousResult || this.poll.isClosed; + this.commentsCount = this.poll.commentCount; + this.votesCount = this.poll.voteCount; console.info(this.poll); this.update(); - if (this.selectedTab == 'votes') { - riot.mount(this.refs.content, "pollvotes", { - pollId: this.pollId, - poll:this.poll, - session: session, - permission: this.permission + let tags = riot.mount(this.refs.content, "poll" + this.selectedTab, { + pollId: this.pollId, + poll: this.poll, + session: session, + permission: this.permission + }); + let countName = this.selectedTab == 'results' ? '' : (this.selectedTab + 'Count'); + if (countName) { + tags[0].on('count', count => { + this[countName] = count; + let args = {}; + args[countName] = count; + this.update(args); }); } - if (this.selectedTab == 'comments') { - riot.mount(this.refs.content, "pollcomments", { - pollId: this.pollId, - session: session, - permission: this.permission - }); - } - }); + }); }); - </script> <style> + .block { + cursor: not-allowed; + color: gray; + } + + .block > * { + color: gray; + } + .container { display: flex; justify-content: space-around; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollComments.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollComments.tag index 978d237..f0e70b4 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/PollComments.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollComments.tag @@ -3,10 +3,15 @@ require('./CommentPopup.tag'); <PollComments> <div class="comment-container"> + <div class="actions"> + <a class="button mainColorBackground" onclick="{openAddComment}"><i class="fa fa-plus"/> {__.addComment}</a> + </div> + <div class="legend"> {__.title} <a if="{comments.length > -1}" onclick="{toggleSort}"><i ref="sortOwner" class="fa fa-sort-amount-desc"></i></a> </div> + <div show="{loaded}" class="body"> <div show="{comments.length == 0}">{__.noComment}</div> @@ -47,10 +52,6 @@ require('./CommentPopup.tag'); </tr> </tfoot> </table> - - <div class="actions"> - <a class="button mainColorBackground" onclick="{openAddComment}">{__.addComment}</a> - </div> </div> </div> @@ -150,6 +151,7 @@ require('./CommentPopup.tag'); return commentService.getComments(this.pollId, pagination, this.permission).then((result) => { this.comments = result.elements; console.info(this.comments); + this.trigger('count', result.pagination.count); this.loaded = true; this.update(); return result; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollResults.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollResults.tag new file mode 100644 index 0000000..e3f6beb --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollResults.tag @@ -0,0 +1,95 @@ +<PollResults> + <div class="result-container"> + <div class="legend"> + {__.title} + </div> + <div> + <div if="{!poll.continiousResult && !poll.isClosed}"> + {__.noResult} + </div> + <div if="{poll.continiousResult || poll.isClosed}" class="result-body" > + <div if="{results.nbVotants==1}">1 {__.voter}</div> + <div if="{results.nbVotants>1}">{results.nbVotants} {__.voters}</div> + <br/> + <div class="result-content" each="{result in results.scores}"> + <div class='bold'>{result.choice}</div> + <div>{parent.__.rank} {result.scoreOrder + 1}</div> + <div>{parent.__.votesCount} {result.scoreValue}</div> + </div> + </div> + </div> + </div> + + <script> + this.loaded = false; + let session = require("../../js/Session"); + this.installBundle(session, "poll_results"); + let resultService = require("../../js/ResultService"); + let choiceService = require("../../js/ChoiceService"); + + this.pollId = opts.pollId; + this.poll = opts.poll; + this.permission = opts.permission; + console.info("permission:: " + this.permission); + + this.results = {nbVotants: 0, scores: []}; + this.choices = []; + this.scores = []; + this.on('mount', () => { + + + choiceService.getChoices(this.pollId, this.permission).then((result) => { + console.info("get choices"); + console.info(result); + this.choices = result; + + resultService.getResults(this.pollId, this.permission).then((result) => { + console.info("get results"); + console.info(result); + this.results = result; + this.results.scores.forEach(s => { + this.choices.forEach(c => { + if (c.id == s.choiceId) { + s.choice = c.choiceValue; + } + }); + }); + this.loaded = true; + + this.update(); + }); + }); + }); + + + </script> + <style> + + .bold { + font-weight: bold; + } + .result-container { + width: 800px; + } + + .result-body { + margin-top: 20px; + } + + .result-content { + display: flex; + flex-direction: row; + justify-content: space-between; + } + + .result-content > div:first-child { + width: 200px; + } + + .legend { + width: 800px; + margin-bottom: 20px; + } + + </style> +</PollResults> \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollVotes.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollVotes.tag index 42abedf..5d31b40 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/PollVotes.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollVotes.tag @@ -54,8 +54,7 @@ <a onclick="{cancelEditVote}" class="small danger"> <i class="fa fa-remove fa-15x"/> </a> - <button class="icon" ref="vote_{vote.id}_vote" type="submit" - value="{__.vote}"> + <button class="icon" ref="vote_{vote.id}_vote" type="submit"> <i class="fa fa-check fa-15x"/> </button> </div> @@ -124,7 +123,6 @@ this.voteId = e.target.parentNode.parentNode.id; let tr = e.target.parentNode.parentNode.parentNode.parentNode; tr.classList.add("selected"); - this.refs['vote_' + this.voteId + "_vote"].value = this.__.vote; this.votes.forEach(v => { if (this.voteId == v.id) { this.refs['vote_' + this.voteId + "_voter"].value = v.voterName; @@ -149,12 +147,11 @@ vote.id = null; vote.voterName = this.refs.voterName.value; - let form = this.refs.form; this.choices.forEach(c => { vote.choice.push({ choiceId: c.id, - voteValue: form[c.id + '.voteValue'].checked ? 1 : 0 + voteValue: this.form[c.id + '.voteValue'].checked ? 1 : 0 }); }); @@ -232,6 +229,7 @@ this.votes = result; console.info("Reload votes"); console.info(this.votes); + this.trigger('count', result.length); this.loaded = true; this.update(); return result; -- 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/pollen-riot-js in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit b08b3c683ea47e6e94648f84b1288df0d50cc51c Author: Tony CHEMIT <dev@tchemit.fr> Date: Wed Jan 25 00:17:49 2017 +0100 Utilisation de moment pour afficher les dates + continue le dev sur les sondages --- .../src/main/web/tag/{polls/CreatedPolls.tag => poll/Polls.tag} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/tag/polls/CreatedPolls.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag similarity index 97% rename from pollen-ui-riot-js/src/main/web/tag/polls/CreatedPolls.tag rename to pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag index ce76ca7..72d6f24 100644 --- a/pollen-ui-riot-js/src/main/web/tag/polls/CreatedPolls.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag @@ -1,5 +1,5 @@ require('../Pagination.tag'); -<CreatedPolls> +<Polls> <div class="body-container"> <div class="container"> @@ -41,6 +41,7 @@ require('../Pagination.tag'); <script> this.sortName = 'title'; this.sortValue = false; // means asc + this.method = opts.method; let pollService = require('../../js/PollService'); this.callback = (pagination) => { console.info("Request data with pagination::"); @@ -49,7 +50,7 @@ require('../Pagination.tag'); pagination.desc = this.sortValue; } console.info(pagination); - return pollService.createdPolls(pagination).then((result) => { + return pollService[this.method](pagination).then((result) => { this.polls = result.elements; console.info(this.polls); this.update(); @@ -134,4 +135,4 @@ require('../Pagination.tag'); font-size: 20px; } </style> -</CreatedPolls> \ No newline at end of file +</Polls> \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm