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
1 package org.legrog.presentation; 1 package org.legrog.presentation;
2 2
3 import org.legrog.application.PublisherRevisionService; 3 import org.legrog.application.PublisherRevisionService;
4 +import org.legrog.application.SharedService;
4 import org.legrog.entities.Country; 5 import org.legrog.entities.Country;
5 import org.legrog.entities.PublisherRevision; 6 import org.legrog.entities.PublisherRevision;
6 import org.legrog.entities.User; 7 import org.legrog.entities.User;
7 import org.slf4j.Logger; 8 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory; 9 import org.slf4j.LoggerFactory;
9 10
11 +import javax.annotation.PostConstruct;
10 import javax.faces.view.ViewScoped; 12 import javax.faces.view.ViewScoped;
11 import javax.inject.Inject; 13 import javax.inject.Inject;
12 import javax.inject.Named; 14 import javax.inject.Named;
13 import java.io.Serializable; 15 import java.io.Serializable;
14 import java.sql.Timestamp; 16 import java.sql.Timestamp;
17 +import java.util.List;
15 18
16 @Named 19 @Named
17 @ViewScoped 20 @ViewScoped
...@@ -20,7 +23,12 @@ public class PublisherRevisionView implements Serializable { ...@@ -20,7 +23,12 @@ public class PublisherRevisionView implements Serializable {
20 23
21 @Inject 24 @Inject
22 PublisherRevisionService publisherRevisionService; 25 PublisherRevisionService publisherRevisionService;
26 + @Inject
27 + private SharedService sharedService;
28 +
29 + private boolean editMode;
23 30
31 + // Données temporaires d'un PublisherRevision
24 private int publisherRevisionId; 32 private int publisherRevisionId;
25 private String publisherName; 33 private String publisherName;
26 private String publisherStreetAddress; 34 private String publisherStreetAddress;
...@@ -37,6 +45,26 @@ public class PublisherRevisionView implements Serializable { ...@@ -37,6 +45,26 @@ public class PublisherRevisionView implements Serializable {
37 private User publisherRevisionAuthor; 45 private User publisherRevisionAuthor;
38 private Timestamp publisherRevisionDatetime; 46 private Timestamp publisherRevisionDatetime;
39 47
48 + // Table de codification
49 + private List<Country> availableCountries;
50 +
51 + @PostConstruct
52 + public void init() {
53 + availableCountries = sharedService.getAllCountries();
54 + }
55 +
56 + public void edit() {
57 + editMode = true;
58 + }
59 +
60 + public void cancel() {
61 + editMode = false;
62 + }
63 +
64 + public boolean isEditMode() {
65 + return editMode;
66 + }
67 +
40 public void loadData() { 68 public void loadData() {
41 logger.debug("publisherRevisionId = {}", this.publisherRevisionId); 69 logger.debug("publisherRevisionId = {}", this.publisherRevisionId);
42 70
...@@ -187,4 +215,11 @@ public class PublisherRevisionView implements Serializable { ...@@ -187,4 +215,11 @@ public class PublisherRevisionView implements Serializable {
187 this.publisherRevisionDatetime = publisherRevisionDatetime; 215 this.publisherRevisionDatetime = publisherRevisionDatetime;
188 } 216 }
189 217
218 + public List<Country> getAvailableCountries() {
219 + return availableCountries;
220 + }
221 +
222 + public void setAvailableCountries(List<Country> availableCountries) {
223 + this.availableCountries = availableCountries;
224 + }
190 } 225 }
......
...@@ -22,45 +22,47 @@ ...@@ -22,45 +22,47 @@
22 22
23 <h:panelGrid columns="2"> 23 <h:panelGrid columns="2">
24 <h:outputText value='publisherName'/> 24 <h:outputText value='publisherName'/>
25 - <h:outputText value='#{publisherRevisionView.publisherName}'/> 25 + <h:inputText value='#{publisherRevisionView.publisherName}' disabled="#{not publisherRevisionView.editMode}"/>
26 <h:outputText value='publisherStreetAddress'/> 26 <h:outputText value='publisherStreetAddress'/>
27 - <h:outputText value='#{publisherRevisionView.publisherStreetAddress}'/> 27 + <h:inputText value='#{publisherRevisionView.publisherStreetAddress}' disabled="#{not publisherRevisionView.editMode}"/>
28 <h:outputText value='publisherPostalCode'/> 28 <h:outputText value='publisherPostalCode'/>
29 - <h:outputText value='#{publisherRevisionView.publisherPostalCode}'/> 29 + <h:inputText value='#{publisherRevisionView.publisherPostalCode}' disabled="#{not publisherRevisionView.editMode}"/>
30 <h:outputText value='publisherPostOfficeBoxNumber'/> 30 <h:outputText value='publisherPostOfficeBoxNumber'/>
31 - <h:outputText value='#{publisherRevisionView.publisherPostOfficeBoxNumber}'/> 31 + <h:inputText value='#{publisherRevisionView.publisherPostOfficeBoxNumber}' disabled="#{not publisherRevisionView.editMode}"/>
32 <h:outputText value='publisherAddressRegion'/> 32 <h:outputText value='publisherAddressRegion'/>
33 - <h:outputText value='#{publisherRevisionView.publisherAddressRegion}'/> 33 + <h:inputText value='#{publisherRevisionView.publisherAddressRegion}' disabled="#{not publisherRevisionView.editMode}"/>
34 <h:outputText value='publisherAddressLocality'/> 34 <h:outputText value='publisherAddressLocality'/>
35 - <h:outputText value='#{publisherRevisionView.publisherAddressLocality}'/> 35 + <h:inputText value='#{publisherRevisionView.publisherAddressLocality}' disabled="#{not publisherRevisionView.editMode}"/>
36 36
37 <h:outputText value='publisherAddressCountry'/> 37 <h:outputText value='publisherAddressCountry'/>
38 - <h:outputText value='#{publisherRevisionView.publisherAddressCountry.countryName}'/> 38 + <ui:remove>
39 -<ui:remove> 39 + <h:outputText value='#{publisherRevisionView.publisherAddressCountry.countryName}'/>
40 - <h:selectOneMenu value="#{publisherRevisionView.publisherAddressCountry}" converter="omnifaces.SelectItemsConverter"> 40 + </ui:remove>
41 + <h:selectOneMenu value="#{publisherRevisionView.publisherAddressCountry}" converter="omnifaces.SelectItemsConverter" disabled="#{not publisherRevisionView.editMode}">
41 <f:selectItems value="#{publisherRevisionView.availableCountries}" var="country" itemLabel="#{country.countryName}"/> 42 <f:selectItems value="#{publisherRevisionView.availableCountries}" var="country" itemLabel="#{country.countryName}"/>
42 </h:selectOneMenu> 43 </h:selectOneMenu>
43 -</ui:remove>
44 44
45 <h:outputText value='publisherTelephone'/> 45 <h:outputText value='publisherTelephone'/>
46 - <h:outputText value='#{publisherRevisionView.publisherTelephone}'/> 46 + <h:inputText value='#{publisherRevisionView.publisherTelephone}' disabled="#{not publisherRevisionView.editMode}"/>
47 <h:outputText value='publisherEmail'/> 47 <h:outputText value='publisherEmail'/>
48 - <h:outputText value='#{publisherRevisionView.publisherEmail}'/> 48 + <h:inputText value='#{publisherRevisionView.publisherEmail}' disabled="#{not publisherRevisionView.editMode}"/>
49 <h:outputText value='publisherURL'/> 49 <h:outputText value='publisherURL'/>
50 - <h:outputText value='#{publisherRevisionView.publisherURL}'/> 50 + <h:inputText value='#{publisherRevisionView.publisherURL}' disabled="#{not publisherRevisionView.editMode}"/>
51 51
52 <h:outputText value='publisherActive'/> 52 <h:outputText value='publisherActive'/>
53 - <h:outputText value="#{publisherRevisionView.publisherActive}"/>
54 <ui:remove> 53 <ui:remove>
55 - <h:selectBooleanCheckbox value="#{publisherRevisionView.publisherActive}"/> 54 + <h:outputText value="#{publisherRevisionView.publisherActive}"/>
56 </ui:remove> 55 </ui:remove>
56 + <h:selectBooleanCheckbox value="#{publisherRevisionView.publisherActive}" disabled="#{not publisherRevisionView.editMode}"/>
57 57
58 <h:outputText value='publisherHistory'/> 58 <h:outputText value='publisherHistory'/>
59 - <h:outputText value='#{publisherRevisionView.publisherHistory}'/> 59 + <h:inputText value='#{publisherRevisionView.publisherHistory}' disabled="#{not publisherRevisionView.editMode}"/>
60 <h:outputText value="publisherRevisionAuthor"/> 60 <h:outputText value="publisherRevisionAuthor"/>
61 <h:outputText value="#{publisherRevisionView.publisherRevisionAuthor.displayName}"/> 61 <h:outputText value="#{publisherRevisionView.publisherRevisionAuthor.displayName}"/>
62 <h:outputText value="publisherRevisionDatetime"/> 62 <h:outputText value="publisherRevisionDatetime"/>
63 <h:outputText value="#{publisherRevisionView.publisherRevisionDatetime}"/> 63 <h:outputText value="#{publisherRevisionView.publisherRevisionDatetime}"/>
64 + <h:commandButton value="Edit" action="#{publisherRevisionView.edit}" rendered="#{not publisherRevisionView.editMode}"/>
65 + <h:commandButton value="Cancel" action="#{publisherRevisionView.cancel}" rendered="#{publisherRevisionView.editMode}"/>
64 <ui:remove> 66 <ui:remove>
65 <h:outputText value='Add'/> 67 <h:outputText value='Add'/>
66 <h:commandButton action="#{publisherRevisionView.update}" value="Add"/> 68 <h:commandButton action="#{publisherRevisionView.update}" value="Add"/>
......