Author: bleny Date: 2011-01-09 18:14:18 +0000 (Sun, 09 Jan 2011) New Revision: 900 Log: refactor contacts Modified: trunk/pom.xml trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactFilterImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties trunk/wao-business/src/main/xmi/wao.zargo trunk/wao-ui/pom.xml trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ContactForm.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java trunk/wao-ui/src/main/resources/i18n/wao-ui_en_GB.properties trunk/wao-ui/src/main/resources/i18n/wao-ui_fr_FR.properties trunk/wao-ui/src/main/webapp/ContactForm.tml trunk/wao-ui/src/main/webapp/Contacts.tml trunk/wao-ui/src/main/webapp/css/contacts.css Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/pom.xml 2011-01-09 18:14:18 UTC (rev 900) @@ -50,7 +50,7 @@ </dependency> <dependency> <groupId>org.nuiton.web</groupId> - <artifactId>nuiton-tapestry-extra</artifactId> + <artifactId>nuiton-tapestry</artifactId> <version>${nuitonWebVersion}</version> </dependency> <!-- ToPIA --> @@ -330,7 +330,7 @@ <!-- libraries version --> <nuitonI18nVersion>2.1-SNAPSHOT</nuitonI18nVersion> <nuitonUtilsVersion>1.5.3</nuitonUtilsVersion> - <nuitonWebVersion>0.1</nuitonWebVersion> + <nuitonWebVersion>1.0-SNAPSHOT</nuitonWebVersion> <topiaVersion>2.5</topiaVersion> <eugeneVersion>2.3</eugeneVersion> <tapestryVersion>5.2.4</tapestryVersion> Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactFilterImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactFilterImpl.java 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactFilterImpl.java 2011-01-09 18:14:18 UTC (rev 900) @@ -49,6 +49,9 @@ getState() != null || isComment() || isCommentAdmin() || - isCommentCompany(); + isCommentCompany() || + getDataReliability() != null || + getFishingGearDCF() != null || + getTargetSpeciesDCF() != null; } } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2011-01-09 18:14:18 UTC (rev 900) @@ -42,6 +42,8 @@ import fr.ifremer.wao.bean.DataReliability; import fr.ifremer.wao.bean.SamplingStrategy; import fr.ifremer.wao.bean.UserRole; +import fr.ifremer.wao.bean.ValidationResult; +import fr.ifremer.wao.bean.ValidationResultImpl; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Contact; @@ -275,6 +277,151 @@ } } + @Override + protected ValidationResult executeValidateContact(TopiaContext transaction, Contact contact) throws Exception { + + boolean success = true; + String message = null; + + if (contact.getMainObserver() == null) { + success = false; + message = "Il faut au moins un observateur référant"; + } + + if (success && contact.getSecondaryObservers().contains(contact.getMainObserver())) { + success = false; + message = "L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires"; + } + + // Validation for saving contact depends on contactState + ContactState contactState = contact.getContactState(); + if (log.isDebugEnabled()) { + log.debug("For state : " + contactState); + } + + Date observationBeginDate = contact.getObservationBeginDate(); + if (success && observationBeginDate != null && ! contact.getSampleRow().isValid(observationBeginDate)) { + success = false; + message = "La date de début de la marée doit correspondre à un " + + "mois valide (non vide) de la ligne " + contact.getSampleRow().getCode(); + } + + Date observationEndDate = contact.getObservationEndDate(); + if (success && observationBeginDate != null && observationEndDate != null + && observationEndDate.before(observationBeginDate)) { + success = false; + message = "La date de fin d'observation ne peut pas être antérieure à celle du début"; + } + + Date currentDate = context.getCurrentDate(); + + if (success && observationEndDate != null && observationEndDate.after(currentDate)) { + success = false; + message = "La date de fin de la marée ne peut pas être postérieure à la date du jour"; + } + + Date dataInputDate = contact.getDataInputDate(); + if (success && observationEndDate != null && dataInputDate != null && observationEndDate.after(dataInputDate)) { + success = false; + message = "La date de saisie des données ne peut pas être antérieure à la date de fin de la marée"; + } + + if (success && dataInputDate != null && dataInputDate.after(currentDate)) { + success = false; + message = "La date de saisie des données ne peut pas être postérieure à la date du jour"; + } + + // Non abouti, Refus ou Refus Définitif + if (success && contactState.isUnfinishedState()) { + + Contact oldContact = null; + if (contact.getTopiaId() != null) { + oldContact = executeGetContact(transaction, contact.getTopiaId()); + } + + if (oldContact != null) { + + String newComment = contact.getComment(); + + boolean commentDefined = StringUtils.isNotEmpty(newComment); + boolean commentChanged = commentDefined && + !newComment.equals(oldContact.getComment()); + + // Ano #2540 : NPE on oldState, extract boolean for + // previous unfinishedState case + boolean previousUnfinishedState = commentDefined && + oldContact.getContactState() != null && oldContact.getContactState().isUnfinishedState(); + + // Ano #2440 : no restriction if previous state is unfinished + if (previousUnfinishedState || commentChanged) { + + // RAZ des champs + contact.setObservationBeginDate(null); + contact.setObservationEndDate(null); + contact.setNbObservants(0); + contact.setMammalsCapture(false); + contact.setMammalsObservation(false); + contact.setDataInputDate(null); + + } else { + success = false; + message = "Vous devez ajouter un commentaire pour l'état '" + contactState.libelle() + "'"; + } + } + // Embarquement Réalisé + } else if (success && contactState.equals(ContactState.BOARDING_DONE)) { + + if (observationBeginDate == null) { + success = false; + message = "La date de début de marée est obligatoire pour l'état '" + contactState.libelle() + "'"; + } + if (success && observationEndDate == null) { + success = false; + message = "La date de fin d'observation marée est obligatoire pour l'état '" + contactState.libelle() + "'"; + } + if (success && contact.getNbObservants() == 0) { + success = false; + message = "Il ne peut y avoir aucun observateur pour l'état '" + contactState.libelle() + "'"; + } + + if (log.isDebugEnabled()) { + log.debug("validationProgram = " + contact.isValidationProgram()); + } + } + + if (success && BooleanUtils.isTrue(contact.isValidationProgram())) { + + // it's an admin validation, data-reliability field must be filled + if (log.isDebugEnabled()) { + log.debug("field data reliability is " + contact.getDataReliability()); + } + + if (contact.getDataReliability() == null || + contact.getDataReliability() == DataReliability.UNKNOWN) { + success = false; + message = "Il faut préciser la qualité des données avant de valider"; + } else if (contact.getDataReliability() != DataReliability.RELIABLE + && StringUtils.isEmpty(contact.getCommentAdmin())) { + success = false; + message = "Il faut préciser dans le commentaire administrateur pourquoi la donnée n'est pas exploitable"; + } + } + + ValidationResult result = new ValidationResultImpl(); + result.setSuccess(success); + result.setMessage(message); + + if (log.isDebugEnabled()) { + String logMessage = "validation of contact " + contact + " return " + result.isSuccess(); + if ( ! result.isSuccess()) { + logMessage += ". reason is '" + result.getMessage() + "'"; + } + log.debug(logMessage); + } + + return result; + } + /** * Create or Update a Contact from {@code source} to {@code destination}. * The sampleMonth referenced to this contact will be automatically updated Modified: trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties 2011-01-09 18:14:18 UTC (rev 900) @@ -130,6 +130,7 @@ wao.error.serviceContact.saveContact= wao.error.serviceContact.sendContactDoneEmail= wao.error.serviceContact.updateSampleMonthTidesValue= +wao.error.serviceContact.validateContact= wao.error.serviceNews.getNewNews= wao.error.serviceNews.getNews= wao.error.serviceNews.saveNews= Modified: trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties 2011-01-09 18:14:18 UTC (rev 900) @@ -150,6 +150,7 @@ wao.error.serviceContact.saveContact=Impossible de sauvegarder le contact wao.error.serviceContact.sendContactDoneEmail= wao.error.serviceContact.updateSampleMonthTidesValue= +wao.error.serviceContact.validateContact= wao.error.serviceNews.getNewNews= wao.error.serviceNews.getNews=Impossible de r\u00E9cup\u00E9rer l'ensemble des news wao.error.serviceNews.saveNews=Impossible d'enregistrer la news ayant pour titre '%1$s' Modified: trunk/wao-business/src/main/xmi/wao.zargo =================================================================== (Binary files differ) Modified: trunk/wao-ui/pom.xml =================================================================== --- trunk/wao-ui/pom.xml 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-ui/pom.xml 2011-01-09 18:14:18 UTC (rev 900) @@ -41,7 +41,7 @@ </dependency> <dependency> <groupId>org.nuiton.web</groupId> - <artifactId>nuiton-tapestry-extra</artifactId> + <artifactId>nuiton-tapestry</artifactId> <scope>runtime</scope> </dependency> <!-- Tapestry framework + components --> Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ContactForm.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ContactForm.java 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ContactForm.java 2011-01-09 18:14:18 UTC (rev 900) @@ -7,6 +7,7 @@ import fr.ifremer.wao.bean.DataReliability; import fr.ifremer.wao.bean.ObsProgram; import fr.ifremer.wao.bean.UserRole; +import fr.ifremer.wao.bean.ValidationResult; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.WaoUser; @@ -182,9 +183,6 @@ /****************************** OBSERVERS *********************************/ - @Property - private boolean refreshObserversForm; - @Inject private Block viewObservers; @@ -260,16 +258,12 @@ getSecondaryObservers().add(observerToAdd); } } - - refreshObserversForm = true; return observersFormZone; } @Log public Zone onActionFromRemoveSecondaryObserver(int secondaryObserverIndex) { getSecondaryObservers().remove(secondaryObserverIndex); - - refreshObserversForm = true; return observersFormZone; } @@ -329,140 +323,162 @@ saveContact = true; } +// @Log +// void onValidateFormFromContactForm() { +// +// contactForm.clearErrors(); +// +// if ( ! saveContact) { +// return; +// } +// +// if (mainObserverId != null) { +// WaoUser mainObserver = getObserverSelectModel().findObject(mainObserverId); +// contact.setMainObserver(mainObserver); +// if (logger.isDebugEnabled()) { +// logger.debug("main observer is " + mainObserver); +// } +// } +// +// contact.setSecondaryObservers(getSecondaryObservers()); +// +// if (contact.getMainObserver() == null) { +// contactForm.recordError("Il faut au moins un observateur référant"); +// } +// +// if (contact.getSecondaryObservers().contains(contact.getMainObserver())) { +// contactForm.recordError("L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires"); +// } +// +// // Validation for saving contact depends on contactState (only edition +// // form) +// ContactState contactState = contact.getContactState(); +// if (logger.isDebugEnabled()) { +// logger.debug("For state : " + contactState); +// } +// +// Date begin = contact.getObservationBeginDate(); +// Date end = contact.getObservationEndDate(); +// Date input = contact.getDataInputDate(); +// SampleRow row = contact.getSampleRow(); +// +// if (logger.isDebugEnabled()) { +// logger.debug(String.format("begin = %s, end = %s, input = %s", begin, end, input)); +// } +// +// if (begin != null && !row.isValid(begin)) { +// contactForm.recordError( +// "La date de début de la marée doit correspondre à un " + +// "mois valide (non vide) de la ligne " + row.getCode()); +// } +// +// if (begin != null && end != null && end.before(begin)) { +// contactForm.recordError("La date de fin de la marée" + +// " ne peut pas être antérieure à celle de début"); +// } +// +// Date current = manager.getCurrentDate(); +// +// if (end != null && end.after(current)) { +// contactForm.recordError("La date de fin de la marée" + +// " ne peut pas être postérieure à la date du jour"); +// } +// +// if (end != null && input != null && end.after(input)) { +// contactForm.recordError("La date de saisie des" + +// " données ne peut pas être antérieure à la date de" + +// " fin de la marée"); +// } +// +// if (input != null && input.after(current)) { +// contactForm.recordError("La date de saisie des" + +// " données ne peut pas être postérieure à la date" + +// " du jour"); +// } +// +// // Non abouti, Refus ou Refus Définitif +// if (contactState.isUnfinishedState()) { +// String newComment = contact.getComment(); +// +// boolean commentDefined = StringUtils.isNotEmpty(newComment); +// boolean commentChanged = commentDefined && +// !newComment.equals(oldContact.getComment()); +// +// // Ano #2540 : NPE on oldState, extract boolean for +// // previous unfinishedState case +// boolean previousUnfinishedState = commentDefined && +// oldContact.getContactState() != null && oldContact.getContactState().isUnfinishedState(); +// +// // Ano #2440 : no restriction if previous state is unfinished +// if (previousUnfinishedState || commentChanged) { +// +// // RAZ des champs +// contact.setObservationBeginDate(null); +// contact.setObservationEndDate(null); +// contact.setNbObservants(0); +// contact.setMammalsCapture(false); +// contact.setMammalsObservation(false); +// contact.setDataInputDate(null); +// +// } else { +// contactForm.recordError("Vous devez ajouter" + +// " un commentaire pour l'état" + +// " '" + contactState.libelle() + "'"); +// } +// // Embarquement Réalisé +// } else if (contactState.equals(ContactState.BOARDING_DONE)) { +// +// if (begin == null) { +// contactForm.recordError("La date de début de" + +// " marée est obligatoire pour l'état" + +// " '" + contactState.libelle() + "'"); +// } +// if (end == null) { +// contactForm.recordError("La date de fin de" + +// " marée est obligatoire pour l'état" + +// " '" + contactState.libelle() + "'"); +// } +// if (contact.getNbObservants() == 0) { +// contactForm.recordError("Il ne peut y" + +// " avoir aucun observateur pour l'état" + +// " '" + contactState.libelle() + "'"); +// } +// +// if (logger.isDebugEnabled()) { +// logger.debug("ValidationProgram = " + contact.isValidationProgram()); +// } +// +// if (BooleanUtils.isTrue(contact.isValidationProgram())) { +// +// // it's an admin validation, data-reliability field must be filled +// if (logger.isDebugEnabled()) { +// logger.debug("field data reliability is " + +// contact.getDataReliability()); +// } +// +// if (contact.getDataReliability() == null || +// contact.getDataReliability() == DataReliability.UNKNOWN) { +// contactForm.recordError("Il faut préciser la qualité des données avant de valider"); +// } +// } +// } +// } + @Log void onValidateFormFromContactForm() { - contactForm.clearErrors(); - if ( ! saveContact) { - return; - } - - if (mainObserverId == null) { - contactForm.recordError("Il faut au moins un observateur"); - } else { + if (mainObserverId != null) { WaoUser mainObserver = getObserverSelectModel().findObject(mainObserverId); - if (logger.isDebugEnabled()) { - logger.debug("main observer is " + mainObserver); - } contact.setMainObserver(mainObserver); - contact.setSecondaryObservers(getSecondaryObservers()); } + contact.setSecondaryObservers(getSecondaryObservers()); - // Validation for saving contact depends on contactState (only edition - // form) - ContactState contactState = contact.getContactState(); - if (logger.isDebugEnabled()) { - logger.debug("For state : " + contactState); + ValidationResult validationResult = serviceContact.validateContact(contact); + if ( ! validationResult.isSuccess()) { + contactForm.recordError(validationResult.getMessage()); } - - Date begin = contact.getObservationBeginDate(); - Date end = contact.getObservationEndDate(); - Date input = contact.getDataInputDate(); - SampleRow row = contact.getSampleRow(); - - if (logger.isDebugEnabled()) { - logger.debug(String.format("begin = %s, end = %s, input = %s", begin, end, input)); - } - - if (begin != null && !row.isValid(begin)) { - contactForm.recordError( - "La date de début de la marée doit correspondre à un " + - "mois valide (non vide) de la ligne " + row.getCode()); - } - - if (begin != null && end != null && end.before(begin)) { - contactForm.recordError("La date de fin de la marée" + - " ne peut pas être antérieure à celle de début"); - } - - Date current = manager.getCurrentDate(); - - if (end != null && end.after(current)) { - contactForm.recordError("La date de fin de la marée" + - " ne peut pas être postérieure à la date du jour"); - } - - if (end != null && input != null && end.after(input)) { - contactForm.recordError("La date de saisie des" + - " données ne peut pas être antérieure à la date de" + - " fin de la marée"); - } - - if (input != null && input.after(current)) { - contactForm.recordError("La date de saisie des" + - " données ne peut pas être postérieure à la date" + - " du jour"); - } - - // Non abouti, Refus ou Refus Définitif - if (contactState.isUnfinishedState()) { - String newComment = contact.getComment(); - - boolean commentDefined = StringUtils.isNotEmpty(newComment); - boolean commentChanged = commentDefined && - !newComment.equals(oldContact.getComment()); - - // Ano #2540 : NPE on oldState, extract boolean for - // previous unfinishedState case - boolean previousUnfinishedState = commentDefined && - oldContact.getContactState() != null && oldContact.getContactState().isUnfinishedState(); - - // Ano #2440 : no restriction if previous state is unfinished - if (previousUnfinishedState || commentChanged) { - - // RAZ des champs - contact.setObservationBeginDate(null); - contact.setObservationEndDate(null); - contact.setNbObservants(0); - contact.setMammalsCapture(false); - contact.setMammalsObservation(false); - contact.setDataInputDate(null); - - } else { - contactForm.recordError("Vous devez ajouter" + - " un commentaire pour l'état" + - " '" + contactState.libelle() + "'"); - } - // Embarquement Réalisé - } else if (contactState.equals(ContactState.BOARDING_DONE)) { - - if (begin == null) { - contactForm.recordError("La date de début de" + - " marée est obligatoire pour l'état" + - " '" + contactState.libelle() + "'"); - } - if (end == null) { - contactForm.recordError("La date de fin de" + - " marée est obligatoire pour l'état" + - " '" + contactState.libelle() + "'"); - } - if (contact.getNbObservants() == 0) { - contactForm.recordError("Il ne peut y" + - " avoir aucun observateur pour l'état" + - " '" + contactState.libelle() + "'"); - } - - if (logger.isDebugEnabled()) { - logger.debug("ValidationProgram = " + contact.isValidationProgram()); - } - - if (BooleanUtils.isTrue(contact.isValidationProgram())) { - - // it's an admin validation, data-reliability field must be filled - if (logger.isDebugEnabled()) { - logger.debug("field data reliability is " + - contact.getDataReliability()); - } - - if (contact.getDataReliability() == null || - contact.getDataReliability() == DataReliability.UNKNOWN) { - contactForm.recordError("Il faut préciser la qualité des données avant de valider"); - } - } - } } - @Log Object onFailureFromContactForm() { // refresh zone to show errors Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2011-01-09 18:14:18 UTC (rev 900) @@ -30,9 +30,9 @@ import fr.ifremer.wao.bean.ContactFilter; import fr.ifremer.wao.bean.ContactFilterImpl; import fr.ifremer.wao.bean.ContactState; -import fr.ifremer.wao.bean.DataReliability; import fr.ifremer.wao.bean.SamplingFilter; import fr.ifremer.wao.bean.UserRole; +import fr.ifremer.wao.bean.ValidationResult; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.SampleRow; @@ -51,7 +51,6 @@ import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.tapestry5.ComponentResources; -import org.apache.tapestry5.Field; import org.apache.tapestry5.RenderSupport; import org.apache.tapestry5.StreamResponse; import org.apache.tapestry5.annotations.Environmental; @@ -62,12 +61,10 @@ import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.beaneditor.BeanModel; -import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.ioc.services.PropertyAccess; -import org.apache.tapestry5.json.JSONObject; import org.apache.tapestry5.services.BeanModelSource; import org.apache.tapestry5.upload.services.UploadedFile; import org.slf4j.Logger; @@ -76,9 +73,7 @@ import java.io.InputStream; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Calendar; -import java.util.Date; import java.util.GregorianCalendar; import java.util.List; @@ -93,7 +88,6 @@ @SuppressWarnings({"UnusedDeclaration"}) @RequiresAuthentication(allowedRoles = {UserRole.ADMIN, UserRole.COORDINATOR, UserRole.OBSERVER}) @Import(stylesheet = "context:css/contacts.css") -//@IncludeJavaScriptLibrary("context:js/contacts.js") public class Contacts extends AbstractFilteredPage { @Inject @@ -112,14 +106,19 @@ @Environmental private RenderSupport renderSupport; + @Inject + private WaoManager manager; + + @Inject + private Messages messages; + + public String getLabelForEnum(Enum value) { + return messages.get(value.getDeclaringClass().getSimpleName() + "." + value.name()); + } + @Log void setupRender() throws WaoException { - if (logger.isDebugEnabled()) { - logger.debug("RESET DATA"); - logger.debug("User : " + user.getFullName()); - } contacts = null; - contactsForm.clearErrors(); // Initialize filters if needed if (isFiltersVisible()) { initSelectFilters(true, true, true); @@ -132,13 +131,9 @@ initCompanyFilter(); } - /** - * Add script to renderSupport - */ @Log void afterRender() { - //addCommentScript(); - //addSendEmailScript(); + contactSelectedId = null; } /**************************** CONTACT FILTERS *****************************/ @@ -233,7 +228,6 @@ if (logger.isDebugEnabled()) { logger.debug("change sample row code in filter to " + getFilter().getSampleRow()); } - edited = true; } /**************************** CONTACT IMPORT/EXPORT ***********************/ @@ -331,6 +325,9 @@ private GenericSelectModel<WaoUser> userSelectModel; + @Persist + private String contactSelectedId; + @Property @Persist private String contactUserId; @@ -389,6 +386,16 @@ return manager.getTooltipBoat(contact.getBoat()); } + public String getSecondaryObservers() { + StringBuilder result = new StringBuilder(); + result.append(contact.getMainObserver().getFullName()); + for (WaoUser observer : contact.getSecondaryObservers()) { + result.append(", "); + result.append(observer.getFullName()); + } + return result.toString(); + } + public String getTooltipExportFrom() throws WaoException { if (getContactFilter().getFromDate() != null) { return "depuis le " + getDateFormat().format(getContactFilter().getFromDate()); @@ -416,11 +423,6 @@ return new SimpleDateFormat("dd/MM/yyyy HH:mm"); } - public boolean isEditionMode() { - //return contact.getTopiaId().equals(contactEditedId); - return contactEdited != null && contact.equals(contactEdited); - } - public boolean isEmpty(Boolean validation) { return validation == null; } @@ -431,30 +433,6 @@ /**************************** CONTACT ROW ACTION **************************/ - public boolean canUpdateDataReliability() { - boolean result = user.isAdmin() && ! user.isReadOnly() && - contact.getValidationProgram() == null; - return result; - } - - - /** - * Flag to know if it's only edition (=true) or save action (=false) - */ - private boolean edited; - - private boolean deleted; - - @Persist - @Property - private Contact contactEdited; - - @Persist - private String oldComment; - - @Persist - private ContactState oldState; - public boolean hasActions() { return !user.isAdmin() && contact.getValidationCompany() == null && !user.isReadOnly(); @@ -472,9 +450,6 @@ public boolean canValidate() { // Can't validate during edition of the contact row - if (isEditionMode()) { - return false; - } switch (user.getRole()) { case ADMIN: return contact.getValidationProgram() == null && @@ -505,519 +480,83 @@ } } - void onSelectedFromAcceptContact(String contactId) throws WaoException { + /****************************************** CONTACT ACTIONS *******************************************************/ + + private Contact modifiedContact; + + @Log + void onActionFromAcceptContact(String contactId) throws WaoException { if (logger.isDebugEnabled()) { logger.debug("Accept contact : " + contactId); } - contactEdited = getContacts().get(contactId); + contactSelectedId = contactId; + modifiedContact = getContacts().get(contactId); if (user.isAdmin()) { - contactEdited.setValidationProgram(Boolean.TRUE); + modifiedContact.setValidationProgram(Boolean.TRUE); } else { - // For company accepted, addRealTideTime -// contactEdited.getSampleRow().addRealTideTime(contactEdited); - contactEdited.setValidationCompany(Boolean.TRUE); + modifiedContact.setValidationCompany(Boolean.TRUE); } + saveContact(modifiedContact); } - void onSelectedFromRefuseContact(String contactId) throws WaoException { + @Log + void onActionFromUnvalidateContact(String contactId) throws WaoException { if (logger.isDebugEnabled()) { - logger.debug("Refuse contact : " + contactId); + logger.debug("Unvalidate contact : " + contactId); } - contactEdited = getContacts().get(contactId); + contactSelectedId = contactId; + modifiedContact = getContacts().get(contactId); if (user.isAdmin()) { - // For program refused, removeRealTideTime -// contactEdited.getSampleRow().removeRealTideTime(contactEdited); - contactEdited.setValidationProgram(Boolean.FALSE); + modifiedContact.setValidationProgram(null); } else { - contactEdited.setValidationCompany(Boolean.FALSE); + modifiedContact.setValidationCompany(null); } + saveContact(modifiedContact); } - void onSelectedFromUnvalidateContact(String contactId) throws WaoException { + @Log + void onActionFromRefuseContact(String contactId) throws WaoException { if (logger.isDebugEnabled()) { - logger.debug("Unvalidate contact : " + contactId); + logger.debug("Refuse contact : " + contactId); } - contactEdited = getContacts().get(contactId); + contactSelectedId = contactId; + modifiedContact = getContacts().get(contactId); if (user.isAdmin()) { - // For program unvalidate from previous refused validation, addRealTideTime -// if (BooleanUtils.isFalse(contactEdited.getValidationProgram())) { -// contactEdited.getSampleRow().addRealTideTime(contactEdited); -// } - contactEdited.setValidationProgram(null); + modifiedContact.setValidationProgram(Boolean.FALSE); } else { - // For company unvalidate from previous accepted validation, - // removeRealTideTime -// if (BooleanUtils.isTrue(contactEdited.getValidationCompany())) { -// contactEdited.getSampleRow().removeRealTideTime(contactEdited); -// } - contactEdited.setValidationCompany(null); + modifiedContact.setValidationCompany(Boolean.FALSE); } + saveContact(modifiedContact); } - @Log - void onSelectedFromEditContact(String contactId) throws WaoException { - if (logger.isDebugEnabled()) { - logger.debug("Edit contact : " + contactId); - logger.debug("Contact : " + getContacts().get(contactId)); - logger.debug("Set observerId : " + getContacts().get(contactId).getMainObserver()); + protected void saveContact(Contact contact) { + ValidationResult validationResult = serviceContact.validateContact(contact); + if (validationResult.isSuccess()) { + serviceContact.saveContact(contact, false); + } else { + layout.addError(validationResult.getMessage()); } - contactEdited = getContacts().get(contactId); //prepareContactEdited(contactId); - contactUserId = contactEdited.getMainObserver().getId(); - //contactEditedId = contactId; - contactSelectedId = contactId; - oldComment = contactEdited.getComment(); - oldState = contactEdited.getContactState(); - edited = true; } @Log - void onSelectedFromDeleteContact(String contactId) throws WaoException { + void onActionFromDeleteContact(String contactId) throws WaoException { if (logger.isDebugEnabled()) { logger.debug("Delete contact : " + contactId); } - contactEdited = getContacts().get(contactId); - deleted = true; + contactSelectedId = contactId; + modifiedContact = getContacts().get(contactId); + serviceContact.saveContact(modifiedContact, true); } - @Log - void onSelectedFromSaveContact(String contactId) throws WaoException { - if (logger.isDebugEnabled()) { - logger.debug("Save contact : " + contactId); - logger.debug("Observer Id : " + contactUserId); - } - // ContactEdited is in session, previously set by Edit action -// contactEdited.setState(contactState.toString()); -// WaoUser contactUser = getUserSelectModel().findObject(contactUserId); -// contactEdited.setMainObserver(contactUser); - - if (logger.isDebugEnabled()) { - logger.debug("Comment : " + contactEdited.getComment()); - } - } - - void onSelectedFromCancelEditContact() throws WaoException { - contactEdited = null; - edited = true; - } - - /**************************** CONTACT SAVE ********************************/ - - @Persist//(PersistenceConstants.FLASH) - private String contactSelectedId; - - @InjectComponent - private Form contactsForm; - - @InjectComponent - private Zone gridZone; - - @InjectComponent - private Field beginDate; - - @InjectComponent - private Field endDate; - - @InjectComponent - private Field nbObservants; - - @InjectComponent - private Field comment; - - @InjectComponent - private Field inputDate; - - @Inject - private WaoManager manager; - - @Inject - private Messages messages; - - @Property - private boolean sendEmail; - - protected void addSendEmailScript() { - // Ask user to send an email if not already sent - if (contactEdited != null && !contactEdited.getEmailSent()) { - - String confirmMessage = - "Souhaitez vous envoyer un email de demande d\\'ajout " + - "du navire à votre portefeuille Allegro afin de pouvoir " + - "saisir les données ?"; - - // TODO-fdesbois-2010-07-27 : manage array of states in JavaScript - renderSupport.addScript("new ContactSendEmail('%s', '%s');", - confirmMessage, - // Check state BOARDING_DONE - ContactState.BOARDING_DONE.name()); - - renderSupport.addScript("new ContactSendEmail('%s', '%s');", - confirmMessage, - // Check state BOARDING_EXPECTED - ContactState.BOARDING_EXPECTED.name()); - } - } - - @Log - void onValidateFormFromContactsForm() { - contactsForm.clearErrors(); - // Validation for saving contact depends on contactState (only edition - // form) - if (!edited && contactEdited != null) { - ContactState contactState = contactEdited.getContactState(); - if (logger.isDebugEnabled()) { - logger.debug("For state : " + contactState); - } - - Date begin = contactEdited.getObservationBeginDate(); - Date end = contactEdited.getObservationEndDate(); - Date input = contactEdited.getDataInputDate(); - SampleRow row = contactEdited.getSampleRow(); - //DateFormat dateFormat = new SimpleDateFormat("MM/yyyy"); - - if (begin != null && !row.isValid(begin)) { - contactsForm.recordError(beginDate, - "La date de début de la marée doit correspondre à un " + - "mois valide (non vide) de la ligne " + row.getCode()); - } - - if (begin != null && end != null && end.before(begin)) { - contactsForm.recordError(endDate, "La date de fin de la marée" + - " ne peut pas être antérieure à celle de début"); - } - - Date current = manager.getCurrentDate(); - - if (end != null && end.after(current)) { - contactsForm.recordError(endDate, "La date de fin de la marée" + - " ne peut pas être postérieure à la date du jour"); - } - - if (end != null && input != null && end.after(input)) { - contactsForm.recordError(inputDate, "La date de saisie des" + - " données ne peut pas être antérieure à la date de" + - " fin de la marée"); - } - - if (input != null && input.after(current)) { - contactsForm.recordError(inputDate, "La date de saisie des" + - " données ne peut pas être postérieure à la date" + - " du jour"); - } - - if (contactEdited.getMainObserver() == null) { - contactsForm.recordError("Il faut un observateur référant"); - } - - // Non abouti, Refus ou Refus Définitif - if (contactState.isUnfinishedState()) { - String newComment = contactEdited.getComment(); - - boolean commentDefined = StringUtils.isNotEmpty(newComment); - boolean commentChanged = commentDefined && - !newComment.equals(oldComment); - - // Ano #2540 : NPE on oldState, extract boolean for - // previous unfinishedState case - boolean previousUnfinishedState = commentDefined && - oldState != null && oldState.isUnfinishedState(); - - // Ano #2440 : no restriction if previous state is unfinished - if (previousUnfinishedState || commentChanged) { - - // RAZ des champs - contactEdited.setObservationBeginDate(null); - contactEdited.setObservationEndDate(null); - contactEdited.setNbObservants(0); - contactEdited.setMammalsCapture(false); - contactEdited.setMammalsObservation(false); - contactEdited.setDataInputDate(null); - - } else { - contactsForm.recordError(comment, "Vous devez ajouter" + - " un commentaire pour l'état" + - " '" + contactState.libelle() + "'"); - } - // Embarquement Réalisé - } else if (contactState.equals(ContactState.BOARDING_DONE)) { - - if (begin == null) { - contactsForm.recordError(beginDate, "La date de début de" + - " marée est obligatoire pour l'état" + - " '" + contactState.libelle() + "'"); - } - if (end == null) { - contactsForm.recordError(endDate, "La date de fin de" + - " marée est obligatoire pour l'état" + - " '" + contactState.libelle() + "'"); - } - if (contactEdited.getNbObservants() == 0) { - contactsForm.recordError(nbObservants, "Il ne peut y" + - " avoir aucun observateur pour l'état" + - " '" + contactState.libelle() + "'"); - } - - if (logger.isDebugEnabled()) { - logger.debug("ValidationProgram = " + contactEdited.isValidationProgram()); - } - - if (BooleanUtils.isTrue(contactEdited.isValidationProgram())) { - - // it's an admin validation, data-reliability field must be filled - if (logger.isDebugEnabled()) { - logger.debug("field data reliability is " + - contactEdited.getDataReliability()); - } - - if (contactEdited.getDataReliability() == null || - contactEdited.getDataReliability() == DataReliability.UNKNOWN) { - contactsForm.recordError("Il faut préciser la qualité des données avant de valider"); - } - } - } - } - } - - @Log - Object onSuccessFromContactsForm() { - if (!edited && contactEdited != null) { - if (logger.isDebugEnabled()) { - logger.debug("Contact save : " + contactEdited); - logger.debug("Contact sendEmail : " + sendEmail); - } - serviceContact.saveContact(contactEdited, deleted); - - try { - if (sendEmail && serviceContact.sendContactDoneEmail(contactEdited)) { - layout.addInfo("Un email a été envoyé pour l'ajout du navire au portefeuille ALLEGRO."); - } - } catch (WaoBusinessException eee) { - String message = manager.getErrorMessage(eee, messages, logger); - layout.addError(message); - } - - contactSelectedId = contactEdited.getTopiaId(); - oldComment = null; - contactEdited = null; - } - return this; - } - - @Log - Object onFailureFromContactsForm() { - if (logger.isDebugEnabled()) { - logger.debug("Contact can't be saved with errors"); - } - - // ANO #2565 : - // ContactEdited need to be reset if a validationProgram error occurs - // isEditionMode need to return false to avoid conflict with other save - if (BooleanUtils.isTrue(contactEdited.isValidationProgram())) { - contactEdited = null; - } - - return contactsForm; - } - public void createNewContact(Boat boat, SampleRow sampleRow) throws WaoException { contact = serviceContact.getNewContact(user.getUser(), sampleRow, boat); // Check boat not null and validation for create the new contact if (boat != null && boat.canCreateContact(user.getCompany())) { serviceContact.saveContact(contact, Boolean.FALSE); - contactSelectedId = contact.getTopiaId(); + String contactSelectedId = contact.getTopiaId(); } else { layout.addError("Un contact en cours existe déjà pour ce navire"); } } - /****************************** COMMENT POPUP *****************************/ - - @Property - private String contactId; - - @Property - private String extraComment; - - protected void addCommentScript() { - renderSupport.addScript("commentController = new ContactComment('" + - contactsForm.getClientId() + "');"); - } - - /** - * Retrieve the current contact comment depends on edition. Also a comment - * can be added separatly by admin or coordinator. - * - * @return the current contact comment used for edition in commentWindow - * @see #getCommentData() - */ - public String getContactComment() { - String comment = null; - if (isEditionMode()) { - comment = contact.getComment(); - } else { - switch (user.getRole()) { - case ADMIN: - comment = contact.getCommentAdmin(); break; - case COORDINATOR: - comment = contact.getCommentCoordinator(); - } - } - return comment == null ? "" : comment.replace("'", "\'"); - } - - /** - * Prepare comment data for commentController javascript. This data is - * used to open the comment window in javascript. - * - * @return a JSONObject that contains data needed for javascript - */ - public JSONObject getCommentData() { - JSONObject json = new JSONObject(); - if (isEditionMode()) { - json.put("formId", contactsForm.getClientId()); - } - json.put("id", contact.getId()); - json.put("edited", isEditionMode()); - json.put("unfinished", contact.getContactState().isUnfinishedState()); - json.put("comment", getContactComment()); - return json; - } - - @Log - void onSuccessFromCommentForm() { - serviceContact.saveComment(contactId, user.getRole(), extraComment); - } - - /****************************** OBSERVERS POPUP ***************************/ - - @Property - @Persist - private boolean observersFormZoneVisible; - - @InjectComponent - private Zone observersFormZone; - - @InjectComponent - private Form observersForm; - - private boolean saveObservers; - - @Persist - private List<WaoUser> secondaryObservers; - - @Persist - @Property - private String selectedSecondaryObserverId; - - @Property - private int secondaryObserverIndex; - - @Property - private WaoUser observer; // for loop - - public List<WaoUser> getSecondaryObservers() { - if (secondaryObservers == null) { - secondaryObservers = new ArrayList<WaoUser>(contactEdited.getSecondaryObservers()); - } - return secondaryObservers; - } - - public String getSecondaryObserversDescription() { - StringBuilder result = new StringBuilder(); - result.append(contact.getMainObserver().getFullName()); - for (WaoUser observer : contact.getSecondaryObservers()) { - result.append(", "); - result.append(observer.getFullName()); - } - return result.toString(); - } - - @Log - public Zone onActionFromShowObserversForm() { - contactUserId = contactEdited.getMainObserver().getTopiaId(); - - // show form - observersFormZoneVisible = true; - return observersFormZone; - } - - @Log - public void onChangeFromSecondaryObserver(String value) { - if (StringUtils.isEmpty(value)) { - selectedSecondaryObserverId = null; - } else { - selectedSecondaryObserverId = value; - } - if (logger.isDebugEnabled()) { - logger.debug("selected observer changed to " + selectedSecondaryObserverId); - } - } - - @Log - public void onChangeFromMainObserver(String value) { - if (StringUtils.isEmpty(value)) { - contactUserId = null; - } else { - contactUserId = value; - } - } - - - @Log - public Zone onActionFromAddSecondaryObserver() { - if (selectedSecondaryObserverId != null) { - WaoUser observerToAdd = getObserverSelectModel().findObject(selectedSecondaryObserverId); - - if (observerToAdd == null) { - logger.error("observerToAdd is null, id is " + selectedSecondaryObserverId); - } else if ( ! getSecondaryObservers().contains(observersForm)) { - - getSecondaryObservers().add(observerToAdd); - } - } - return observersFormZone; - } - - @Log - public Zone onActionFromRemoveSecondaryObserver(int secondaryObserverIndex) { - getSecondaryObservers().remove(secondaryObserverIndex); - return observersFormZone; - } - - @Log - public void onSelectedFromCancelEditObservers() { - saveObservers = false; - } - - @Log - public void onSelectedFromSaveObservers() { - saveObservers = true; - } - - @Log - public void onValidateFromObserversForm() { - if (saveObservers) { - if (contactUserId == null) { - observersForm.recordError("Il faut renseigner au moins un observateur"); - } - } - } - - @Log - public Object onSuccessFromObserversForm() { - if (saveObservers) { - WaoUser mainObserver = getObserverSelectModel().findObject(contactUserId); - if (logger.isDebugEnabled()) { - logger.debug("main observer is " + mainObserver); - } - contactEdited.setMainObserver(mainObserver); - contactEdited.setSecondaryObservers(getSecondaryObservers()); - } - observersFormZoneVisible = false; - return this; - } - - public String getLabelForEnum(Enum value) { - return messages.get(value.getDeclaringClass().getSimpleName() + "." + value.name()); - } - } Modified: trunk/wao-ui/src/main/resources/i18n/wao-ui_en_GB.properties =================================================================== --- trunk/wao-ui/src/main/resources/i18n/wao-ui_en_GB.properties 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-ui/src/main/resources/i18n/wao-ui_en_GB.properties 2011-01-09 18:14:18 UTC (rev 900) @@ -88,6 +88,7 @@ wao.ui.field.SampleRow.profession= wao.ui.field.SampleRow.programName= wao.ui.field.User.firstName= +wao.ui.field.User.lastName= wao.ui.field.User.login= wao.ui.field.UserProfile.userRole= wao.ui.field.WaoUser.login= @@ -107,6 +108,7 @@ wao.ui.form.programEvaluation= wao.ui.form.readOnly= wao.ui.form.removeRole= +wao.ui.form.roles= wao.ui.import.activityCalendarImportLabel= wao.ui.import.activityCalendarImportRunning= wao.ui.import.activityCalendarLabel= Modified: trunk/wao-ui/src/main/resources/i18n/wao-ui_fr_FR.properties =================================================================== --- trunk/wao-ui/src/main/resources/i18n/wao-ui_fr_FR.properties 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-ui/src/main/resources/i18n/wao-ui_fr_FR.properties 2011-01-09 18:14:18 UTC (rev 900) @@ -69,7 +69,8 @@ wao.ui.field.SampleRow.profession=M\u00E9tier wao.ui.field.SampleRow.programName=Programme wao.ui.field.User.firstName=Pr\u00E9nom -wao.ui.field.User.login=identifiant +wao.ui.field.User.lastName=Nom +wao.ui.field.User.login=Identifiant wao.ui.field.UserProfile.userRole=R\u00F4le wao.ui.field.WaoUser.login=Identifiant wao.ui.field.WaoUser.password=Mot de passe @@ -88,6 +89,7 @@ wao.ui.form.programEvaluation=\u00C9valuation programme wao.ui.form.readOnly=lecture seule wao.ui.form.removeRole=retirer ce role +wao.ui.form.roles=R\u00F4les wao.ui.import.activityCalendarImportLabel=de l'import des calendriers d'activit\u00E9 wao.ui.import.activityCalendarImportRunning=Import des calendriers d'activit\u00E9 en cours. Vous pouvez continuer \u00E0 naviguer sur le site en attendant la fin du chargement. wao.ui.import.activityCalendarLabel=des calendriers d'activit\u00E9 Modified: trunk/wao-ui/src/main/webapp/ContactForm.tml =================================================================== --- trunk/wao-ui/src/main/webapp/ContactForm.tml 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-ui/src/main/webapp/ContactForm.tml 2011-01-09 18:14:18 UTC (rev 900) @@ -71,7 +71,7 @@ <t:block id="editObservers"> <div> - <t:label t:for="mainObserver" /> + <label for="mainObserver">${message:wao.ui.field.Contact.mainObserver}</label> <input t:type="select" t:id="mainObserver" t:model="observerSelectModel" t:validate="required" t:value="mainObserverId" /> </div> <t:zone t:id="observersFormZone" t:visible="true" t:update="show"> @@ -161,19 +161,17 @@ </t:if> </div> - <t:unless test="connectedUser.observer"> - <div> - <label>${message:wao.ui.field.Contact.commentCoordinator}</label> - <t:if t:test="contact.commentCoordinator"> - <div class="value"> - ${contact.commentCoordinator} - </div> - <p:else> - <em>${message:wao.ui.misc.noComment}</em> - </p:else> - </t:if> - </div> - </t:unless> + <div> + <label>${message:wao.ui.field.Contact.commentCoordinator}</label> + <t:if t:test="contact.commentCoordinator"> + <div class="value"> + ${contact.commentCoordinator} + </div> + <p:else> + <em>${message:wao.ui.misc.noComment}</em> + </p:else> + </t:if> + </div> </t:block> <t:block id="editObservationReport"> @@ -208,10 +206,6 @@ <input t:type="checkbox" t:id="mammalsCapture" value="contact.mammalsCapture" /> </div> <div> - <label for="observerComment">${message:wao.ui.field.Contact.dataInputDate}</label> - <input t:type="textarea" t:id="observerComment" value="contact.comment" /> - </div> - <div> <label for="inputDate">${message:wao.ui.field.Contact.dataInputDate}</label> <input t:type="datefield" t:id="inputDate" class="date" value="contact.dataInputDate" /> </div> Modified: trunk/wao-ui/src/main/webapp/Contacts.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Contacts.tml 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-ui/src/main/webapp/Contacts.tml 2011-01-09 18:14:18 UTC (rev 900) @@ -184,251 +184,129 @@ </t:if> </p> <t:zone t:id="gridZone"> - <form t:type="form" t:id="contactsForm" t:zone="gridZone"> - <t:errors id="so-contact-form-errors" t:banner="message:contactsForm-errors-banner"/> - <input t:type="hidden" t:id="hiddenSendEmail" t:value="sendEmail" /> - <div t:type="grid" t:source="contacts" t:row="contact" class="t-data-grid ${gridClass}" t:model="contactModel" t:rowClass="prop:rowClass" - t:rowsPerPage="20"> - <p:mainObserverCell> - <t:if test="contact.secondaryObservers"> - <span t:type="ck/Tooltip" title="${message:wao.ui.field.Contact.secondaryObservers}" t:value="prop:secondaryObserversDescription" t:effect="appear"> - ${contact.mainObserver.fullName}… - </span> - <p:else> - ${contact.mainObserver.fullName} - </p:else> - </t:if> - <!--t:if t:test="editionMode"> - <a t:type="actionlink" t:id="showObserversForm" t:zone="observersFormZone" context="${contact.topiaId}" class="display-form" title="Modifier les observateurs associés à ce contact">...</a> - </t:if--> - </p:mainObserverCell> - <p:sampleRowCell> - <span t:type="ck/Tooltip" title="Infos" t:value="prop:sampleRowDescription" t:effect="appear"> - ${contact.sampleRow.code} + <div t:type="grid" t:source="contacts" t:row="contact" class="t-data-grid ${gridClass}" t:model="contactModel" t:rowClass="prop:rowClass" + t:rowsPerPage="20"> + <p:mainObserverCell> + <t:if test="contact.secondaryObservers"> + <span t:type="ck/Tooltip" title="${message:wao.ui.field.Contact.secondaryObservers}" t:value="prop:secondaryObservers" t:effect="appear"> + ${contact.mainObserver.fullName}… </span> - </p:sampleRowCell> - <p:topiaCreateDateCell> - <t:output value="contact.topiaCreateDate" format="dateFormat" /> - </p:topiaCreateDateCell> - <p:boatCell> - <span t:type="ck/Tooltip" title="Infos" t:value="prop:boatDescription" t:effect="appear"> - ${contact.boat.name} + <p:else> + ${contact.mainObserver.fullName} + </p:else> + </t:if> + </p:mainObserverCell> + <p:sampleRowCell> + <span t:type="ck/Tooltip" title="Infos" t:value="prop:sampleRowDescription" t:effect="appear"> + ${contact.sampleRow.code} + </span> + </p:sampleRowCell> + <p:topiaCreateDateCell> + <t:output value="contact.topiaCreateDate" format="dateFormat" /> + </p:topiaCreateDateCell> + <p:boatCell> + <span t:type="ck/Tooltip" title="Infos" t:value="prop:boatDescription" t:effect="appear"> + ${contact.boat.name} + </span> + </p:boatCell> + <p:stateCell> + ${getLabelForEnum(contact.contactState)} + </p:stateCell> + <p:observationBeginDateCell> + <t:output value="contact.observationBeginDate" format="dateTimeFormat" /> + </p:observationBeginDateCell> + <p:observationEndDateCell> + <t:output value="contact.observationEndDate" format="dateTimeFormat" /> + </p:observationEndDateCell> + <p:nbObservantsCell> + ${contact.nbObservants} + </p:nbObservantsCell> + <p:mammalsCell> + <t:if t:test="contact.mammalsObservation"> + <img src="${asset:context:img/eye-22px.png}" alt="Observations" title="Observations" /> + </t:if> + <t:if t:test="contact.mammalsCapture"> + <img src="${asset:context:img/fishing-net-22px.png}" alt="Captures" title="Captures" /> + </t:if> + </p:mammalsCell> + <p:validationCell> + <t:booleanImage t:value="contact.validationCompany" t:empty="isEmpty(contact.validationCompany)" + t:emptyTitle="Non validé par la société" + t:trueTitle="Validé par la société" t:falseTitle="Refusé par la société"/> + <t:booleanImage t:value="contact.validationProgram" t:empty="isEmpty(contact.validationProgram)" + t:emptyTitle="Non validé par le programme" + t:trueTitle="Validé par le programme" t:falseTitle="Refusé par le programme"/> + </p:validationCell> + <p:dataInputDateCell> + <t:output value="contact.dataInputDate" format="dateFormat" /> + </p:dataInputDateCell> + <p:commentCell> + <t:if t:test="contact.comment"> + <span t:type="ck/Tooltip" title="Commentaire" t:value="${getCommentTooltip(contact.comment)}" t:effect="appear"> + ${getCommentDisplayText(contact.comment)} </span> - </p:boatCell> - <p:stateCell> - <t:if t:test="editionMode"> - <input t:type="select" t:id="contactState" t:value="contactEdited.contactState" t:validate="required"/> - <p:else>${contact.contactState.libelle()}</p:else> + </t:if> + </p:commentCell> + <p:dataReliabilityCell> + <t:if t:test="boardingDone"> + <t:if t:test="contact.validationCompany"> + ${getLabelForEnum(contact.dataReliability)} </t:if> - </p:stateCell> - <p:observationBeginDateCell> - <t:if t:test="editionMode"> - <input t:type="datefield" t:id="beginDate" class="date" value="contactEdited.observationBeginDate" /> - <p:else><t:output value="contact.observationBeginDate" format="dateTimeFormat" /></p:else> - </t:if> - </p:observationBeginDateCell> - <p:observationEndDateCell> - <t:if t:test="editionMode"> - <input t:type="datefield" t:id="endDate" class="date" value="contactEdited.observationEndDate" /> - <p:else><t:output value="contact.observationEndDate" format="dateTimeFormat" /></p:else> - </t:if> - </p:observationEndDateCell> - <p:nbObservantsCell> - <t:if t:test="editionMode"> - <input t:type="textfield" t:id="nbObservants" class="nbObservants" value="contactEdited.nbObservants" /> - <p:else>${contact.nbObservants}</p:else> - </t:if> - </p:nbObservantsCell> - <p:mammalsCell> - <t:if t:test="editionMode"> - <input t:type="checkbox" t:id="mammalsObservation" value="contactEdited.mammalsObservation"/> - <t:label t:for="mammalsObservation"> - <img src="${asset:context:img/eye-22px.png}" alt="Observations" - title="Observations" /> - </t:label> - <input t:type="checkbox" t:id="mammalsCapture" value="contactEdited.mammalsCapture" /> - <t:label t:for="mammalsCapture"> - <img src="${asset:context:img/fishing-net-22px.png}" alt="Captures" - title="Captures" /> - </t:label> - <p:else> - <t:if t:test="contact.mammalsObservation"> - <img src="${asset:context:img/eye-22px.png}" alt="Observations" title="Observations" /> - </t:if> - <t:if t:test="contact.mammalsCapture"> - <img src="${asset:context:img/fishing-net-22px.png}" alt="Captures" title="Captures" /> - </t:if> - </p:else> - </t:if> - </p:mammalsCell> - <p:validationCell> - <t:booleanImage t:value="contact.validationCompany" t:empty="isEmpty(contact.validationCompany)" - t:emptyTitle="Non validé par la société" - t:trueTitle="Validé par la société" t:falseTitle="Refusé par la société"/> - <t:booleanImage t:value="contact.validationProgram" t:empty="isEmpty(contact.validationProgram)" - t:emptyTitle="Non validé par le programme" - t:trueTitle="Validé par le programme" t:falseTitle="Refusé par le programme"/> - </p:validationCell> - <p:dataInputDateCell> - <t:if t:test="editionMode"> - <input t:type="datefield" t:id="inputDate" class="date" value="contactEdited.dataInputDate" /> - <p:else><t:output value="contact.dataInputDate" format="dateFormat" /></p:else> - </t:if> - </p:dataInputDateCell> - <p:commentCell> - <t:if t:test="editionMode"> - - <a onclick="commentController.openWindow(${commentData})" title="Ajouter un commentaire"> - <img id="commentImage" src="${asset:context:img/comment-22px.png}" alt="Ajout commentaire" /> - <img id="commentInvalidImage" class="hidden" src="${asset:context:img/comment-invalid-22px.png}" - alt="Commentaire non valide" title="Le commentaire est obligatoire pour un échec" /> - <img id="commentValidImage" class="hidden" src="${asset:context:img/comment-valid-22px.png}" - alt="Commentaire valide" title="Le commentaire a bien été ajouté" /> - </a> - - <textarea t:type="textarea" t:id="comment" class="hidden" value="contactEdited.comment" /> - - <p:else> - <t:if t:test="contact.comment"> - <span t:type="ck/Tooltip" title="Commentaire" t:value="${getCommentTooltip(contact.comment)}" t:effect="appear"> - ${getCommentDisplayText(contact.comment)} - </span> - </t:if> - </p:else> - </t:if> - </p:commentCell> - <p:dataReliabilityCell> - <t:if t:test="boardingDone"> - <t:if t:test="contact.validationCompany"> - <t:if test="contact.validationProgram"> - ${getLabelForEnum(contact.dataReliability)} - <!--p:else> - <t:if test="canUpdateDataReliability()"> - <input t:type="select" t:id="dataReliability" t:value="contact.dataReliability" validate="required" /> - </t:if> - </p:else--> - </t:if> - </t:if> - </t:if> - </p:dataReliabilityCell> - <p:commentCoordinatorCell> + </t:if> + </p:dataReliabilityCell> + <p:commentCoordinatorCell> + <t:if t:test="contact.commentCoordinator"> <span t:type="ck/Tooltip" title="Commentaire société" t:value="${getCommentTooltip(contact.commentCoordinator)}" t:effect="appear"> ${getCommentDisplayText(contact.commentCoordinator)} </span> - </p:commentCoordinatorCell> - <p:commentAdminCell> + </t:if> + </p:commentCoordinatorCell> + <p:commentAdminCell> + <t:if t:test="contact.commentAdmin"> <span t:type="ck/Tooltip" title="Commentaire admin" t:value="${getCommentTooltip(contact.commentAdmin)}" t:effect="appear"> ${getCommentDisplayText(contact.commentAdmin)} </span> - </p:commentAdminCell> - <p:actionsCell> - <t:unless t:test="contact.validationProgram"> - <a t:type="pagelink" t:page="contactForm" t:anchor="focus" t:context="contact.topiaId"> - <img src="${asset:context:}/img/edit.png" alt="Modifier" title="Modifier le contact"/> + </t:if> + </p:commentAdminCell> + <p:actionsCell> + <t:unless t:test="contact.validationProgram"> + <a t:type="pagelink" t:page="contactForm" t:anchor="focus" t:context="contact.topiaId"> + <img src="${asset:context:}/img/edit.png" alt="Modifier" title="Modifier le contact"/> + </a> + <p:else> + <img src="${asset:context:img/edit-unavailable-22px.png}" alt="Edit unavailable" title="Modification du contact indisponible"/> + </p:else> + </t:unless> + <t:if t:test="hasActions()"> + <a t:type="actionlink" t:id="deleteContact" t:context="contact.topiaId" t:mixins="nuiton/confirm" t:message="literal:Etes-vous sûr de vouloir supprimer définitivement ce contact ?"> + <img src="${asset:context:img/delete2.png}" alt="Delete contact" /> + </a> + <p:else> + <img src="${asset:context:img/delete-unavailable-22px.png}" alt="Delete unavailable" title="Suppression du contact indisponible" /> + </p:else> + </t:if> + <t:if t:test="hasValidationActions()"> + <t:if t:test="canValidate()"> + <a t:type="actionlink" t:id="acceptContact" t:context="contact.topiaId"> + <img src="${asset:context:img/accept-22px.png}" alt="Accept contact" /> </a> + <a t:type="actionlink" t:id="refuseContact" t:context="contact.topiaId"> + <img src="${asset:context:img/refuse-22px.png}" alt="Refuse contact" /> + </a> <p:else> - <img src="${asset:context:img/edit-unavailable-22px.png}" alt="Edit unavailable" title="Modification du contact indisponible"/> - </p:else> - </t:unless> - <t:if t:test="hasActions()"> - <t:if t:test="editionMode"> - <input t:type="submit" t:id="cancelEditContact" class="ico22px undo22px" value="Undo" - title="Annuler les modifications" /> - <input t:type="submitContext" t:id="saveContact" class="ico22px save22px" value="Save" - t:context="contact.topiaId" title="Enregistrer le contact" /> - <p:else> - <!--input t:type="submitContext" t:id="editContact" class="ico edit" value="Edit" - t:context="contact.topiaId" title="Modifier le contact" /--> - <input t:type="submitContext" t:id="deleteContact" class="ico22px delete" value="Delete" - t:context="contact.topiaId" title="Supprimer le contact" - t:mixins="nuiton/confirm" t:message="literal:Etes-vous sûr de vouloir supprimer définitivement ce contact ?" /> - </p:else> - </t:if> - <p:else> - <t:unless t:test="user.admin"> - <!--img src="${asset:context:img/edit-unavailable-22px.png}" alt="Edit unavailable" title="Edition du contact indisponible"/--> - <img src="${asset:context:img/delete-unavailable-22px.png}" alt="Delete unavailable" title="Suppression du contact indisponible"/> + <t:unless t:test="canUnvalidate()"> + <img src="${asset:context:img/accept-unavailable-22px.png}" alt="Accept unavailable" title="Validation du contact indisponible"/> + <img src="${asset:context:img/refuse-unavailable-22px.png}" alt="Refuse unavailable" title="Refus du contact indisponible"/> </t:unless> </p:else> </t:if> - <t:if t:test="hasValidationActions()"> - <t:if t:test="canValidate()"> - <input t:type="submitContext" t:id="acceptContact" class="ico22px accept" value="Accept" - t:context="contact.topiaId" title="Valider le contact" /> - <input t:type="submitContext" t:id="refuseContact" class="ico22px refuse" value="Refuse" - t:context="contact.topiaId" title="Refuser le contact" /> - <p:else> - <t:unless t:test="canUnvalidate()"> - <img src="${asset:context:img/accept-unavailable-22px.png}" alt="Accept unavailable" title="Validation du contact indisponible"/> - <img src="${asset:context:img/refuse-unavailable-22px.png}" alt="Refuse unavailable" title="Refus du contact indisponible"/> - </t:unless> - </p:else> - </t:if> - <t:if t:test="canUnvalidate()"> - <input t:type="submitContext" t:id="unvalidateContact" class="ico22px unvalidate" value="Unvalidate" - t:context="contact.topiaId" title="Enlever la validation du contact" /> - </t:if> - <!--t:if t:test="editionMode"> - <img src="${asset:context:img/comment-unavailable-22px.png}" alt="Add comment" /> - <p:else> - <a class="link" onclick="commentController.openWindow(${commentData});"> - <img src="${asset:context:img/comment-22px.png}" alt="Add comment" /> - </a> - </p:else> - </t:if--> + <t:if t:test="canUnvalidate()"> + <a t:type="actionlink" t:id="unvalidateContact" t:context="contact.topiaId"> + <img src="${asset:context:img/help-22px.png}" alt="Unvalidate contact" /> + </a> </t:if> - </p:actionsCell> - </div> - </form> + </t:if> + </p:actionsCell> + </div> </t:zone> -<div t:type="ck/Window" t:id="commentWindow" t:show="false" t:modal="true" - title="literal:Ajouter un commentaire" t:width="510" t:height="195"> - <form t:type="form" t:id="commentForm" action="tapestry"> - <p> - <textarea t:type="textarea" t:id="editComment" t:value="extraComment" cols="50" rows="7" /> - <input t:type="hidden" t:id="hiddenContactId" t:value="contactId" /> - </p> - <p> </p> - <p class="aright"> - <a onclick="commentController.saveComment()" class="save"> - <img src="${asset:context:img/save-22px.png}" alt="Save comment"/> - </a> - - </p> - </form> -</div> -<t:zone t:id="observersFormZone" t:visible="observersFormZoneVisible"> - <t:if test="contactEdited"> <!-- only if contact != null : prevent NPE at peage loading --> - Modification des observateurs associés à ce contact : - <form t:type="form" t:id="observersForm" action="tapestry"> - <p> - <t:errors /> - </p> - <p> - <t:label t:for="mainObserver" />: - <input t:type="select" t:id="mainObserver" t:model="observerSelectModel" t:validate="required" t:value="contactUserId" t:mixins="ck/onEvent" t:event="change" /> - </p> - <p> - <t:label t:for="secondaryObserver" />: - <input t:type="select" t:id="secondaryObserver" t:model="observerSelectModel" t:value="selectedSecondaryObserverId" t:mixins="ck/onEvent" t:event="change" /> - <a t:type="actionlink" t:id="addSecondaryObserver" title="Ajouter un observateur" t:zone="observersFormZone"> - <img src="${asset:context:img/add-16px.png}" /> - </a> - <ul> - <li t:type="loop" t:source="secondaryObservers" t:value="observer" t:index="secondaryObserverIndex" t:volatile="true"> - ${observer.fullName} - <a t:type="actionlink" t:id="removeSecondaryObserver" t:context="secondaryObserverIndex" title="Supprimer cet observateur" t:zone="observersFormZone"> - <img src="${asset:context:img/remove-22px.png}" /> - </a> - </li> - </ul> - </p> - <p> </p> - <p class="aright"> - <input t:type="submit" t:id="cancelEditObservers" class="ico22px undo22px" value="Undo" title="Annuler les modifications" /> - <input t:type="submit" t:id="saveObservers" class="ico22px save22px" value="Save" title="Enregistrer les observateurs" /> - </p> - </form> - </t:if> -</t:zone> </t:layout> Modified: trunk/wao-ui/src/main/webapp/css/contacts.css =================================================================== --- trunk/wao-ui/src/main/webapp/css/contacts.css 2011-01-06 11:11:16 UTC (rev 899) +++ trunk/wao-ui/src/main/webapp/css/contacts.css 2011-01-09 18:14:18 UTC (rev 900) @@ -141,10 +141,7 @@ white-space: nowrap; } -div#so-contacts table.t-data-grid tbody tr td.commentCoordinator, -div#so-contacts table.t-data-grid tbody tr td.commentAdmin, div#so-contacts table.t-data-grid tbody tr td.comment, -div#so-contacts table.t-data-grid thead tr th.comment, div#so-contacts table.t-data-grid thead tr th.commentCoordinator, div#so-contacts table.t-data-grid thead tr th.commentAdmin div#so-contacts table.t-data-grid thead tr th.dataReliability {