[Suiviobsmer-commits] r1129 - in trunk/wao-ui/src/main: java/fr/ifremer/wao/ui/pages java/fr/ifremer/wao/ui/services resources/fr/ifremer/wao/ui/pages webapp
Author: bleny Date: 2011-04-01 15:07:05 +0000 (Fri, 01 Apr 2011) New Revision: 1129 Log: use topiaEntitySelector in contact form Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ContactForm.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/ContactModelFactory.java trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/pages/Contacts_fr.properties trunk/wao-ui/src/main/webapp/ContactForm.tml trunk/wao-ui/src/main/webapp/Contacts.tml 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-04-01 11:34:49 UTC (rev 1128) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ContactForm.java 2011-04-01 15:07:05 UTC (rev 1129) @@ -167,8 +167,8 @@ @Persist private String contactId; - @Persist - private Contact oldContact; +// @Persist +// private Contact oldContact; @Persist private Contact contact; @@ -177,23 +177,10 @@ public Contact getContact() { if (contact == null) { if (StringUtils.isEmpty(contactId)) { - // contact = serviceContact.getNewContact() + throw new IllegalStateException(); } else { - oldContact = serviceContact.getContact(contactId); contact = serviceContact.getContact(contactId); - - mainObserverId = contact.getMainObserver().getTopiaId(); - if (contact.getTerrestrialLocation() != null) { - terrestrialLocationId = contact.getTerrestrialLocation().getTopiaId(); - } - if (oldContact == contact) { - throw new IllegalStateException("il faut deux instances différentes"); - } } - if (logger.isDebugEnabled()) { - logger.debug("contact : " + contact.getTopiaCreateDate() + - contact.getId() + contact.getSampleRow().getCode()); - } } return contact; } @@ -224,75 +211,13 @@ } @Property - private String mainObserverId; - - @InjectComponent - private Zone observersFormZone; - - @Persist - private List<WaoUser> secondaryObservers; - - @Persist - @Property - private String selectedSecondaryObserverId; - - @Property - private int secondaryObserverIndex; - - @Property private WaoUser observer; // for loop - private GenericSelectModel<WaoUser> observerSelectModel; - - public GenericSelectModel<WaoUser> getObserverSelectModel() throws WaoException { - if (observerSelectModel == null) { - List<WaoUser> observers = - serviceUser.getObservers(connectedUser.getCompany(), true); - observerSelectModel = new GenericSelectModel<WaoUser>(observers,WaoUser.class, - "fullName", "topiaId", propertyAccess); - } - return observerSelectModel; + public List<WaoUser> getObservers() { + List<WaoUser> observers = serviceUser.getObservers(connectedUser.getCompany(), true); + return observers; } - public List<WaoUser> getSecondaryObservers() { - if (secondaryObservers == null) { - secondaryObservers = new ArrayList<WaoUser>(getContact().getSecondaryObservers()); - } - return secondaryObservers; - } - - @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 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(observerToAdd)) { - getSecondaryObservers().add(observerToAdd); - } - } - return observersFormZone; - } - - @Log - public Zone onActionFromRemoveSecondaryObserver(int secondaryObserverIndex) { - getSecondaryObservers().remove(secondaryObserverIndex); - return observersFormZone; - } - /************************ OBSERVATION REPORT ******************************/ @Component @@ -315,20 +240,11 @@ @Inject private ServiceReferential serviceReferential; - private GenericSelectModel<TerrestrialLocation> terrestrialLocationSelectModel; - - @Property - private String terrestrialLocationId; - - public GenericSelectModel<TerrestrialLocation> getTerrestrialLocationSelectModel() { - if (terrestrialLocationSelectModel == null) { - List<TerrestrialLocation> locations = + public List<TerrestrialLocation> getTerrestrialLocations() { + List<TerrestrialLocation> locations = serviceReferential.getAllTerrestrialLocations(new ContactFilterImpl(), contact.getSampleRow().getTerrestrialLocation().getDistrictCode()); - terrestrialLocationSelectModel = new GenericSelectModel<TerrestrialLocation>(locations, TerrestrialLocation.class, - "description", TerrestrialLocation.TOPIA_ID, propertyAccess); - } - return terrestrialLocationSelectModel; + return locations; } public SelectModel getContactStateSelectModel() { @@ -374,16 +290,6 @@ void onValidateFormFromContactForm() { contactForm.clearErrors(); - if (mainObserverId != null) { - WaoUser mainObserver = getObserverSelectModel().findObject(mainObserverId); - contact.setMainObserver(mainObserver); - } - contact.setSecondaryObservers(getSecondaryObservers()); - if (terrestrialLocationId != null) { - TerrestrialLocation terrestrialLocation = getTerrestrialLocationSelectModel().findObject(terrestrialLocationId); - contact.setTerrestrialLocation(terrestrialLocation); - } - ValidationResult validationResult = serviceContact.validateContact(contact); if ( ! validationResult.isSuccess()) { contactForm.recordError(validationResult.getMessage()); @@ -429,8 +335,6 @@ } else { // reset contact = null; - mainObserverId = null; - secondaryObservers = null; } if (saveContact) { Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/ContactModelFactory.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/ContactModelFactory.java 2011-04-01 11:34:49 UTC (rev 1128) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/ContactModelFactory.java 2011-04-01 15:07:05 UTC (rev 1129) @@ -76,7 +76,7 @@ // order is meaningful, properties will be displayed in columnsForImport from left to right - addNonSortableProperty(TopiaEntity.TOPIA_CREATE_DATE, null); + addNonSortableProperty(Contact.PROPERTY_CREATION_DATE, null); addNonSortableProperty(Contact.PROPERTY_MAIN_OBSERVER, getUserPropertyConduit()); addNonSortableProperty(WaoUser.PROPERTY_COMPANY, getCompanyPropertyConduit()); addNonSortableProperty(Contact.PROPERTY_SAMPLE_ROW, getSampleRowPropertyConduit()); Modified: trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/pages/Contacts_fr.properties =================================================================== --- trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/pages/Contacts_fr.properties 2011-04-01 11:34:49 UTC (rev 1128) +++ trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/pages/Contacts_fr.properties 2011-04-01 15:07:05 UTC (rev 1129) @@ -28,7 +28,7 @@ sampleRow-label: M\u00e9tier boat-label: Navire state-label: Etat -topiaCreateDate-label: Cr\u00e9ation +creationDate-label: Cr\u00e9ation observationBeginDate-label: D\u00e9but de l'observation observationEndDate-label: Fin de l'observation nbObservants-label: Nb obs. Modified: trunk/wao-ui/src/main/webapp/ContactForm.tml =================================================================== --- trunk/wao-ui/src/main/webapp/ContactForm.tml 2011-04-01 11:34:49 UTC (rev 1128) +++ trunk/wao-ui/src/main/webapp/ContactForm.tml 2011-04-01 15:07:05 UTC (rev 1129) @@ -65,7 +65,7 @@ </ul> </p> <p> - ${message:wao.ui.field.Contact.creationDate} : <t:output value="contact.topiaCreateDate" format="dateFormat" /> + ${message:wao.ui.field.Contact.creationDate} : <t:output value="contact.creationDate" format="dateFormat" /> </p> <div style="clear: right;"></div> </fieldset> @@ -95,27 +95,22 @@ <t:block id="editObservers"> <div> <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" /> + <t:topiaEntitySelector t:id="mainObserver" + t:clazzName="WaoUser" + t:labelPropertyName="fullName" + t:values="observers" + t:selectedValue="contact.mainObserver" /> </div> - <t:zone t:id="observersFormZone" t:visible="true" t:update="show" id="observersFormZoneId"> - <div> - <label for="secondaryObserver">${message:wao.ui.field.Contact.secondaryObservers}</label> - <div> - <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="observersFormZoneId"> - <img src="${asset:context:img/add-16px.png}" /> - </a> - <ul class="value"> - <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="observersFormZoneId"> - <img src="${asset:context:img/remove-22px.png}" /> - </a> - </li> - </ul> - </div> - </div> - </t:zone> + <div> + <label for="secondaryObservers">${message:wao.ui.field.Contact.secondaryObservers}</label> + <t:topiaEntitySelector t:id="secondaryObservers" + t:multiple="true" + t:clazzName="WaoUser" + t:labelPropertyName="fullName" + t:values="observers" + t:selectedValues="contact.secondaryObservers" + size="6"/> + </div> </t:block> <fieldset> @@ -250,11 +245,11 @@ <label for="terrestrialLocation"> ${message:wao.ui.field.Contact.terrestrialLocation} </label> - <input t:id="terrestrialLocation" - t:type="select" - t:model="terrestrialLocationSelectModel" - t:value="terrestrialLocationId" - t:validate="required" /> + <t:topiaEntitySelector t:id="terrestrialLocation" + t:clazzName="TerrestrialLocation" + t:labelPropertyName="description" + t:values="terrestrialLocations" + t:selectedValue="contact.terrestrialLocation" /> </div> <div> <label for="actualSamplingStrategy">${message:wao.ui.field.Contact.samplingStrategy}</label> Modified: trunk/wao-ui/src/main/webapp/Contacts.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Contacts.tml 2011-04-01 11:34:49 UTC (rev 1128) +++ trunk/wao-ui/src/main/webapp/Contacts.tml 2011-04-01 15:07:05 UTC (rev 1129) @@ -247,9 +247,9 @@ ${contact.sampleRow.code} </span> </p:sampleRowCell> - <p:topiaCreateDateCell> - <t:output value="contact.topiaCreateDate" format="dateFormat" /> - </p:topiaCreateDateCell> + <p:creationDateCell> + <t:output value="contact.creationDate" format="dateFormat" /> + </p:creationDateCell> <p:terrestrialLocationCell> <t:if t:test="contact.terrestrialLocation"> <span t:type="ck/Tooltip" title="Infos" t:value="${contact.terrestrialLocation.description}" t:effect="appear">
participants (1)
-
bleny@users.labs.libre-entreprise.org