Author: fdesbois Date: 2012-04-24 11:41:18 +0200 (Tue, 24 Apr 2012) New Revision: 3306 Url: http://chorem.org/repositories/revision/pollen/3306 Log: Add missing close action on poll form when edition is activated. There is an issue when rendering the close.jsp page (no layout) but it seems that the decorator doesn't exclude this page. Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/close.jsp trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClosePoll.jsp trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollListHelper.jsp trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-04-24 08:18:28 UTC (rev 3305) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-04-24 09:41:18 UTC (rev 3306) @@ -395,6 +395,20 @@ return result; } + public PollUrl getPollResultUrl(Poll poll) { + URL applicationUrl = serviceContext.getApplicationURL(); + String baseUrl = applicationUrl + "/poll/results/"; + PollUri pollUri = PollUri.newPollUri(poll.getPollId()); + + if (!poll.isPublicResults()) { + String creatorId = poll.getCreator().getAccountId(); + pollUri.setAccountId(creatorId); + } + + PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri); + return result; + } + public List<Poll> getPolls(TopiaFilterPagerUtil.FilterPagerBean pager) { Preconditions.checkNotNull(pager); Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-04-24 08:18:28 UTC (rev 3305) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-04-24 09:41:18 UTC (rev 3306) @@ -247,16 +247,7 @@ return creator.getUserAccount() != null; } - protected int getNbChoices() { - //TODO tchemit-2012-03-05 use a default value from configuration - return 5; - } - - protected int getDefaultNbVotingLists() { - return 1; - } - - protected boolean isEdit() { + public boolean isEdit() { return StringUtils.isNotEmpty(getPoll().getTopiaId()); } Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java 2012-04-24 08:18:28 UTC (rev 3305) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java 2012-04-24 09:41:18 UTC (rev 3306) @@ -23,6 +23,7 @@ */ package org.chorem.pollen.ui.actions.poll; +import org.chorem.pollen.business.persistence.Poll; import org.chorem.pollen.services.impl.PollService; /** @@ -35,22 +36,39 @@ private static final long serialVersionUID = 1L; - protected String redirectUrl; + protected PollService pollService; + + protected Poll poll; + + protected String pollResultUrl; - public String getRedirectUrl() { - return redirectUrl; + protected PollService getPollService() { + if (pollService == null) { + pollService = newService(PollService.class); + } + return pollService; } + + public Poll getPoll() { + return poll; + } - public void setRedirectUrl(String redirectUrl) { - this.redirectUrl = redirectUrl; + public String getPollResultUrl() { + return pollResultUrl; } @Override public String execute() throws Exception { + + String pollUid = getPollId(); - PollService service = newService(PollService.class); + poll = getPollService().getPollByPollId(pollUid); - service.closePoll(getPollId(), getPollenUserAccount(), getAccountId()); + pollResultUrl = getPollService().getPollResultUrl(poll).getUrl(); + + getPollService().closePoll(pollUid, + getPollenUserAccount(), + getAccountId()); return SUCCESS; } } Modified: trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-04-24 08:18:28 UTC (rev 3305) +++ trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-04-24 09:41:18 UTC (rev 3306) @@ -98,7 +98,7 @@ <action name="close/*" class="org.chorem.pollen.ui.actions.poll.ClosePoll"> <param name="uriId">{1}</param> - <result type="redirect2"/> + <result>/WEB-INF/jsp/poll/close.jsp</result> </action> <!-- confirm delete poll --> Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-04-24 08:18:28 UTC (rev 3305) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-04-24 09:41:18 UTC (rev 3306) @@ -113,6 +113,7 @@ pollen.common.pollType=Who can vote ? pollen.common.pollType.help=Free\: accessible to everyone <br/><br/> Restricted\: accessible only to a list of persons <br/><br/> Group\: accessible to several lists of persons pollen.common.postDate=Comment date +pollen.common.resultAction=Count pollen.common.results=Results\: pollen.common.select.choiceType=Select the type of choice pollen.common.select.userFavoriteList=List @@ -235,8 +236,9 @@ pollen.label.contact.administrator=Send an email to an administrator pollen.label.pollEditPage=The link below leads to the page to modify your poll. Save it to be able to modify your poll later if you need it or to close it \: pollen.label.pollRegisterPage=If you are a logged user, you can find these links on the page +pollen.label.pollResultPage=The link below leads to the page to count the votes. Save it to be able to count the vote later \: pollen.label.pollVotePage=The link below leads to the page to vote for your poll. Save it and send it to the people that you want to vote \: -pollen.label.pollVotePage.restricted= +pollen.label.pollVotePage.restricted=The link below leads to the page to vote for your poll. This access is available only for you as poll's creator \: pollen.legend.login=Login pollen.legend.select.favoriteList.to.add=Sélectionner la liste de favoris à ajouter pollen.legend.select.personList.to.create.votingList=Sélectionner la liste des votant à importer dans le nouveau groupe Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-04-24 08:18:28 UTC (rev 3305) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-04-24 09:41:18 UTC (rev 3306) @@ -116,6 +116,7 @@ pollen.common.pollType=Qui peut voter ? pollen.common.pollType.help=Libre \: accessible à tout le monde <br/><br/> Restreint \: accessible uniquement à une liste de votants <br/><br/> Groupe \: accessible à plusieurs listes de votants pollen.common.postDate=Date du commentaire +pollen.common.resultAction=Dépouillement pollen.common.results=Résultats \: pollen.common.select.choiceType=Sélectionner le type de choix pollen.common.select.userFavoriteList=Liste @@ -139,7 +140,6 @@ pollen.common.voterName=Votant pollen.common.votingList=Groupe pollen.common.weight=Poids -pollen.common.x=Dépouillement pollen.error.accountNotFound= pollen.error.choice.empty=%s obligatoire pollen.error.comment.name.empty=Nom du commentaire obligatoire @@ -239,6 +239,7 @@ pollen.label.contact.administrator=Contacter un administrateur pollen.label.pollEditPage=Le lien ci-dessous mène à la page de modification du sondage. Enregistrez-le pour pouvoir modifier votre sondage au besoin ou le clore \: pollen.label.pollRegisterPage=Si vous êtes un utilisateur identifié, vous pouvez retrouver ces liens dans la page +pollen.label.pollResultPage=Le lien ci-dessous mène à la page de dépouillement. Enregistrez-le pour pouvoir accéder au dépouillement plus tard \: pollen.label.pollVotePage=Le lien ci-dessous mène à la page de vote. Enregistrez-le et envoyez-le à ceux que vous voulez voir voter \: pollen.label.pollVotePage.restricted=Le lien ci-dessous mène à la page de vote. Cet accès n'est valable que pour vous en tant que créateur du sondage \: pollen.legend.login=Login Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/close.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/close.jsp 2012-04-24 08:18:28 UTC (rev 3305) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/close.jsp 2012-04-24 09:41:18 UTC (rev 3306) @@ -21,5 +21,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --%> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<h2>close poll TODO</h2> \ No newline at end of file +<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<h1 class="titleCreation"><s:property value="poll.title"/></h1> + +<h3><s:property value="poll.title"/> <s:text name="pollen.common.by"/> + <s:property value="poll.creator.votingId"/></h3> + +<div style="margin-top: 10px;"> + <img src="<s:url value='/img/count.png'/>" + alt="<s:text name='pollen.common.resultAction'/>" + style="margin-right: 18px;"/> + <s:text name='pollen.label.pollResultPage'/> + <br/> + <s:set name="resultUrl" value="%{pollResultUrl}"/> + <s:a href="%{resultUrl}" cssStyle="margin-left:50px;"> + <s:property value="resultUrl"/> + </s:a> +</div> +<div style="margin-top: 30px;"> + <s:text name="pollen.label.pollRegisterPage"/> + <s:a namespace="/user" action="myPolls"> + <s:text name="pollen.common.myPolls"/> + </s:a>. +</div> \ No newline at end of file Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClosePoll.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClosePoll.jsp 2012-04-24 08:18:28 UTC (rev 3305) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClosePoll.jsp 2012-04-24 09:41:18 UTC (rev 3306) @@ -32,7 +32,7 @@ <s:form method="POST" namespace="/poll"> <fieldset class="ui-widget-content ui-corner-all"> - <s:hidden key="redirectUrl" label=''/> + <!--<s:hidden key="redirectUrl" label=''/>--> <s:hidden key="uriId" label=''/> <s:text name="pollen.information.confirmClosePoll"/> Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-04-24 08:18:28 UTC (rev 3305) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-04-24 09:41:18 UTC (rev 3306) @@ -54,7 +54,12 @@ reminder:'<s:property value="%{reminder}"/>', voteCountingType:'<s:property value="%{poll.voteCountingType.name()}"/>', choiceType:'<s:property value="%{poll.choiceType.name()}"/>', - pollType:'<s:property value="%{poll.pollType.name()}"/>' + pollType:'<s:property value="%{poll.pollType.name()}"/>', + + adminId:'<s:property value="%{poll.adminId}"/>', + confirmCloseTitle: "<s:text name='pollen.title.close.poll'/>", + confirmCloseUrl: '<s:url action="confirmClosePoll/" namespace="/poll"/>' + + '<s:property value="%{poll.adminId}"/>' } ); </script> @@ -253,6 +258,13 @@ <br/> <s:submit action="save" value="%{actionLabel}" align="center"/> + <s:if test="edit"> + <div align="center" style="margin-top: 10px"> + <button onclick="return confirmClose();"> + <s:text name="pollen.action.close"/> + </button> + </div> + </s:if> </s:form> <script type="text/javascript"> @@ -278,3 +290,5 @@ <sj:dialog id="selectPersonListDialog" resizable="true" autoOpen="false" modal="true" width="500"/> + +<sj:dialog id="confirmDialog" autoOpen="false" modal="true" width="500"/> Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollListHelper.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollListHelper.jsp 2012-04-24 08:18:28 UTC (rev 3305) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollListHelper.jsp 2012-04-24 09:41:18 UTC (rev 3306) @@ -74,7 +74,7 @@ $('.ui-dialog-title').html("<s:text name="pollen.title.close.poll"/>") var dialog = $("#confirmDialog"); var url = "<s:url action='confirmClosePoll/' namespace='/poll'/>"; - url += id + '?' + $.param({redirectUrl:redirectUrl}); + url += id; dialog.load(url); dialog.dialog('open'); return false; Modified: trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-04-24 08:18:28 UTC (rev 3305) +++ trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-04-24 09:41:18 UTC (rev 3306) @@ -485,6 +485,15 @@ return false; }*/ +function confirmClose() { + $('.ui-dialog-title').html(datas['confirmCloseTitle']) + var dialog = $("#confirmDialog"); + var url = datas['confirmCloseUrl']; + dialog.load(url); + dialog.dialog('open'); + return false; +} + jQuery(document).ready(function () { function changeChoiceAddAllowed(val) {