Jean-Francois Leveque

https://tree.taiga.io/project/jr-utily-grog-v3/us/44

Implementer l'historisation pour les éditeurs
https://tree.taiga.io/project/jr-utily-grog-v3/task/75
Rendre l'affichage éditable
package org.legrog.presentation;
import org.legrog.application.PublisherRevisionService;
import org.legrog.application.SharedService;
import org.legrog.entities.Country;
import org.legrog.entities.PublisherRevision;
import org.legrog.entities.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
//import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
@Named
@ViewScoped
......@@ -21,7 +24,12 @@ public class PublisherRevisionView implements Serializable {
@Inject
PublisherRevisionService publisherRevisionService;
@Inject
private SharedService sharedService;
private boolean editMode;
// Données temporaires d'un PublisherRevision
private int publisherRevisionId;
private String publisherName;
private String publisherStreetAddress;
......@@ -38,6 +46,26 @@ public class PublisherRevisionView implements Serializable {
private User publisherRevisionAuthor;
private Timestamp publisherRevisionDatetime;
// Table de codification
private List<Country> availableCountries;
@PostConstruct
public void init() {
availableCountries = sharedService.getAllCountries();
}
public void edit() {
editMode = true;
}
public void cancel() {
editMode = false;
}
public boolean isEditMode() {
return editMode;
}
public void loadData() {
logger.debug("publisherRevisionId = {}", this.publisherRevisionId);
......@@ -188,4 +216,11 @@ public class PublisherRevisionView implements Serializable {
this.publisherRevisionDatetime = publisherRevisionDatetime;
}
public List<Country> getAvailableCountries() {
return availableCountries;
}
public void setAvailableCountries(List<Country> availableCountries) {
this.availableCountries = availableCountries;
}
}
......
......@@ -22,45 +22,47 @@
<h:panelGrid columns="2">
<h:outputText value='publisherName'/>
<h:outputText value='#{publisherRevisionView.publisherName}'/>
<h:inputText value='#{publisherRevisionView.publisherName}' disabled="#{not publisherRevisionView.editMode}"/>
<h:outputText value='publisherStreetAddress'/>
<h:outputText value='#{publisherRevisionView.publisherStreetAddress}'/>
<h:inputText value='#{publisherRevisionView.publisherStreetAddress}' disabled="#{not publisherRevisionView.editMode}"/>
<h:outputText value='publisherPostalCode'/>
<h:outputText value='#{publisherRevisionView.publisherPostalCode}'/>
<h:inputText value='#{publisherRevisionView.publisherPostalCode}' disabled="#{not publisherRevisionView.editMode}"/>
<h:outputText value='publisherPostOfficeBoxNumber'/>
<h:outputText value='#{publisherRevisionView.publisherPostOfficeBoxNumber}'/>
<h:inputText value='#{publisherRevisionView.publisherPostOfficeBoxNumber}' disabled="#{not publisherRevisionView.editMode}"/>
<h:outputText value='publisherAddressRegion'/>
<h:outputText value='#{publisherRevisionView.publisherAddressRegion}'/>
<h:inputText value='#{publisherRevisionView.publisherAddressRegion}' disabled="#{not publisherRevisionView.editMode}"/>
<h:outputText value='publisherAddressLocality'/>
<h:outputText value='#{publisherRevisionView.publisherAddressLocality}'/>
<h:inputText value='#{publisherRevisionView.publisherAddressLocality}' disabled="#{not publisherRevisionView.editMode}"/>
<h:outputText value='publisherAddressCountry'/>
<h:outputText value='#{publisherRevisionView.publisherAddressCountry.countryName}'/>
<ui:remove>
<h:selectOneMenu value="#{publisherRevisionView.publisherAddressCountry}" converter="omnifaces.SelectItemsConverter">
<ui:remove>
<h:outputText value='#{publisherRevisionView.publisherAddressCountry.countryName}'/>
</ui:remove>
<h:selectOneMenu value="#{publisherRevisionView.publisherAddressCountry}" converter="omnifaces.SelectItemsConverter" disabled="#{not publisherRevisionView.editMode}">
<f:selectItems value="#{publisherRevisionView.availableCountries}" var="country" itemLabel="#{country.countryName}"/>
</h:selectOneMenu>
</ui:remove>
<h:outputText value='publisherTelephone'/>
<h:outputText value='#{publisherRevisionView.publisherTelephone}'/>
<h:inputText value='#{publisherRevisionView.publisherTelephone}' disabled="#{not publisherRevisionView.editMode}"/>
<h:outputText value='publisherEmail'/>
<h:outputText value='#{publisherRevisionView.publisherEmail}'/>
<h:inputText value='#{publisherRevisionView.publisherEmail}' disabled="#{not publisherRevisionView.editMode}"/>
<h:outputText value='publisherURL'/>
<h:outputText value='#{publisherRevisionView.publisherURL}'/>
<h:inputText value='#{publisherRevisionView.publisherURL}' disabled="#{not publisherRevisionView.editMode}"/>
<h:outputText value='publisherActive'/>
<h:outputText value="#{publisherRevisionView.publisherActive}"/>
<ui:remove>
<h:selectBooleanCheckbox value="#{publisherRevisionView.publisherActive}"/>
<h:outputText value="#{publisherRevisionView.publisherActive}"/>
</ui:remove>
<h:selectBooleanCheckbox value="#{publisherRevisionView.publisherActive}" disabled="#{not publisherRevisionView.editMode}"/>
<h:outputText value='publisherHistory'/>
<h:outputText value='#{publisherRevisionView.publisherHistory}'/>
<h:inputText value='#{publisherRevisionView.publisherHistory}' disabled="#{not publisherRevisionView.editMode}"/>
<h:outputText value="publisherRevisionAuthor"/>
<h:outputText value="#{publisherRevisionView.publisherRevisionAuthor.displayName}"/>
<h:outputText value="publisherRevisionDatetime"/>
<h:outputText value="#{publisherRevisionView.publisherRevisionDatetime}"/>
<h:commandButton value="Edit" action="#{publisherRevisionView.edit}" rendered="#{not publisherRevisionView.editMode}"/>
<h:commandButton value="Cancel" action="#{publisherRevisionView.cancel}" rendered="#{publisherRevisionView.editMode}"/>
<ui:remove>
<h:outputText value='Add'/>
<h:commandButton action="#{publisherRevisionView.update}" value="Add"/>
......