64,6 → 64,7 |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import org.tela_botanica.client.composants.InfoLogger; |
import org.tela_botanica.client.composants.pagination.Proxy; |
import org.tela_botanica.client.composants.pagination.ProxyProjets; |
import org.tela_botanica.client.composants.pagination.ProxyValeur; |
import org.tela_botanica.client.composants.pagination.TransformateurJSONaModelData; |
|
75,6 → 76,7 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar; |
import com.extjs.gxt.ui.client.widget.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.DateField; |
import com.extjs.gxt.ui.client.widget.form.Field; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.LabelField; |
import com.extjs.gxt.ui.client.widget.form.Radio; |
81,6 → 83,7 |
import com.extjs.gxt.ui.client.widget.form.RadioGroup; |
import com.extjs.gxt.ui.client.widget.form.TextArea; |
import com.extjs.gxt.ui.client.widget.form.TextField; |
import com.extjs.gxt.ui.client.widget.form.Validator; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign; |
import com.extjs.gxt.ui.client.widget.layout.ColumnData; |
242,23 → 245,28 |
fsProjet.setHeading(i18nC.menuProjet()); |
fsProjet.setLayout(new FormLayout()); |
|
ListStore<Projet> storeProjets = new ListStore<Projet>(); |
ComboBox cbProjets = new ComboBox<Projet>(); |
cbProjets.setFieldLabel(i18nC.personneProjet()+ " :"); |
cbProjets.setEmptyText(i18nC.txtListeProjetDefaut()); |
cbProjets.setLabelSeparator(""); |
cbProjets.setDisplayField("nom"); |
cbProjets.setEditable(false); |
cbProjets.setTriggerAction(TriggerAction.ALL); |
cbProjets.setStore(storeProjets); |
cbProjets.setAllowBlank(false); |
cbProjets.addStyleName(ComposantClass.OBLIGATOIRE); |
cbProjets.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
fsProjet.add(cbProjets, new FormData(250, 0)); |
ModelType modelTypeProjets = new ModelType(); |
modelTypeProjets.setRoot("projets"); |
modelTypeProjets.setTotalName("nbElements"); |
modelTypeProjets.addField("cpr_nom"); |
modelTypeProjets.addField("cpr_id_projet"); |
|
String displayNameProjets = "cpr_nom"; |
ProxyProjets<ModelData> proxyProjets = new ProxyProjets<ModelData>(); |
|
ChampComboBoxRechercheTempsReelPaginable cbProjets = new ChampComboBoxRechercheTempsReelPaginable(proxyProjets, modelTypeProjets, displayNameProjets); |
cbProjets.setWidth(100, 600); |
cbProjets.getCombo().setTabIndex(tabIndex++); |
cbProjets.getCombo().setFieldLabel(i18nC.personneProjet()); |
cbProjets.getCombo().setEmptyText(i18nC.txtListeProjetDefaut()); |
cbProjets.getCombo().addStyleName(ComposantClass.OBLIGATOIRE); |
cbProjets.getCombo().addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire()); |
cbProjets.getCombo().setAllowBlank(false); |
cbProjets.getCombo().setEditable(false); |
|
fsProjet.add(cbProjets, new FormData(600, 0)); |
|
hmIdentite.put("cbProjets", cbProjets); |
|
mediateur.selectionnerProjet(this, null, sequenceur); |
|
left.add(fsProjet); |
|
871,6 → 879,8 |
if (info.getDonnee(0) != null) { |
personneSelectionnee.setId(info.getDonnee(0).toString()); |
GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null); |
this.personne = personneSelectionnee; |
this.personneId = personneSelectionnee.getId(); |
InfoLogger.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")"); |
repandreRafraichissement(); |
if (clicBoutonvalidation) { |
901,6 → 911,9 |
|
mettreAJourPersonne(personne); |
|
this.personne = personne; |
this.personneId = personne.getId(); |
|
nouvellesDonnees = null; |
} else { |
InfoLogger.display("messages", info.getMessages().toString()); |
988,10 → 1001,9 |
|
private void mettreAJourPersonne(Personne personne) { |
|
//Mise à jour de la personne |
//Personne personne = (Personne) nouvellesDonnees; |
ComboBox cbProjets = hmIdentite.getComboBox("cbProjets"); |
cbProjets.setValue(cbProjets.getStore().findModel("id_projet", personne.get("ce_projet"))); |
//Mise à jour de la personne |
ChampComboBoxRechercheTempsReelPaginable cbProjets = hmIdentite.getComboBoxRechercheTempsReelPaginable("cbProjets"); |
cbProjets.getCombo().setValue(cbProjets.getStore().findModel("cpr_id_projet", personne.get("ce_projet"))); |
|
//Prefixe |
String prefixe = personne.get("ce_truk_prefix"); |
1190,11 → 1202,11 |
boolean success = true; |
LinkedList<String> lstMessageErreur = new LinkedList<String>(); |
|
ComboBox<Projet> cbProjets = hmIdentite.getComboBox("cbProjets"); |
Projet projet = cbProjets.getValue(); |
if (projet == null) { |
ChampComboBoxRechercheTempsReelPaginable cbProjets = hmIdentite.getComboBoxRechercheTempsReelPaginable("cbProjets"); |
if (cbProjets.getValeur() == null) { |
lstMessageErreur.add("Le projet n'a pas été renseigné"); |
} else { |
Projet projet = new Projet(cbProjets.getValeur()); |
personneSelectionnee.set("ce_projet", projet.getId()); |
} |
|
1254,41 → 1266,21 |
} |
|
personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe); |
|
//Verifier que la date est soit JJ/MM/AAAA soit AAAA |
|
/** NAISSANCE **/ |
String valeurDateNaissance = (String) hmIdentite.getTextField("tfDateNaissance").getValue(); |
if (!UtilString.isEmpty(valeurDateNaissance)) { |
if (valeurDateNaissance.matches("\\d{2}/\\d{2}/\\d{4}")) { |
Date naissanceDate = DateTimeFormat.getFormat("dd/MM/yyyy").parse(valeurDateNaissance); |
personneSelectionnee.setNaissanceDate(naissanceDate); |
} else if (valeurDateNaissance.matches("\\d{4}")) { |
personneSelectionnee.set("naissance_date", valeurDateNaissance + "-00-00"); |
} else { |
lstMessageErreur.add("La date de naissance n'est pas au format jj/mm/AAAA ou AAAA."); |
} |
} |
traiterDate("naissance", valeurDateNaissance, personneSelectionnee, lstMessageErreur); |
|
/** DECES **/ |
Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee"); |
if (rbEstDecedee.getValue() == true) { |
|
if (rbEstDecedee.getValue() == true) { |
// date |
String valeurDateDeces = (String) hmIdentite.getTextField("tfDateDeces").getValue(); |
traiterDate("décès", valeurDateDeces, personneSelectionnee, lstMessageErreur); |
// lieu |
String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue(); |
|
//Verifier que la date est soit JJ/MM/AAAA soit AAAA |
Date dateDeces = null; |
String valeurDateDeces = (String) hmIdentite.getTextField("tfDateDeces").getValue(); |
if (!UtilString.isEmpty(valeurDateDeces)) { |
if (valeurDateDeces.matches("\\d{2}/\\d{2}/\\d{4}")) { |
dateDeces = DateTimeFormat.getFormat("dd/MM/yyyy").parse(valeurDateDeces); |
personneSelectionnee.setDeces(dateDeces, decesLieu); |
} else if (valeurDateDeces.matches("\\d{4}")) { |
personneSelectionnee.set("deces_date", valeurDateDeces + "-00-00"); |
personneSelectionnee.setDecesLieu(decesLieu); |
} else { |
lstMessageErreur.add("La date de deces n'est pas au format jj/mm/AAAA ou AAAA."); |
} |
} |
|
} else { |
personneSelectionnee.setDecesLieu(decesLieu); |
} else { |
personneSelectionnee.setNonDecedee(); |
} |
|
1333,4 → 1325,75 |
|
return success; |
} |
|
private void traiterDate(String typeDate, String date, Personne personneSelectionnee, LinkedList<String> lstMessageErreur) { |
String valeurDate = date; |
if (!UtilString.isEmpty(valeurDate)){ |
|
String jour = ""; |
String mois = ""; |
String annee = ""; |
|
/** JJ/MM/AAAA **/ |
if (valeurDate.matches("\\d{2}/\\d{2}/\\d{4}")) { |
jour = valeurDate.substring(0,2); |
mois = valeurDate.substring(3,5); |
annee = valeurDate.substring(6,10); |
String dateComplete = annee+"-"+mois+"-"+jour; |
if (jour == "00" || mois == "00" || annee == "0000") { |
lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA."); |
} |
else { |
if (typeDate=="naissance") { |
Date naissanceDate = DateTimeFormat.getFormat("dd/MM/yyyy").parse(valeurDate); |
personneSelectionnee.setNaissanceDate(naissanceDate); |
} else if (typeDate=="décès") { |
Date decesDate = DateTimeFormat.getFormat("dd/MM/yyyy").parse(valeurDate); |
personneSelectionnee.setDecesDate(decesDate); |
} |
} |
|
/** MM/AAAA **/ |
} else if (valeurDate.matches("\\d{2}/\\d{4}")) { |
jour = "00"; |
mois = valeurDate.substring(0,2); |
annee = valeurDate.substring(3,7); |
String dateComplete = annee+"-"+mois+"-"+jour; |
if (mois == "00" || annee == "0000") { |
lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA."); |
} |
else { |
if (typeDate=="naissance") personneSelectionnee.set("naissance_date", dateComplete); |
else if (typeDate=="décès") { |
personneSelectionnee.set("deces_date", dateComplete); |
personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE); |
} |
} |
} |
|
/** AAAA **/ |
else if (valeurDate.matches("\\d{4}")) { |
if (valeurDate == "0000") { |
lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA."); |
} |
else { |
if (typeDate=="naissance") personneSelectionnee.set("naissance_date", valeurDate + "-00-00"); |
else if (typeDate=="décès") { |
personneSelectionnee.set("deces_date", valeurDate + "-00-00"); |
personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE); |
} |
} |
} else { |
lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA."); |
} |
} |
} |
|
public Personne getPersonne() { |
return this.personne; |
} |
|
public String getPersonneId() { |
return this.personneId; |
} |
} |