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 ffecc85c6f306d76c74c618be3c1c8e6852837ed Author: Tony CHEMIT <dev@tchemit.fr> Date: Wed Jan 25 00:18:38 2017 +0100 Utilisation de moment pour afficher les dates + continue le dev sur les sondages --- pollen-ui-riot-js/package.json | 1 + pollen-ui-riot-js/src/main/web/css/main.css | 3 + pollen-ui-riot-js/src/main/web/i18n.json | 23 +++++--- pollen-ui-riot-js/src/main/web/js/I18nHelper.js | 5 +- pollen-ui-riot-js/src/main/web/js/PollForm.js | 6 +- pollen-ui-riot-js/src/main/web/js/PollService.js | 4 ++ pollen-ui-riot-js/src/main/web/js/Session.js | 16 ++++-- pollen-ui-riot-js/src/main/web/tag/Header.tag | 66 ++++++++++++++-------- pollen-ui-riot-js/src/main/web/tag/Home.tag | 11 ++-- pollen-ui-riot-js/src/main/web/tag/Pagination.tag | 1 + pollen-ui-riot-js/src/main/web/tag/Pollen.tag | 36 ++++++++---- .../src/main/web/tag/poll/CreatePoll.tag | 54 +++++++++--------- pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag | 18 ++++-- .../src/main/web/tag/poll/PollComments.tag | 56 ++++++++++++++---- .../src/main/web/tag/poll/PollResults.tag | 4 +- .../src/main/web/tag/poll/PollVotes.tag | 17 +++--- .../tag/{polls/CreatedPolls.tag => poll/Polls.tag} | 27 ++++++--- 17 files changed, 233 insertions(+), 115 deletions(-) diff --git a/pollen-ui-riot-js/package.json b/pollen-ui-riot-js/package.json index 359a232..8638b14 100644 --- a/pollen-ui-riot-js/package.json +++ b/pollen-ui-riot-js/package.json @@ -34,6 +34,7 @@ }, "dependencies": { "font-awesome": "4.6.3", + "moment": "^2.17.1", "riot": "^3.0.5", "riot-route": "^2.5.0" } diff --git a/pollen-ui-riot-js/src/main/web/css/main.css b/pollen-ui-riot-js/src/main/web/css/main.css index f3ea224..a3d4993 100644 --- a/pollen-ui-riot-js/src/main/web/css/main.css +++ b/pollen-ui-riot-js/src/main/web/css/main.css @@ -61,6 +61,9 @@ a.mainColorBackground, input.mainColorBackground { background-color: #13a2ff; } +.mainColor { + color: #13a2ff; +} a { text-decoration: none; color: #13a2ff; diff --git a/pollen-ui-riot-js/src/main/web/i18n.json b/pollen-ui-riot-js/src/main/web/i18n.json index 48ce6f6..b4f285b 100644 --- a/pollen-ui-riot-js/src/main/web/i18n.json +++ b/pollen-ui-riot-js/src/main/web/i18n.json @@ -23,10 +23,11 @@ "comment_popup_action":"Enregistrer", "comment_popup_authorPlaceholder":"Saisir votre nom", "comment_popup_textPlaceholder":"Saisir le commentaire", - "polls_created_title":"Mes sondages", - "polls_created_name":"Nom", - "polls_created_createDate":"Date de création", - "polls_created_status":"Statut", + "polls_createdPolls":"Mes sondages", + "polls_polls":"Tous les sondages", + "polls_name":"Nom", + "polls_createDate":"Date de création", + "polls_status":"Statut", "signup_title": "Créer un compte", "signup_email": "Email", "signup_email_placeholder": "Entrer l'email", @@ -76,6 +77,8 @@ "header_i18n_lang": "Langue", "header_myProfile": "Mon profile", "header_myPolls": "Mes sondages", + "header_polls": "Sondages", + "header_users": "Utilisateurs", "header_myFavoriteLists": "Mes listes de favoris", "home_createTextPoll": "Créer un sondage de type text", "home_createImagePoll": "Créer un sondage de type image", @@ -182,10 +185,12 @@ "comment_popup_action":"Save", "comment_popup_authorPlaceholder":"Fill your name", "comment_popup_textPlaceholder":"Fill your comment", - "polls_created_title":"My polls", - "polls_created_name":"Name", - "polls_created_createDate":"Created date", - "polls_created_status":"Status", + "polls_title":"My polls", + "polls_name":"Name", + "polls_createDate":"Created date", + "polls_status":"Status", + "polls_createdPolls":"My polls", + "polls_polls":"All polls", "signup_title": "Create an account", "signup_email": "Email", "signup_email_placeholder": "Enter your email", @@ -235,6 +240,8 @@ "header_i18n_lang": "Language", "header_myProfile": "My profile", "header_myPolls": "My polls", + "header_polls": "Polls", + "header_users": "Users", "header_myFavoriteLists": "My favorite lists", "home_createTextPoll": "Create a text poll", "home_createImagePoll": "Create a image poll", diff --git a/pollen-ui-riot-js/src/main/web/js/I18nHelper.js b/pollen-ui-riot-js/src/main/web/js/I18nHelper.js index 95cbabb..72b751c 100644 --- a/pollen-ui-riot-js/src/main/web/js/I18nHelper.js +++ b/pollen-ui-riot-js/src/main/web/js/I18nHelper.js @@ -20,12 +20,15 @@ */ module.exports = { - installBundle(session, value) { + installBundle(session, value,callback) { this.bundle = session.i18n; this.debug = session.configuration.debugI18n; this.generateBundle(session.locale, value); session.onLocaleChanged((locale) => { this.generateBundle(locale, value); + if (callback) { + callback(locale); + } try { this.update(); } catch (e) { 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 06f725f..99d503b 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollForm.js +++ b/pollen-ui-riot-js/src/main/web/js/PollForm.js @@ -34,7 +34,7 @@ class PollForm { this.choices = []; } - init() { + init(user) { this.isInit = true; console.info("init form"); this.step = 0; @@ -48,6 +48,10 @@ class PollForm { this.model.description = "Premier sondage!"; this.model.name = "Dick Laurent"; this.model.email = "user@pollen.org"; + if (user) { + this.model.name = user.name; + this.model.email = user.email; + } this.model.voteCountingType= "1"; this.model.participant = []; this.choices = [ 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 4318798..a343d8d 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollService.js +++ b/pollen-ui-riot-js/src/main/web/js/PollService.js @@ -35,6 +35,10 @@ class PollService extends FetchService { return this.getWithParams("/v1/polls/created", {paginationParameter: pagination}); } + polls(pagination) { + return this.getWithParams("/v1/polls", {paginationParameter: pagination}); + } + getPoll(pollId) { return this.get("/v1/polls/"+pollId); } diff --git a/pollen-ui-riot-js/src/main/web/js/Session.js b/pollen-ui-riot-js/src/main/web/js/Session.js index fa33333..9760c01 100644 --- a/pollen-ui-riot-js/src/main/web/js/Session.js +++ b/pollen-ui-riot-js/src/main/web/js/Session.js @@ -49,10 +49,15 @@ class Session { start() { if (this.isConnected()) { - return this.connect(require("./AuthService")); - }else { - return Promise.resolve(); + this.user = this.connect(require("./AuthService")); + } else { + this.user = Promise.resolve(); } + return this.user; + } + + getUser() { + return this.user; } emitUnauthorize() { @@ -110,8 +115,9 @@ class Session { } console.info("Connect user::"); console.info(user); - this.user = user; + this.user = Promise.resolve(user); this.emitConnected(user); + return user; }); } @@ -126,7 +132,7 @@ class Session { } console.info("SignIn user::"); console.info(user); - this.user = user; + this.user = Promise.resolve(user); this.emitConnected(user); return user; }); diff --git a/pollen-ui-riot-js/src/main/web/tag/Header.tag b/pollen-ui-riot-js/src/main/web/tag/Header.tag index 75c6841..54b3fa0 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Header.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Header.tag @@ -1,23 +1,23 @@ /*- - * #%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% - */ +* #%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% +*/ require("./HeaderI18n.tag"); <Header> <div class="header-home"> @@ -25,6 +25,13 @@ require("./HeaderI18n.tag"); </div> <div class="header-separator"></div> <div class="header-space"></div> + <div if="{admin}" class="dropdown"> + <a class="header-link"><i class="fa fa-gear fa-15x"/></a> + <div class="dropdown-content"> + <a href="#user">{__.users}</a> + <a href="#poll">{__.polls}</a> + </div> + </div> <a class="button header-button header-signin" if="{!user}" onclick="{signIn}">{__.signin}</a> <a class="button header-button header-signup" if="{!user}" href="#signup">{__.signup}</a> @@ -32,7 +39,7 @@ require("./HeaderI18n.tag"); <a class="header-link">{user.email}</a> <div class="dropdown-content"> <a href="#user/profile">{__.myProfile}</a> - <a href="#polls/created">{__.myPolls}</a> + <a href="#poll/created">{__.myPolls}</a> <a href="#user/favoriteLists">{__.myFavoriteLists}</a> <span role="separator" class="divider"></span> <a onclick="{signOut}">{__.signout}</a> @@ -47,26 +54,35 @@ require("./HeaderI18n.tag"); this.installBundle(session, "header"); - this.signIn= ()=> { - route("signin?url="+window.location.hash.substring(1)); + this.signIn = () => { + route("signin?url=" + window.location.hash.substring(1)); }; this.signOut = () => { let callback = () => { this.user = null; + this.admin = false; + this.update({user: this.user, admin: this.admin}); route("home"); }; authService.signOut().then(callback, callback); + }; this.user = null; if (session.isConnected()) { - this.user = session.user; + + session.getUser().then(user => { + this.user = user; + this.admin = user.administrator; + this.update({user: this.user, admin: this.admin}); + }); } session.onConnected((user) => { this.user = user; + this.admin = user.administrator; this.update(); }); @@ -79,6 +95,10 @@ require("./HeaderI18n.tag"); <style> + .fa-15x { + font-size: 1.5em; + } + header { display: flex; align-items: center; diff --git a/pollen-ui-riot-js/src/main/web/tag/Home.tag b/pollen-ui-riot-js/src/main/web/tag/Home.tag index c6129cb..80be1ce 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Home.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Home.tag @@ -36,17 +36,20 @@ this.installBundle(session, "home"); this.createText = () => { - form.init(session.user).then(() => { - route("/poll/new/text/0"); + session.getUser().then(user=> { + form.init(user).then(() => { + route("/poll/new/text/0"); + }); }); + }; this.createImage = () => { - form.init(session.user).then(() => { + form.init(session.getUser).then(() => { route("/poll/new/image/0"); }); }; this.createDate = () => { - form.init(session.user).then(() => { + form.init(session.getUser).then(() => { route("/poll/new/date/0"); }); }; diff --git a/pollen-ui-riot-js/src/main/web/tag/Pagination.tag b/pollen-ui-riot-js/src/main/web/tag/Pagination.tag index 6dfe1ce..20bb06d 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pagination.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Pagination.tag @@ -26,6 +26,7 @@ this.on('mount', () => { this.refs.pageSize.value = this.pageSize; + console.info('pagination ---- on mount') this.refresh(); }); 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 ca631b2..337ccd2 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag @@ -26,15 +26,24 @@ require("./SignCheck.tag"); require("./Home.tag"); require("./poll/CreatePoll.tag"); require("./poll/Poll.tag"); -require("./polls/CreatedPolls.tag"); +require("./poll/Polls.tag"); <Pollen class="body-wrapper"> <Header></Header> <div class="body-content" ref="content"></div> <Footer></Footer> <script> - let route = require("riot-route"); let session = require("../js/Session"); + + + session.start().then(user => { + console.info("session started"); + }); + + this.installBundle(session, "main"); + + let route = require("riot-route"); + route("/poll/create", () => { riot.mount(this.refs.content, "createpoll"); }); @@ -54,9 +63,6 @@ require("./polls/CreatedPolls.tag"); route("/signcheck/*/*", (id, token) => { riot.mount(this.refs.content, "signcheck", {id: id, token: token}); }); - route("/poll", () => { - riot.mount(this.refs.content, "polls"); - }); route("/poll/*/vote", (pollId) => { riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'votes'}); @@ -84,13 +90,23 @@ require("./polls/CreatedPolls.tag"); riot.mount(this.refs.content, "userfavoritelists"); }); - route("/polls/created", () => { + route("/poll/created", () => { if (!session.isConnected()) { - route("/signin?url=/polls/created"); + route("/signin?url=/poll/created"); } else { - riot.mount(this.refs.content, "createdpolls"); + riot.mount(this.refs.content, "polls", { method: "createdPolls", session: session}); } }); + + route("/poll", () => { + if (!session.isConnected()) { + route("/signin?url=/poll"); + } else { + + riot.mount(this.refs.content, "polls", {method: "polls", session: session}); + } + }); + route("/poll/new/*/*", (type, step) => { riot.mount(this.refs.content, "createpoll", {type: type, step: step}); }); @@ -98,9 +114,5 @@ require("./polls/CreatedPolls.tag"); riot.mount(this.refs.content, "home"); }); - session.start().then(() => { - //console.info('session loaded'); - }); - </script> </Pollen> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag b/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag index cce322d..66b5643 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag @@ -1,23 +1,23 @@ /*- - * #%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% - */ +* #%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% +*/ require("./PollDescription.tag"); require("./PollChoicesText.tag"); require("./PollChoicesImage.tag"); @@ -81,7 +81,7 @@ require("./PollCreated.tag"); </div> </div> - <div if="{form.step==4}" class="header-container"> + <div if="{form.step == 4}" class="header-container"> <div> <span class="fa-stack fa-2x"> <i class="fa fa-circle-o fa-stack-2x"></i> @@ -150,17 +150,15 @@ require("./PollCreated.tag"); }; this.finalizeInit = () => { - let step = this.form.step; -// console.info("Current step!!!!!! " + step); - - riot.mount(this.refs.content, this.steps[step], {form: this.form, session: this.session}); - + riot.mount(this.refs.content, this.steps[this.form.step], {form: this.form, session: this.session}); }; if (!this.form.isInit) { - this.form.init().then(() => { - this.form.setStep(0); - this.finalizeInit(); + this.session.getUser().then(user => { + this.form.init(user).then(() => { + this.form.setStep(0); + this.finalizeInit(); + }); }); } else { 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 883f08f..964c088 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 @@ -12,12 +12,12 @@ require('./PollResults.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} ({votesCount}) + <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} ({commentsCount}) + <i class="fa fa-comments-o"></i> {__.comments} ({commentsCount}) </a> </div> <div class="{selectedTab=='results'?'tab-selected':'tab-not-selected'}"> @@ -26,7 +26,9 @@ require('./PollResults.tag'); <i class="fa fa-bar-chart-o"></i><span>{__.results}</span> </a> </div> - + <div if="{poll.permission}" class="actions"> + <i class="fa fa-bars fa-2x mainColor"/> + </div> </div> <div ref="content" class="tab-content"/> </div> @@ -46,7 +48,7 @@ require('./PollResults.tag'); let pollService = require('../../js/PollService'); pollService.getPoll(this.pollId).then(result => { this.poll = result; - this.withResults = this.poll.continiousResult || this.poll.isClosed; + this.withResults = this.poll.continuousResult || this.poll.isClosed; this.commentsCount = this.poll.commentCount; this.votesCount = this.poll.voteCount; console.info(this.poll); @@ -114,9 +116,11 @@ require('./PollResults.tag'); } .tab-header { + width: 820px; display: flex; flex-direction: row; padding-top: 20px; + align-items: center; } .tab-header > div { @@ -130,5 +134,11 @@ require('./PollResults.tag'); .tab-not-selected > a { color: black; } + .actions { + flex-grow: 1; + display: flex; + justify-content: flex-end; + align-items: center; + } </style> </Poll> \ No newline at end of file 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 f0e70b4..6da439f 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 @@ -18,22 +18,21 @@ require('./CommentPopup.tag'); <table show="{comments.length > 0}"> <tbody> <tr each="{comment in comments}"> - <td> - <div class="comment-header"> + <td class="comment-header"> + <div> <div> <i class="fa fa-user"/> {comment.authorName} </div> <div> <i class="fa fa-calendar-o"/> - {comment.postDate} - </div> - <div if="{comment.permission}" id="{comment.id}"> - <a onclick="{parent.openEditComment}"><i class="fa fa-pencil-square-o"/></a> - <a onclick="{parent.deleteComment}"><i class="fa fa-trash danger"/></a> + {comment.postDateStr} </div> </div> - + <div class="comment-header-actions" if="{comment.permission}" id="{comment.id}"> + <a onclick="{parent.deleteComment}"><i class="fa fa-trash fa-15x danger"/></a> + <a onclick="{parent.openEditComment}"><i class="fa fa-pencil-square-o fa-15x"/></a> + </div> </td> <td> <div class="comment-content"> @@ -46,7 +45,7 @@ require('./CommentPopup.tag'); <tr> <th colspan="3"> <div> - <Pagination ref=pagination" sortName='"postDate"' sortValue='true' callback="{callback}"/> + <Pagination ref="pagination" sortName='"postDate"' sortValue='true' callback="{callback}"/> </div> </th> </tr> @@ -60,7 +59,12 @@ require('./CommentPopup.tag'); <script> this.loaded = false; let session = require("../../js/Session"); - this.installBundle(session, "poll_comments"); + this.installBundle(session, "poll_comments", locale => { + this.moment.locale(locale); + this.comments.forEach(c => { + c.postDateStr = this.moment(c.postDate).format('LLLL'); + }); + }); let commentService = require("../../js/CommentService"); this.pollId = opts.pollId; @@ -70,6 +74,9 @@ require('./CommentPopup.tag'); this.pagination = this.tags.pagination; }); + this.moment = require('moment'); + this.moment.locale(session.locale); + this.sortName = 'postDate'; this.sortValue = true; // means desc @@ -150,7 +157,11 @@ require('./CommentPopup.tag'); console.info(pagination); return commentService.getComments(this.pollId, pagination, this.permission).then((result) => { this.comments = result.elements; + console.info("comments::"); console.info(this.comments); + this.comments.forEach(c => { + c.postDateStr = this.moment(c.postDate).format('LLLL'); + }); this.trigger('count', result.pagination.count); this.loaded = true; this.update(); @@ -161,6 +172,10 @@ require('./CommentPopup.tag'); </script> <style> + .fa-15x { + font-size: 1.5em; + } + .danger { color: red; } @@ -170,9 +185,22 @@ require('./CommentPopup.tag'); } .comment-header { - width: 200px; + width: 360px; + flex-grow: 1; + display: flex; + justify-content: flex-end; + } + + .comment-header-actions { + flex-grow: 1; + display: flex; + justify-content: flex-end; + align-items: center; } + .comment-header-actions > a { + padding-left: 5px; + } .legend { width: 800px; } @@ -185,10 +213,14 @@ require('./CommentPopup.tag'); border-right: 1px solid #ddd; } + tr > td:last-child { + width: 500px; + } + tr td { border-bottom: 1px solid #ddd; vertical-align: top; - padding: 5px 5px 15px; + padding: 5px 5px 5px; } table { 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 index e3f6beb..ef7de4b 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/PollResults.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollResults.tag @@ -4,10 +4,10 @@ {__.title} </div> <div> - <div if="{!poll.continiousResult && !poll.isClosed}"> + <div if="{!poll.continuousResult && !poll.isClosed}"> {__.noResult} </div> - <div if="{poll.continiousResult || poll.isClosed}" class="result-body" > + <div if="{poll.continuousResult || poll.isClosed}" class="result-body" > <div if="{results.nbVotants==1}">1 {__.voter}</div> <div if="{results.nbVotants>1}">{results.nbVotants} {__.voters}</div> <br/> 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 5d31b40..48572f1 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 @@ -46,8 +46,8 @@ </div> <div class="actions vote right" if="{vote.permission && (!voteId || voteId != vote.id)}" id="{vote.id}"> - <a onclick="{parent.onEditVote}"><i class="fa fa-pencil-square-o fa-15x"/></a> <a onclick="{parent.deleteVote}"><i class="fa fa-trash danger fa-15x"/></a> + <a onclick="{parent.onEditVote}"><i class="fa fa-pencil-square-o fa-15x"/></a> </div> <div class="actions right vote-cancel" show="{voteId == vote.id}"> @@ -90,8 +90,11 @@ this.choices = []; this.on('mount', () => { - if (session.isConnected() && this.poll.canVote && session.user) { - this.refs.voterName.value = session.user.name; + if (session.isConnected() && this.poll.canVote) { + session.getUser().then(user=> { + this.refs.voterName.value = user.name; + }) + } this.form = this.refs.form; }); @@ -247,6 +250,10 @@ </script> <style> + .fa-15x { + font-size: 1.5em; + } + .actions { width: 70px; } @@ -260,10 +267,6 @@ background-color: white; } - .fa-15x { - font-size: 1.5em; - } - .danger { color: red; } 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 85% 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..1972d8f 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,10 +1,10 @@ require('../Pagination.tag'); -<CreatedPolls> +<Polls> <div class="body-container"> <div class="container"> - <div class="legend">{__.title}</div> + <div class="legend">{__[method]}</div> <table> <thead> <tr> @@ -20,7 +20,7 @@ require('../Pagination.tag'); <td> <a href="#poll/{poll.id}/vote">{poll.title}</a> </td> - <td>{poll.beginDate}</td> + <td>{poll.beginDateStr}</td> <td>{poll.status}</td> </tr> </tbody> @@ -41,16 +41,22 @@ require('../Pagination.tag'); <script> this.sortName = 'title'; this.sortValue = false; // means asc + this.method = opts.method; let pollService = require('../../js/PollService'); + this.moment = require('moment'); + this.moment.locale(opts.session.locale); this.callback = (pagination) => { console.info("Request data with pagination::"); - if (!pagination.sortName) { + if (!pagination.order) { pagination.order = this.sortName; pagination.desc = this.sortValue; } console.info(pagination); - return pollService.createdPolls(pagination).then((result) => { + return pollService[this.method](pagination).then((result) => { this.polls = result.elements; + this.polls.forEach(p=> { + p.beginDateStr = this.moment(p.beginDate).format('LL'); + }); console.info(this.polls); this.update(); return result; @@ -59,12 +65,17 @@ require('../Pagination.tag'); this.polls = null; let session = require("../../js/Session"); - this.installBundle(session, "polls_created"); + this.installBundle(session, "polls", locale => { + this.moment.locale(locale); + this.polls.forEach(p=> { + p.beginDateStr = this.moment(p.beginDate).format('LL'); + }); + }); this.on('mount', () => { this.pagination = this.tags.pagination; this.sortOwner = this.refs.sortName; this.refs.sortName.setAttribute('sortName', 'title'); - this.refs.sortCreateDate.setAttribute('sortName', 'topiaCreatedDate'); + this.refs.sortCreateDate.setAttribute('sortName', 'topiaCreateDate'); }); this.toggleSort = (e) => { @@ -134,4 +145,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>.