r22 - in branches/alpha3-periodicity: . cash-business cash-business/src/main/java/org/chorem/cash/impl cash-business/src/main/xmi cash-ui cash-ui/src/main/java/org/chorem/cash/ui/base cash-ui/src/main/java/org/chorem/cash/ui/components cash-ui/src/main/resources/org/chorem/cash/ui/components cash-ui/src/main/webapp cash-ui/src/main/webapp/META-INF cash-ui/src/main/webapp/css cash-ui/src/main/webapp/img cash-ui/src/main/webapp/img/icons cash-ui/src/main/webapp/img/icons/crystal
Author: fdesbois Date: 2009-08-24 11:38:34 +0200 (Mon, 24 Aug 2009) New Revision: 22 Added: branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/base/FrequencyEndCondition.java branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/components/SubmitContext.java Removed: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/cancel.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/address.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/address2.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/apply.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/blabla.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/cellphone.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/delete.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/email.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/fax.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/internet.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/internet2.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/phone.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/reference.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/delete.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/delete_icon.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/earth.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/edit_icon.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/first.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/iaction.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/last.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/maximize.gif branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/mini_cross.gif branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/mini_tick.gif branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/minimize.gif branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/movedown.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/movetobottom.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/movetotop.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/moveup.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/next.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/previous.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/tick.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/pollen.png Modified: branches/alpha3-periodicity/cash-business/pom.xml branches/alpha3-periodicity/cash-business/src/main/java/org/chorem/cash/impl/ServiceEntryImpl.java branches/alpha3-periodicity/cash-business/src/main/xmi/cash.zargo branches/alpha3-periodicity/cash-ui/nbactions.xml branches/alpha3-periodicity/cash-ui/pom.xml branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/base/ListEntries.java branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/components/EntryForm.java branches/alpha3-periodicity/cash-ui/src/main/resources/org/chorem/cash/ui/components/EntryForm.properties branches/alpha3-periodicity/cash-ui/src/main/resources/org/chorem/cash/ui/components/EntryForm.tml branches/alpha3-periodicity/cash-ui/src/main/webapp/META-INF/context.xml branches/alpha3-periodicity/cash-ui/src/main/webapp/PreviewTable.tml branches/alpha3-periodicity/cash-ui/src/main/webapp/css/common.css branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/add.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/cancel.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/clock.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/edit.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/info.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/movedown.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/movetobottom.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/movetotop.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/moveup.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/reload.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/remove.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/save.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/showdetails.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/stop.png branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/warning.png branches/alpha3-periodicity/pom.xml Log: Change icons size and other stuff for UI Modified: branches/alpha3-periodicity/cash-business/pom.xml =================================================================== --- branches/alpha3-periodicity/cash-business/pom.xml 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/cash-business/pom.xml 2009-08-24 09:38:34 UTC (rev 22) @@ -10,7 +10,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>cash</artifactId> - <version>1.0.0-alpha-2-SNAPSHOT</version> + <version>1.0.0-alpha-3-SNAPSHOT</version> </parent> <groupId>org.chorem.cash</groupId> Modified: branches/alpha3-periodicity/cash-business/src/main/java/org/chorem/cash/impl/ServiceEntryImpl.java =================================================================== --- branches/alpha3-periodicity/cash-business/src/main/java/org/chorem/cash/impl/ServiceEntryImpl.java 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/cash-business/src/main/java/org/chorem/cash/impl/ServiceEntryImpl.java 2009-08-24 09:38:34 UTC (rev 22) @@ -26,30 +26,20 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.cash.CashException; import org.chorem.cash.CashModelDAOHelper; import org.chorem.cash.ContextUtilCash; import org.chorem.cash.business.EntryHelper; -import org.chorem.cash.business.PeriodicHelper; -import org.chorem.cash.business.PeriodicHelperByMonth; import org.chorem.cash.business.Periodicity; -import org.chorem.cash.business.ReferenceHelper; -import org.chorem.cash.dto.Category; import org.chorem.cash.dto.Entry; import org.chorem.cash.dto.Reference; -import org.chorem.cash.persistence.CategoryEntity; -import org.chorem.cash.persistence.CategoryEntityDAO; import org.chorem.cash.persistence.EntryEntity; import org.chorem.cash.persistence.EntryEntityDAO; import org.chorem.cash.persistence.EntryFrequencyEntity; import org.chorem.cash.services.ServiceEntry; import org.chorem.cash.services.ServiceEntryAbstract; -import org.chorem.exceptions.ConvertException; -import org.chorem.utils.DateUtils; import org.chorem.utils.PeriodDates; import org.chorem.utils.ServiceHelper; import org.nuiton.topia.TopiaContext; @@ -89,9 +79,9 @@ EntryFrequencyEntity frequency = oldEntry.getEntryFrequencyEntity(); - if (frequency != null && (entry.getPeriodicity() == null || "".equals(entry.getPeriodicity()))) { // Entite anciennement periodique mais l'entree courante devient indépendante + if (frequency != null && (entry.getFrequencyId() == null || "".equals(entry.getFrequencyId()))) { // Entite anciennement periodique mais l'entree courante devient indépendante - if (frequency.getUnlimited()) { // Cas illimite : une seule entite en base + if (frequency.getUnlimited()) { // Cas illimite // On recupere l'ancienne version de l'entite (avec sa frequence) Calendar calendar = new GregorianCalendar(); @@ -117,6 +107,9 @@ newAfterEntry.setEntryDate(calendar.getTime()); EntryHelper.createUpdateEntry(newAfterEntry, transaction, log); + + entry.setFrequencyId(""); + entry.setPeriodicity(""); } else if (frequency.getNbTimes() > 0) { } @@ -197,7 +190,42 @@ return result; } + /** + * FIXME clone entry + * @param entry + * @return + */ @Override + public Entry getNewEntry(Entry entry) { + Entry result = new Entry(); + result.setId(entry.getId()); + result.setLibelle(entry.getLibelle()); + result.setCategory(entry.getCategory()); + result.setAmount(entry.getAmount()); + result.setComment(entry.getComment()); + result.setEntryDate(entry.getEntryDate()); + + result.setReferences(new ArrayList<Reference>(entry.getReferences())); // Clone references ? + + // principal for frequency + result.setFrequencyId(entry.getFrequencyId()); + result.setCurrentDate(entry.getCurrentDate()); + + // for frequency + result.setPeriodicity(entry.getPeriodicity()); + result.setInterval(entry.getInterval()); + result.setNbTimes(entry.getNbTimes()); + result.setUnlimited(entry.getUnlimited()); + result.setDay(entry.getDay()); + result.setDayOfWeek(entry.getDayOfWeek()); + + // for ui + result.setShowFrequency(entry.getShowFrequency()); + + return result; + } + + @Override public Map<String, List<Entry>> getEntriesBetweenDates(PeriodDates period) throws CashException { TopiaContext transaction = null; Map<String, List<Entry>> results = new HashMap<String, List<Entry>>(); Modified: branches/alpha3-periodicity/cash-business/src/main/xmi/cash.zargo =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/nbactions.xml =================================================================== --- branches/alpha3-periodicity/cash-ui/nbactions.xml 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/cash-ui/nbactions.xml 2009-08-24 09:38:34 UTC (rev 22) @@ -4,6 +4,8 @@ <actionName>CUSTOM-Tomcat embedded</actionName> <displayName>Tomcat embedded</displayName> <goals> + <goal>clean</goal> + <goal>install</goal> <goal>tomcat:run</goal> <goal>-Dtapestry.compress-whitespace=false</goal> <goal>-Dorg.apache.tapestry.disable-caching=true</goal> Modified: branches/alpha3-periodicity/cash-ui/pom.xml =================================================================== --- branches/alpha3-periodicity/cash-ui/pom.xml 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/cash-ui/pom.xml 2009-08-24 09:38:34 UTC (rev 22) @@ -9,7 +9,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>cash</artifactId> - <version>1.0.0-alpha-2-SNAPSHOT</version> + <version>1.0.0-alpha-3-SNAPSHOT</version> </parent> <groupId>org.chorem.cash</groupId> Added: branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/base/FrequencyEndCondition.java =================================================================== --- branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/base/FrequencyEndCondition.java (rev 0) +++ branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/base/FrequencyEndCondition.java 2009-08-24 09:38:34 UTC (rev 22) @@ -0,0 +1,33 @@ +/** + * *##% Ca$h Web Interface + * Copyright (C) 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +package org.chorem.cash.ui.base; + +/** + * FrequencyEndCondition.java + * + * @author fdesbois + * @version $Revision: 3 $ + * + * Last update: $Date: 2009-07-31 16:54:15 +0200 (ven 31 jui 2009) $ + * by : $Author: fdesbois $ + */ +public enum FrequencyEndCondition { + UNLIMITED, UNTIL_DATE, NB_TIMES +} Modified: branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/base/ListEntries.java =================================================================== --- branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/base/ListEntries.java 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/base/ListEntries.java 2009-08-24 09:38:34 UTC (rev 22) @@ -25,6 +25,7 @@ import java.util.List; import org.chorem.cash.dto.Category; import org.chorem.cash.dto.Entry; +import org.chorem.cash.services.ServiceEntry; import org.chorem.utils.DateUtils; /** @@ -42,7 +43,7 @@ * Last update: $Date: 2009-08-13 09:14:50 +0200 (Thu, 13 Aug 2009) $ * by : $Author: fdesbois $ */ -public class ListEntries implements Serializable { +public class ListEntries implements Serializable, Cloneable { private Category category; @@ -62,6 +63,18 @@ this.libelle = ""; } + public ListEntries(ListEntries listEntries, ServiceEntry service) { + this.category = listEntries.getCategory(); + this.month = listEntries.getMonth(); + this.amount = listEntries.getAmount(); + this.libelle = listEntries.getLibelle(); + this.entries = new ArrayList<Entry>(); + for (Entry entry : listEntries.getEntries()) { + Entry newEntry = service.getNewEntry(entry); + this.entries.add(newEntry); + } + } + /** * Total calcule au moment de son acces pour permettre les mises a jour depuis formulaires. * @return le montant total de toutes les entrees de la liste @@ -114,12 +127,12 @@ * Suppression d'une entree * @param entryId identifiant de l'entree a supprimer */ - public void removeEntry(String entryId) { + /*public void removeEntry(String entryId) { Entry entry = getEntry(entryId); if (entry != null) { entries.remove(entry); } - } + }*/ /** * Accesseur pour recuperer une seule entree identifier par le parametre donne. Modified: branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/components/EntryForm.java =================================================================== --- branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/components/EntryForm.java 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/components/EntryForm.java 2009-08-24 09:38:34 UTC (rev 22) @@ -21,6 +21,7 @@ import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.InjectContainer; @@ -33,12 +34,15 @@ import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.services.PageRenderLinkSource; import org.chorem.cash.CashException; +import org.chorem.cash.business.Periodicity; import org.chorem.cash.dto.Entry; import org.chorem.cash.services.ServiceEntry; import org.chorem.cash.ui.base.DataLoader; +import org.chorem.cash.ui.base.FrequencyEndCondition; import org.chorem.cash.ui.base.ListEntries; import org.chorem.cash.ui.pages.PreviewTable; import org.chorem.cash.ui.utils.ErrorHelper; +import org.chorem.utils.DateUtils; import org.slf4j.Logger; /** @@ -68,12 +72,6 @@ private ClientMessages clientMessages; /** - * Page dans laquelle est utiliser le composant EntryForm. Il s'agit du tableau previsionnel afficher par mois. - */ - @InjectContainer - private PreviewTable previewTable; - - /** * PageRender pour garder l'identifiant de la liste entries, utiliser comme contexte de la page PreviewTable. */ @Inject @@ -89,8 +87,8 @@ * Parametre d'entree du composant. List des entrees fournie (et persister) par la page PreviewTable. * Le cache est desactive pour recuperer la ListEntries depuis PreviewTable a chaque demande du composant. */ - @Parameter(cache = false) - private ListEntries listEntries; + @Parameter(cache = false, required = true) + private ListEntries listEntriesParameter; /** * Entree courante pour affichage des lignes du formulaire @@ -99,20 +97,23 @@ private Entry entry; /** - * Liste des entrees (recuperer depuis la ListEntries passe en parametre) + * Liste des entrees persistante pour modifications (copier de la ListEntries passe en parametre) */ - private List<Entry> entries; + @Persist + private ListEntries listEntries; /** * Flag pour detecter l'activation du bouton d'ajout d'une ligne de formulaire */ - private boolean addEntrySelected; + private boolean editSelected; /** * Flag pour detecter l'activation du bouton de retour en arriere (rechargement de la page PreviewTable) */ private boolean cancelFormSelected; + //private boolean clockFormSelected; + /** * Formulaire pour l'ajout/modification des entrees */ @@ -125,6 +126,9 @@ @InjectComponent private Zone entryFormComponent; + @Property + private int indexEntry; + /** * Liste des identifiants des entrees a supprimer une fois le formulaire soumis. (sauvegarde) */ @@ -132,16 +136,104 @@ private List<String> entriesDeleted; public ListEntries getListEntries() { - return this.listEntries; + if (listEntries == null) { + if (log.isDebugEnabled()) { + log.debug("GET ENTRIES FROM CONTAINER"); + } + listEntries = new ListEntries(listEntriesParameter, serviceEntry); + } + return listEntries; } public List<Entry> getEntries() { - if (entries == null) { - entries = getListEntries().getEntries(); + return getListEntries().getEntries(); + } + + + public double getEntryAmount() { + return entry.getAmount(); + } + + @Log + public void setEntryAmount(double amount) { + if (!listEntries.getCategory().getCredit() && amount > 0) { + amount = -amount; } - return entries; + entry.setAmount(amount); } + public Date getEntryDate() { + if (getPeriodic()) { + return entry.getCurrentDate(); + } + return entry.getEntryDate(); + } + + public void setEntryDate(Date date) { + if (getPeriodic()) { + entry.setCurrentDate(date); + } else { + entry.setEntryDate(date); + } + } + + public FrequencyEndCondition getFrequencyEndCondition() { + if (entry.getUnlimited()) { + return FrequencyEndCondition.UNLIMITED; + } else if (entry.getNbTimes() > 0) { + return FrequencyEndCondition.NB_TIMES; + } else if (entry.getUntilDate() != null) { + return FrequencyEndCondition.UNTIL_DATE; + } + return FrequencyEndCondition.UNLIMITED; + } + + @Log + public void setFrequencyEndCondition(FrequencyEndCondition frequencyEnd) { + switch (frequencyEnd) { + case UNLIMITED: + entry.setUnlimited(true); + entry.setUntilDate(null); + entry.setNbTimes(0); + break; + case NB_TIMES: + entry.setUnlimited(false); + entry.setUntilDate(null); + break; + case UNTIL_DATE: + entry.setUnlimited(false); + entry.setNbTimes(0); + break; + } + if (log.isDebugEnabled()) { + log.debug("FREQUENCY_END : " + frequencyEnd); + log.debug("ENTRY : " + entry); + log.debug("ENTRY : unlimited=" + entry.getUnlimited() + ", untilDate=" + entry.getUntilDate() + ", nbTimes=" + entry.getNbTimes()); + } + } + + public FrequencyEndCondition getFrequencyUnlimited() { + return FrequencyEndCondition.UNLIMITED; + } + + public FrequencyEndCondition getFrequencyUntilDate() { + return FrequencyEndCondition.UNTIL_DATE; + } + + public FrequencyEndCondition getFrequencyNbTimes() { + return FrequencyEndCondition.NB_TIMES; + } + + public boolean getPeriodic() { + return entry.getPeriodicity() != null && !entry.getPeriodicity().isEmpty(); + } + + public void setPeriodic(boolean periodic) { + if (!periodic) { + entry.setFrequencyId(""); + } + } + /** * Chargement des donnees du composant. Si la ListEntries provenant de PreviewTable est vide, un message est afficher a l'utilisateur * via le composant ClientMessages. @@ -151,26 +243,17 @@ public void loadData() { clientMessages.clean(); entriesDeleted = new ArrayList<String>(); - if (getListEntries() != null && getEntries().size() == 0) { + + // listEntries persistant different de la listEntries en parametre + if (listEntries != null && !listEntries.getKey().equals(listEntriesParameter.getKey())) { + listEntries = null; + } + + if (getEntries().size() == 0) { clientMessages.addInfo("Aucune entrée existante, clickez sur le + pour en ajouter une nouvelle"); } } - /** - * Suppression d'une ligne de formulaire. Une entree est supprimable si elle a deja ete sauvegarde. - * @param entryId identifiant de l'entree a supprimer. - * @return un MultiZoneUpdate gerer par le composant ClientMessages (rafraichissement du formulaire et de la zone de messages) - */ - @Log - Object onActionFromRemoveEntry(String entryId) { - clientMessages.clean(); - if (entryId != null) { - clientMessages.addInfo("La suppression sera effective uniquement après sauvegarde"); - getListEntries().removeEntry(entryId); - entriesDeleted.add(entryId); - } - return clientMessages.zoneManager("entryFormComponent", entryFormComponent.getBody()); - } /** * Action sur le bouton d'ajout d'une entree au formulaire. Une nouvelle entree vide est ajouter a la ListEntries. @@ -183,36 +266,108 @@ if (log.isDebugEnabled()) { log.debug("DATE : " + entry.getEntryDate()); } - addEntrySelected = true; + editSelected = true; } + @Log + void onSelectedFromShowPeriodicity(int index) { + entry = getEntries().get(index); + + if (entry.getShowFrequency()) { + entry.setShowFrequency(false); + } else { + entry.setShowFrequency(true); + if (!getPeriodic()) { + entry.setPeriodicity(Periodicity.MONTHLY.toString()); + entry.setCurrentDate(entry.getEntryDate()); + } + } + + getEntries().set(index, entry); + editSelected = true; + } + + + @Log + Object onChangeFromAddPeriodicity(int index, String value) { // Checkbox + entry = getEntries().get(index); + + String periodicity = entry.getPeriodicity(); + if (log.isDebugEnabled()) { + log.debug("PERIODICITY : " + periodicity); + } + + if (entry.getShowFrequency()) { + entry.setShowFrequency(false); + } else if (!entry.getShowFrequency() && !getPeriodic()) { + entry.setShowFrequency(true); + } + + if (getPeriodic()) { + entry.setPeriodicity(null); + } else { + entry.setPeriodicity(Periodicity.MONTHLY.toString()); + entry.setCurrentDate(entry.getEntryDate()); + } + + getEntries().set(index, entry); + return clientMessages.getGlobalZone(); + } + /** + * Suppression d'une ligne de formulaire. Une entree est supprimable si elle a deja ete sauvegarde. + * @param entryId identifiant de l'entree a supprimer. + * @return un MultiZoneUpdate gerer par le composant ClientMessages (rafraichissement du formulaire et de la zone de messages) + */ + @Log + void onSelectedFromDeleteEntry(int index) { + String entryId = getEntries().get(index).getId(); + clientMessages.addInfo("La suppression sera effective uniquement après sauvegarde"); + getEntries().remove(index); + entriesDeleted.add(entryId); + editSelected = true; + } + + @Log + void onSelectedFromRemoveEntry(int index) { + getEntries().remove(index); + editSelected = true; + } + + /** * Action sur le bouton d'annulation qui activera le rechargement de la page. Les actions en cours (suppression/ajout/modification) ne * seront pas pris en compte. */ + @Log void onSelectedFromCancelForm() { - cancelFormSelected = true; + listEntries = null; + clientMessages.addInfo("Rechargement des données depuis la dernière sauvegarde"); + editSelected = true; } /** - * Succes du formulaire (les champs libelle et amount doivent etre valides). - * Trois cas de soumissions : - * - Cancel : Rechargement de la page PreviewTable ; - * - AddEntry : Ajout d'une ligne pour une nouvelle entree dans le formulaire ; - * - Save : Sauvegarde des ajouts/modifications/suppressions effectues par l'utilisateur. + * Succes du formulaire. Appele lors d'une action sur le formulaire (addEntry, cancelForm, removeEntry, deleteEntry, showPeriodicity, saveEntries). + * Sauvegarde des données uniquement lors de l'action sur le bouton saveEntries (editSelected = false). * @return la page PreviewTable si annulation ou sauvegarde effectue avec succes. La zone global du composant sinon. * @see org.chorem.cash.ui.components.ClientMessages */ @Log Object onSuccessFromEntryForm() { - clientMessages.clean(); + //clientMessages.clean(); entryForm.clearErrors(); - if (cancelFormSelected) { - return pageRender.createPageRenderLinkWithContext(PreviewTable.class, getListEntries().getKey()); - } - if (!addEntrySelected) { + /*if (cancelFormSelected) { + //return pageRender.createPageRenderLinkWithContext(PreviewTable.class, getListEntries().getKey()); + listEntries = null; + if (log.isDebugEnabled()) { + log.debug("CANCEL FORM"); + } + clientMessages.addInfo("Rechargement des données depuis la dernière sauvegarde"); + return clientMessages.zoneManager("entryFormComponent", entryFormComponent); + }*/ + if (!editSelected) { try { int index = 1; + for (Entry current : getEntries()) { if (current.getEntryDate() != null && current.getLibelle() != null) { serviceEntry.createUpdateEntry(current); @@ -220,7 +375,7 @@ entryForm.recordError("Champs incorrects pour entree " + index); } index++; - } + } for (String entryId : entriesDeleted) { serviceEntry.deleteEntry(entryId); @@ -239,7 +394,8 @@ } } } - return clientMessages.getGlobalZone().getBody();//clientMessages.zoneManager("entryFormComponent", entryForm); + //return clientMessages.getGlobalZone().getBody();//clientMessages.zoneManager("entryFormComponent", entryForm); + return clientMessages.zoneManager("entryFormComponent", entryForm); } /** Added: branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/components/SubmitContext.java =================================================================== --- branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/components/SubmitContext.java (rev 0) +++ branches/alpha3-periodicity/cash-ui/src/main/java/org/chorem/cash/ui/components/SubmitContext.java 2009-08-24 09:38:34 UTC (rev 22) @@ -0,0 +1,129 @@ +// Copyright 2007 The Apache Software Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.chorem.cash.ui.components; + +import org.apache.tapestry5.ComponentResources; +import org.apache.tapestry5.MarkupWriter; +import org.apache.tapestry5.annotations.Environmental; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.corelib.base.AbstractField; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.apache.tapestry5.services.FormSupport; +import org.apache.tapestry5.services.Heartbeat; +import org.apache.tapestry5.services.Request; + +/** + * Corresponds to <input type="submit">, a client-side element that can force the + * enclosing form to submit. The submit responsible for the form submission will post a + * notification that allows the application to know that it was the responsible entity. The + * notification is named "selected" and has a String context. + */ +public final class SubmitContext extends AbstractField +{ + static final String SELECTED_EVENT = "selected"; + + /** + * If true, then any notification sent by the component will be deferred until the end of + * the form submission (this is usually desirable). + */ + @Parameter + private boolean _defer = true; + + @Parameter + private String _context; + + @Environmental + private FormSupport _formSupport; + + @Environmental + private Heartbeat _heartbeat; + + @Inject + private ComponentResources _resources; + + @Inject + private Request _request; + + public SubmitContext() + { + } + + SubmitContext(Request request) + { + _request = request; + } + + void beginRender(MarkupWriter writer) + { + // write a hidden input for the context + //String elementName = getElementName(); + String elementName = getControlName(); //Modified to work with 5.0.12 + writer.element("input", "type", "hidden", "name", elementName + "X", "value", _context); + writer.end(); + + // now the submit + writer.element("input", "type", "submit", "name", elementName, "id", getClientId()); + _resources.renderInformalParameters(writer); + } + + void afterRender(MarkupWriter writer) + { + writer.end(); + } + + //protected void processSubmission(FormSupport formSupport, String elementName) + @Override + protected void processSubmission(String elementName) //Modified to work with 5.0.12 + { + String value = _request.getParameter(elementName); + final String context = _request.getParameter(elementName + "X"); + + if (value == null) + return; + + Runnable sendNotification = new Runnable() + { + public void run() + { + _resources.triggerEvent(SELECTED_EVENT, new Object[] {context}, null); + } + }; + + // When not deferred, don't wait, fire the event now (actually, at the end of the current + // heartbeat). This is most likely because the Submit is inside a Loop and some contextual + // information will change if we defer. Another option might be to wait until the next + // heartbeak? + + if (_defer) + _formSupport.defer(sendNotification); + else + _heartbeat.defer(sendNotification); + + } + + // For testing: + + void setDefer(boolean defer) + { + _defer = defer; + } + + void setup(ComponentResources resources, FormSupport support, Heartbeat heartbeat) + { + _resources = resources; + _formSupport = support; + _heartbeat = heartbeat; + } +} Modified: branches/alpha3-periodicity/cash-ui/src/main/resources/org/chorem/cash/ui/components/EntryForm.properties =================================================================== --- branches/alpha3-periodicity/cash-ui/src/main/resources/org/chorem/cash/ui/components/EntryForm.properties 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/cash-ui/src/main/resources/org/chorem/cash/ui/components/EntryForm.properties 2009-08-24 09:38:34 UTC (rev 22) @@ -0,0 +1,12 @@ + +periodicity=Fr\u00E9quence de r\u00E9p\u00E9tition (P\u00E9riodicit\u00E9) +periodicity-bymonth=Entr\u00E9e r\u00E9p\u00E9t\u00E9e par mois : choisissez tous les combien de mois (intervalle) et la condition de fin (illimit\u00E9, date de fin ou nombre de fois) +frequencyInterval-label=Tous les +addPeriodicity-label=P\u00E9riodique ? + +entry-add-submit=Ajouter une nouvelle entr\u00E9e +entry-remove-submit=Supprimer la nouvelle entr\u00E9e +entry-delete-submit=Supprimer l'entr\u00E9e +entries-save-submit=Sauvegarder les entr\u00E9es +entries-cancel-submit=Annuler toutes les modifications +periodicity-show-submit=Afficher la gestion p\u00E9riodique de l'entr\u00E9e \ No newline at end of file Modified: branches/alpha3-periodicity/cash-ui/src/main/resources/org/chorem/cash/ui/components/EntryForm.tml =================================================================== --- branches/alpha3-periodicity/cash-ui/src/main/resources/org/chorem/cash/ui/components/EntryForm.tml 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/cash-ui/src/main/resources/org/chorem/cash/ui/components/EntryForm.tml 2009-08-24 09:38:34 UTC (rev 22) @@ -16,23 +16,56 @@ <form t:type="form" t:id="entryForm" t:zone="${globalZoneId}"> <t:errors /> <t:if test="listEntries"> - <t:loop source="entries" value="entry" volatile="true"> + <t:loop source="entries" value="entry" volatile="true" t:index="indexEntry"> <p> - <t:label for="libelle" /> : <input t:type="textfield" t:id="libelle" t:value="entry.libelle" /> - <t:label for="amount" /> : <input t:type="textfield" t:id="amount" t:value="entry.amount" /> - <t:label for="date" /> : <input t:type="datefield" t:id="date" t:value="entry.entryDate" /> + <t:label for="libelle" /> : <input t:type="textfield" t:id="libelle" t:value="entry.libelle"/> + <t:label for="amount" /> : <input t:type="textfield" t:id="amount" t:value="entryAmount" /> + <t:label for="date" /> : <input t:type="datefield" t:id="date" t:value="entryDate"/> + <t:label for="addPeriodicity" /> + <input t:type="checkbox" t:id="addPeriodicity" value="periodic" + t:mixins="zoneUpdater" t:event="change" t:zone="${globalZoneId}" t:context="indexEntry" /> + + <input t:type="submitContext" class="ico clock" value="ShowPeriodicity" title="${message:periodicity-show-submit}" t:id="showPeriodicity" t:context="indexEntry" /> + <t:if test="entry.id"> - <a t:type="actionlink" class="img" t:id="removeEntry" t:context="entry.id" t:zone="entryFormMessages" title="${message:remove-entry}"> - <img src="${asset:context:/img/icons/crystal/cancel.png}" alt="${message:remove-entry}"/> - </a> + <input t:type="submitContext" class="ico delete" value="DeleteEntry" title="${message:entry-delete-submit}" t:id="deleteEntry" t:context="indexEntry" /> + <p:else> + <input t:type="submitContext" class="ico remove" value="RemoveEntry" title="${message:entry-remove-submit}" t:id="removeEntry" t:context="indexEntry" /> + </p:else> </t:if> </p> + <t:if t:test="entry.showFrequency"> + <fieldset> + <legend>${message:periodicity}</legend> + <p>${message:periodicity-bymonth}</p> + <p> + <t:label for="frequencyInterval" /> + <input t:type="textfield" class="interval" t:id="frequencyInterval" value="entry.interval" /> mois + </p> + <t:radiogroup t:id="frequencyEndCondition" t:value="frequencyEndCondition"> + <p> + <t:radio t:id="frequencyUnlimited" /> + <t:label for="frequencyUnlimited" /> + </p> + <p> + <t:radio t:id="frequencyUntilDate" /> + <t:label for="frequencyUntilDate" /> + <input t:type="datefield" t:id="entryUntilDate" value="entry.untilDate" /> + </p> + <p> + <t:radio t:id="frequencyNbTimes" /> + <t:label for="frequencyNbTimes" /> + <input t:type="textfield" t:id="entryNbTimes" value="entry.nbTimes" /> + </p> + </t:radiogroup> + </fieldset> + </t:if> </t:loop> </t:if> <p class="actions"> - <input t:type="submit" class="cancel" value="${message:cancel-form}" t:id="cancelForm" /> - <input t:type="submit" class="save" value="${message:save-entries}" t:id="saveEntries" /> - <input t:type="submit" class="add" value="${message:add-entry}" t:id="addEntry" /> + <input t:type="submit" class="ico cancel" value="CancelEntries" title="${message:entries-cancel-submit}" t:id="cancelForm" /> + <input t:type="submit" class="ico save" value="SaveEntries" title="${message:entries-save-submit}" t:id="saveEntries" /> + <input t:type="submit" class="ico add" value="AddEntry" title="${message:entry-add-submit}" t:id="addEntry" /> </p> </form> </div> Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/META-INF/context.xml =================================================================== --- branches/alpha3-periodicity/cash-ui/src/main/webapp/META-INF/context.xml 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/cash-ui/src/main/webapp/META-INF/context.xml 2009-08-24 09:38:34 UTC (rev 22) @@ -1,2 +1,2 @@ <?xml version="1.0" encoding="UTF-8"?> -<Context antiJARLocking="true" path="/cash"/> +<Context antiJARLocking="true" path="/cash-branche"/> Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/PreviewTable.tml =================================================================== --- branches/alpha3-periodicity/cash-ui/src/main/webapp/PreviewTable.tml 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/cash-ui/src/main/webapp/PreviewTable.tml 2009-08-24 09:38:34 UTC (rev 22) @@ -14,7 +14,7 @@ <t:if test="formFlag"> <fieldset> <legend><strong><em>${entriesEditable.category.name}</em></strong> pour le mois <strong>${entriesEditable.month}</strong></legend> - <t:entryForm t:listEntries="entriesEditable" /> + <t:entryForm t:listEntriesParameter="entriesEditable" /> </fieldset> <p:else> <fieldset> Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/css/common.css =================================================================== --- branches/alpha3-periodicity/cash-ui/src/main/webapp/css/common.css 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/cash-ui/src/main/webapp/css/common.css 2009-08-24 09:38:34 UTC (rev 22) @@ -74,33 +74,38 @@ } /* Boutons caches par des images */ -input.add { - background: url(../img/icons/crystal/add.png) no-repeat center center; +input.ico { border: 0 none; font-size: 0; - width: 32px; - height: 32px; + width: 24px; + height: 24px; cursor: pointer; } +input.add { + background: url(../img/icons/crystal/add.png) no-repeat center center; +} + input.save { background: url(../img/icons/crystal/save.png) no-repeat center center; - border: 0 none; - font-size: 0; - width: 32px; - height: 32px; - cursor: pointer; } input.cancel { background: url(../img/icons/crystal/reload.png) no-repeat center center; - border: 0 none; - font-size: 0; - width: 32px; - height: 32px; - cursor: pointer; } +input.clock { + background: url(../img/icons/crystal/clock.png) no-repeat center center; +} + +input.remove { + background: url(../img/icons/crystal/remove.png) no-repeat center center; +} + +input.delete { + background: url(../img/icons/crystal/cancel.png) no-repeat center center; +} + /* Configuration du BlockManager */ div.component { border: 2px outset #000000; @@ -194,6 +199,10 @@ margin: 8px; } +#entryFormComponent input.interval { + width: 30px; +} + div.zoneFlash { padding: 10px; border: 1px solid black; Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/cancel.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/add.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/address.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/address2.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/apply.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/blabla.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/cancel.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/cellphone.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/clock.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/delete.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/edit.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/email.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/fax.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/info.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/internet.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/internet2.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/movedown.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/movetobottom.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/movetotop.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/moveup.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/phone.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/reference.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/reload.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/remove.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/save.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/showdetails.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/stop.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/crystal/warning.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/delete.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/delete_icon.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/earth.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/edit_icon.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/first.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/iaction.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/last.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/maximize.gif =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/mini_cross.gif =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/mini_tick.gif =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/minimize.gif =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/movedown.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/movetobottom.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/movetotop.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/moveup.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/next.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/previous.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/icons/tick.png =================================================================== (Binary files differ) Deleted: branches/alpha3-periodicity/cash-ui/src/main/webapp/img/pollen.png =================================================================== (Binary files differ) Modified: branches/alpha3-periodicity/pom.xml =================================================================== --- branches/alpha3-periodicity/pom.xml 2009-08-24 09:22:24 UTC (rev 21) +++ branches/alpha3-periodicity/pom.xml 2009-08-24 09:38:34 UTC (rev 22) @@ -9,12 +9,12 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>mavenpom</artifactId> - <version>1.0.0-rc-5-SNAPSHOT</version> + <version>1.0.0</version> </parent> <groupId>org.chorem</groupId> <artifactId>cash</artifactId> - <version>1.0.0-alpha-2-SNAPSHOT</version> + <version>1.0.0-alpha-3-SNAPSHOT</version> <modules> <module>cash-ui</module> @@ -135,8 +135,7 @@ <!-- Nuiton librairies --> <topia.version>2.2.0-rc-5-SNAPSHOT</topia.version> <generator.version>1.0.0-rc-3</generator.version> - <jrst.version>1.0.0-rc-4-SNAPSHOT</jrst.version> - <skin.version>1.0.0-rc-2-SNAPSHOT</skin.version> + <jrst.version>1.0.0</jrst.version> <!-- ChoReg --> <choreg.version>1.0.0-alpha-2-SNAPSHOT</choreg.version> @@ -154,6 +153,24 @@ <chenillekit.version>1.0.2</chenillekit.version> </properties> + <build> + <defaultGoal>install</defaultGoal> + <pluginManagement> + <plugins> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <dependencies> + <dependency> + <groupId>org.nuiton.jrst</groupId> + <artifactId>doxia-module-jrst</artifactId> + <version>${jrst.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </pluginManagement> + </build> + <!-- ************************************************************* --> <!-- *** Build Environment ************************************** --> <!-- ************************************************************* -->
participants (1)
-
fdesbois@users.chorem.org