Author: tchemit Date: 2012-03-02 19:52:12 +0100 (Fri, 02 Mar 2012) New Revision: 3159 Url: http://chorem.org/repositories/revision/pollen/3159 Log: debut de la page de cr?\195?\169ation Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/pollCreation.css Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Create.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Create.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Create.java 2012-03-02 18:51:13 UTC (rev 3158) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Create.java 2012-03-02 18:52:12 UTC (rev 3159) @@ -23,8 +23,11 @@ */ package org.chorem.pollen.ui.actions.poll; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.opensymphony.xwork2.Preparable; +import org.chorem.pollen.business.persistence.Choice; +import org.chorem.pollen.business.persistence.ChoiceImpl; import org.chorem.pollen.business.persistence.Poll; import org.chorem.pollen.business.persistence.UserAccount; import org.chorem.pollen.common.ChoiceType; @@ -34,6 +37,7 @@ import org.chorem.pollen.services.impl.PollService; import org.chorem.pollen.ui.actions.PollenActionSupport; +import java.util.List; import java.util.Map; /** @@ -64,6 +68,15 @@ protected int notificationNumber; + /** Nombre de choix affichés initialement. */ + private int nbChoices = 5; + + private List<Choice> textChoices; + + private List<Choice> dateChoices; + + private List<Choice> imageChoices; + public String getPageLogo() { return "Creation"; } @@ -128,6 +141,43 @@ this.notificationNumber = notificationNumber; } + public int getNbChoices() { + return nbChoices; + } + + public List<Choice> getTextChoices() { + if (textChoices == null) { + textChoices = Lists.newLinkedList(); + } + return textChoices; + } + + public Choice getTextChoices(int index) { + return getChoices(getTextChoices(), index); + } + + public Choice getDateChoices(int index) { + return getChoices(getDateChoices(), index); + } + + public Choice getImageChoices(int index) { + return getChoices(getImageChoices(), index); + } + + public List<Choice> getDateChoices() { + if (dateChoices == null) { + dateChoices = Lists.newLinkedList(); + } + return dateChoices; + } + + public List<Choice> getImageChoices() { + if (imageChoices == null) { + imageChoices = Lists.newLinkedList(); + } + return imageChoices; + } + @Override public String execute() throws Exception { @@ -142,7 +192,7 @@ // } // back to input - return INPUT; + return SUCCESS; } @Override @@ -161,4 +211,11 @@ } return result; } + + private Choice getChoices(List<Choice> choices, int index) { + while (choices.size() < index) { + choices.add(new ChoiceImpl()); + } + return choices.get(index); + } } Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-03-02 18:51:13 UTC (rev 3158) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-03-02 18:52:12 UTC (rev 3159) @@ -6,6 +6,7 @@ poll.common.vote.results-help=Display results poll.common.vote.return=Back to poll poll.common.vote.return-help=Back to poll +pollen.action.addChoice=Add choice pollen.action.addComment=Add a comment pollen.action.backToFavoriteLists=Back to favorite lists pollen.action.create=Create @@ -43,6 +44,7 @@ pollen.common.chartType-pie=Pie pollen.common.chartType-pie3d=Pie 3D pollen.common.chartType-ring=Ring +pollen.common.choice=Choice pollen.common.commentName=Name pollen.common.commentText=Comment pollen.common.csvImport=CSV import @@ -79,7 +81,7 @@ pollen.common.pollOption.publicResults=Public results pollen.common.pollOption.reminder=Send reminder emails pollen.common.pollOption.reminderHourCountdown=Hours before end -pollen.common.pollType=Poll type +pollen.common.pollType=Who can vote ? pollen.common.postDate=Comment date pollen.common.results=Results\: pollen.common.title=Title @@ -87,7 +89,7 @@ pollen.common.victories=Winners\: pollen.common.victory=Winner\: pollen.common.voteCounting-label=Vote Counting\: -pollen.common.voteCountingType=Counting type +pollen.common.voteCountingType=Response type pollen.common.voteCountingTypeHelp.condorcet=Condorcet vote\: rank choices by preference order from 1 to N (1\=favorite). Only the rank is taken into account, not the values. Two choices can have the same value. pollen.common.voteCountingTypeHelp.normal=Normal vote\: vote for your favorite choice. pollen.common.voteCountingTypeHelp.number=Voting by number\: The answer is free, leave blank or enter a integer. Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-03-02 18:51:13 UTC (rev 3158) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-03-02 18:52:12 UTC (rev 3159) @@ -6,6 +6,7 @@ poll.common.vote.results-help=Voir les résultats poll.common.vote.return=Retour au sondage poll.common.vote.return-help=Retour au sondage +pollen.action.addChoice=Ajouter un choix pollen.action.addComment=Ajouter un commentaire pollen.action.backToFavoriteLists=Retour à la liste des favoris pollen.action.create=Créer @@ -43,6 +44,7 @@ pollen.common.chartType-pie=Camembert pollen.common.chartType-pie3d=Camembert 3D pollen.common.chartType-ring=Anneau +pollen.common.choice=Choix pollen.common.commentName=Nom pollen.common.commentText=Commentaire pollen.common.csvImport=Import CSV @@ -80,14 +82,14 @@ pollen.common.pollOption.publicResults=Résultats publics pollen.common.pollOption.reminder=Envoyer des emails de rappel pollen.common.pollOption.reminderHourCountdown=heures avant la fin du sondage -pollen.common.pollType=Type de sondage +pollen.common.pollType=Qui peut voter ? pollen.common.postDate=Date du commentaire pollen.common.results=Résultats \: pollen.common.title=Titre pollen.common.userSupport=Support utilisateur pollen.common.victories=Gagnants \: pollen.common.victory=Gagnant \: -pollen.common.voteCountingType=Type de dépouillement +pollen.common.voteCountingType=Type de Réponse pollen.common.voteCountingTypeHelp.condorcet=Vote Condorcet \: classer les choix par ordre de préférence de 1 à N (1\=préféré). Seul l'ordre des choix compte, peu importe les valeurs. Deux choix peuvent avoir la même valeur. pollen.common.voteCountingTypeHelp.normal=Vote normal \: voter pour le ou les choix préférés. pollen.common.voteCountingTypeHelp.number=Vote par nombre \: La réponse est libre, laissez vide ou entrez un nombre entier @@ -170,6 +172,8 @@ pollen.menu.preferences=Mon compte pollen.menu.register=Inscrivez-vous pollen.menu.userFavoriteLists=Listes de votants +pollen.tab.poll.general=Informations +pollen.tab.poll.options=Options pollen.title.createPoll=Nouveau sondage pollen.title.delete.pollChoice=Confirmer la suppresion d'un choix pollen.title.delete.pollComment=Confirmer la suppresion d'un commentaire Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-03-02 18:51:13 UTC (rev 3158) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-03-02 18:52:12 UTC (rev 3159) @@ -24,10 +24,12 @@ <%@ page language="java" contentType="text/html" pageEncoding="utf-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sj" uri="/struts-jquery-tags" %> +<link rel="stylesheet" type="text/css" + href="<s:url value='/css/pollCreation.css'/>"/> <script type="text/javascript"> jQuery(document).ready(function () { - $('[name="poll.choiceAddAllowed"]').change(function(event) { + $('[name="poll.choiceAddAllowed"]').change(function (event) { var val = $(this).prop('checked'); if (val) { $('#addChoiceAddAllowedPanel').show(); @@ -36,7 +38,7 @@ } }); - $('[name="limitChoice"]').change(function(event) { + $('[name="limitChoice"]').change(function (event) { var val = $(this).prop('checked'); if (val) { $('#maxChoiceNbPanel').show(); @@ -45,7 +47,7 @@ } }); - $('[name="reminder"]').change(function(event) { + $('[name="reminder"]').change(function (event) { var val = $(this).prop('checked'); if (val) { $('#reminderPanel').show(); @@ -54,7 +56,7 @@ } }); - $('[name="notification"]').change(function(event) { + $('[name="notification"]').change(function (event) { var val = $(this).prop('checked'); if (val) { $('#notificationPanel').show(); @@ -63,75 +65,214 @@ } }); - $('[name="poll.anonymous"]').change(function(event) { + $('[name="poll.anonymous"]').change(function (event) { var val = $(this).prop('checked'); $('[name="poll.anonymousVoteAllowed"]').prop('checked', val); }); - $('[name="poll.continuousResults"]').change(function(event) { + $('[name="poll.continuousResults"]').change(function (event) { var val = $(this).prop('checked'); $('[name="poll.publicResults"]').prop('checked', val); }); + + function changeChoicetype(type) { + $('.choices').addClass('hidden'); + $('#choices' + type).removeClass('hidden'); + } + + $('[name="poll.choiceType"]').change(function (event) { + changeChoicetype($(this).val()); + }); + $('[name="poll.pollType"][value="<s:property value="%{poll.pollType.ordinal()}"/>"]').prop('checked', true); + $('[name="poll.voteCountingType"][value="<s:property value="%{poll.voteCountingType.ordinal()}"/>"]').prop('checked', true); + + var choiceType = '<s:property value="%{poll.choiceType.ordinal()}"/>'; + $('[name="poll.choiceType"][value="' + choiceType + '"]').prop('checked', true); + changeChoicetype(choiceType); }); </script> <title><s:text name="pollen.title.createPoll"/></title> <h1 class="title${pageLogo}"><s:text name="pollen.title.createPoll"/></h1> -<s:form method="POST" key="registerForm" namespace="/poll"> +<s:form method="POST" id="registerForm" namespace="/poll"> - <fieldset> - <legend><s:text name="pollen.fieldset.poll.you"/></legend> - <s:textfield key="poll.creator.name" label="%{getText('pollen.common.login')}" required="true"/> - <s:textfield key="poll.creator.email" label="%{getText('pollen.common.email')}"/> - </fieldset> + <sj:tabbedpanel id="formTabs"> - <fieldset> - <legend><s:text name="pollen.fieldset.poll.general"/></legend> + <sj:tab id="tabGeneral" target="tgeneral" key="pollen.tab.poll.general"/> + <sj:tab id="tabOptions" target="toptions" key="pollen.tab.poll.options"/> - <s:textfield key="poll.title" label="%{getText('pollen.common.title')}" required="true"/> - <s:textfield key="poll.description" label="%{getText('pollen.common.description')}"/> - <sj:datepicker key="poll.beginDate" label="%{getText('pollen.common.beginDate')}" displayFormat="dd/mm/yy"/> - <sj:datepicker key="poll.endDate" label="%{getText('pollen.common.endDate')}" displayFormat="dd/mm/yy"/> - <s:radio key='poll.pollType' list="pollTypes" label='%{getText("pollen.common.pollType")}' /> - <s:radio key='poll.voteCountingType' list="voteCountingTypes" label='%{getText("pollen.common.voteCountingType")}' /> - </fieldset> + <div id="tgeneral"> - <fieldset> - <legend><s:text name="pollen.fieldset.poll.options"/></legend> + <fieldset> + <%--<legend><s:text name="pollen.common.voteCountingType"/></legend>--%> - <s:checkbox key="poll.anonymous" label="%{getText('pollen.common.pollOption.anonymous')}" /> - <s:checkbox key="poll.anonymousVoteAllowed" label="%{getText('pollen.common.pollOption.anonymousVoteAllowed')}" /> - <s:checkbox key="poll.continuousResults" label="%{getText('pollen.common.pollOption.continuousResults')}" /> - <s:checkbox key="poll.publicResults" label="%{getText('pollen.common.pollOption.publicResults')}" /> - <s:checkbox key="poll.choiceAddAllowed" label="%{getText('pollen.common.pollOption.choiceAddAllowed')}" /> - <div id='addChoiceAddAllowedPanel' class="hidden"> - <sj:datepicker key="poll.beginChoiceDate" label="%{getText('pollen.common.beginChoiceDate')}" displayFormat="dd/mm/yy"/> - <sj:datepicker key="poll.endChoiceDate" label="%{getText('pollen.common.endChoiceDate')}" displayFormat="dd/mm/yy"/> + <s:textfield key="poll.title" label="%{getText('pollen.common.title')}" + required="true" size="80"/> + <s:textarea key="poll.description" rows="3" cols="54" + label="%{getText('pollen.common.description')}"/> + </fieldset> + + <br/> + + <fieldset> + <legend><s:text name="pollen.common.voteCountingType"/></legend> + <s:radio key='poll.voteCountingType' list="voteCountingTypes" + label='' theme="simple"/> + + </fieldset> + <br/> + + <fieldset> + <legend><s:text name="pollen.fieldset.poll.choices"/></legend> + <s:radio key='poll.choiceType' list="choiceTypes" + label='' theme="simple"/> + <hr/> + + <div id="choices0" class="choices"> + <s:iterator begin="0" end="nbChoices" status="status"> + <s:set name="tprefix">textChoices[<s:property + value="#status.index"/>].</s:set> + <div class="fleft choiceName"> + <s:label for="%{#tprefix}name" key="pollen.common.choice" + theme="simple"/> + <s:textfield cssClass="nameField" id='%{#tprefix}name' + key="%{#tprefix}name" label='' theme="simple"/> + - + <s:label for="%{#tprefix}description" + key="pollen.common.description" theme="simple"/> + </div> + <div class="fleft"> + <s:textarea cols="30" id="%{#tprefix}description" + key="%{#tprefix}description" label='' theme="simple"/> + </div> + <div class="cleanBoth"></div> + </s:iterator> + </div> + + <div id="choices1" class="choices"> + <s:iterator begin="0" end="nbChoices" status="status"> + <s:set name="dprefix">dateChoices.<s:property + value="#status.index"/>.</s:set> + <div class="fleft choiceName"> + <s:label for="%{#dprefix}name" key="pollen.common.choice" + theme="simple"/> + <sj:datepicker id='%{#dprefix}name' key="%{#dprefix}name" + changeMonth="true" changeYear="true" + labelSeparator="" theme="simple" label="" + timepicker="true"/> + - + <s:label for="%{#dprefix}description" + key="pollen.common.description" theme="simple"/> + </div> + <div class="fleft"> + <s:textarea cols="30" id="%{#dprefix}description" + key="%{#dprefix}description" label='' theme="simple"/> + </div> + <div class="cleanBoth"></div> + </s:iterator> + </div> + <div id="choices2" class="choices"> + <s:iterator begin="0" end="nbChoices" status="status"> + <s:set name="iprefix">imageChoices[<s:property + value="#status.index"/>].</s:set> + <div class="fleft choiceName"> + <s:label for="%{#iprefix}name" key="pollen.common.choice" + theme="simple"/> + <s:file id='%{#iprefix}name' key="%{#iprefix}name" + label='' theme="simple" cssClass="nameField"/> + - + <s:label for="%{#iprefix}description" + key="pollen.common.description" theme="simple"/> + </div> + <div class="fleft"> + <s:textarea cols="30" id="%{#iprefix}description" + key="%{#iprefix}description" label='' theme="simple"/> + </div> + <div class="cleanBoth"></div> + </s:iterator> + </div> + <hr/> + <s:submit key="pollen.action.addChoice" align="center"/> + + </fieldset> + </div> - <s:checkbox key="limitChoice" label="%{getText('pollen.common.pollOption.limitChoice')}" /> - <div id='maxChoiceNbPanel' class="hidden"> - <s:textfield key="poll.maxChoiceNb" label="%{getText('pollen.common.pollOption.maxChoiceNb')}"/> - </div> - <s:checkbox key="notification" label="%{getText('pollen.common.pollOption.notification')}" /> - <div id='notificationPanel' class="hidden"> - <s:textfield key="notificationNumber" - label="%{getText('pollen.common.pollOption.notificationNumber')}" /> + + <div id="toptions"> + + <fieldset> + <legend><s:text name="pollen.fieldset.poll.you"/></legend> + <s:textfield key="poll.creator.name" + label="%{getText('pollen.common.login')}"/> + <s:textfield key="poll.creator.email" + label="%{getText('pollen.common.email')}"/> + </fieldset> + + <br/> + + <fieldset> + <legend><s:text name="pollen.fieldset.poll.options"/></legend> + + <s:checkbox key="poll.anonymous" + label="%{getText('pollen.common.pollOption.anonymous')}"/> + <s:checkbox key="poll.anonymousVoteAllowed" + label="%{getText('pollen.common.pollOption.anonymousVoteAllowed')}"/> + <s:checkbox key="poll.continuousResults" + label="%{getText('pollen.common.pollOption.continuousResults')}"/> + <s:checkbox key="poll.publicResults" + label="%{getText('pollen.common.pollOption.publicResults')}"/> + <s:checkbox key="poll.choiceAddAllowed" + label="%{getText('pollen.common.pollOption.choiceAddAllowed')}"/> + <div id='addChoiceAddAllowedPanel' class="hidden"> + <sj:datepicker key="poll.beginChoiceDate" + label="%{getText('pollen.common.beginChoiceDate')}" + displayFormat="dd/mm/yy"/> + <sj:datepicker key="poll.endChoiceDate" + label="%{getText('pollen.common.endChoiceDate')}" + displayFormat="dd/mm/yy"/> + </div> + <s:checkbox key="limitChoice" + label="%{getText('pollen.common.pollOption.limitChoice')}"/> + <div id='maxChoiceNbPanel' class="hidden"> + <s:textfield key="poll.maxChoiceNb" + label="%{getText('pollen.common.pollOption.maxChoiceNb')}"/> + </div> + <s:checkbox key="notification" + label="%{getText('pollen.common.pollOption.notification')}"/> + <div id='notificationPanel' class="hidden"> + <s:textfield key="notificationNumber" + label="%{getText('pollen.common.pollOption.notificationNumber')}"/> + </div> + <s:checkbox key="reminder" + label="%{getText('pollen.common.pollOption.reminder')}"/> + <div id='reminderPanel' class="hidden"> + <s:textfield key="reminderHourCountdown" + label="%{getText('pollen.common.pollOption.reminderHourCountdown')}"/> + </div> + + </fieldset> + + <br/> + + <fieldset> + <legend><s:text name="pollen.fieldset.poll.general"/></legend> + + <sj:datepicker key="poll.beginDate" + label="%{getText('pollen.common.beginDate')}" + displayFormat="dd/mm/yy"/> + <sj:datepicker key="poll.endDate" + label="%{getText('pollen.common.endDate')}" + displayFormat="dd/mm/yy"/> + <s:radio key='poll.pollType' list="pollTypes" + label='%{getText("pollen.common.pollType")}'/> + + </fieldset> + </div> - <s:checkbox key="reminder" label="%{getText('pollen.common.pollOption.reminder')}" /> - <div id='reminderPanel' class="hidden"> - <s:textfield key="reminderHourCountdown" - label="%{getText('pollen.common.pollOption.reminderHourCountdown')}" /> - </div> - </fieldset> + </sj:tabbedpanel> - <fieldset> - <legend><s:text name="pollen.fieldset.poll.choices"/></legend> - <s:select key="poll.choiceType" label='%{getText("poll.common.select.choiceType")}' - list="choiceTypes" headerKey="" headerValue=""/> - </fieldset> - <br/> <s:submit action="create" key="pollen.action.createPoll" align="center"/> </s:form> Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/pollCreation.css (from rev 3153, branches/pollen-1.2.6-struts2/pollen-ui/src/main/webapp/css/pollCreation.css) =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/pollCreation.css (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/css/pollCreation.css 2012-03-02 18:52:12 UTC (rev 3159) @@ -0,0 +1,122 @@ +#pollCreationZone { + width: 550px; + margin: auto; + -moz-border-radius: 15px; +} + +legend { + color: #727a7e; + font-weight: bold; +} + +#pollCreationFormDiv fieldset { + border: 1px solid #aab; + padding: 15px; + width: 380px; + margin: auto; + vertical-align: top; + text-align: left; +} + +#optionsCreationFormDiv fieldset { + border: 1px solid #aab; + padding: 15px; + width: 300px; + margin: auto; + vertical-align: top; + text-align: left; +} + +#listsCreationFormDiv fieldset { + border: 1px solid #aab; + padding: 15px; + width: 550px; + margin: auto; + vertical-align: top; + text-align: left; +} + +#choicesCreationFormDiv div { + margin-bottom: 5px; +} + +#choicesCreationFormDiv fieldset { + border: 1px solid #aab; + padding: 15px; + width: 670px; + margin: auto; + vertical-align: top; + text-align: left; +} + +#choicesCreationFormDiv div.choiceName { + padding-top: 12px; +} + +#choicesCreationFormDiv div.choiceName input.nameField { + width: 280px; +} + +#pollCreationFormDiv label { + display: block; + width: 150px; + float: left; +} + +#listsCreationFormDiv .groupDiv { + padding: 10px; +} + +#listsCreationFormDiv .currentGroupDiv { + background-color: #d0d0ff; + padding: 5px; + -moz-border-radius: 3px; +} + +#listsCreationFormDiv .groupTitleDiv { + background-color: #32b5c9; + padding: 3px; + -moz-border-radius: 3px; +} + +#listsCreationFormDiv .cmd { + float: right; +} + +#listsCreationFormDiv .editGroupSubmit { + border: none; + font-size: 0px; + background: transparent url('../img/editSmall.png') no-repeat top left; + width: 15px; + height: 16px; +} + +#listsCreationFormDiv .deleteGroupSubmit { + border: none; + font-size: 0px; + background: transparent url('../img/delete.png') no-repeat top left; + width: 16px; + height: 16px; +} + +#pollCreationFormDiv div, +#optionsCreationFormDiv div, +#listsCreationFormDiv div { + margin-bottom: 10px; +} + +#choiceDateDiv, +#choiceNbDiv, +#notificationDiv, +#reminderDiv { + color: #555; +} + +.buttons { + text-align: center; + margin-top: 20px; +} + +.buttons input { + margin-left: 10px; +} \ No newline at end of file