branch feature/253-tuiles updated (0910eb55 -> b7af57b6)
This is an automated email from the git hooks/post-receive script. New change to branch feature/253-tuiles in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git from 0910eb55 WIP Mise en place du header de la page 'Mes sondages'. RAF problèmes alignements new b7af57b6 ref #253 Menu 'Mes sondages' 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 b7af57b6baf0d98fecd731f38f7a7bfd27510ade Author: Cécilia Bossard <bossard@codelutin.com> Date: Tue Feb 25 10:47:26 2020 +0100 ref #253 Menu 'Mes sondages' Summary of changes: .../pollen/persistence/entity/PollTopiaDao.java | 74 ++++++++++ .../org/chorem/pollen/rest/api/v1/PollApi.java | 23 ++- pollen-rest-api/src/main/resources/mapping | 4 + .../pollen/services/service/PollService.java | 33 +++++ pollen-ui-riot-js/src/main/web/conf.js | 2 +- pollen-ui-riot-js/src/main/web/js/PollService.js | 16 ++ pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html | 24 +++ .../main/web/tag/components/IconButton.tag.html | 4 +- .../src/main/web/tag/components/MenuItem.tag.html | 17 ++- .../main/web/tag/components/PollenButton.tag.html | 2 +- .../main/web/tag/components/SearchReboot.tag.html | 2 - .../{Polls.tag.html => MyPollsHeader.tag.html} | 145 ++++--------------- .../src/main/web/tag/poll/PollCardReboot.tag.html | 6 +- .../src/main/web/tag/poll/Polls.tag.html | 161 +-------------------- 14 files changed, 223 insertions(+), 290 deletions(-) copy pollen-ui-riot-js/src/main/web/tag/poll/{Polls.tag.html => MyPollsHeader.tag.html} (55%) -- 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/253-tuiles in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit b7af57b6baf0d98fecd731f38f7a7bfd27510ade Author: Cécilia Bossard <bossard@codelutin.com> Date: Tue Feb 25 10:47:26 2020 +0100 ref #253 Menu 'Mes sondages' --- .../pollen/persistence/entity/PollTopiaDao.java | 74 ++++++++++ .../org/chorem/pollen/rest/api/v1/PollApi.java | 23 ++- pollen-rest-api/src/main/resources/mapping | 4 + .../pollen/services/service/PollService.java | 33 +++++ pollen-ui-riot-js/src/main/web/conf.js | 2 +- pollen-ui-riot-js/src/main/web/js/PollService.js | 16 ++ pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html | 24 +++ .../main/web/tag/components/IconButton.tag.html | 4 +- .../src/main/web/tag/components/MenuItem.tag.html | 17 ++- .../main/web/tag/components/PollenButton.tag.html | 2 +- .../main/web/tag/components/SearchReboot.tag.html | 2 - .../{Polls.tag.html => MyPollsHeader.tag.html} | 145 ++++--------------- .../src/main/web/tag/poll/PollCardReboot.tag.html | 6 +- .../src/main/web/tag/poll/Polls.tag.html | 161 +-------------------- 14 files changed, 223 insertions(+), 290 deletions(-) diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java index 72c0a479..e2898201 100644 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java +++ b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java @@ -116,6 +116,80 @@ public class PollTopiaDao extends AbstractPollTopiaDao<Poll> { return PaginationResult.of(polls, count, page); } + + private PaginationResult<Poll> findAllUserPollsWithConditions(PollenUser user, PaginationParameter page, String search, Map<String, Object> parameters, String hqlCondition) { + + + String hql = "FROM " + Poll.class.getName() + " as poll " + + " WHERE (poll." + Poll.PROPERTY_CREATOR + "." + PollenPrincipal.PROPERTY_POLLEN_USER + " = :user" + + " OR EXISTS (SELECT 1 FROM " + VoterListMember.class.getName() + " memb" + + " WHERE memb." + VoterListMember.PROPERTY_VOTER_LIST + "." + VoterList.PROPERTY_POLL + "." + Poll.PROPERTY_TOPIA_ID + " = poll." + Poll.PROPERTY_TOPIA_ID + + " AND memb." + VoterListMember.PROPERTY_MEMBER + "." + PollenPrincipal.PROPERTY_POLLEN_USER + " = :user )" + + " OR EXISTS (SELECT 1 FROM " + Vote.class.getName() + " vote" + + " WHERE vote." + Vote.PROPERTY_VOTER + "." + PollenPrincipal.PROPERTY_POLLEN_USER + " = :user " + + " AND vote." + Vote.PROPERTY_QUESTION + "." + Question.PROPERTY_POLL + "." + Poll.PROPERTY_TOPIA_ID + " = poll." + Poll.PROPERTY_TOPIA_ID +")" + + ")"; + + if(StringUtils.isNotBlank(hqlCondition)) { + hql += " AND " + hqlCondition; + } + + if (StringUtils.isNotBlank(search)) { + hql += " AND " + DaoUtils.getSearchClause("poll", parameters, Poll.PROPERTY_TITLE, search); + } + + PaginationOrder order = page.getOrderClauses().get(0); + + PaginationParameter page2 = PaginationParameter.of(page.getPageNumber(), page.getPageSize(), "poll." + order.getClause(), order.isDesc()); + + List<Poll> polls = find("SELECT poll " + hql, parameters, page2); + long count = count("SELECT COUNT(poll.topiaId) " + hql, parameters); + return PaginationResult.of(polls, count, page); + } + + + public PaginationResult<Poll> findAllUserPolls(PollenUser user, PaginationParameter page, String search) { + + Map<String, Object> parameters = Maps.newHashMap(); + parameters.put("user", user); + + return findAllUserPollsWithConditions(user, page, search, parameters,""); + } + + public PaginationResult<Poll> findAllUpcomming(PollenUser user, PaginationParameter page, String search) { + + Map<String, Object> parameters = Maps.newHashMap(); + parameters.put("user", user); + parameters.put("today", new Date()); + + String hqlCondition = "poll." + Poll.PROPERTY_BEGIN_DATE + " IS NOT NULL " + + " AND poll." + Poll.PROPERTY_BEGIN_DATE + " >= :today "; + return findAllUserPollsWithConditions(user, page, search, parameters, hqlCondition); + } + + public PaginationResult<Poll> findAllPast(PollenUser user, PaginationParameter page, String search) { + + Map<String, Object> parameters = Maps.newHashMap(); + parameters.put("user", user); + parameters.put("today", new Date()); + + String hqlCondition = "poll." + Poll.PROPERTY_END_DATE + " IS NOT NULL " + + " AND poll." + Poll.PROPERTY_END_DATE + " >= :today "; + return findAllUserPollsWithConditions(user, page, search, parameters, hqlCondition); + } + + + public PaginationResult<Poll> findAllCurrent(PollenUser user, PaginationParameter page, String search) { + + Map<String, Object> parameters = Maps.newHashMap(); + parameters.put("user", user); + parameters.put("today", new Date()); + + String hqlCondition = "(poll." + Poll.PROPERTY_BEGIN_DATE+ " IS NULL OR poll." + Poll.PROPERTY_BEGIN_DATE + " <= :today) " + + " AND ( poll." + Poll.PROPERTY_END_DATE + " IS NULL OR poll." + Poll.PROPERTY_END_DATE + ">= :today)"; + return findAllUserPollsWithConditions(user, page, search, parameters, hqlCondition); + } + public Set<Poll> findAllFreePolls() { List<Poll> polls = forPollTypeEquals(PollType.FREE).findAll(); diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java index 4c64188b..ca3c54d2 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java @@ -75,12 +75,23 @@ public class PollApi { if (StringUtils.isBlank(context)) { return pollService.getPolls(paginationParameter, search); - } else if ("invited".equals(context)) { - return pollService.getInvitedPolls(paginationParameter, search); - } else if ("participated".equals(context)) { - return pollService.getParticipatedPolls(paginationParameter, search); - } else /*if ("created".equals(context))*/ { - return pollService.getCreatedPolls(paginationParameter, search); + } else { + switch (context) { + case "invited" : + return pollService.getInvitedPolls(paginationParameter, search); + case "participated" : + return pollService.getParticipatedPolls(paginationParameter, search); + case "created" : + return pollService.getCreatedPolls(paginationParameter, search); + case "past" : + return pollService.getPastPolls(paginationParameter, search); + case "current" : + return pollService.getCurentPolls(paginationParameter, search); + case "upcomming" : + return pollService.getUpcommingPolls(paginationParameter, search); + default : + return pollService.getAllPolls(paginationParameter, search); + } } } diff --git a/pollen-rest-api/src/main/resources/mapping b/pollen-rest-api/src/main/resources/mapping index de064f7a..77249cef 100644 --- a/pollen-rest-api/src/main/resources/mapping +++ b/pollen-rest-api/src/main/resources/mapping @@ -114,9 +114,13 @@ GET /v1/favoriteLists/{favoriteListId}/all FavoriteListApi. GET /v1/polls/new PollApi.getNewPoll GET /v1/polls PollApi.getPolls +GET /v1/polls/all PollApi.getAllPolls GET /v1/polls/created PollApi.getCreatedPolls GET /v1/polls/invited PollApi.getInvitedPolls GET /v1/polls/participated PollApi.getParticipatedPolls +GET /v1/polls/past PollApi.getPastPolls +GET /v1/polls/current PollApi.getCurrentPolls +GET /v1/polls/upcomming PollApi.getUpcommingPolls POST /v1/polls PollApi.createPoll #fix me POST,PUT /v1/polls/{pollId} PollApi.editPoll 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 af67afe4..a635787a 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 @@ -204,6 +204,16 @@ public class PollService extends PollenServiceSupport { } + public PaginationResultBean<PollBean> getAllPolls(PaginationParameterBean paginationParameter, String search) { + + PollenUser connectedUser = checkAndGetConnectedUser(); + + PaginationParameter page = getPaginationParameter(paginationParameter); + PaginationResult<Poll> polls = getPollDao().findAllUserPolls(connectedUser, page, search); + return toPaginationListBean(polls, this::toPollBean); + + } + public PaginationResultBean<PollBean> getCreatedPolls(PaginationParameterBean paginationParameter, String search) { PollenUser connectedUser = checkAndGetConnectedUser(); @@ -234,6 +244,27 @@ public class PollService extends PollenServiceSupport { } + public PaginationResultBean<PollBean> getPastPolls(PaginationParameterBean paginationParameter, String search) { + PollenUser connectedUser = checkAndGetConnectedUser(); + PaginationParameter page = getPaginationParameter(paginationParameter); + PaginationResult<Poll> polls = getPollDao().findAllPast(connectedUser, page, search); + return toPaginationListBean(polls, this::toPollBean); + } + + public PaginationResultBean<PollBean> getCurentPolls(PaginationParameterBean paginationParameter, String search) { + PollenUser connectedUser = checkAndGetConnectedUser(); + PaginationParameter page = getPaginationParameter(paginationParameter); + PaginationResult<Poll> polls = getPollDao().findAllCurrent(connectedUser, page, search); + return toPaginationListBean(polls, this::toPollBean); + } + + public PaginationResultBean<PollBean> getUpcommingPolls(PaginationParameterBean paginationParameter, String search) { + PollenUser connectedUser = checkAndGetConnectedUser(); + PaginationParameter page = getPaginationParameter(paginationParameter); + PaginationResult<Poll> polls = getPollDao().findAllUpcomming(connectedUser, page, search); + return toPaginationListBean(polls, this::toPollBean); + } + public PollBean getPoll(String pollId) { checkIsConnectedRequired(); @@ -700,4 +731,6 @@ public class PollService extends PollenServiceSupport { return invalidEmails; } + + } diff --git a/pollen-ui-riot-js/src/main/web/conf.js b/pollen-ui-riot-js/src/main/web/conf.js index 1e76631e..5d0c4927 100644 --- a/pollen-ui-riot-js/src/main/web/conf.js +++ b/pollen-ui-riot-js/src/main/web/conf.js @@ -19,7 +19,7 @@ * #L% */ window.pollenConf = { - endPoint: POLLEN_API_URL, + endPoint: "http://localhost:8888/pollen-rest-api", piwikUrl: "", // add the piwik url, eg: http://localhost/piwik piwikSiteId: "", // add the site id, eg: 3 defaultMessageTimeout: 15, 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 c96eaa8a..7582723d 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollService.js +++ b/pollen-ui-riot-js/src/main/web/js/PollService.js @@ -95,6 +95,22 @@ class PollService extends FetchService { return this._getPolls(pagination, "participated", search); } + pastPolls(pagination, search) { + return this._getPolls(pagination, "past", search); + } + + currentPolls(pagination, search) { + return this._getPolls(pagination, "current", search); + } + + upcommingPolls(pagination, search) { + return this._getPolls(pagination, "upcomming", search); + } + + allPolls(pagination, search) { + return this._getPolls(pagination, "all", search); + } + polls(pagination, search) { return this._getPolls(pagination, "", search); } diff --git a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html index 40bb3948..9951d015 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html @@ -188,6 +188,12 @@ import "./popup/ShowReportsModal.tag.html"; </Authorization> </route> + <route path="polls/all"> + <Authorization connected="true"> + <PageChanged page="allPolls"/> + <Polls method="allPolls"/> + </Authorization> + </route> <route path="polls/created"> <Authorization connected="true"> <PageChanged page="createdPolls"/> @@ -206,6 +212,24 @@ import "./popup/ShowReportsModal.tag.html"; <Polls method="participatedPolls"/> </Authorization> </route> + <route path="polls/past"> + <Authorization connected="true"> + <PageChanged page="pastPolls"/> + <Polls method="pastPolls"/> + </Authorization> + </route> + <route path="polls/current"> + <Authorization connected="true"> + <PageChanged page="currentPolls"/> + <Polls method="currentPolls"/> + </Authorization> + </route> + <route path="polls/upcomming"> + <Authorization connected="true"> + <PageChanged page="upcommingPolls"/> + <Polls method="upcommingPolls"/> + </Authorization> + </route> <route path="polls"> <Authorization admin="true"> <PageChanged page="admin_polls"/> diff --git a/pollen-ui-riot-js/src/main/web/tag/components/IconButton.tag.html b/pollen-ui-riot-js/src/main/web/tag/components/IconButton.tag.html index 51ffb0d6..9101598a 100644 --- a/pollen-ui-riot-js/src/main/web/tag/components/IconButton.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/components/IconButton.tag.html @@ -45,6 +45,7 @@ .iconButton { display: flex; flex-direction: column; + padding-left: 20px; } .icon { @@ -62,13 +63,12 @@ .selector { width: 6px; height: 6px; - right: 57px; top: 215px; background: #14A39F; border-radius: 4px; - margin-left: 5px; + margin-left: 4.5px; visibility: hidden; } diff --git a/pollen-ui-riot-js/src/main/web/tag/components/MenuItem.tag.html b/pollen-ui-riot-js/src/main/web/tag/components/MenuItem.tag.html index 825f52b7..023189db 100644 --- a/pollen-ui-riot-js/src/main/web/tag/components/MenuItem.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/components/MenuItem.tag.html @@ -22,9 +22,9 @@ <MenuItem> <div> - <a href="{opts.href}"> - <span class="{activeClassName}">{opts.label}</span> - <div class="selector {this.visibleSelector}" /> + <a href="{opts.href}" class="{activeClassName}"> + <span >{opts.label}</span> + <div class="selector {visibleSelector}"/> </a> </div> @@ -33,7 +33,10 @@ this.activeClassName = ""; this.visibleSelector = "hidden"; - if(this.opts.active) { + var method = this.opts.method; + var ref = this.opts.ref; + + if(method === ref) { this.activeClassName = "active"; this.visibleSelector = "visible"; } @@ -55,10 +58,9 @@ color: black; text-align: left; padding-top: 30px; - padding-left: 20px; - padding-right: 20px; + padding-left: 10px; + padding-right: 10px; text-decoration: none; - } .active { @@ -67,7 +69,6 @@ } .selector { - width: 19px; height: 2px; left: 50px; top: 213px; diff --git a/pollen-ui-riot-js/src/main/web/tag/components/PollenButton.tag.html b/pollen-ui-riot-js/src/main/web/tag/components/PollenButton.tag.html index 3632035d..fc320121 100644 --- a/pollen-ui-riot-js/src/main/web/tag/components/PollenButton.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/components/PollenButton.tag.html @@ -21,7 +21,7 @@ <PollenButton> - <a class="btn {className}" href="{opts.url}"> + <a class="btn {className}" href="{opts.url}" onclick="{opts.onclick}"> <i class="{opts.icon}" /> <span>{opts.label}</span> </a> diff --git a/pollen-ui-riot-js/src/main/web/tag/components/SearchReboot.tag.html b/pollen-ui-riot-js/src/main/web/tag/components/SearchReboot.tag.html index 4f3112e3..d87fd495 100644 --- a/pollen-ui-riot-js/src/main/web/tag/components/SearchReboot.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/components/SearchReboot.tag.html @@ -20,7 +20,6 @@ --> <SearchReboot> <div class="search"> - <!-- <div class="o-field o-field--icon-left o-field--icon-right">--> <i class="icon-search"></i> <input class="searchField" id="search" @@ -32,7 +31,6 @@ <i class="icon-delete" aria-hidden="true" if={refs && refs.search.value} onclick={deleteSearch}></i> - <!--</div>--> </div> <script type="es6"> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/MyPollsHeader.tag.html similarity index 55% copy from pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html copy to pollen-ui-riot-js/src/main/web/tag/poll/MyPollsHeader.tag.html index 5137152a..86adabcf 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/MyPollsHeader.tag.html @@ -18,42 +18,39 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --> -import "./PollCard.tag.html"; -import "./PollCardReboot.tag.html"; -import "../components/LazyLoad.tag.html"; -import "../components/LoadingCard.tag.html"; + import "../components/SearchReboot.tag.html"; import "../components/PollenButton.tag.html"; import "../components/IconButton.tag.html"; import "../components/MenuItem.tag.html"; -<Polls> - <div class="container" show="{loaded}"> +<MyPollsHeader> + <div> <!-- Header --> <div class="header"> <div class="leftHeader"> <span>{_t.createdPolls}</span> <PollenButton primary="true" label={_t.newPoll} icon="icon-new" url="#poll/new/text"/> - <PollenButton secondary="true" label={_t.assignPollToMe_title} url=""/> + <PollenButton secondary="true" label={_t.assignPollToMe_title} url="" onclick={this.assignPoll} /> </div> <div> - <SearchReboot onsearch="{refresh}" search="{search}"/> + <SearchReboot onsearch="{this.parent.refresh}" search="{this.opts.search}"/> </div> </div> <!-- Sub-menus --> <div class="submenu"> <div class="leftSubMenu"> - <MenuItem active="true" href="#polls/all" label="{_t.allPolls}" /> - <MenuItem href="#polls/created" label="{_t.myPolls}" /> - <MenuItem href="#polls/invited" label="{_t.invitedPolls}" /> - <MenuItem href="#polls/participated" label="{_t.participatedPolls}" /> + <MenuItem href="#polls/all" label="{_t.allPolls}" ref="allPolls" method="{this.parent.opts.method}"/> + <MenuItem href="#polls/created" label="{_t.myPolls}" ref="createdPolls" method="{this.parent.opts.method}"/> + <MenuItem href="#polls/invited" label="{_t.invitedPolls}" ref="invitedPolls" method="{this.parent.opts.method}"/> + <MenuItem href="#polls/participated" label="{_t.participatedPolls}" ref="participatedPolls" method="{this.parent.opts.method}"/> <!-- TODO A remplacer par un separator --> - <MenuItem label="|" /> - <MenuItem href="#polls/past" label="{_t.pastPolls}" /> - <MenuItem href="#polls/current" label="{_t.currentPolls}" /> - <MenuItem href="#polls/upcomming" label="{_t.upcommingPolls}" /> + <MenuItem label="|" ref="none"/> + <MenuItem href="#polls/past" label="{_t.pastPolls}" ref="pastPolls" method="{this.parent.opts.method}"/> + <MenuItem href="#polls/current" label="{_t.currentPolls}" ref="currentPolls" method="{this.parent.opts.method}"/> + <MenuItem href="#polls/upcomming" label="{_t.upcommingPolls}" ref="upcommingPolls" method="{this.parent.opts.method}"/> </div> <div class="rightSubMenu"> <div><IconButton icon="icon-List" /></div> @@ -61,42 +58,22 @@ import "../components/MenuItem.tag.html"; </div> </div> - - <div class="main-content"> - - <LazyLoad pagination={pagination} onload={lazyLoad} load-size="20" ref="lazyLoad" class="elements"> - <yield to="element"> - <PollCardReboot poll={element} on-poll-list-change={parent.parent.refresh}/> - </yield> - <yield to="loading"> - <LoadingCard loading={nbNextGroup}> - {parent.parent._l("loading", nbNext)} - </LoadingCard> - </yield> - </LazyLoad> - - <ContextualMenu if={opts.method === "createdPolls"}> - <a onclick={parent.assignPoll}> - {parent._t.assignPollToMe_title} - </a> - </ContextualMenu> - - <Modal ref="assignModal" onsubmit={assign} header={_t.assignPollToMe_title} label={_t.assignPollToMe} type="success"> - <div class="o-form-element"> - <label class="c-label" for="pollToAssign">{parent._t.assignPollToMe_desc}</label> - <div class="o-field o-field--icon-left"> - <i class="fa fa-fw fa-link c-icon" aria-hidden="true"></i> - <input class="c-field" - type="text" - name="pollToAssign" - ref="pollToAssign" - placeholder={parent.pollToAssignPlaceholder} - pattern={parent.pollToAssignUrlPattern} - required> - </div> + <Modal ref="assignModal" onsubmit={assign} header={_t.assignPollToMe_title} label={_t.assignPollToMe} type="success"> + <div class="o-form-element"> + <label class="c-label" for="pollToAssign">{parent._t.assignPollToMe_desc}</label> + <div class="o-field o-field--icon-left"> + <i class="fa fa-fw fa-link c-icon" aria-hidden="true"></i> + <input class="c-field" + type="text" + name="pollToAssign" + ref="pollToAssign" + placeholder={parent.pollToAssignPlaceholder} + pattern={parent.pollToAssignUrlPattern} + required> </div> - </Modal> - </div> + </div> + </Modal> + </div> <script type="es6"> @@ -104,60 +81,10 @@ import "../components/MenuItem.tag.html"; import Message from "../../js/Message"; import pollService from "../../js/PollService"; - this.loaded = false; this.installBundle(session, "polls"); this.pollToAssignPlaceholder = session.pollenUIContext.uiEndPoint + "/#poll/xxxx/vote/xxxx"; this.pollToAssignUrlPattern = session.pollenUIContext.uiEndPoint + "/#poll/(.+)/vote/(.+)"; - this.pagination = { - order: "topiaCreateDate", - desc: true, - pageSize: -1, - pageNumber: 0 - }; - this.search = {value: ""}; - this.count = 0; - this.filteredCount = 0; - - this.getCountLabel = () => { - let label; - if (this.count === 0) { - label = this._l("noPoll"); - } else { - if (this.count === 1) { - label = this._l("one", this.count); - } else { - label = this._l("many", this.count); - } - if (this.filteredCount !== this.count) { - if (this.filteredCount === 0) { - label = this._l("noFound") + label; - } else if (this.filteredCount === 1) { - label = this._l("oneFound", this.filteredCount) + label; - } else { - label = this._l("manyFound", this.filteredCount) + label; - } - } - } - return label; - }; - - this.refresh = () => { - this.refs.lazyLoad.reload(); - }; - - this.lazyLoad = pagination => { - return pollService[this.opts.method](pagination, this.search.value).then((result) => { - if (!this.loaded) { - this.count = result.pagination.count; - this.loaded = true; - } - this.filteredCount = result.pagination.count; - this.update(); - return result; - }); - }; - this.assignPoll = () => { this.refs.assignModal.open().then(() => { this.update(); @@ -187,16 +114,11 @@ import "../components/MenuItem.tag.html"; </script> <style> - .elements { - display: flex; - flex-wrap: wrap; - justify-content: flex-start; - } .header { font-family: Open Sans; font-style: normal; - font-weight: 300; + font-weight: normal; font-size: 40px; line-height: 54px; @@ -219,16 +141,16 @@ import "../components/MenuItem.tag.html"; display: flex; justify-content: space-between; align-items: center; - flex-basis: 25%; } PollenButton { align-content: center; display: flex; + padding-left: 20px; } SearchReboot { - padding-top: 10px; + padding-top: 5px; align-content: center; display: flex; } @@ -256,13 +178,10 @@ import "../components/MenuItem.tag.html"; flex-grow: 2; } - - - .active span { color: #29817E; font-weight: bold; } </style> -</Polls> +</MyPollsHeader> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollCardReboot.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/PollCardReboot.tag.html index aa790c28..ccac1a66 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/PollCardReboot.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollCardReboot.tag.html @@ -81,9 +81,9 @@ import "../components/Avatar.tag.html"; var now = new Date(); this.ended = this.opts.poll.endDate < now; - this.running = this.opts.poll.startDate < now && opts.poll.endDate>now; - this.started = this.opts.poll.startDate < now && !opts.poll.endDate; - this.starting = this.opts.poll.startDate > now; + this.running = this.opts.poll.beginDate < now && opts.poll.endDate>now; + this.started = this.opts.poll.beginDate < now && !opts.poll.endDate; + this.starting = this.opts.poll.beginDate > now; this.deletePoll = (e) => { e.preventDefault(); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html index 5137152a..acac6fbd 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html @@ -22,45 +22,12 @@ import "./PollCard.tag.html"; import "./PollCardReboot.tag.html"; import "../components/LazyLoad.tag.html"; import "../components/LoadingCard.tag.html"; -import "../components/SearchReboot.tag.html"; -import "../components/PollenButton.tag.html"; -import "../components/IconButton.tag.html"; -import "../components/MenuItem.tag.html"; +import "./MyPollsHeader.tag.html"; <Polls> <div class="container" show="{loaded}"> - <!-- Header --> - <div class="header"> - <div class="leftHeader"> - <span>{_t.createdPolls}</span> - <PollenButton primary="true" label={_t.newPoll} icon="icon-new" url="#poll/new/text"/> - <PollenButton secondary="true" label={_t.assignPollToMe_title} url=""/> - </div> - <div> - <SearchReboot onsearch="{refresh}" search="{search}"/> - </div> - </div> - - <!-- Sub-menus --> - <div class="submenu"> - <div class="leftSubMenu"> - <MenuItem active="true" href="#polls/all" label="{_t.allPolls}" /> - <MenuItem href="#polls/created" label="{_t.myPolls}" /> - <MenuItem href="#polls/invited" label="{_t.invitedPolls}" /> - <MenuItem href="#polls/participated" label="{_t.participatedPolls}" /> - <!-- TODO A remplacer par un separator --> - <MenuItem label="|" /> - <MenuItem href="#polls/past" label="{_t.pastPolls}" /> - <MenuItem href="#polls/current" label="{_t.currentPolls}" /> - <MenuItem href="#polls/upcomming" label="{_t.upcommingPolls}" /> - </div> - <div class="rightSubMenu"> - <div><IconButton icon="icon-List" /></div> - <div><IconButton href="#" icon="icon-Mosaic" active="true"/></div> - </div> - </div> - + <MyPollsHeader search="{search}"/> <div class="main-content"> @@ -75,27 +42,6 @@ import "../components/MenuItem.tag.html"; </yield> </LazyLoad> - <ContextualMenu if={opts.method === "createdPolls"}> - <a onclick={parent.assignPoll}> - {parent._t.assignPollToMe_title} - </a> - </ContextualMenu> - - <Modal ref="assignModal" onsubmit={assign} header={_t.assignPollToMe_title} label={_t.assignPollToMe} type="success"> - <div class="o-form-element"> - <label class="c-label" for="pollToAssign">{parent._t.assignPollToMe_desc}</label> - <div class="o-field o-field--icon-left"> - <i class="fa fa-fw fa-link c-icon" aria-hidden="true"></i> - <input class="c-field" - type="text" - name="pollToAssign" - ref="pollToAssign" - placeholder={parent.pollToAssignPlaceholder} - pattern={parent.pollToAssignUrlPattern} - required> - </div> - </div> - </Modal> </div> </div> @@ -106,8 +52,6 @@ import "../components/MenuItem.tag.html"; this.loaded = false; this.installBundle(session, "polls"); - this.pollToAssignPlaceholder = session.pollenUIContext.uiEndPoint + "/#poll/xxxx/vote/xxxx"; - this.pollToAssignUrlPattern = session.pollenUIContext.uiEndPoint + "/#poll/(.+)/vote/(.+)"; this.pagination = { order: "topiaCreateDate", @@ -158,110 +102,19 @@ import "../components/MenuItem.tag.html"; }); }; - this.assignPoll = () => { - this.refs.assignModal.open().then(() => { - this.update(); - }, () => {}); - this.update(); - }; - - this.assign = () => { - var pollUrl = this.refs.assignModal.refs.pollToAssign.value; - var regex = new RegExp(this.pollToAssignUrlPattern); - var finds = regex.exec(pollUrl); - return pollService.assignPoll(finds[1], finds[2]).then((result) => { - if (result) { - this.refresh(); - this.bus.trigger("message", new Message(this._l("assignSuccessMessage", result.title), "success")); - } else { - this.bus.trigger("message", new Message(this._t.alreadyAssignMessage, "warning")); - } - this.refs.assignModal.refs.pollToAssign.value = ""; - this.update(); - }, errors => { - this.bus.trigger("message", errors, "error"); - this.update(); - }); - }; </script> <style> - .elements { - display: flex; - flex-wrap: wrap; - justify-content: flex-start; - } - - .header { - font-family: Open Sans; - font-style: normal; - font-weight: 300; - font-size: 40px; - line-height: 54px; - - color: #14A39F; - - display: flex; - width: 100%; - justify-content: space-between; - - padding-top: 40px; - padding-left: 2%; - padding-right: 2%; - } - - .header div:last-child { - margin-left: auto; - } - - .leftHeader { - display: flex; - justify-content: space-between; - align-items: center; - flex-basis: 25%; - } - - PollenButton { - align-content: center; - display: flex; - } - - SearchReboot { - padding-top: 10px; - align-content: center; - display: flex; - } - /* Submenu styles */ - .submenu { - padding: 0px 2%; - display: flex; - margin-top: 30px; - margin-bottom: 25px; - width: 100%; - line-height: 19px; - } - - .leftSubMenu { - display: flex; - justify-content: space-between; - align-items: center; + .container { + background: #E5E5E5; } - .rightSubMenu { + .elements { display: flex; - justify-content: flex-end; - align-items: center; - flex-grow: 2; - } - - - - - .active span { - color: #29817E; - font-weight: bold; + flex-wrap: wrap; + justify-content: flex-start; } </style> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm