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
Showing
2 changed files
with
52 additions
and
15 deletions
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.faces.context.FacesContext; | 13 | //import javax.faces.context.FacesContext; |
12 | import javax.inject.Inject; | 14 | import javax.inject.Inject; |
13 | import javax.inject.Named; | 15 | import javax.inject.Named; |
14 | import java.io.Serializable; | 16 | import java.io.Serializable; |
15 | import java.sql.Timestamp; | 17 | import java.sql.Timestamp; |
18 | +import java.util.List; | ||
16 | 19 | ||
17 | @Named | 20 | @Named |
18 | @ViewScoped | 21 | @ViewScoped |
... | @@ -21,7 +24,12 @@ public class PublisherRevisionView implements Serializable { | ... | @@ -21,7 +24,12 @@ public class PublisherRevisionView implements Serializable { |
21 | 24 | ||
22 | @Inject | 25 | @Inject |
23 | PublisherRevisionService publisherRevisionService; | 26 | PublisherRevisionService publisherRevisionService; |
27 | + @Inject | ||
28 | + private SharedService sharedService; | ||
29 | + | ||
30 | + private boolean editMode; | ||
24 | 31 | ||
32 | + // Données temporaires d'un PublisherRevision | ||
25 | private int publisherRevisionId; | 33 | private int publisherRevisionId; |
26 | private String publisherName; | 34 | private String publisherName; |
27 | private String publisherStreetAddress; | 35 | private String publisherStreetAddress; |
... | @@ -38,6 +46,26 @@ public class PublisherRevisionView implements Serializable { | ... | @@ -38,6 +46,26 @@ public class PublisherRevisionView implements Serializable { |
38 | private User publisherRevisionAuthor; | 46 | private User publisherRevisionAuthor; |
39 | private Timestamp publisherRevisionDatetime; | 47 | private Timestamp publisherRevisionDatetime; |
40 | 48 | ||
49 | + // Table de codification | ||
50 | + private List<Country> availableCountries; | ||
51 | + | ||
52 | + @PostConstruct | ||
53 | + public void init() { | ||
54 | + availableCountries = sharedService.getAllCountries(); | ||
55 | + } | ||
56 | + | ||
57 | + public void edit() { | ||
58 | + editMode = true; | ||
59 | + } | ||
60 | + | ||
61 | + public void cancel() { | ||
62 | + editMode = false; | ||
63 | + } | ||
64 | + | ||
65 | + public boolean isEditMode() { | ||
66 | + return editMode; | ||
67 | + } | ||
68 | + | ||
41 | public void loadData() { | 69 | public void loadData() { |
42 | logger.debug("publisherRevisionId = {}", this.publisherRevisionId); | 70 | logger.debug("publisherRevisionId = {}", this.publisherRevisionId); |
43 | 71 | ||
... | @@ -188,4 +216,11 @@ public class PublisherRevisionView implements Serializable { | ... | @@ -188,4 +216,11 @@ public class PublisherRevisionView implements Serializable { |
188 | this.publisherRevisionDatetime = publisherRevisionDatetime; | 216 | this.publisherRevisionDatetime = publisherRevisionDatetime; |
189 | } | 217 | } |
190 | 218 | ||
219 | + public List<Country> getAvailableCountries() { | ||
220 | + return availableCountries; | ||
221 | + } | ||
222 | + | ||
223 | + public void setAvailableCountries(List<Country> availableCountries) { | ||
224 | + this.availableCountries = availableCountries; | ||
225 | + } | ||
191 | } | 226 | } | ... | ... |
... | @@ -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 | + <ui:remove> | ||
38 | <h:outputText value='#{publisherRevisionView.publisherAddressCountry.countryName}'/> | 39 | <h:outputText value='#{publisherRevisionView.publisherAddressCountry.countryName}'/> |
39 | -<ui:remove> | 40 | + </ui:remove> |
40 | - <h:selectOneMenu value="#{publisherRevisionView.publisherAddressCountry}" converter="omnifaces.SelectItemsConverter"> | 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"/> | ... | ... |
-
Please register or login to post a comment