Author: fdesbois Date: 2010-05-12 19:42:29 +0200 (Wed, 12 May 2010) New Revision: 2994 Url: http://chorem.org/repositories/revision/pollen/2994 Log: Some test for refresh zone inside a form, needed for list managment Removed: trunk/pollen-ui/src/main/webapp/js/jquery.test.js Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties trunk/pollen-ui/src/main/webapp/js/pollForm.js trunk/pollen-ui/src/main/webapp/poll/PollForm.tml Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-11 15:34:24 UTC (rev 2993) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-12 17:42:29 UTC (rev 2994) @@ -1,13 +1,8 @@ - package org.chorem.pollen.ui.pages.poll; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.tapestry5.Block; +import org.apache.tapestry5.ComponentResources; import org.apache.tapestry5.RenderSupport; import org.apache.tapestry5.annotations.Environmental; import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary; @@ -17,14 +12,16 @@ import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.corelib.components.Form; -import org.apache.tapestry5.corelib.components.FormFragment; +import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; import org.chorem.pollen.PollenBusinessException; import org.chorem.pollen.common.PollType; import org.chorem.pollen.common.VoteCountingType; -import org.chorem.pollen.entity.Choice; +import org.chorem.pollen.entity.Participant; +import org.chorem.pollen.entity.ParticipantList; import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.PollAccountImpl; import org.chorem.pollen.entity.PreventRule; import org.chorem.pollen.entity.PreventRuleImpl; import org.chorem.pollen.mail.PreventRuleManager; @@ -32,18 +29,24 @@ import org.chorem.pollen.ui.base.AbstractPollenPage; import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.data.AddressBar; -import org.chorem.pollen.ui.data.ChoiceField; import org.slf4j.Logger; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + /** * PollForm : Creation and Modification. - * + * <p/> * For modification, the poll is getting from using pollUID set in url * (activate/passivate context). - * + * <p/> * This page is mostly dynamic, so all fields in the form used zoneUpdate mixin - * to refresh the form zone if necessary (for selects or some checkbox options). - * + * to refresh the form zone if necessary (for selects or some checkbox + * options). + * <p/> * This page is composed of three parts : * <pre> * - Main informations : title, creator, begin and end dates, types, ... @@ -51,22 +54,25 @@ * - Choices of the poll (depends on type : DATE, IMAGE, TEXT). * - Lists/Groups for pollType different from FREE. * </pre> - * + * <p/> * Created: 2 mars 2010 * * @author fdesbois * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ + * <p/> + * Mise a jour: $Date$ + * par : $Author$ */ @IncludeStylesheet("context:css/poll.css") -@IncludeJavaScriptLibrary({"context:js/pollForm.js", "context:js/jquery-1.4.2.min.js", "jquery.test.js"}) +@IncludeJavaScriptLibrary({"context:js/pollForm.js", "context:js/jquery-1.4.2.min.js"}) public class PollForm extends AbstractPollenPage { @InjectComponent private Border border; + @InjectComponent + private Zone mainZone; + @Override public Border getBorder() { return border; @@ -74,7 +80,7 @@ @Inject private Logger log; - + @Inject private Messages messages; @@ -101,8 +107,8 @@ } /** - * Get the main poll used in the form. The existing poll is loaded if - * the pollUID exist. + * Get the main poll used in the form. The existing poll is loaded if the + * pollUID exist. * * @return poll existing or a new one * @throws PollenBusinessException @@ -139,7 +145,7 @@ * Page title for border component. * * @return the page title depends on create or update mode. - * @throws PollenBusinessException + * @throws PollenBusinessException */ public String getPageTitle() throws PollenBusinessException { String title = ""; @@ -155,7 +161,7 @@ * AddressBar for border component. * * @return the address bar. - * @throws PollenBusinessException + * @throws PollenBusinessException */ public AddressBar getAddressBar() throws PollenBusinessException { return AddressBar.newBar().appendCurrent(getPageTitle()); @@ -176,29 +182,31 @@ @Environmental private RenderSupport renderSupport; - @InjectComponent - private FormFragment optionsFragment; +// @InjectComponent +// private FormFragment optionsFragment; /** - * Action when rendering form. A script is added to manage form interactions + * Action when rendering form. A script is added to manage form + * interactions */ @Log void onPrepareForRender() { String formId = mainForm.getClientId(); if (log.isDebugEnabled()) { log.debug("form id : " + formId); - log.debug("options fragment id : " + optionsFragment.getClientId()); +// log.debug("options fragment id : " + optionsFragment.getClientId()); } if (formId != null) { // Script for form interactions : see "webapp/js/pollForm.js" - renderSupport.addScript("new PollForm('%s', '%s', '%s');", - formId, - VoteCountingType.NORMAL, - PollType.FREE); + renderSupport.addScript("new PollForm('%s', '%s', '%s', '%s');", + formId, + VoteCountingType.NORMAL, + PollType.FREE, + getUrl()); } } - /**************************** MAIN INFOS **********************************/ + /** ************************* MAIN INFOS ********************************* */ @InjectComponent private Form mainForm; @@ -213,87 +221,87 @@ /************************** CHOIX *****************************************/ - @Property - private ChoiceField choice; +// @Property +// private ChoiceField choice; +// +// private List<ChoiceField> choices; +// +// @Inject +// private Block choiceText; +// +// @Inject +// private Block choiceDate; +// +// @Inject +// private Block choiceImage; +// +// private boolean refresh; +// +// /** +// * Get choices from poll if it exists or initialized 4 choices with the +// * default type : TEXT. +// * +// * @return a list of ChoiceDTO +// */ +// public List<ChoiceField> getChoices() throws PollenBusinessException { +// if (choices == null) { +// choices = new ArrayList<ChoiceField>(); +// if (isCreateMode()) { +// // Initialized to choice TEXT type +// for (int i = 0; i < 4; i++) { +// choices.add(ChoiceField.getChoiceText()); +// } +// } else { +// for (Choice current : getPoll().getChoice()) { +// choices.add(new ChoiceField(getPoll(), current)); +// } +// } +// } +// return choices; +// } +// +// public Block getChoiceTypeBlock() { +// switch(poll.getChoiceType()) { +// case DATE: +// return choiceDate; +// case IMAGE: +// return choiceImage; +// default: +// return choiceText; +// } +// } +// +// void onSelectedFromRefreshOptions() { +// refresh = true; +// } +// +// // TEMP +// @Log +// Object onSuccessFromMainForm() { +// if (!refresh) { +// +// } +// return mainForm; +// } - private List<ChoiceField> choices; - - @Inject - private Block choiceText; - - @Inject - private Block choiceDate; - - @Inject - private Block choiceImage; - - private boolean refresh; - - /** - * Get choices from poll if it exists or initialized 4 choices with the - * default type : TEXT. - * - * @return a list of ChoiceDTO - */ - public List<ChoiceField> getChoices() throws PollenBusinessException { - if (choices == null) { - choices = new ArrayList<ChoiceField>(); - if (isCreateMode()) { - // Initialized to choice TEXT type - for (int i = 0; i < 4; i++) { - choices.add(ChoiceField.getChoiceText()); - } - } else { - for (Choice current : getPoll().getChoice()) { - choices.add(new ChoiceField(getPoll(), current)); - } - } - } - return choices; - } - - public Block getChoiceTypeBlock() { - switch(poll.getChoiceType()) { - case DATE: - return choiceDate; - case IMAGE: - return choiceImage; - default: - return choiceText; - } - } - - void onSelectedFromRefreshOptions() { - refresh = true; - } - - // TEMP - @Log - Object onSuccessFromMainForm() { - if (!refresh) { - - } - return mainForm; - } - /************************** OPTIONS ***************************************/ - /** Synchronization with anonymous and anonymousVoteAllowed options **/ + /** Synchronization with anonymous and anonymousVoteAllowed options * */ @Property @Persist private boolean anonymousVoteAllowedDisabled; - /** Synchronization with continuousResults and publicResults options **/ + /** Synchronization with continuousResults and publicResults options * */ @Property @Persist private boolean publicResultsDisabled; - /** ChoiceNb option **/ + /** ChoiceNb option * */ @Property @Persist private boolean hasChoiceNb; - /** Notification option **/ + /** Notification option * */ @Property @Persist private boolean hasNotification; @@ -301,7 +309,7 @@ @Persist private PreventRule notification; - /** Reminder option **/ + /** Reminder option * */ @Property @Persist private boolean hasReminder; @@ -346,7 +354,7 @@ * Condition to enable or not the notification option. * * @return true if the mail is not defined - * @throws PollenBusinessException + * @throws PollenBusinessException */ public boolean isNotificationDisabled() throws PollenBusinessException { // no email defined @@ -383,5 +391,90 @@ return getPoll().getPollType().isFree(); } - + /** *********************** LISTS **************************************** */ + + @Persist + private Map<String, ParticipantList> lists; // for GROUP + + @Property + private ParticipantList list; + + @Persist + private Map<String, Participant> participants; // for RESTRICTED + + @InjectComponent + private Zone listsZone; + + @Property + private String listName; + + @Inject + private ComponentResources resources; + + private boolean flag; + + @Inject + private Block listsForm; + + @Inject + @Property + private Block listsFields; + + public Map<String, ParticipantList> getLists() { + if (lists == null) { + lists = new HashMap<String, ParticipantList>(); + } + return lists; + } + + public Map<String, Participant> getParticipants() { + if (participants == null) { + participants = new HashMap<String, Participant>(); + } + return participants; + } + + @Log + public boolean canDisplayLists() throws PollenBusinessException { + return getPoll().getPollType().isRestrictedOrGroup(); + } + + @Log + Object onChangeFromPollType(String value) throws PollenBusinessException { + getPoll().setPollType(PollType.valueOf(value)); + flag = false; + return listsZone.getBody(); + } + + @Log + public Block getListsBlock() throws PollenBusinessException { + if (canDisplayLists()) { + if (flag) { + return listsFields; + } + return listsForm; + } + return null; + } + + @Log + void onSelectedFromAddList() { + flag = true; + addList(listName); + } + + protected void addList(String name) { + if (!getLists().containsKey(name)) { + ParticipantList list = new PollAccountImpl(); + list.setName(name); + getLists().put(name, list); + } + } + + @Log + Object onSuccess() throws PollenBusinessException { + return mainZone; + } + + } Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-05-11 15:34:24 UTC (rev 2993) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-05-12 17:42:29 UTC (rev 2994) @@ -80,31 +80,7 @@ <input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.list.update.addParticipant}"/> </div> </fieldset> - <!--<table class="t-data-grid"> - <tr> - <td class="votingId"> - <input t:type="textfield" t:id="name" t:value="newParticipant.name" t:validate="required" size="10"/> - </td> - <td class="email"> - <input t:type="textfield" t:id="email" t:value="newParticipant.email" t:validate="regexp" size="15"/> - </td> - <td class="weight"> - <input t:type="textfield" t:id="weight" t:value="newParticipant.weight" size="5"/> - </td> - <td class="functions"> - <input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.list.update.addParticipant}"/> - </td> - </tr> - </table>--> </form> - - <!-- Delete the favoriteListSelected --> - <!-- <p> - <a t:type="actionlink" t:id="deleteList"> - <img src="${asset:context:img/delete.png}" alt="Delete"/>${message:deleteList} - </a> - </p>--> - </div> <p:else> Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties 2010-05-11 15:34:24 UTC (rev 2993) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties 2010-05-12 17:42:29 UTC (rev 2994) @@ -1,4 +1,4 @@ -pageTitle-create=Cr\u00E9ation d'un nouveau sondage +pageTitle-create=Cr\u00e9ation d'un nouveau sondage mainTitle-create=Nouveau sondage pageTitle-update=Modification du sondage %s @@ -15,18 +15,18 @@ title-label=Titre * title-required-message=Vous devez fournir un titre pour le sondage. description-label=Description -beginDate-label=D\u00E9but +beginDate-label=D\u00e9but beginDate-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})? -beginDate-regexp-message=La date de d\u00E9but doit-\u00EAtre au format 31/12/2000 23:59. -beginDate-validate=La date de d\u00E9but doit-\u00EAtre post\u00E9rieure \u00E0 la date actuelle. +beginDate-regexp-message=La date de d\u00e9but doit-\u00eatre au format 31/12/2000 23:59. +beginDate-validate=La date de d\u00e9but doit-\u00eatre post\u00e9rieure \u00e0 la date actuelle. endDate-label=Fin endDate-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})? -endDate-regexp-message=La date de fin doit-\u00EAtre au format 31/12/2000 23:59. -endDate-validate=La date de fin doit-\u00EAtre post\u00E9rieure \u00E0 la date de d\u00E9but. +endDate-regexp-message=La date de fin doit-\u00eatre au format 31/12/2000 23:59. +endDate-validate=La date de fin doit-\u00eatre post\u00e9rieure \u00e0 la date de d\u00e9but. pollType-label=Restriction des votants -pollType-help=<strong>Aucune</strong> : accessible \u00E0 tout le monde<br/><strong>Liste simple</strong> : accessible uniquement \u00E0 une liste de votants<br/><strong>Par groupes</strong> : accessible \u00E0 plusieurs listes de votants -VoteCountingType-label=D\u00E9pouillement -VoteCountingType-help=<strong>Normal</strong> : s\u00E9lection de 1 ou n choix parmis les choix possibles<br/><strong>Pourcentage</strong> : attribution d\'un pourcentage \u00E0 chaque choix<br/><strong>Condorcet</strong> : classement des choix par ordre de pr\u00E9f\u00E9rence<br/><strong>Nombre</strong> : R\u00E9ponse libre. Fait la somme et la moyenne des nombres. +pollType-help=<strong>Aucune</strong> : accessible \u00e0 tout le monde<br/><strong>Liste simple</strong> : accessible uniquement \u00e0 une liste de votants<br/><strong>Par groupes</strong> : accessible \u00e0 plusieurs listes de votants +VoteCountingType-label=D\u00e9pouillement +VoteCountingType-help=<strong>Normal</strong> : s\u00e9lection de 1 ou n choix parmis les choix possibles<br/><strong>Pourcentage</strong> : attribution d\'un pourcentage \u00e0 chaque choix<br/><strong>Condorcet</strong> : classement des choix par ordre de pr\u00e9f\u00e9rence<br/><strong>Nombre</strong> : R\u00e9ponse libre. Fait la somme et la moyenne des nombres. # Labels for enums PollType.FREE=Aucune @@ -41,52 +41,53 @@ ChoiceType.IMAGE=Image # Options -advancedOptions-label=Options avanc\u00E9es +legend-options=Options +advancedOptions-label=Options avanc\u00e9es anonymous-label=Sondage anonyme anonymous-help=Les votants ainsi que leurs votes sont anonymes anonymousVoteAllowed-label=Autoriser le vote anonyme -anonymousVoteAllowed-help=Les votants peuvent \u00EAtre anonymes -continuousResults-label=R\u00E9sultats continus -continuousResults-help=Les r\u00E9sultats du sondage sont affich\u00E9s en continu au moment du vote -publicResults-label=R\u00E9sultats publics -publicResults-help=Les r\u00E9sultats du sondage sont consultables par tout le monde +anonymousVoteAllowed-help=Les votants peuvent \u00eatre anonymes +continuousResults-label=R\u00e9sultats continus +continuousResults-help=Les r\u00e9sultats du sondage sont affich\u00e9s en continu au moment du vote +publicResults-label=R\u00e9sultats publics +publicResults-help=Les r\u00e9sultats du sondage sont consultables par tout le monde choiceAddAllowed-label=Autoriser l'ajout de choix choiceAddAllowed-help=Il est possible d\'ajouter des choix au sondage. -beginChoiceDate-label=Date de d\u00E9but +beginChoiceDate-label=Date de d\u00e9but beginChoiceDate-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})? -beginChoiceDate-regexp-message=La date de d\u00E9but doit-\u00EAtre au format 31/12/2000 23:59. -beginChoiceDate-validate=La date d'ajout de choix doit-\u00EAtre ant\u00E9rieure \u00E0 la date de d\u00E9but du sondage. +beginChoiceDate-regexp-message=La date de d\u00e9but doit-\u00eatre au format 31/12/2000 23:59. +beginChoiceDate-validate=La date d'ajout de choix doit-\u00eatre ant\u00e9rieure \u00e0 la date de d\u00e9but du sondage. endChoiceDate-label=Date de fin endChoiceDate-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})? -endChoiceDate-regexp-message=La date de fin doit-\u00EAtre au format 31/12/2000 23:59. -endChoiceDate-validate=La date de fin d'ajout de choix doit-\u00EAtre post\u00E9rieure \u00E0 la date de d\u00E9but. +endChoiceDate-regexp-message=La date de fin doit-\u00eatre au format 31/12/2000 23:59. +endChoiceDate-validate=La date de fin d'ajout de choix doit-\u00eatre post\u00e9rieure \u00e0 la date de d\u00e9but. choiceNb-label=Limiter le nombre de choix par vote -choiceNb-help=Le nombre de choix que l\'utilisateur peut s\u00E9lectionner est limit\u00E9. Option disponible uniquement pour un d\u00E9pouillement simple. +choiceNb-help=Le nombre de choix que l\'utilisateur peut s\u00e9lectionner est limit\u00e9. Option disponible uniquement pour un d\u00e9pouillement simple. maxChoiceNb-label=Limite -maxChoiceNb-min-message=La valeur doit-\u00EAtre sup\u00E9rieure \u00E0 0. +maxChoiceNb-min-message=La valeur doit-\u00eatre sup\u00e9rieure \u00e0 0. sendNotification-label=Recevoir des emails de notification -sendNotification-help=Un email vous est envoy\u00E9 tous les N votes pour vous permettre de suivre l'avanc\u00E9e du sondage. Vous devez pr\u00E9ciser votre email pour acc\u00E9der \u00E0 cette option. +sendNotification-help=Un email vous est envoy\u00e9 tous les N votes pour vous permettre de suivre l'avanc\u00e9e du sondage. Vous devez pr\u00e9ciser votre email pour acc\u00e9der \u00e0 cette option. notification-label=Tous les notification-label2=votes -notification-min-message=La valeur doit-\u00EAtre sup\u00E9rieure \u00E0 0. +notification-min-message=La valeur doit-\u00eatre sup\u00e9rieure \u00e0 0. sendReminder-label=Envoyer des emails de rappel -sendReminder-help=Un email de rappel est envoy\u00E9 aux votants qui n\'ont pas encore vot\u00E9 N heures avant la fin du sondage. Option disponible uniquement pour un sondage restreint ou par groupes. +sendReminder-help=Un email de rappel est envoy\u00e9 aux votants qui n\'ont pas encore vot\u00e9 N heures avant la fin du sondage. Option disponible uniquement pour un sondage restreint ou par groupes. reminder-label=heures avant la fin -reminder-min-message=La valeur doit-\u00EAtre sup\u00E9rieure \u00E0 0. +reminder-min-message=La valeur doit-\u00eatre sup\u00e9rieure \u00e0 0. #choices choiceType-label=Choix de type choiceTextField-label=Choix choiceImageField-label=Image choiceImageField-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$ -choiceImageField-regexp-message=L'image doit-\u00EAtre au format JPG, GIF ou PNG. +choiceImageField-regexp-message=L'image doit-\u00eatre au format JPG, GIF ou PNG. choiceDateField-label=Date et heure choiceDateField-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})? -choiceDateField-regexp-message=La date doit-\u00EAtre au format 31/12/2000 23:59. +choiceDateField-regexp-message=La date doit-\u00eatre au format 31/12/2000 23:59. choiceDescription-label=Description -refreshChoices-button=Rafra\u00EEchir les champs en fonction du type s\u00E9lectionn\u00E9 +refreshChoices-button=Rafra\u00eechir les champs en fonction du type s\u00e9lectionn\u00e9 addChoice=Ajouter un choix noChoice-validate=Vous devez saisir au moins un choix. -choice-validate=Les choix doivent \u00EAtre uniques. -uploadError=Une erreur s'est produite lors du transfert des fichiers. La taille maximale autoris\u00E9e est de %s par fichier et %s au total. \ No newline at end of file +choice-validate=Les choix doivent \u00eatre uniques. +uploadError=Une erreur s'est produite lors du transfert des fichiers. La taille maximale autoris\u00e9e est de %s par fichier et %s au total. \ No newline at end of file Deleted: trunk/pollen-ui/src/main/webapp/js/jquery.test.js =================================================================== --- trunk/pollen-ui/src/main/webapp/js/jquery.test.js 2010-05-11 15:34:24 UTC (rev 2993) +++ trunk/pollen-ui/src/main/webapp/js/jquery.test.js 2010-05-12 17:42:29 UTC (rev 2994) @@ -1,12 +0,0 @@ -$J('#clicker').click(function() { - alert('clicked !'); -}); - -alert('after'); - -$J('#p-pollForm-mainInfos a.toggleAction').click(function() { - alert('click'); - $('#p-pollForm-mainInfos div.body').slideToggle('slow', function() { - alert('cool'); - }); -}); \ No newline at end of file Modified: trunk/pollen-ui/src/main/webapp/js/pollForm.js =================================================================== --- trunk/pollen-ui/src/main/webapp/js/pollForm.js 2010-05-11 15:34:24 UTC (rev 2993) +++ trunk/pollen-ui/src/main/webapp/js/pollForm.js 2010-05-12 17:42:29 UTC (rev 2994) @@ -2,7 +2,7 @@ PollForm.prototype = { - initialize: function(formId, voteCountingNormal, pollTypeFree) { + initialize: function(formId, voteCountingNormal, pollTypeFree, contextPath) { // Tapestry.debug('Form id : ' + formId); @@ -35,6 +35,41 @@ this.reminder = this.form.sendReminder; this.reminderFragmentId = 'reminderHidden'; + this.contextPath = contextPath; + +// this.contextBlockVisible = ['true', 'false']; +// this.contextBlockId = ['mainInfos', 'options']; +// +// $J('#p-pollForm-mainInfos img.p-pollForm-toggle').click(this.executeToggleBlock(0)); + + var mainInfosActionImage = '#p-pollForm-mainInfos img.form-toggle'; + var mainInfosVisible = true; + var mainInfosBlockPath = '#p-pollForm-mainInfos div.form-block'; + $J(mainInfosActionImage).click(function() { + $J(mainInfosBlockPath).slideToggle('slow', function() { + mainInfosVisible = !mainInfosVisible; + if (mainInfosVisible) { + $J(mainInfosActionImage).attr('src', contextPath + '/img/1uparrow.png'); + } else { + $J(mainInfosActionImage).attr('src', contextPath + '/img/1downarrow.png'); + } + }); + }); + + var optionsActionImage = '#p-pollForm-options img.form-toggle'; + var optionsVisible = false; + var optionsBlockPath = '#p-pollForm-options div.form-block'; + $J(optionsActionImage).click(function() { + $J(optionsBlockPath).slideToggle('slow', function() { + optionsVisible = !optionsVisible; + if (optionsVisible) { + $J(optionsActionImage).attr('src', contextPath + '/img/1uparrow.png'); + } else { + $J(optionsActionImage).attr('src', contextPath + '/img/1downarrow.png'); + } + }); + }); + this.voteCounting.observe('change', this.updateFromVoteCounting.bindAsEventListener(this)); this.pollType.observe('change', this.updateFromPollType.bindAsEventListener(this)); this.email.observe('blur', this.updateFromEmail.bindAsEventListener(this)); @@ -42,6 +77,28 @@ this.continuousResults.observe('change', this.updateFromContinuousResults.bindAsEventListener(this)); }, +// executeToggleBlock: function(index) { +// var context = '#p-pollForm-' + this.contextBlockId[index]; +// +// alert('context toggle : ' + this.contextBlockId); +// +// $J(context + ' div.p-pollForm-block').slideToggle('slow', +// this.refreshToggleImage(index, context)); +// }, +// +// refreshToggleImage: function(index, context) { +// alert('context visible : ' + this.contextBlockVisible); +// +// var actionImage = $J(context + ' img.p-pollForm-toggle'); +// +// this.contextBlockVisible[index] = !this.contextBlockVisible[index]; +// if (this.contextBlockVisible[index]) { +// actionImage.attr('src', this.contextPath + '/img/1uparrow.png'); +// } else { +// actionImage.attr('src', this.contextPath + '/img/1downarrow.png'); +// } +// }, + /* * Action when voteCounting select change. This change affects choiceNb * checkbox : choiceNb is only available if voteCounting is 'NORMAL'. Modified: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml =================================================================== --- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-11 15:34:24 UTC (rev 2993) +++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-12 17:42:29 UTC (rev 2994) @@ -16,103 +16,53 @@ <div id="p-pollForm-mainInfos"> <fieldset> <legend> - ${message:legend-mainInfos} + <img class="form-toggle" src="${asset:context:img/1uparrow.png}" /> ${message:legend-mainInfos} </legend> - <p> - <span><label t:type="label" t:for="title"/>:</span> - <input type="text" t:type="textfield" class="title" t:id="title" value="poll.title" t:validate="required"/> - </p> - <p> - <span><label t:type="label" t:for="creatorName"/>:</span> - <input type="text" t:type="textfield" t:id="creatorName" value="poll.creator.name" t:validate="required,minlength=2"/> - <label t:type="label" t:for="email"/>: - <input type="text" t:type="textfield" class="email" t:id="email" value="poll.creator.email" t:validate="regexp"/> - </p> - <p> - <span><label t:type="label" t:for="description"/>: </span> - <textarea t:type="textarea" cols="80" rows="2" t:id="description" t:value="poll.description">${poll.description}</textarea> - </p> - <p> - <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component --> - <span><label t:type="label" t:for="beginDate"/>: </span> - <input t:type="ck/dateTimeField" t:id="beginDate" value="poll.beginDate" t:validate="regexp" - t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/> - <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component --> - <label t:type="label" t:for="endDate"/>: - <input t:type="ck/dateTimeField" t:id="endDate" value="poll.endDate" t:validate="regexp" - t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/> - <label t:type="label" t:for="voteCountingType"/>: - <select t:type="select" t:id="voteCountingType" t:value="poll.voteCountingType" t:validate="required"> - <option></option> - </select> - <span t:type="ck/Tooltip" title="${message:help}" t:value="${message:voteCounting-help}" t:effect="appear"> - <img src="${asset:context:img/help.png}" alt="${message:help}"/> - </span> - </p> - </fieldset> - </div> - <!-- CHOICES --> - <div id="p-pollForm-choices"> - <fieldset> - <legend> - <label t:type="label" t:for="choiceType" />: - <select t:type="select" t:id="choiceType" t:value="poll.choiceType" t:validate="required"> - <option></option> - </select> - <input type="image" t:type="submit" class="ico refresh" t:id="refreshChoices" value="Refresh choices" title="${message:refreshChoices-button}"/> - </legend> - <div t:type="loop" t:source="choices" t:value="choice" t:volatile="true" class="clearfix"> - <div class="fleft choiceName"> - <t:delegate t:to="choiceTypeBlock" /> - <t:block t:id="choiceText"> - <label t:type="label" t:for="choiceTextField" />: - <input type="text" class="nameField" t:type="textfield" t:id="choiceTextField" value="choice.text" /> - </t:block> - <t:block t:id="choiceDate"> - <label t:type="label" t:for="choiceDateField" />: - <input t:type="ck/dateTimeField" t:id="choiceDateField" value="choice.date" t:validate="regexp" - t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/> - </t:block> - <t:block t:id="choiceImage"> - <label t:type="label" t:for="choiceImageField" />: - <input type="file" class="nameField" t:type="upload" t:id="choiceImageField" value="choice.image" t:validate="regexp" /> - </t:block> - <t:block t:id="choiceDisplay"> - ${choice.name} - </t:block> - - <t:label t:for="choiceDescription" />: - </div> - <div class="fleft"> - <t:textarea cols="34" rows="1" t:id="choiceDescription" t:value="choice.description" /> - </div> + <div class="form-block"> + <p> + <span><label t:type="label" t:for="title"/>:</span> + <input type="text" t:type="textfield" class="title" t:id="title" value="poll.title" t:validate="required"/> + </p> + <p> + <span><label t:type="label" t:for="creatorName"/>:</span> + <input type="text" t:type="textfield" t:id="creatorName" value="poll.creator.name" t:validate="required,minlength=2"/> + <label t:type="label" t:for="email"/>: + <input type="text" t:type="textfield" class="email" t:id="email" value="poll.creator.email" t:validate="regexp"/> + </p> + <p> + <span><label t:type="label" t:for="description"/>: </span> + <textarea t:type="textarea" cols="80" rows="2" t:id="description" t:value="poll.description">${poll.description}</textarea> + </p> + <p> + <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component --> + <span><label t:type="label" t:for="beginDate"/>: </span> + <input t:type="ck/dateTimeField" t:id="beginDate" value="poll.beginDate" t:validate="regexp" + t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/> + <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component --> + <label t:type="label" t:for="endDate"/>: + <input t:type="ck/dateTimeField" t:id="endDate" value="poll.endDate" t:validate="regexp" + t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/> + <label t:type="label" t:for="voteCountingType"/>: + <select t:type="select" t:id="voteCountingType" t:value="poll.voteCountingType" t:validate="required"> + <option></option> + </select> + <span t:type="ck/Tooltip" title="${message:help}" t:value="${message:voteCounting-help}" t:effect="appear"> + <img src="${asset:context:img/help.png}" alt="${message:help}"/> + </span> + </p> </div> </fieldset> </div> - <!-- LISTS --> - <div id="p-pollForm-lists"> - <fieldset> - <legend> - <label t:type="label" t:for="pollType"/>: - <select t:type="select" t:id="pollType" t:value="poll.pollType" t:validate="required"> - <option></option> - </select> - <span t:type="ck/Tooltip" title="message:help" t:value="message:pollType-help" - t:effect="appear"> - <img src="${asset:context:img/help.png}" alt="message:help"/> - </span> - </legend> - </fieldset> - </div> <!-- OPTIONS --> <div id="p-pollForm-options"> <fieldset> <legend> - <input t:type="checkbox" t:id="advancedOptions" t:mixins="triggerfragment" t:fragment="optionsFragment"/> - <label t:type="label" t:for="advancedOptions"/> + <!--<input t:type="checkbox" t:id="advancedOptions" t:mixins="triggerfragment" t:fragment="optionsFragment"/>--> + <!--<label t:type="label" t:for="advancedOptions"/>--> + <img class="form-toggle" src="${asset:context:img/1downarrow.png}" /> ${message:legend-options} </legend> - <div class="clearfix"> - <t:formFragment t:id="optionsFragment" visible="advancedOptions"> + <div class="form-block clearfix" style="display:none;"> + <!--<t:formFragment t:id="optionsFragment" visible="advancedOptions">--> <!-- LEFT COLUMN --> <div class="left-column fleft"> <p> @@ -209,10 +159,86 @@ </t:formFragment> </p> </div> - </t:formFragment> + <!--</t:formFragment>--> </div> </fieldset> </div> + <!-- CHOICES --> + <!--<div id="p-pollForm-choices">--> + <!--<fieldset>--> + <!--<legend>--> + <!--<label t:type="label" t:for="choiceType" />: --> + <!--<select t:type="select" t:id="choiceType" t:value="poll.choiceType" t:validate="required">--> + <!--<option></option>--> + <!--</select> --> + <!--<input type="image" t:type="submit" class="ico refresh" t:id="refreshChoices" value="Refresh choices" title="${message:refreshChoices-button}"/>--> + <!--</legend>--> + <!--<div t:type="loop" t:source="choices" t:value="choice" t:volatile="true" class="clearfix">--> + <!--<div class="fleft choiceName">--> + <!--<t:delegate t:to="choiceTypeBlock" />--> + <!--<t:block t:id="choiceText">--> + <!--<label t:type="label" t:for="choiceTextField" />: --> + <!--<input type="text" class="nameField" t:type="textfield" t:id="choiceTextField" value="choice.text" />--> + <!--</t:block>--> + <!--<t:block t:id="choiceDate">--> + <!--<label t:type="label" t:for="choiceDateField" />: --> + <!--<input t:type="ck/dateTimeField" t:id="choiceDateField" value="choice.date" t:validate="regexp"--> + <!--t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/>--> + <!--</t:block>--> + <!--<t:block t:id="choiceImage">--> + <!--<label t:type="label" t:for="choiceImageField" />: --> + <!--<input type="file" class="nameField" t:type="upload" t:id="choiceImageField" value="choice.image" t:validate="regexp" />--> + <!--</t:block>--> + <!--<t:block t:id="choiceDisplay">--> + <!--${choice.name}--> + <!--</t:block>--> + <!-- --> + <!--<t:label t:for="choiceDescription" />: --> + <!--</div>--> + <!--<div class="fleft">--> + <!--<t:textarea cols="34" rows="1" t:id="choiceDescription" t:value="choice.description" />--> + <!--</div>--> + <!--</div>--> + <!--</fieldset>--> + <!--</div>--> + <!-- LISTS --> + <div id="p-pollForm-lists"> + <fieldset> + <legend> + <label t:type="label" t:for="pollType" />: + <select t:type="select" class="list-select" t:id="pollType" t:value="poll.pollType" t:validate="required" + t:mixins="nuiton/zoneUpdater" t:event="change" t:zone="p-pollForm-lists-zone"/> + <span t:type="ck/Tooltip" title="message:help" t:value="message:pollType-help" t:effect="appear"> + <img src="${asset:context:img/help.png}" alt="message:help" /> + </span> + </legend> + <div t:type="zone" id="p-pollForm-lists-zone" t:id="listsZone" class="form-block"> + <t:delegate t:to="listsBlock" /> + <t:block t:id="listsForm"> + <form t:type="form" action="tapestry"> + <t:delegate t:to="listsFields" /> + </form> + </t:block> + <t:block t:id="listsFields"> + <t:if t:test="poll.pollType.group"> + <p> + <label t:type="label" t:for="listName" />: + <input t:type="textfield" t:id="listName" value="listName"/> + <input t:type="submit" t:id="addList" value="ADD"/> + </p> + <p> + <t:loop t:source="lists.values()" t:value="list" t:volatile="true"> + ${list.name} + </t:loop> + </p> + <p:else> + COOL + </p:else> + </t:if> + </t:block> + </div> + </fieldset> + </div> </form> </t:zone> </html>