Author: fdesbois Date: 2010-03-15 11:42:07 +0100 (Mon, 15 Mar 2010) New Revision: 2939 Log: Continue evol #122 : poll form (miss list managment for poll creation + fusion creation/modification) Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java trunk/pollen-ui/src/main/webapp/img/refresh-22px.png Modified: trunk/doc/presentation-2010-03-11/ trunk/doc/presentation-2010-03-11/Presentation-Pollen.odp trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/ImageUtil.java trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties trunk/pollen-ui/src/main/webapp/css/main.css trunk/pollen-ui/src/main/webapp/css/poll.css trunk/pollen-ui/src/main/webapp/js/pollForm.js trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml trunk/pollen-ui/src/main/webapp/poll/PollForm.tml trunk/pom.xml Property changes on: trunk/doc/presentation-2010-03-11 ___________________________________________________________________ Added: svn:ignore + .~lock.Presentation-Pollen.odp# Modified: trunk/doc/presentation-2010-03-11/Presentation-Pollen.odp =================================================================== (Binary files differ) Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-03-15 10:42:07 UTC (rev 2939) @@ -101,8 +101,8 @@ pollDAO = PollenModelDAOHelper.getPollDAO(transaction); - // Create with a new pollId generated for links - String pollId = PollenContext.createPollenUrlId(); + // Create with the pollId from dto + String pollId = pollDTO.getPollId(); Poll entity = pollDAO.create(pollId); PollenConverter.convert(pollDTO, entity); @@ -291,6 +291,7 @@ PollDTO newPoll = new PollDTO(); newPoll.setVoteCounting(VoteCountingType.NORMAL); newPoll.setPollType(PollType.FREE); + newPoll.setPollId(PollenContext.createPollenUrlId()); return newPoll; } Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java =================================================================== --- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-03-15 10:42:07 UTC (rev 2939) @@ -89,7 +89,7 @@ TestManager.start("testCreatePoll"); instance = new ServicePollImpl(); - PollDTO dto = new PollDTO(); + PollDTO dto = instance.getNewPoll(); dto.setBeginChoiceDate(new Date()); dto.setBeginDate(new Date()); dto.setChoiceType(ChoiceType.TEXT); @@ -151,7 +151,7 @@ instance = new ServicePollImpl(); String pollId = ""; - PollDTO dto = new PollDTO(); + PollDTO dto = instance.getNewPoll(); dto.setDescription("Test_updatePoll"); dto.setTitle("Test_updatePoll"); dto.setCreatorId("erwan"); @@ -174,7 +174,7 @@ TestManager.start("testDeletePoll"); instance = new ServicePollImpl(); - PollDTO dto = new PollDTO(); + PollDTO dto = instance.getNewPoll(); dto.setDescription("Test_deletePoll"); dto.setCreatorId("erwan"); dto.setAnonymous(false); @@ -195,7 +195,7 @@ instance = new ServicePollImpl(); String pollId = ""; - PollDTO dto = new PollDTO(); + PollDTO dto = instance.getNewPoll(); dto.setDescription("Test_findPollByPollId"); dto.setTitle("Test_findPollByPollId"); dto.setAnonymous(false); @@ -219,7 +219,7 @@ TestManager.start("testFindPollsByName"); instance = new ServicePollImpl(); - PollDTO dto = new PollDTO(); + PollDTO dto = instance.getNewPoll(); dto.setDescription("Test_findPollsByName"); dto.setCreatorId("erwan"); dto.setAnonymous(false); @@ -248,7 +248,7 @@ String userId = su.createUser(user, "password"); // création du sondage - PollDTO poll = new PollDTO(); + PollDTO poll = instance.getNewPoll(); poll.setTitle("Test_findPollsByUser"); poll.setUserId(userId); poll.setPollType(PollType.FREE); @@ -283,7 +283,7 @@ String accountId = spa.createPollAccount(account); // création du sondage - PollDTO poll = new PollDTO(); + PollDTO poll = instance.getNewPoll(); poll.setTitle("Test_findParticipatedPolls"); poll.setPollType(PollType.FREE); poll.setChoiceType(ChoiceType.TEXT); @@ -311,7 +311,7 @@ Date now = PollenContext.getCurrentDate(); // sondage en cours sans date de fin - PollDTO poll1 = new PollDTO(); + PollDTO poll1 = instance.getNewPoll(); poll1.setTitle("Test_findRunningPolls1"); poll1.setPollType(PollType.FREE); poll1.setChoiceType(ChoiceType.TEXT); @@ -319,7 +319,7 @@ instance.createPoll(poll1); // sondage en cours - PollDTO poll2 = new PollDTO(); + PollDTO poll2 = instance.getNewPoll(); poll2.setTitle("Test_findRunningPolls2"); poll2.setEndDate(new Date(now.getTime() + 100000)); poll2.setPollType(PollType.FREE); @@ -328,7 +328,7 @@ instance.createPoll(poll2); // sondage terminé - PollDTO poll3 = new PollDTO(); + PollDTO poll3 = instance.getNewPoll(); poll3.setTitle("Test_findRunningPolls3"); poll3.setEndDate(new Date(now.getTime() - 100000)); poll3.setPollType(PollType.FREE); @@ -337,7 +337,7 @@ instance.createPoll(poll3); // sondage pas commencé - PollDTO poll4 = new PollDTO(); + PollDTO poll4 = instance.getNewPoll(); poll4.setTitle("Test_findRunningPolls4"); poll4.setBeginDate(new Date(now.getTime() + 100000)); poll4.setPollType(PollType.FREE); @@ -359,7 +359,7 @@ TestManager.start("testSelectPolls"); instance = new ServicePollImpl(); - PollDTO dto = new PollDTO(); + PollDTO dto = instance.getNewPoll(); dto.setDescription("test selectPolls"); dto.setTitle("selectPolls"); dto.setAnonymous(false); @@ -396,7 +396,7 @@ instance = new ServicePollImpl(); /** PREPARE DATA **/ - PollDTO poll = new PollDTO(); + PollDTO poll = instance.getNewPoll(); poll.setTitle("createComment"); poll.setPollType(PollType.FREE); poll.setChoiceType(ChoiceType.TEXT); @@ -441,7 +441,7 @@ instance = new ServicePollImpl(); /** PREPARE DATA **/ - PollDTO poll = new PollDTO(); + PollDTO poll = instance.getNewPoll(); poll.setTitle("deleteComment"); poll.setPollType(PollType.FREE); poll.setChoiceType(ChoiceType.TEXT); Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-03-15 10:42:07 UTC (rev 2939) @@ -89,6 +89,10 @@ @Property private String pageLogo; + @Parameter(defaultPrefix = BindingConstants.LITERAL, value = "body") + @Property + private String pageBodyId; + /** Title of the page **/ @Parameter(defaultPrefix = BindingConstants.LITERAL) @Property Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-03-15 10:42:07 UTC (rev 2939) @@ -0,0 +1,201 @@ + +package org.chorem.pollen.ui.data; + +import java.io.File; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.tapestry5.upload.services.UploadedFile; +import org.chorem.pollen.business.PollenProperty; +import org.chorem.pollen.business.dto.ChoiceDTO; +import org.chorem.pollen.common.ChoiceType; +import org.chorem.pollen.ui.utils.ImageUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class extends ChoiceDTO to have the same properties. It had the + * behavior to be an image or a date depends on the choice type. + * You have to set the type when needed (changing) or using static methods : + * <pre> + * - {@link #getChoiceDate(java.lang.String)} : need the date pattern to format + * - {@link #getChoiceImage(java.lang.String)} : need the pollId to save the + * image + * - {@link #getChoiceText()} + * </pre> + * + * Before saving choices using servicePoll, you have to save the name using + * {@link #saveName()} method : the name to save depends on the choice type. + * + * Created: 6 mars 2010 + * + * @author fdesbois + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ +public class ChoiceField extends ChoiceDTO { + + private static final Logger log = LoggerFactory.getLogger(ChoiceField.class); + + protected ChoiceType type; + + protected DateFormat dateFormat; + + protected Date date; + + protected UploadedFile image; + + protected String imageDir; + + protected String text; + + /** + * Instantiate a new choiceField for a Date ChoiceType. + * + * @param pattern date pattern to format the date when name will be saved + * @return the ChoiceField which is date typed + * @see #setDateType(java.lang.String) + */ + public static ChoiceField getChoiceDate(String pattern) { + ChoiceField result = new ChoiceField(); + result.setDateType(pattern); + return result; + } + + /** + * Instantiate a new choiceField for an Image ChoiceType. + * + * @param pollUId used to save the image (corresponding to the folder where + * the image will be saved). + * @return the ChoiceField which is image typed + * @see #setImageType(java.lang.String) + */ + public static ChoiceField getChoiceImage(String pollUId) { + ChoiceField result = new ChoiceField(); + result.setImageType(pollUId); + return result; + } + + /** + * Instantiate a new choiceField for a Text ChoiceType. + * + * @return the ChoiceField which is text typed + * @see #setTextType() + */ + public static ChoiceField getChoiceText() { + ChoiceField result = new ChoiceField(); + result.setTextType(); + return result; + } + + /** + * Change type of the choice to date type. The date type need a + * {@code pattern} to format the date when saving the choice. + * + * @param pattern + * @see #saveName() + */ + public void setDateType(String pattern) { + this.type = ChoiceType.DATE; + dateFormat = new SimpleDateFormat(pattern); + image = null; + } + + /** + * Change type of the choice to image type. The image type need the pollId + * of the choice as saving folder for the resulting image file. + * + * @param pollUId used as saving folder + * @see #saveName() + */ + public void setImageType(String pollUId) { + this.type = ChoiceType.IMAGE; + imageDir = pollUId; + date = null; + } + + /** + * Change type of the choice to text type. + */ + public void setTextType() { + this.type = ChoiceType.TEXT; + date = null; + image = null; + } + + public void setDate(Date date) { + this.date = date; + } + + public Date getDate() { + return date; + } + + public void setImage(UploadedFile image) throws FileUploadException { + if (image != null) { + this.image = image; + if (!image.getContentType().equals("image") || + !image.getContentType().equals("IMAGE")) { + throw new FileUploadException("wrong type for image upload"); + } + } + } + + public UploadedFile getImage() throws ParseException { + return image; + } + + public void setText(String text) { + this.text = text; + } + + public String getText() { + return text; + } + + /** + * Save name of the choice depends on ChoiceType : + * <pre> + * - DATE : the date will be formated ; + * - IMAGE : the image file will be saved and the choice name will + * correspond to the image file name ; + * - TEXT : the text becomes the choice name. + * </pre> + */ + public void saveName() { + String name = ""; + switch (type) { + case DATE: + name = dateFormat.format(getDate()); + break; + case IMAGE: + // Get directory to save the image using the context from + // pollen properties. + File dir = new File(PollenProperty.IMG_DIR.getValue(), imageDir); + if (!dir.exists()) { + dir.mkdirs(); + } + // Save the image file + File file = new File(dir, image.getFileName()); + image.write(file); + if (log.isDebugEnabled()) { + log.debug("Image saved: " + image.getFileName() + + " (size=" + image.getSize() + ")"); + } + // Create image thumbnail + ImageUtil.createThumbnail(dir, file, 100); + if (log.isDebugEnabled()) { + log.debug("save name for image : " + file.getName()); + } + name = file.getName(); + break; + case TEXT: + name = getText(); + } + setName(name); + } +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" 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-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-03-15 10:42:07 UTC (rev 2939) @@ -3,8 +3,11 @@ 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.RenderSupport; import org.apache.tapestry5.annotations.Environmental; import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary; @@ -15,9 +18,11 @@ import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.corelib.components.Form; +import org.apache.tapestry5.corelib.components.FormFragment; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; import org.chorem.pollen.business.business.PreventRuleManager; +import org.chorem.pollen.business.dto.ChoiceDTO; import org.chorem.pollen.business.dto.PollDTO; import org.chorem.pollen.business.dto.PreventRuleDTO; import org.chorem.pollen.business.dto.UserDTO; @@ -25,6 +30,7 @@ import org.chorem.pollen.common.PollType; import org.chorem.pollen.common.VoteCountingType; import org.chorem.pollen.ui.data.AddressBar; +import org.chorem.pollen.ui.data.ChoiceField; import org.slf4j.Logger; /** @@ -169,6 +175,9 @@ @Environmental private RenderSupport renderSupport; + @InjectComponent + private FormFragment optionsFragment; + /** * Action when rendering form. A script is added to manage form interactions */ @@ -177,6 +186,7 @@ String formId = mainForm.getClientId(); if (log.isDebugEnabled()) { log.debug("form id : " + formId); + log.debug("options fragment id : " + optionsFragment.getClientId()); } if (formId != null) { // Script for form interactions : see "webapp/js/pollForm.js" @@ -200,6 +210,71 @@ advancedOptions = false; } + /************************** CHOIX *****************************************/ + + @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() { + 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 (ChoiceDTO current : getPoll().getChoiceDTOs()) { + choices.add((ChoiceField)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 **/ Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/ImageUtil.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/ImageUtil.java 2010-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/ImageUtil.java 2010-03-15 10:42:07 UTC (rev 2939) @@ -100,7 +100,7 @@ * @param img L'image à miniaturiser. * @param width La largeur de la miniature. */ - private static void createThumbnail(File dir, File img, int width) { + public static void createThumbnail(File dir, File img, int width) { ImageIcon ii = new ImageIcon(img.getAbsolutePath()); Image image = ii.getImage(); double imageRatio = (double) image.getHeight(null) Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml 2010-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml 2010-03-15 10:42:07 UTC (rev 2939) @@ -157,7 +157,7 @@ </div> <!-- Contenu --> - <div id="content"> + <div id="${pageBodyId}" class="content"> <noscript> <t:feedback t:id="errorJs" /> </noscript> 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-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties 2010-03-15 10:42:07 UTC (rev 2939) @@ -15,25 +15,24 @@ title-label=Titre * title-required-message=Vous devez fournir un titre pour le sondage. description-label=Description -beginDate-label=Date de 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. -endDate-label=Date de fin +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. -pollType-label=Type de sondage -pollType-help=Libre : accessible \u00E0 tout le monde<br/>Liste restreinte : accessible uniquement \u00E0 une liste de votants<br/>Par groupes : accessible \u00E0 plusieurs listes de votants -voteCounting-label=Type de d\u00E9pouillement -voteCounting-help=Simple : s\u00E9lection de 1 ou n choix parmis les choix possibles<br/>Pourcentage : attribution d\'un pourcentage \u00E0 chaque choix<br/>Condorcet : classement des choix par ordre de pr\u00E9f\u00E9rence<br/>Nombre : R\u00E9ponse libre. Fait la somme et la moyenne des nombres. -advancedOptions-label=Options avanc\u00E9es ? +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 +voteCounting-label=D\u00E9pouillement +voteCounting-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=Libre -PollType.RESTRICTED=Liste restreinte +PollType.FREE=Aucune +PollType.RESTRICTED=Liste simple PollType.GROUP=Par groupes -VoteCountingType.NORMAL=Simple +VoteCountingType.NORMAL=Normal VoteCountingType.PERCENTAGE=Pourcentage VoteCountingType.CONDORCET=Condorcet VoteCountingType.NUMBER=Nombre @@ -42,7 +41,7 @@ ChoiceType.IMAGE=Image # Options -legend-options=Options avanc\u00E9es +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 @@ -73,4 +72,21 @@ 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. reminder-label=heures avant la fin -reminder-min-message=La valeur doit-\u00EAtre sup\u00E9rieure \u00E0 0. \ No newline at end of file +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. +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. +choiceDescription-label=Description +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 Modified: trunk/pollen-ui/src/main/webapp/css/main.css =================================================================== --- trunk/pollen-ui/src/main/webapp/css/main.css 2010-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-ui/src/main/webapp/css/main.css 2010-03-15 10:42:07 UTC (rev 2939) @@ -406,7 +406,7 @@ background-color: #ff8c8f; } -#content { +.content { padding: 15px; } Modified: trunk/pollen-ui/src/main/webapp/css/poll.css =================================================================== --- trunk/pollen-ui/src/main/webapp/css/poll.css 2010-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-ui/src/main/webapp/css/poll.css 2010-03-15 10:42:07 UTC (rev 2939) @@ -6,49 +6,67 @@ Stylesheet for poll pages. */ -legend { - color: #727a7e; - font-weight: bold; +input.ico { + border: 0 none; + font-size: 0; + cursor: pointer; + vertical-align: top; } -.disabled { - color: #555; +input.refresh { + width: 22px; + height: 22px; + background: url(../img/refresh-22px.png) no-repeat center center; } -#pollForm-mainInfos fieldset { +/** GLOBAL style for PollForm **/ +#p-pollForm .datepicker { + width: 140px; +} + +#p-pollForm fieldset { border: 1px solid #aab; - padding: 15px; - width: 410px; - margin-left: 30px; + padding: 10px; + width: 705px; + margin-left: auto; + margin-right: auto; vertical-align: top; text-align: left; + margin-bottom: 10px; } -#pollForm-mainInfos label { +#p-pollForm fieldset p { + margin-top: 0px; + margin-bottom: 5px; +} + +#p-pollForm legend { + color: #727a7e; + font-weight: bold; +} + +/* LOCAL style for PollForm mainInfos block */ +#p-pollForm-mainInfos fieldset legend span:first-child, +#p-pollForm-mainInfos fieldset p span:first-child { display: block; - width: 150px; + padding-top: 5px; + width: 100px; float: left; } -#pollForm-mainInfos div, -#pollForm-options div, -#listsCreationFormDiv div { - margin-bottom: 10px; +#p-pollForm-mainInfos fieldset input.title { + width: 580px; } -#pollForm-options fieldset { - border: 1px solid #aab; - padding: 15px; - width: 410px; - margin-left: 20px; - vertical-align: top; - text-align: left; +#p-pollForm-mainInfos fieldset input.email { + width: 293px; } -/*#choiceDateDiv, -#choiceNbDiv, -#notificationDiv, -#reminderDiv { - color: #555; -}*/ +/* LOCAL style for PollForm options block */ +#p-pollForm-options fieldset div.left-column { + display: block; + padding-top: 5px; + width: 350px; + float: left; +} Added: trunk/pollen-ui/src/main/webapp/img/refresh-22px.png =================================================================== (Binary files differ) Property changes on: trunk/pollen-ui/src/main/webapp/img/refresh-22px.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/pollen-ui/src/main/webapp/js/pollForm.js =================================================================== --- trunk/pollen-ui/src/main/webapp/js/pollForm.js 2010-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-ui/src/main/webapp/js/pollForm.js 2010-03-15 10:42:07 UTC (rev 2939) @@ -13,12 +13,12 @@ // Attributes for email and notification synchronization this.email = this.form.email; this.notification = this.form.sendNotification; - this.notificationFragmentId = 'notificationFragment'; + this.notificationFragmentId = 'notificationHidden'; // Attributes for voteCounting and choiceNb synchronization this.voteCounting = this.form.voteCounting; this.voteCountingNormal = voteCountingNormal; - this.choiceNbFragmentId = 'choiceNbFragment'; + this.choiceNbFragmentId = 'choiceNbHidden'; this.choiceNb = this.form.choiceNb; // Attributes for anonymous options @@ -33,7 +33,7 @@ this.pollType = this.form.pollType; this.pollTypeFree = pollTypeFree; this.reminder = this.form.sendReminder; - this.reminderFragmentId = 'reminderFragment'; + this.reminderFragmentId = 'reminderHidden'; this.voteCounting.observe('change', this.updateFromVoteCounting.bindAsEventListener(this)); this.pollType.observe('change', this.updateFromPollType.bindAsEventListener(this)); Modified: trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml =================================================================== --- trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-03-15 10:42:07 UTC (rev 2939) @@ -229,14 +229,14 @@ <t:FeedContextLink t:id="feedContext" /> <t:form t:id="choicesCreationForm"> <div id="choicesCreationFormDiv"> - <t:if test="!isNumberVoteCounting()"> - <div> - <t:label for="choiceType" />: - <t:select t:id="choiceType" t:value="poll.choiceType" t:validate="required" - t:mixins="ck/OnEvent" event="change" onCompleteCallback="onCompleteZoneUpdate"> - </t:select> - </div> - </t:if> + <t:unless test="numberVoteCounting"> + <div> + <t:label for="choiceType" />: + <t:select t:id="choiceType" t:value="poll.choiceType" t:validate="required" + t:mixins="ck/OnEvent" event="change" onCompleteCallback="onCompleteZoneUpdate"> + </t:select> + </div> + </t:unless> <t:errors/> <fieldset> <legend>${stepLegend}</legend> Modified: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml =================================================================== --- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-03-15 10:34:46 UTC (rev 2938) +++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-03-15 10:42:07 UTC (rev 2939) @@ -1,5 +1,5 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<t:border t:address="addressBar.items" t:pageLogo="literal:Creation" t:pageTitle="prop:pageTitle" +<t:border t:address="addressBar.items" t:pageLogo="literal:Creation" t:pageBodyId="p-pollForm" t:pageTitle="prop:pageTitle" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> <t:feedback t:id="feedback"/> <h1 class="titlePoll"> @@ -9,183 +9,209 @@ </t:if> </h1> <t:zone t:id="mainZone" t:update="show"> -<form t:type="form" t:id="mainForm" t:zone="mainZone" action="post"> -<t:errors/> -<div class="clearfix"> -<!-- MAIN INFOS --> -<div id="pollForm-mainInfos" class="fleft"> - <fieldset> - <legend>${message:legend-mainInfos}</legend> - <div> - <label t:type="label" for="creatorName"/> - <input type="text" t:type="textfield" t:id="creatorName" value="poll.creatorName" t:validate="required,minlength=2"/> + <form t:type="form" t:id="mainForm" t:zone="mainZone" action="post"> + <t:errors/> + <!-- MAIN INFOS --> + <div id="p-pollForm-mainInfos"> + <fieldset> + <legend> + ${message:legend-mainInfos} + </legend> + <p> + <span><label t:type="label" 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" for="creatorName"/>:</span> + <input type="text" t:type="textfield" t:id="creatorName" value="poll.creatorName" t:validate="required,minlength=2"/> + <label t:type="label" for="email"/>: + <input type="text" t:type="textfield" class="email" t:id="email" value="poll.creatorEmail" t:validate="regexp"/> + </p> + <p> + <span><label t:type="label" 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" 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" 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" for="voteCounting"/>: + <select t:type="select" t:id="voteCounting" t:value="poll.voteCounting" 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> - <div> - <label t:type="label" for="email"/> - <input type="text" t:type="textfield" t:id="email" value="poll.creatorEmail" t:validate="regexp"/> + <!-- CHOICES --> + <div id="p-pollForm-choices"> + <fieldset> + <legend> + <label t:type="label" 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" 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" 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" 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 for="choiceDescription" />: + </div> + <div class="fleft"> + <t:textarea cols="34" rows="1" t:id="choiceDescription" t:value="choice.description" /> + </div> + </div> + </fieldset> </div> - <br/> - - <div> - <label t:type="label" for="title"/> - <input type="text" t:type="textfield" t:id="title" value="poll.title" t:validate="required"/> + <!-- LISTS --> + <div id="p-pollForm-lists"> + <fieldset> + <legend> + <label t:type="label" 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> - <div> - <label t:type="label" for="description"/> - <textarea t:type="textarea" cols="23" rows="1" t:id="description" t:value="poll.description">${poll.description}</textarea> + <!-- 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" for="advancedOptions"/> + </legend> + <div class="clearfix"> + <t:formFragment t:id="optionsFragment" visible="advancedOptions"> + <!-- LEFT COLUMN --> + <div class="left-column fleft"> + <p> + <input t:type="checkbox" t:id="anonymous" value="poll.anonymous" /> + <label t:type="label" for="anonymous"/> + <span t:type="ck/Tooltip" title="message:help" t:value="message:anonymous-help" t:effect="appear"> + <img src="${asset:context:img/help.png}" alt="message:help"/> + </span> + </p> + <p> + <input t:type="checkbox" t:id="continuousResults" value="poll.continuousResults"/> + <label t:type="label" for="continuousResults"/> + <span t:type="ck/Tooltip" title="message:help" t:value="message:continuousResults-help" t:effect="appear"> + <img src="${asset:context:img/help.png}" alt="message:help"/> + </span> + </p> + <p> + <input t:type="checkbox" t:id="choiceAddAllowed" value="poll.choiceAddAllowed" + t:mixins="triggerfragment" t:fragment="choiceDateFragment"/> + <label t:type="label" for="choiceAddAllowed"/> + <span t:type="ck/Tooltip" title="message:help" t:value="message:choiceAddAllowed-help}" t:effect="appear"> + <img src="${asset:context:img/help.png}" alt="message:help"/> + </span> + </p> + <p> + <t:formFragment t:id="choiceDateFragment" t:visible="poll.choiceAddAllowed"> + <label t:type="label" for="beginChoiceDate"/> + <input t:type="ck/dateTimeField" t:id="beginChoiceDate" value="poll.beginChoiceDate" t:validate="regexp" + t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/> + <br/> + <label t:type="label" for="endChoiceDate"/> + <input t:type="ck/dateTimeField" t:id="endChoiceDate" value="poll.endChoiceDate" t:validate="regexp" + t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/> + </t:formFragment> + </p> + <p> + <input t:type="checkbox" t:id="sendNotification" value="hasNotification" + disabled="notificationDisabled" t:mixins="triggerfragment" t:fragment="notificationFragment"/> + <label t:type="label" for="sendNotification"/> + <span t:type="ck/Tooltip" title="message:help" t:value="message:sendNotification-help" t:effect="appear"> + <img src="${asset:context:img/help.png}" alt="message:help"/> + </span> + </p> + <p> + <t:formFragment id="notificationHidden" t:id="notificationFragment" t:visible="hasNotification"> + <label t:type="label" for="notification"/> + <input t:type="textfield" t:id="notification" value="notification.sensibility" t:size="3" t:validate="min=0"/> + ${message:notification-label2} + </t:formFragment> + </p> + </div> + <!-- RIGHT COLUMN --> + <div class="fleft"> + <p> + <input t:type="checkbox" t:id="anonymousVoteAllowed" value="poll.anonymousVoteAllowed" disabled="anonymousVoteAllowedDisabled"/> + <label t:type="label" for="anonymousVoteAllowed"/> + <span t:type="ck/Tooltip" title="message:help" t:value="message:anonymousVoteAllowed-help" t:effect="appear"> + <img src="${asset:context:img/help.png}" alt="message:help"/> + </span> + </p> + <p> + <input t:type="checkbox" t:id="publicResults" value="poll.publicResults" disabled="publicResultsDisabled"/> + <label t:type="label" for="publicResults"/> + <span t:type="ck/Tooltip" title="message:help" t:value="message:publicResults-help" t:effect="appear"> + <img src="${asset:context:img/help.png}" alt="message:help"/> + </span> + </p> + <p> + <input t:type="checkbox" t:id="choiceNb" value="hasChoiceNb" disabled="choiceNbDisabled" + t:mixins="triggerFragment" t:fragment="choiceNbFragment"/> + <label t:type="label" for="choiceNb"/> + <span t:type="ck/Tooltip" title="message:help" t:value="message:choiceNb-help" t:effect="appear"> + <img src="${asset:context:img/help.png}" alt="message:help"/> + </span> + </p> + <p> + <t:formFragment id="choiceNbHidden" t:id="choiceNbFragment" t:visible="hasChoiceNb"> + <label t:type="label" for="maxChoiceNb"/> + <input t:type="textfield" t:id="maxChoiceNb" t:value="poll.maxChoiceNb" t:size="1" t:validate="min=0"/> + </t:formFragment> + </p> + <p> + <input t:type="checkbox" t:id="sendReminder" t:value="hasReminder" disabled="reminderDisabled" + t:mixins="triggerfragment" t:fragment="reminderFragment"/> + <label t:type="label" for="sendReminder"/> + <span t:type="ck/Tooltip" title="message:help" t:value="message:sendReminder-help" t:effect="appear"> + <img src="${asset:context:img/help.png}" alt="message:help"/> + </span> + </p> + <p> + <t:formFragment id="reminderHidden" t:id="reminderFragment" t:visible="hasReminder"> + <input t:type="textfield" t:id="reminder" t:value="reminder.sensibility" t:size="1" t:validate="min=0"/> + <label t:type="label" for="reminder"/> + </t:formFragment> + </p> + </div> + </t:formFragment> + </div> + </fieldset> </div> - <div> - <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component --> - <label t:type="label" for="beginDate"/> - <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"/> - </div> - <div> - <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component --> - <label t:type="label" 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"/> - </div> - <div> - <label t:type="label" 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> - </div> - <div> - <label t:type="label" for="voteCounting"/> - <select t:type="select" t:id="voteCounting" t:value="poll.voteCounting" 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> - </div> - </fieldset> - <!-- <div class="buttons"> - <input t:type="submit" value="${message:next-button}" /> - </div>--> -</div> -<!-- OPTIONS --> - -<div id="pollForm-options" class="fleft"> - <fieldset> - <legend> - <input t:type="checkbox" t:id="advancedOptions" t:mixins="triggerfragment" t:fragment="optionsFragment"/> - <label t:type="label" for="advancedOptions"/> - </legend> - <t:formFragment t:id="optionsFragment" visible="advancedOptions"> - <div> - <input t:type="checkbox" t:id="anonymous" value="poll.anonymous" /> - <label t:type="label" for="anonymous"/> - <span t:type="ck/Tooltip" title="message:help" t:value="message:anonymous-help" t:effect="appear"> - <img src="${asset:context:img/help.png}" alt="message:help"/> - </span> - </div> - <div> - <input t:type="checkbox" t:id="anonymousVoteAllowed" value="poll.anonymousVoteAllowed" disabled="anonymousVoteAllowedDisabled"/> - <label t:type="label" for="anonymousVoteAllowed"/> - <span t:type="ck/Tooltip" title="message:help" t:value="message:anonymousVoteAllowed-help" t:effect="appear"> - <img src="${asset:context:img/help.png}" alt="message:help"/> - </span> - </div> - <div> - <input t:type="checkbox" t:id="continuousResults" value="poll.continuousResults"/> - <label t:type="label" for="continuousResults"/> - <span t:type="ck/Tooltip" title="message:help" t:value="message:continuousResults-help" t:effect="appear"> - <img src="${asset:context:img/help.png}" alt="message:help"/> - </span> - </div> - <div> - <input t:type="checkbox" t:id="publicResults" value="poll.publicResults" disabled="publicResultsDisabled"/> - <label t:type="label" for="publicResults"/> - <span t:type="ck/Tooltip" title="message:help" t:value="message:publicResults-help" t:effect="appear"> - <img src="${asset:context:img/help.png}" alt="message:help"/> - </span> - </div> - <div> - <input t:type="checkbox" t:id="choiceAddAllowed" value="poll.choiceAddAllowed" - t:mixins="triggerfragment" t:fragment="choiceDateFragment"/> - <label t:type="label" for="choiceAddAllowed"/> - <span t:type="ck/Tooltip" title="message:help" t:value="message:choiceAddAllowed-help}" t:effect="appear"> - <img src="${asset:context:img/help.png}" alt="message:help"/> - </span> - <br/> - <t:formFragment t:id="choiceDateFragment" t:visible="poll.choiceAddAllowed"> - <label t:type="label" for="beginChoiceDate"/> - <input t:type="ck/dateTimeField" t:id="beginChoiceDate" value="poll.beginChoiceDate" t:validate="regexp" - t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/> - <br/> - <label t:type="label" for="endChoiceDate"/> - <input t:type="ck/dateTimeField" t:id="endChoiceDate" value="poll.endChoiceDate" t:validate="regexp" - t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/> - </t:formFragment> - <!-- <span id="choiceDateDiv" style="display: none;"> - - </span>--> - </div> - <!--<t:if test="normalVoteCounting">--> - <div> - <input t:type="checkbox" t:id="choiceNb" value="hasChoiceNb" disabled="choiceNbDisabled" - t:mixins="triggerFragment" t:fragment="choiceNbFragment"/> - <label t:type="label" for="choiceNb"/> - <span t:type="ck/Tooltip" title="message:help" t:value="message:choiceNb-help" t:effect="appear"> - <img src="${asset:context:img/help.png}" alt="message:help"/> - </span> - <br/> - <t:formFragment t:id="choiceNbFragment" t:visible="hasChoiceNb"> - <label t:type="label" for="maxChoiceNb"/> - <input t:type="textfield" t:id="maxChoiceNb" t:value="poll.maxChoiceNb" t:size="1" t:validate="min=0"/> - </t:formFragment> - </div> - <!--</t:if>--> - <!--<t:if test="poll.creatorEmail">--> - <div> - <input t:type="checkbox" t:id="sendNotification" value="hasNotification" - disabled="notificationDisabled" t:mixins="triggerfragment" t:fragment="notificationFragment"/> - <label t:type="label" for="sendNotification"/> - <span t:type="ck/Tooltip" title="message:help" t:value="message:sendNotification-help" t:effect="appear"> - <img src="${asset:context:img/help.png}" alt="message:help"/> - </span> - <br/> - <t:formFragment t:id="notificationFragment" t:visible="hasNotification"> - <label t:type="label" for="notification"/> - <input t:type="textfield" t:id="notification" value="notification.sensibility" t:size="3" t:validate="min=0"/> - ${message:notification-label2} - </t:formFragment> - </div> - <!--</t:if>--> - <!--<t:unless test="freePoll">--> - <div> - <input t:type="checkbox" t:id="sendReminder" t:value="hasReminder" disabled="reminderDisabled" - t:mixins="triggerfragment" t:fragment="reminderFragment"/> - <label t:type="label" for="sendReminder"/> - <span t:type="ck/Tooltip" title="message:help" t:value="message:sendReminder-help" t:effect="appear"> - <img src="${asset:context:img/help.png}" alt="message:help"/> - </span> - <br/> - <t:formFragment t:id="reminderFragment" t:visible="hasReminder"> - <input t:type="textfield" t:id="reminder" t:value="reminder.sensibility" t:size="1" t:validate="min=0"/> - <label t:type="label" for="reminder"/> - </t:formFragment> - </div> - <!--</t:unless>--> - </t:formFragment> - </fieldset> - <!-- <div class="buttons"> - <t:eventLink t:event="previous" t:zone="pollCreationZone" style="text-decoration: none;"> - <input type="button" value="${message:prev-button}" /> - </t:eventLink> - <t:submit t:value="${message:next-button}" t:zone="pollCreationZone" /> - </div>--> -</div> - -</div> -</form> + </form> </t:zone> </t:border> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-03-15 10:34:46 UTC (rev 2938) +++ trunk/pom.xml 2010-03-15 10:42:07 UTC (rev 2939) @@ -10,7 +10,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>mavenpom4redmine</artifactId> - <version>2.0.5</version> + <version>2.0.6</version> </parent> <groupId>org.chorem</groupId>