/trunk/widget/modules/saisie/squelettes/js/PlantesEtLichensASL.js |
---|
1,3 → 1,6 |
import {WidgetsSaisiesASL} from './WidgetsSaisiesASL.js'; |
import {valOk} from './Utils.js'; |
/** |
* Constructeur PlantesEtLichensASL par défaut |
* S'applique au squelette apaforms.tpl.html |
5,32 → 8,27 |
* Lors de la saisie des plantes ou des lichens |
*/ |
// ASL : APA, sTREETs, Lichen's Go! |
function PlantesEtLichensASL( proprietes, widgetProp ) { |
if ( utils.valOk( proprietes ) && utils.valOk( widgetProp ) ) { |
this.sujet = proprietes.sujet; |
this.tagImg = proprietes.tagImg; |
this.separationTagImg = proprietes.separationTagImg; |
this.tagImg = proprietes.tagImg; |
this.tagObs = proprietes.tagObs; |
this.separationTagObs = proprietes.separationTagObs; |
this.nomSciReferentiel = proprietes.nomSciReferentiel; |
this.referentielImpose = proprietes.referentielImpose; |
this.widgetProp = widgetProp; |
this.urlWidgets = widgetProp.urlWidgets; |
this.projet = widgetProp.projet; |
export function PlantesEtLichensASL(plantesEtLichensProp) { |
if ( valOk( plantesEtLichensProp ) && valOk( widgetProp ) ) { |
this.sujet = plantesEtLichensProp.sujet; |
this.tagImg = plantesEtLichensProp.tagImg; |
this.separationTagImg = plantesEtLichensProp.separationTagImg; |
this.tagImg = plantesEtLichensProp.tagImg; |
this.tagObs = plantesEtLichensProp.tagObs; |
this.separationTagObs = plantesEtLichensProp.separationTagObs; |
this.nomSciReferentiel = plantesEtLichensProp.nomSciReferentiel; |
this.referentielImpose = plantesEtLichensProp.referentielImpose; |
this.tagsMotsCles = widgetProp.tagsMotsCles + ',' + this.sujet; |
} |
this.isTaxonListe = false; |
this.numArbre = 0; |
} |
PlantesEtLichensASL.prototype = new WidgetsSaisiesASL( this.widgetProp ); |
PlantesEtLichensASL.prototype = new WidgetsSaisiesASL(); |
/** |
* Initialise le formulaire, les validateurs, les listes de complétion... |
*/ |
PlantesEtLichensASL.prototype.initForm = function() { |
const lthis = this; |
$('[type="date"]').prop('max', function(){ |
return new Date().toJSON().split('T')[0]; |
}); |
43,23 → 41,23 |
* Initialise les écouteurs d'événements |
*/ |
PlantesEtLichensASL.prototype.initEvts = function() { |
const lthis = this; |
var releveDatas = [], |
idUtilisateur = $( '#id_utilisateur' ).val(); |
const idUtilisateur = $( '#id_utilisateur' ).val(); |
if( this.valOk( idUtilisateur ) ) { |
if( valOk( idUtilisateur ) ) { |
// #releve-data est modifié, bouton dans #releves-utilisateur |
this.btnsChargerForm( '#bouton-nouveau-releve' ); |
if( this.valOk( $( '#releve-data' ).val() ) ) { |
if( valOk( $( '#releve-data' ).val() ) ) { |
this.releveDatas = $.parseJSON( $( '#releve-data' ).val() ); |
if ( this.valOk( this.releveDatas[0].utilisateur, true, idUtilisateur ) ) { |
if ( valOk( this.releveDatas[0].utilisateur, true, idUtilisateur ) ) { |
// Sur téléchargement image |
this.initEvtsFichier(); |
// Création / Suppression / Transmission des obs |
// Défilement des miniatures dans le résumé obs |
this.initEvtsObs(); |
// chargement plantes ou lichens, ajout du bouton #poursuivre |
var btnChargementForm = this.determinerBtnsChargementForm( '#', true ); |
const btnChargementForm = this.determinerBtnsChargementForm( '#', true ); |
// #releve-data n'est pas modifié, bouton dans #charger-form |
this.btnsChargerForm( btnChargementForm, false, false ); |
if ( 'lichens' === this.sujet ) { |
101,12 → 99,11 |
PlantesEtLichensASL.prototype.checkboxToutesLesFaces = function() { |
$('input[name=lichens-tronc]').on( 'click', function( event ) { |
var face = $( this ).data( 'face' ); |
const face = $( this ).data( 'face' ); |
if ( $( this ).is( ':checked' ) ) { |
console.log('hello'); |
if( $( this ).hasClass( 'lichens-tronc-all' ) ) { |
for ( i = 1; i <= 5 ; i++ ) { |
for ( let i = 1; i <= 5 ; i++ ) { |
$( '#lichens-tronc-' + face + i ).prop( 'checked', false ); |
} |
} else { |
122,7 → 119,7 |
* dont les données seront transmises dans la table cel-obs-etendues |
*/ |
PlantesEtLichensASL.prototype.getObsChpSpecifiques = function( numArbre ) { |
var retour = [ |
const retour = [ |
{ cle : 'num-arbre', valeur : numArbre }, |
{ cle : 'id_obs_arbre', valeur : this.releveDatas[numArbre]['id_observation'] }, |
{ cle : 'rue' , valeur : this.releveDatas[0].rue } |
129,9 → 126,9 |
]; |
if ( 'lichens' === this.sujet ) { |
var valeursLT = ''; |
const $lichensTronc = $( 'input[name=lichens-tronc]:checked' ); |
const LTLenght = $lichensTronc.length; |
const $lichensTronc = $( 'input[name=lichens-tronc]:checked' ), |
LTLenght = $lichensTronc.length; |
let valeursLT = ''; |
$( 'input[name=lichens-tronc]:checked' ).each( function( i, value ) { |
valeursLT += $(value).val(); |
154,8 → 151,9 |
}); |
// Validation Taxon si pas de miniature |
$( '#taxon' ).on( 'change', function() { |
var images = lthis.valOk( $( '#miniatures .miniature' ) ); |
lthis.validerTaxonImage( lthis.valOk( $( this ).val() ), images ); |
const images = valOk( $( '#miniatures .miniature' ) ); |
lthis.validerTaxonImage( valOk( $( this ).val() ), images ); |
}); |
// // Validation miniatures avec MutationObserver |
197,8 → 195,9 |
}; |
PlantesEtLichensASL.prototype.validerTaxonImage = function( taxon = false, images = false ) { |
var taxonOuImage = ( images || taxon ); |
if ( images || taxon ) { |
const taxonOuImage = images || taxon; |
if ( taxonOuImage ) { |
this.masquerPanneau( '#dialogue-taxon-or-image' ); |
$( '#bloc-taxon' ).removeClass( 'error' ) |
.find( 'span.error' ).hide(); |
221,7 → 220,8 |
$( '#fichier' ).parent( 'label.label-file' ).addClass( 'error' ); |
$( '#photos-conteneur').addClass( 'error' ).find( 'span.error' ).show(); |
} |
return ( images || taxon ); |
return taxonOuImage; |
}; |
/** |
228,11 → 228,11 |
* Valide le formulaire au click sur un bouton "suivant" |
*/ |
PlantesEtLichensASL.prototype.validerForm = function() { |
const images = this.valOk( $( '#miniatures .miniature' ) ); |
const taxon = this.valOk( $( '#taxon' ).val() ); |
const taxonOuImage = this.validerTaxonImage( taxon, images ); |
const observateur = ( $( '#form-observateur' ).valid() && $( '#courriel' ).valid() ) |
const obs = $( '#form-' + this.sujet ).valid(); |
const images = valOk( $( '#miniatures .miniature' ) ), |
taxon = valOk( $( '#taxon' ).val() ), |
taxonOuImage = this.validerTaxonImage( taxon, images ), |
observateur = $( '#form-observateur' ).valid() && $( '#courriel' ).valid(), |
obs = $( '#form-' + this.sujet ).valid(); |
// panneau observateur |
if ( observateur ) { |
/trunk/widget/modules/saisie/squelettes/js/WidgetsSaisiesCommun.js |
---|
1,15 → 1,18 |
const utils = new Utils; |
import {Geoloc} from './tb-geoloc/js/Geoloc.js'; |
import {Utils,valOk} from './Utils.js'; |
export const utils = new Utils(); |
/** |
* WidgetsSaisiesCommun |
* Methodes communes aux widgets de saisie |
*/ |
function WidgetsSaisiesCommun(){} |
export function WidgetsSaisiesCommun(){} |
WidgetsSaisiesCommun.prototype.init = function() { |
this.geoloc = new Geoloc(); |
// ASL : APA, sTREETs, Lichen's Go! |
// const ASL = ['tb_aupresdemonarbre','tb_streets','tb_lichensgo']; |
// this.isASL = ( utils.valOk( this.projet ) && -1 < $.inArray( this.projet , ASL ) ); |
// this.isASL = ( valOk( this.projet ) && -1 < $.inArray( this.projet , ASL ) ); |
this.initForm(); |
this.initEvts(); |
}; |
73,7 → 76,7 |
$( '#courriel_confirmation' ).on( 'paste', this.bloquerCopierCollerCourriel.bind( this ) ); |
$( '#courriel_confirmation' ).on( 'blur', this.reduireVoletIdentite.bind( this ) ); |
$( '#courriel_confirmation' ).on( 'keypress', function( event ) { |
if ( lthis.valOk( event.which, true, 13 ) ) { |
if ( valOk( event.which, true, 13 ) ) { |
lthis.reduireVoletIdentite(); |
event.preventDefault(); |
event.stopPropagation(); |
85,8 → 88,8 |
WidgetsSaisiesCommun.prototype.initEvtsFichier = function() { |
const lthis = this; |
function fileInputFonctionne() { |
var ua = navigator.userAgent; |
const fileInputFonctionne = () => { |
const ua = navigator.userAgent; |
if ( |
ua.match( /(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/ ) || |
95,7 → 98,7 |
return false; |
} |
var elem = document.createElement( 'input' ); |
const elem = document.createElement( 'input' ); |
elem.type = 'file'; |
107,17 → 110,17 |
$( '#fichier' ).on( 'change', function ( event ) { |
lthis.arreter ( event ); |
var options = { |
beforeSend : function ( jqXHR, settings ) { |
$( '#miniatures' ).on( 'click', '.effacer-miniature', function() { |
jqXHR.abort(jqXHR); |
}); |
const options = { |
beforeSend : function ( jqXHR, settings ) { |
$( '#miniatures' ).on( 'click', '.effacer-miniature', function() { |
jqXHR.abort(jqXHR); |
}); |
}, |
success: lthis.afficherMiniature.bind( lthis ), // post-submit callback |
dataType: 'xml', // 'xml', 'script', or 'json' (expected server response type) |
resetForm: true // reset the form after successful submit |
}, |
success: lthis.afficherMiniature.bind( lthis ), // post-submit callback |
dataType: 'xml', // 'xml', 'script', or 'json' (expected server response type) |
resetForm: true // reset the form after successful submit |
}; |
var imgCheminTmp = $( '#fichier' ).val(), |
imgCheminTmp = $( '#fichier' ).val(), |
parts = imgCheminTmp.split( '\\' ), |
nomImage = parts[ parts.length - 1 ], |
formatImgOk = lthis.verifierFormat( nomImage ), |
136,10 → 139,10 |
} else { |
$( '#form-upload' )[0].reset(); |
if ( !formatImgOk ) { |
lthis.activerModale( lthis.msgTraduction( 'format-non-supporte' ) + ' : ' + $( '#fichier' ).attr( 'accept' ) ); |
utils.activerModale( lthis.msgTraduction( 'format-non-supporte' ) + ' : ' + $( '#fichier' ).attr( 'accept' ) ); |
} |
if ( !imgNonDupliquee ) { |
lthis.activerModale( lthis.msgTraduction( 'image-deja-chargee' ) ); |
utils.activerModale( lthis.msgTraduction( 'image-deja-chargee' ) ); |
} |
} |
return false; |
146,7 → 149,7 |
}); |
$( 'body' ).on( 'click', '.effacer-miniature', function() { |
$( this ).parent().remove(); |
if ( !lthis.valOk( $('.miniature-chargement' ) ) ) { |
if ( !valOk( $('.miniature-chargement' ) ) ) { |
$( '#ajouter-obs' ).removeClass( 'hidden' ); |
$( '#message-chargement' ).addClass( 'hidden' ); |
} |
166,7 → 169,7 |
WidgetsSaisiesCommun.prototype.initEvtsGeoloc = function( isFormArbre = false ) { |
const lthis = this; |
var ancre = '-observation', |
let ancre = '-observation', |
complementSelecteur = ''; |
if ( isFormArbre ) { |
173,13 → 176,17 |
ancre = '-arbres'; |
complementSelecteur = ancre; |
} |
// Empêcher que le module carto ne bind ses events partout |
$( '#zone' + ancre ).on( 'submit blur click focus mousedown mouseleave mouseup change', '#tb-geolocation' + complementSelecteur + ' *', function( event ) { |
event.preventDefault(); |
return false; |
}); |
// evenement location |
$( '#tb-geolocation' + complementSelecteur ).on( 'location' , this.locationHandler.bind( this ) ); |
const $mapEl = $( '#tb-geolocation' + complementSelecteur ); |
if( valOk( $mapEl ) ) { |
const typeLocalisation = $mapEl.data( 'typeLocalisation' ) || 'point'; |
this.geoloc.init(complementSelecteur); |
$( '#coord' ).toggleClass( 'hidden', 'point' !== typeLocalisation ); |
// evenement location |
$mapEl.on( 'location' , this.locationHandler.bind( this ) ); |
} |
}; |
WidgetsSaisiesCommun.prototype.initEvtsObs = function() { |
197,7 → 204,7 |
}); |
// mécanisme de suppression d'une obs |
$( '#liste-obs' ).on( 'click', '.supprimer-obs', function() { |
var buttons = [ |
const buttons = [ |
{ |
label : 'Annuler', |
class : 'btn-secondary', |
210,10 → 217,10 |
} |
]; |
// bricolage pour avoir les deux contextes en même temps (objet et elt. du DOM) |
var that = this, |
const that = this, |
suppObs = lthis.supprimerObs.bind( lthis ); |
lthis.activerModale( lthis.msgTraduction( 'confirmation-suppression' ), '', buttons ); |
utils.activerModale( lthis.msgTraduction( 'confirmation-suppression' ), '', buttons ); |
$( '.confirmer' ).on( 'click', function() { |
suppObs( that ); |
}); |
233,7 → 240,7 |
*/ |
WidgetsSaisiesCommun.prototype.chargerStatutSSO = function() { |
const lthis = this; |
var urlAuth = this.urlBaseAuth + '/identite'; |
let urlAuth = this.urlBaseAuth + '/identite'; |
if( 'local' !== this.mode ) { |
this.connexion( urlAuth, true ); |
240,14 → 247,15 |
if( this.isASL) { |
$( '#connexion' ).on( 'click', function( event ) { |
event.preventDefault(); |
if( $( '#utilisateur-connecte' ).hasClass( 'hidden' ) || !lthis.valOk( $( '#nom-complet' ).text() ) ) { |
var login = $( '#courriel' ).val(), |
mdp = $( '#mdp' ).val(); |
if ( lthis.valOk( login ) && lthis.valOk( mdp ) ) { |
if( $( '#utilisateur-connecte' ).hasClass( 'hidden' ) || !valOk( $( '#nom-complet' ).text() ) ) { |
const login = $( '#courriel' ).val(), |
mdp = $( '#mdp' ).val(); |
if ( valOk( login ) && valOk( mdp ) ) { |
urlAuth = lthis.urlBaseAuth + '/connexion?login=' + login + '&password=' + mdp; |
lthis.connexion( urlAuth, true ); |
} else { |
lthis.activerModale( lthis.msgTraduction( 'non-connexion' ) ); |
utils.activerModale( lthis.msgTraduction( 'non-connexion' ) ); |
} |
} |
}); |
254,6 → 262,7 |
} |
} else { |
urlAuth = this.urlWidgets + 'modules/saisie/test-token.json'; |
// Pour tester le bouton de connexion : |
// $( '#connexion' ).on( 'click', function( event ) { |
// event.preventDefault(); |
// lthis.connexion( urlAuth, true ); |
266,7 → 275,7 |
* Déconnecte l'utilisateur du SSO |
*/ |
WidgetsSaisiesCommun.prototype.deconnecterUtilisateur = function() { |
var urlAuth = this.urlBaseAuth + '/deconnexion'; |
const urlAuth = this.urlBaseAuth + '/deconnexion'; |
if( 'local' === this.mode ) { |
this.definirUtilisateur(); |
305,7 → 314,7 |
WidgetsSaisiesCommun.prototype.definirUtilisateur = function( jeton ) { |
const thisObj = this; |
var idUtilisateur = '', |
let idUtilisateur = '', |
prenom = '', |
nom = '', |
nomComplet = '', |
340,8 → 349,8 |
$( '#courriel' ).val( courriel ); |
$( '#profil-utilisateur a' ).attr( 'href', this.urlSiteTb() + 'membres/me' ); |
if ( this.isASL ) { |
if ( this.valOk( idUtilisateur ) ) { |
var nomSquelette = $( '#charger-form' ).data( 'load' ) || 'arbres'; |
if ( valOk( idUtilisateur ) ) { |
const nomSquelette = $( '#charger-form' ).data( 'load' ) || 'arbres'; |
this.chargerForm( nomSquelette, thisObj ); |
} |
} else { |
355,10 → 364,12 |
* JETON EST VALIDE, ne pas décoder n'importe quoi - pas trouvé de lib simple |
*/ |
WidgetsSaisiesCommun.prototype.decoderJeton = function( jeton ) { |
var parts = jeton.split( '.' ), |
payload = parts[1]; |
const parts = jeton.split( '.' ); |
let payload = parts[1]; |
payload = this.b64d( payload ); |
payload = JSON.parse( payload, true ); |
return payload; |
}; |
366,22 → 377,23 |
* Décodage "url-safe" des chaînes base64 retournées par le SSO (lib jwt) |
*/ |
WidgetsSaisiesCommun.prototype.b64d = function( input ) { |
var remainder = input.length % 4; |
const remainder = input.length % 4; |
if ( 0 !== remainder ) { |
var padlen = 4 - remainder; |
const padlen = 4 - remainder; |
for ( var i = 0; i < padlen; i++ ) { |
for ( let i = 0; i < padlen; i++ ) { |
input += '='; |
} |
} |
input = input.replace( '-', '+' ); |
input = input.replace( '_', '/' ); |
return atob( input ); |
}; |
WidgetsSaisiesCommun.prototype.urlSiteTb = function() { |
var urlPart = ( 'test' === this.mode ) ? '/test/' : '/'; |
const urlPart = ( 'test' === this.mode ) ? '/test/' : '/'; |
return this.urlRacine + urlPart; |
}; |
391,7 → 403,7 |
* Affiche/Cache le champ taxon |
*/ |
WidgetsSaisiesCommun.prototype.surChangementTaxonListe = function() { |
if ( utils.valOk( $( '#taxon-liste' ).val() ) ) { |
if ( valOk( $( '#taxon-liste' ).val() ) ) { |
if ( 'autre' !== $( '#taxon-liste' ).val() ) { |
$( '#taxon-input-groupe' ) |
.hide( 200, function () { |
405,7 → 417,7 |
.show(200) |
.find( '#taxon-autre' ) |
.on( 'change', function() { |
if( !utils.valOk( $( '#taxon-autre' ).data( 'numNomSel' ) ) ) { |
if( !valOk( $( '#taxon-autre' ).data( 'numNomSel' ) ) ) { |
$( '#taxon' ).val( $( '#taxon-autre' ).val() ) |
.data( 'value', $( '#taxon-autre' ).val() ) |
.removeData([ |
423,13 → 435,12 |
}; |
WidgetsSaisiesCommun.prototype.surChangementValeurTaxon = function() { |
var numNomSel = 0; |
if( this.valOk( $( '#taxon-liste' ).val() ) ) { |
if( valOk( $( '#taxon-liste' ).val() ) ) { |
if( 'autre' === $( '#taxon-liste' ).val() ) { |
this.ajouterAutocompletionNoms(); |
} else { |
var optionRetenue = $( '#taxon-liste' ).find( 'option[value="' + $( '#taxon-liste' ).val() + '"]' ); |
const optionRetenue = $( '#taxon-liste' ).find( 'option[value="' + $( '#taxon-liste' ).val() + '"]' ); |
$( '#taxon' ).val( $( '#taxon-liste' ).val() ) |
.data( 'value', $( '#taxon-liste' ).val() ) |
.data( 'numNomSel', optionRetenue.data( 'num-nom-sel' ) ) |
439,9 → 450,10 |
.data( 'famille', optionRetenue.data( 'famille' ) ); |
$( '#taxon' ).trigger( 'change' ); |
numNomSel = $( '#taxon' ).data( 'numNomSel' ); |
const numNomSel = $( '#taxon' ).data( 'numNomSel' ); |
// Si l'espèce est mal déterminée la certitude est "à déterminer" |
if( !this.valOk( numNomSel ) ) { |
if( !valOk( numNomSel ) ) { |
$( '#certitude' ).find( 'option' ).each( function() { |
if ( $( this ).hasClass( 'aDeterminer' ) ) { |
$( this ).attr( 'selected', true ); |
460,9 → 472,9 |
*/ |
WidgetsSaisiesCommun.prototype.ajouterAutocompletionNoms = function() { |
const lthis = this; |
var taxonSelecteur = '#taxon'; |
let taxonSelecteur = '#taxon'; |
if ( this.valOk( $( '#taxon-liste' ).val(), true, 'autre' ) ) { |
if ( valOk( $( '#taxon-liste' ).val(), true, 'autre' ) ) { |
taxonSelecteur += '-autre'; |
} |
$( taxonSelecteur ).autocomplete({ |
469,12 → 481,12 |
source: function( requete, add ) { |
// la variable de requête doit être vidée car sinon le parametre "term" est ajouté |
requete = ''; |
if( lthis.valOk( $( '#referentiel' ).val(), false, 'autre' ) ) { |
var url = lthis.getUrlAutocompletionNomsSci(); |
if( valOk( $( '#referentiel' ).val(), false, 'autre' ) ) { |
const url = lthis.getUrlAutocompletionNomsSci(); |
$( '#taxon-autocomplete-label' ).addClass( 'loading' ); |
$( '#taxon-autocomplete-label' ).addClass( 'loading' ); |
$.getJSON( url, requete, function( data ) { |
var suggestions = lthis.traiterRetourNomsSci( data ); |
let suggestions = lthis.traiterRetourNomsSci( data ); |
add( suggestions ); |
}) |
.fail( function() { |
497,16 → 509,15 |
}; |
WidgetsSaisiesCommun.prototype.getUrlAutocompletionNomsSci = function() { |
var taxonSelecteur = '#taxon'; |
let taxonSelecteur = '#taxon'; |
if ( this.valOk( $( '#taxon-liste' ).val(), true, 'autre' ) ) { |
if ( valOk( $( '#taxon-liste' ).val(), true, 'autre' ) ) { |
taxonSelecteur += '-autre'; |
} |
var mots = $( taxonSelecteur ).val(); |
var url = this.serviceAutocompletionNomSciUrlTpl.replace( '{referentiel}', this.nomSciReferentiel ); |
url = url.replace( '{masque}', mots ); |
const mots = $( taxonSelecteur ).val(), |
url = this.serviceAutocompletionNomSciUrlTpl.replace( '{referentiel}', this.nomSciReferentiel ); |
return url; |
return url.replace( '{masque}', mots ); |
}; |
/** |
513,10 → 524,10 |
* Objet taxons pour autocompletion en fonction de la recherche |
*/ |
WidgetsSaisiesCommun.prototype.traiterRetourNomsSci = function( data ) { |
var taxonSelecteur = '#taxon', |
suggestions = []; |
let taxonSelecteur = '#taxon', |
suggestions = []; |
if ( this.valOk ( $( '#taxon-liste' ).val(), true, 'autre' ) ) { |
if ( valOk ( $( '#taxon-liste' ).val(), true, 'autre' ) ) { |
taxonSelecteur += '-autre'; |
} |
if ( undefined != data.resultat ) { |
523,7 → 534,7 |
$.each( data.resultat, function( i, val ) { |
val.nn = i; |
var nom = { |
const nom = { |
label : '', |
value : '', |
nt : 0, |
564,7 → 575,7 |
* charge les données dans #taxon |
*/ |
WidgetsSaisiesCommun.prototype.surAutocompletionTaxon = function( event, ui ) { |
if ( utils.valOk( ui ) ) { |
if ( valOk( ui ) ) { |
$( '#taxon' ).val( ui.item.value ); |
$( '#taxon' ).data( 'value', ui.item.value ) |
.data( 'numNomSel', ui.item.numNomSel ) |
578,7 → 589,7 |
$( '#taxon' ).removeClass( 'ns-retenu' ); |
} |
// Si l'espèce est mal déterminée la certitude est "à déterminer" |
if( !utils.valOk( $( '#taxon' ).data( 'numNomSel' ) ) ) { |
if( !valOk( $( '#taxon' ).data( 'numNomSel' ) ) ) { |
$( '#certitude' ).find( 'option' ).each( function() { |
if ( $( this ).hasClass( 'aDeterminer' ) ) { |
$( this ).attr( 'selected', true ); |
597,15 → 608,11 |
* la miniature d'une image ajoutée à l'obs |
*/ |
WidgetsSaisiesCommun.prototype.afficherMiniature = function( reponse ) { |
if ( this.debug ) { |
var debogage = $( 'debogage', reponse ).text(); |
} |
var message = $( 'message', reponse ).text(); |
const message = $( 'message', reponse ).text(), |
$blocMiniature = $( '#miniatures .miniature.loading').first(); |
if( this.valOk( $blocMiniature ) ) { |
if ( this.valOk( message ) ) { |
if( valOk( $blocMiniature ) ) { |
if ( valOk( message ) ) { |
$( '.miniature-msg' ).text( message ); |
$blocMiniature.remove(); |
613,7 → 620,7 |
this.creerWidgetMiniature( reponse, $blocMiniature ); |
$blocMiniature.removeClass('loading'); |
} |
if ( !lthis.valOk( $( '.miniature-chargement' ) ) ) { |
if ( !valOk( $( '.miniature-chargement' ) ) ) { |
$( '#ajouter-obs' ).removeClass( 'hidden' ); |
$( '#message-chargement' ).addClass( 'hidden' ); |
} |
625,8 → 632,8 |
* Crée la miniature temporaire (formulaire) + bouton pour l'effacer |
*/ |
WidgetsSaisiesCommun.prototype.creerWidgetMiniature = function( reponse, $blocMiniature ) { |
var miniatureUrl = $( 'miniature-url', reponse ).text(); |
var imgNom = $( 'image-nom', reponse ).text(); |
const miniatureUrl = $( 'miniature-url', reponse ).text(), |
imgNom = $( 'image-nom', reponse ).text(); |
$blocMiniature.removeClass( 'miniature-chargement' ); |
$( '.miniature-img', $blocMiniature ) |
641,7 → 648,7 |
* Retourne true si l'extension de l'image 'nom' est .jpg ou .jpeg |
*/ |
WidgetsSaisiesCommun.prototype.verifierFormat = function( nomImage ) { |
var parts = nomImage.split( '.' ), |
const parts = nomImage.split( '.' ), |
extension = parts[ parts.length - 1 ]; |
return ( 'jpeg' === extension.toLowerCase() || 'jpg' === extension.toLowerCase() ); |
654,8 → 661,7 |
*/ |
WidgetsSaisiesCommun.prototype.verifierDuplication = function( nomImage ) { |
const lthis = this; |
var thisSrcParts = [], |
let thisSrcParts = [], |
thisNomImage = '', |
nonDupliquee = true; |
663,18 → 669,21 |
$( 'img.miniature-img,img.miniature' ).each( function() { |
// vérification avec alt de l'image |
if ( lthis.valOk ( $( this ).attr( 'alt' ) ) && $( this ).attr('alt' ).toLowerCase() === nomImage ) { |
if ( valOk ( $( this ).attr( 'alt' ) ) && $( this ).attr('alt' ).toLowerCase() === nomImage ) { |
nonDupliquee = false; |
return false;// Pas besoin de poursuivre la boucle |
} else { // sinon vérifie aussi avec l'adresse (src) de l'image |
thisSrcParts = $( this ).attr( 'src' ).split( '/' ); |
thisNomImage = thisSrcParts[ thisSrcParts.length - 1 ].replace( '_min', '' ).toLowerCase(); |
if ( lthis.valOk( thisNomImage, true, nomImage ) ) { |
if ( valOk( thisNomImage, true, nomImage ) ) { |
nonDupliquee = false; |
return false; |
} |
} |
}); |
return nonDupliquee; |
}; |
687,38 → 696,47 |
// Geoloc *********************************************************************/ |
WidgetsSaisiesCommun.prototype.transfererCarto = function( donnees ) { |
var typeLocalisation = donnees.typeLocalisation || 'point', |
isPoint = ( typeLocalisation === 'point' ).toString(), |
locationFilter = ( typeLocalisation === 'rue' ) ? 'linestring' : 'point', |
suffixe = ( this.valOk( donnees.suffixe ) ) ? '-' + donnees.suffixe : '', |
$cartoRemplacee = donnees.cartoRemplacee || $( '#tb-geolocation' ), |
layer = donnees.layer || 'osm', |
latitude = donnees.latitude || '46.5', |
longitude = donnees.longitude || '2.9', |
// 18 est le zoom max |
zoomInit = donnees.zoomInit || 18; |
const typeLocalisation = donnees.typeLocalisation || 'point', |
suffixe = valOk( donnees.suffixe ) ? '-' + donnees.suffixe : '', |
formSuffixe = '-arbres' === suffixe ? suffixe : '', |
$cartoRemplacee = donnees.cartoRemplacee || $( '#tb-geolocation' ), |
latitude = donnees.latitude || '', |
longitude = donnees.longitude || '', |
zoomInit = donnees.zoomInit || '', |
$mapContainer = $cartoRemplacee.closest('#map-container'); |
$cartoRemplacee.remove(); |
$( '#geoloc' + suffixe ).append( |
'<tb-geolocation-element'+ |
' id="tb-geolocation' + suffixe +'"'+ |
' layer="' + layer + '"'+ |
' zoom_init="' + zoomInit + '"'+ |
' lat_init="' + latitude + '"'+ |
' lng_init="' + longitude + '"'+ |
' marker="' + isPoint + '"'+ |
' polyline="' + !isPoint + '"'+ |
' polygon="false"'+ |
' show_lat_lng_elevation_inputs="' + isPoint + '"'+ |
' osm_class_filter=""'+ |
' geometry_filter="'+ locationFilter + '"'+ |
' elevation_provider="mapquest"'+ |
' map_quest_api_key="mG6oU5clZHRHrOSnAV0QboFI7ahnGg34"'+ |
' height="400px"'+ |
'>'+ |
'</tb-geolocation-element>' |
); |
this.initEvtsGeoloc( true ); |
if ( valOk( formSuffixe ) || 'point' !== typeLocalisation ) { |
$mapContainer.siblings('#tb-places-zone').remove(); |
} |
if ( 'tb-geolocation' + suffixe !== $cartoRemplacee.attr('id') ) { |
$mapContainer.remove(); |
$( '#geoloc' + suffixe ).append( |
'<div id="map-container">'+ |
'<div'+ |
' id="tb-geolocation' + suffixe +'"'+ |
' data-layer="' + donnees.layer + '"'+ |
' data-zoom="' + zoomInit + '"'+ |
' data-type-localisation="' + typeLocalisation + '"'+ |
' data-form-suffix="' + formSuffixe + '"'+ |
' style="height: 400px;width: 100%"'+ |
'>'+ |
'</div>'+ |
'</div>' |
); |
$( '#coord' ).toggleClass( 'hidden', 'point' !== typeLocalisation ); |
if( valOk( this.geoloc.map ) ) { |
this.geoloc.closeMap(); |
} |
this.initEvtsGeoloc( true ); |
} else { |
this.geoloc.reSetDrawControl(); |
} |
this.geoloc.setMapPosition({'lat': latitude, 'lng': longitude}); |
}; |
// Ajouter Obs ****************************************************************/ |
745,11 → 763,13 |
$( '.obs-nbre' ).text( this.obsNbre ); |
$( '.obs-nbre' ).triggerHandler( 'changement' ); |
//formatage des données |
var obsData = this.formaterFormObsData(); |
const obsData = this.formaterFormObsData(); |
this.afficherObs( obsData ); |
this.stockerObsData( obsData ); |
if ( this.isASL && 'arbres' === this.sujet ) { |
var arbreData = obsData.sujet; |
const arbreData = obsData.sujet; |
// Ajout de donnée utiles puis stockage dans input hidden "releve-data" |
arbreData['date_rue_commune'] = obsData.releve.date + obsData.releve.rue + obsData.releve['commune-nom']; |
arbreData['id_observation'] = 0; |
771,16 → 791,16 |
* Formatage des données du formulaire pour stockage et envoi |
*/ |
WidgetsSaisiesCommun.prototype.formaterFormObsData = function() { |
var obsData = { obsNum : this.obsNbre, sujet : {}}, |
numNomSel = $( '#taxon' ).data( 'numNomSel' ), |
nomSel = $( '#taxon' ).val(), |
nomRet = $( '#taxon' ).data( 'nomRet' ), |
numNomRet = $( '#taxon' ).data( 'numNomRet' ), |
numTaxon = $( '#taxon' ).data( 'nt' ), |
famille = $( '#taxon' ).data( 'famille' ), |
referentiel = ( this.valOk( numNomSel ) ) ? this.nomSciReferentiel : 'autre', |
certitude = ( this.valOk( numNomSel ) ) ? $( '#certitude' ).val() : 'à determiner', |
imgB64 = [], |
const obsData = { obsNum : this.obsNbre, sujet : {}}, |
numNomSel = $( '#taxon' ).data( 'numNomSel' ), |
nomSel = $( '#taxon' ).val(), |
nomRet = $( '#taxon' ).data( 'nomRet' ), |
numNomRet = $( '#taxon' ).data( 'numNomRet' ), |
numTaxon = $( '#taxon' ).data( 'nt' ), |
famille = $( '#taxon' ).data( 'famille' ), |
referentiel = ( valOk( numNomSel ) ) ? this.nomSciReferentiel : 'autre', |
certitude = ( valOk( numNomSel ) ) ? $( '#certitude' ).val() : 'à determiner'; |
let imgB64 = [], |
imgNom = [], |
date = '', |
notes = '', |
794,18 → 814,19 |
obsEtendue = []; |
if( !this.isASL ) { |
notes = $( '#notes' ).val().trim() || ''; |
pays = $( '#pays' ).val() || ''; |
communeNom = $( '#commune-nom' ).val(); |
communeInsee = $( '#commune-insee' ).val() || ''; |
geometry = $( '#geometry' ).val(); |
latitude = $( '#latitude' ).val(); |
longitude = $( '#longitude' ).val(); |
altitude = $( '#altitude' ).val(); |
obsEtendue = this.getObsChpSpecifiques(); |
date = this.fournirDate( $('#date_releve').val()); |
notes = $( '#notes' ).val().trim() || ''; |
pays = $( '#pays' ).val() || ''; |
communeNom = $( '#commune-nom' ).val(); |
communeInsee = $( '#commune-insee' ).val() || ''; |
geometry = $( '#geometry' ).val(); |
latitude = $( '#latitude' ).val(); |
longitude = $( '#longitude' ).val(); |
altitude = $( '#altitude' ).val(); |
obsEtendue = this.getObsChpSpecifiques(); |
date = this.fournirDate( $('#date_releve').val()); |
} else { |
var miniatureImg = []; |
const miniatureImg = []; |
notes = $( '#commentaire' ).val() || ''; |
if ( 'arbres' === this.sujet ) { |
// Dans ce cas cette fonction doit renvoyer des données au même format que l'input hidden "releve-data" |
864,7 → 885,8 |
obsData.releve['pres-lampadaires'] = $( '#pres-lampadaires input:checked' ).val() || ''; |
} |
if ( 'tb_streets' !== this.projet ) { |
var faceOmbre = []; |
const faceOmbre = []; |
$( '#face-ombre input' ).each( function() { |
if( $( this ).is( ':checked' ) ) { |
faceOmbre.push( $( this ).val() ); |
928,7 → 950,7 |
*/ |
WidgetsSaisiesCommun.prototype.afficherObs = function( datasObs ) { |
// différences html liéees au responsive |
var responsivDiff1 = '', |
let responsivDiff1 = '', |
responsivDiff2 = '', |
responsivDiff3 = '', |
responsivDiff4 = '', |
944,8 → 966,8 |
responsivDiff6 = '</div>'; |
} |
var obsNum = datasObs.obsNum, |
numNomSel = datasObs.sujet['num_nom_sel'] || '', |
const obsNum = datasObs.obsNum; |
let numNomSel = datasObs.sujet['num_nom_sel'] || '', |
taxon = '', |
miniatures = '', |
notes = '', |
973,19 → 995,19 |
longitude = datasObs.sujet['longitude'] || ''; |
inseeCommune = datasObs.sujet['commune_code_insee'] || ''; |
commune = datasObs.sujet['commune_nom'] || ''; |
if ( this.valOk( inseeCommune ) ) { |
if ( valOk( inseeCommune ) ) { |
inseeCommuneText = '(INSEE Commune:' + inseeCommune + ') '; |
} |
if ( this.valOk( numNomSel ) ) { |
if ( valOk( numNomSel ) ) { |
referentiel = '<span class="referentiel-obs">' + '[' + datasObs.sujet['referentiel'] + ']' + '</span>'; |
} |
if ( this.valOk( datasObs.sujet['lieudit'] ) ) { |
if ( valOk( datasObs.sujet['lieudit'] ) ) { |
lieudit = '<span>' + this.msgTraduction( 'lieu-dit' ) + ' :</span> ' + datasObs.sujet['lieudit'] + ' '; |
} |
if ( this.valOk( datasObs.sujet['station'] ) ) { |
if ( valOk( datasObs.sujet['station'] ) ) { |
station = '<span>' + this.msgTraduction( 'station' ) + ' :</span> ' + datasObs.sujet['station'] + ' '; |
} |
if ( this.valOk( datasObs.sujet['milieu'] ) ) { |
if ( valOk( datasObs.sujet['milieu'] ) ) { |
milieu = '<span>' + this.msgTraduction( 'milieu' ) + ' :</span> ' + datasObs.sujet['milieu'] + ' '; |
} |
nn = this.ajouterNumNomSel( numNomSel ); |
1016,14 → 1038,14 |
date = this.fournirDate( datasObs.sujet.date ); |
} |
if( !this.isASL || 'arbres' === this.sujet ) { |
if ( this.valOk( commune ) ) { |
if ( valOk( commune ) ) { |
lieuObs = ' ' + this.msgTraduction( 'lieu-obs' ) + ' ' + '<span class="commune">' + commune + '</span> '; |
} |
if ( this.valOk( latitude ) && this.valOk( longitude ) ) { |
if ( valOk( latitude ) && valOk( longitude ) ) { |
coordonnees = '[' + latitude + ' / ' + longitude + ']'; |
} |
} |
if ( this.valOk( notes ) ) { |
if ( valOk( notes ) ) { |
commentaires = |
this.msgTraduction( 'commentaires' ) + |
' : <span>'+ |
1075,7 → 1097,7 |
milieu + |
'</li>'+ |
'<li>'+ |
// this.valOk( notes ) |
// valOk( notes ) |
commentaires + |
'</li>'+ |
'</ul>'+ |
1093,7 → 1115,7 |
*/ |
WidgetsSaisiesCommun.prototype.ajouterImgMiniatureAuTransfert = function( chargerImages = undefined ) { |
const lthis = this; |
var html = |
let html = |
'<div class="defilement-miniatures">'+ |
'<figure class="centre">'+ |
'<img class="miniature align-middle" alt="Aucune photo" src="' + this.pasDePhotoIconeUrl + '" width="80%" />'+ |
1104,12 → 1126,11 |
defilVisible = '', |
length = 0; |
if ( this.valOk( chargerImages ) || this.valOk( $( '#miniatures img' ) ) ) { |
if ( this.valOk( chargerImages ) ) { |
if ( valOk( chargerImages ) || valOk( $( '#miniatures img' ) ) ) { |
if ( valOk( chargerImages ) ) { |
$.each( chargerImages, function( i, value ) { |
var imgVisible = ( 0 < i ) ? 'miniature-cachee' : 'miniature-selectionnee'; |
var css = ( lthis.valOk( value['b64'] ) ) ? 'miniature b64' : 'miniature', |
let imgVisible = ( 0 < i ) ? 'miniature-cachee' : 'miniature-selectionnee', |
css = ( valOk( value['b64'] ) ) ? 'miniature b64' : 'miniature', |
src = value.src, |
alt = value.nom, |
miniature = '<img class="' + css + ' ' + imgVisible + ' align-middle" alt="' + alt + '"src="' + src + '" width="80%" />'; |
1118,12 → 1139,13 |
}); |
length = chargerImages.length; |
} else { |
var premiere = true; |
let premiere = true; |
$( '#miniatures img' ).each( function() { |
var imgVisible = ( premiere ) ? 'miniature-selectionnee' : 'miniature-cachee'; |
let imgVisible = ( premiere ) ? 'miniature-selectionnee' : 'miniature-cachee'; |
premiere = false; |
var css = ( $( this ).hasClass( 'b64' ) ) ? 'miniature b64' : 'miniature', |
let css = ( $( this ).hasClass( 'b64' ) ) ? 'miniature b64' : 'miniature', |
src = $( this ).attr( 'src' ), |
alt = $( this ).attr( 'alt' ), |
miniature = '<img class="' + css + ' ' + imgVisible + ' align-middle" alt="' + alt + '"src="' + src + '" width="80%" />'; |
1136,7 → 1158,7 |
centre = 'centre'; |
defilVisible = ' defilement-miniatures-cache'; |
} |
html = |
html = |
'<div class="defilement-miniatures">'+ |
'<a href="#" class="defilement-miniatures-gauche mr-1' + defilVisible + '"><i class="fas fa-chevron-circle-left"></i></a>'+ |
'<figure class="' + centre + '">'+ |
1153,9 → 1175,9 |
* Construit le html à afficher pour le numNom |
*/ |
WidgetsSaisiesCommun.prototype.ajouterNumNomSel = function( numNomSel ) { |
var nn = '<span class="nn">[nn' + numNomSel + ']</span>'; |
let nn = '<span class="nn">[nn' + numNomSel + ']</span>'; |
if ( !this.valOk( numNomSel ) ) { |
if ( !valOk( numNomSel ) ) { |
nn = '<span class="alert-error">[' + this.msgTraduction( 'non-lie-au-ref' ) + ']</span>'; |
} |
1171,7 → 1193,7 |
// car les données peuvent provenir soit de la formaterFormObsData soit de cet input |
const lthis = this; |
// si releve dupliqué on ne stocke pas l'image : |
var stockerImg = this.valOk( obsDatas.sujet['miniature-img'] ), |
let stockerImg = valOk( obsDatas.sujet['miniature-img'] ), |
imgNom = [], |
imgB64 = []; |
1187,10 → 1209,10 |
// Si les miniatures ne sont pas déjà stockées (résultat de la loop précédente) |
if( stockerImg ) { |
$.each( obsDatas.sujet['miniature-img'] , function( i, obj ) { |
if( lthis.valOk( obj.nom ) ) { |
if( valOk( obj.nom ) ) { |
imgNom.push( obj.nom ); |
} |
if( lthis.valOk( obj['b64'] ) ) { |
if( valOk( obj['b64'] ) ) { |
imgB64.push( obj['b64'] ); |
} |
}); |
1230,7 → 1252,7 |
}; |
WidgetsSaisiesCommun.prototype.getNomsImgsOriginales = function() { |
var noms = new Array(); |
const noms = []; |
$( '.miniature-img' ).each( function() { |
noms.push( $( this ).attr( 'alt' ) ); |
1240,7 → 1262,7 |
}; |
WidgetsSaisiesCommun.prototype.getB64ImgsOriginales = function() { |
var b64 = new Array(); |
const b64 = []; |
$( '.miniature-img' ).each( function() { |
if ( $( this ).hasClass( 'b64' ) ) { |
1289,12 → 1311,12 |
}; |
WidgetsSaisiesCommun.prototype.defilerMiniatures = function( element ) { |
var miniatureSelectionne = element.siblings( 'figure' ).find( 'img.miniature-selectionnee' ); |
const miniatureSelectionne = element.siblings( 'figure' ).find( 'img.miniature-selectionnee' ); |
miniatureSelectionne.removeClass( 'miniature-selectionnee' ); |
miniatureSelectionne.addClass( 'miniature-cachee' ); |
var miniatureAffichee = miniatureSelectionne; |
let miniatureAffichee = miniatureSelectionne; |
if( element.hasClass( 'defilement-miniatures-gauche' ) ) { |
if( 0 !== miniatureSelectionne.prev( '.miniature' ).length ) { |
1314,7 → 1336,7 |
}; |
WidgetsSaisiesCommun.prototype.supprimerObs = function( selector ) { |
var obsId = $( selector ).val(); |
let obsId = $( selector ).val(); |
// Problème avec IE 6 et 7 |
if ( 'Supprimer' === obsId ) { |
1328,6 → 1350,9 |
* et remonte les suivantes d'un cran |
*/ |
WidgetsSaisiesCommun.prototype.supprimerObsParId = function( obsId, transmission = false ) { |
let arbreExId = 0, |
arbreId = 0; |
if ( this.isASL && 'arbres' === this.sujet ) { |
if ( !transmission ) { |
this.releveData = $.parseJSON( $( '#releve-data' ).val() ); |
1340,9 → 1365,6 |
if ( 1 > this.numArbre ) { |
$( '#bloc-info-arbres-title' ).addClass( 'hidden' ); |
} |
var arbreExId = 0, |
arbreId = 0; |
} |
this.obsNbre -= 1; |
$( '.obs-nbre' ).text( this.obsNbre ); |
1351,12 → 1373,12 |
obsId = parseInt(obsId); |
if ( !transmission ) { |
var listObsData = $( '#liste-obs' ).data(), |
exId = 0, |
indexObs = '', |
exIndexObs = ''; |
const listObsData = $( '#liste-obs' ).data(); |
let exId = 0, |
indexObs = '', |
exIndexOb = ''; |
for ( var id = obsId; id <= ( this.obsNbre + 1 ); id++ ) { |
for ( let id = obsId; id <= ( this.obsNbre + 1 ); id++ ) { |
exId = parseInt(id) + 1; |
indexObs = 'obsId' + id; |
exIndexObs = 'obsId' + exId; |
1378,7 → 1400,7 |
.data( 'arbre', arbreId ) |
.text( 'Arbre ' + arbreId ); |
// modification du numero d'arbre dans les obs étendues |
if ( this.valOk( listObsData[exIndexObs] ) ) { |
if ( valOk( listObsData[exIndexObs] ) ) { |
$.each( listObsData[exIndexObs].obs_etendue, function( i, obsE ) { |
if ('num_arbre' === obsE.cle ) { |
listObsData[exIndexObs].obs_etendue[i].valeur = arbreId; |
1389,7 → 1411,7 |
} |
// Mise à jour des données à transmettre |
if ( this.valOk( listObsData[exIndexObs] ) ) { |
if ( valOk( listObsData[exIndexObs] ) ) { |
$( '#liste-obs' ).data( indexObs, listObsData[exIndexObs] ); |
} |
if ( parseInt( id ) !== this.obsNbre ) { |
1402,13 → 1424,13 |
}; |
WidgetsSaisiesCommun.prototype.transmettreObs = function() { |
const lthis = this; |
var observations = $( '#liste-obs' ).data(); |
const lthis = this, |
observations = $( '#liste-obs' ).data(); |
if ( this.debug ) { |
console.dir( observations ); |
} |
if ( !this.valOk( typeof observations, true, 'object' ) ) { |
if ( !valOk( typeof observations, true, 'object' ) ) { |
this.afficherPanneau( '#dialogue-zero-obs' ); |
} else { |
this.nbObsEnCours = 1; |
1423,30 → 1445,30 |
}; |
WidgetsSaisiesCommun.prototype.depilerObsPourEnvoi = function() { |
var observations = $( '#liste-obs' ).data(); |
const observations = $( '#liste-obs' ).data(); |
// la boucle est factice car on utilise un tableau |
// dont on a besoin de n'extraire que le premier élément |
// or javascript n'a pas de méthode cross browsers pour extraire les clés |
// TODO: utiliser var.keys quand ça sera plus répandu |
// ou bien utiliser un vrai tableau et pas un objet |
for ( var obsNum in observations ) { |
var obsATransmettre = { |
'id_projet' : this.idProjet, |
'projet' : this.projet, |
'tag-obs' : this.tagObs, |
'tag-img' : this.tagImg |
}; |
var utilisateur = { |
id_utilisateur : $( '#id_utilisateur' ).val(), |
prenom : $( '#prenom' ).val(), |
nom : $( '#nom' ).val(), |
courriel : $( '#courriel' ).val() |
}; |
for ( let obsNum in observations ) { |
const obsATransmettre = { |
'id_projet' : this.idProjet, |
'projet' : this.projet, |
'tag-obs' : this.tagObs, |
'tag-img' : this.tagImg |
}, |
utilisateur = { |
id_utilisateur : $( '#id_utilisateur' ).val(), |
prenom : $( '#prenom' ).val(), |
nom : $( '#nom' ).val(), |
courriel : $( '#courriel' ).val() |
}; |
obsATransmettre['utilisateur'] = utilisateur; |
obsATransmettre[obsNum] = observations[obsNum]; |
var idObsNumerique = obsNum.replace( 'obsId', '' ); |
const idObsNumerique = obsNum.replace( 'obsId', '' ); |
if( '' !== idObsNumerique ) { |
this.envoyerObsAuCel( idObsNumerique, obsATransmettre ); |
1457,9 → 1479,8 |
WidgetsSaisiesCommun.prototype.envoyerObsAuCel = function( idObs, observation ) { |
const lthis = this; |
let erreurMsg = ''; |
var erreurMsg = ''; |
$.ajax({ |
url : lthis.serviceSaisieUrl, |
type : 'POST', |
1506,7 → 1527,7 |
} |
}, |
complete : function( jqXHR, textStatus ) { |
var debugMsg = lthis.extraireEnteteDebug( jqXHR ); |
const debugMsg = lthis.extraireEnteteDebug( jqXHR ); |
if ( '' !== erreurMsg ) { |
if ( lthis.debug ) { |
1513,7 → 1534,7 |
$( '#dialogue-obs-transaction-ko .alert-txt' ).append( '<pre class="msg-erreur">' + erreurMsg + '</pre>' ); |
$( '#dialogue-obs-transaction-ko .alert-txt' ).append( '<pre class="msg-debug">Débogage : ' + debugMsg + '</pre>' ); |
} |
var hrefCourriel = 'mailto:cel_remarques@tela-botanica.org?'+ |
const hrefCourriel = 'mailto:cel_remarques@tela-botanica.org?'+ |
'subject=Dysfonctionnement du widget de saisie ' + lthis.tagsMotsCles+ |
'&body=' + erreurMsg + '%0D%0ADébogage :%0D%0A' + debugMsg; |
1560,7 → 1581,7 |
WidgetsSaisiesCommun.prototype.mettreAJourProgression = function() { |
this.nbObsTransmises++; |
var pct = ( this.nbObsTransmises / this.totalObsATransmettre ) * 100; |
const pct = ( this.nbObsTransmises / this.totalObsATransmettre ) * 100; |
$( '#barre-progression-upload' ).attr( 'aria-valuenow', this.nbObsTransmises ); |
$( '#barre-progression-upload' ).css( 'width', pct + '%' ); |
1586,7 → 1607,7 |
$.validator.addMethod( |
'dateCel', |
function ( value, element ) { |
return ( lthis.valOk( value ) && ( /^(?:[0-9]{4}-[0-9]{2}-[0-9]{2})|(?:[0-9]{2}\/[0-9]{2}\/[0-9]{4})$/.test( value ) ) ); |
return ( valOk( value ) && ( /^(?:[0-9]{4}-[0-9]{2}-[0-9]{2})|(?:[0-9]{2}\/[0-9]{2}\/[0-9]{4})$/.test( value ) ) ); |
}, |
lthis.msgTraduction( 'date-incomplete' ) |
); |
1593,7 → 1614,7 |
$.validator.addMethod( |
'userEmailOk', |
function ( value, element ) { |
return ( lthis.valOk( value ) ); |
return ( valOk( value ) ); |
}, |
'' |
); |
1608,7 → 1629,7 |
$.validator.addMethod( |
'listFields', |
function ( value, element ) { |
return ( lthis.valOk( value ) ); |
return ( valOk( value ) ); |
}, |
'' |
); |
1622,7 → 1643,7 |
} |
}, |
onfocusout: function( element ) { |
if( lthis.valOk( element.id, false, 'taxon' ) || ( lthis.isASL && 'arbres' === lthis.sujet ) ) { |
if( valOk( element.id, false, 'taxon' ) || ( lthis.isASL && 'arbres' === lthis.sujet ) ) { |
if ( $( element ).valid() ) { |
$( element ).closest( '.control-group' ).removeClass( 'error' ); |
} else { |
1631,7 → 1652,7 |
} |
}, |
onkeyup : function( element ) { |
if( lthis.valOk( element.id, false, 'taxon' ) || ( lthis.isASL && 'arbres' === lthis.sujet ) ) { |
if( valOk( element.id, false, 'taxon' ) || ( lthis.isASL && 'arbres' === lthis.sujet ) ) { |
if ( $( element ).valid() ) { |
$( element ).closest( '.control-group' ).removeClass( 'error' ); |
} else { |
1640,7 → 1661,7 |
} |
}, |
unhighlight: function( element ) { |
if( lthis.valOk( element.id, false, 'taxon' ) || ( lthis.isASL && 'arbres' === lthis.sujet ) ) { |
if( valOk( element.id, false, 'taxon' ) || ( lthis.isASL && 'arbres' === lthis.sujet ) ) { |
$( element ).closest( '.control-group' ).removeClass( 'error' ); |
} |
}, |
1653,9 → 1674,11 |
// Formatage date *************************************************************/ |
WidgetsSaisiesCommun.prototype.fournirDate = function( dateObs ) { |
if ( /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/.test( dateObs ) ) { |
return dateObs; |
} else if ( /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.test( dateObs ) ) { |
var dateArray = dateObs.split( '-' ); |
const dateArray = dateObs.split( '-' ); |
return dateArray[2] + '/' + dateArray[1] + '/' + dateArray[0] |
} else { |
console.dir( 'erreur date : ' + dateObs ) |
1664,12 → 1687,10 |
// scroll vers le formulaire |
WidgetsSaisiesCommun.prototype.scrollFormTop = function( scrollSelecteur, focus = '' ) { |
const lthis = this; |
$( 'html, body' ).stop().animate({ |
scrollTop: $( scrollSelecteur ).offset().top |
}, 300, function() { |
if ( lthis.valOk( focus ) ) { |
if ( valOk( focus ) ) { |
$( focus ).focus(); |
} else { |
return; |
1704,13 → 1725,13 |
* défaut); si celle-ci n'exite pas, retourne "N/A". |
*/ |
WidgetsSaisiesCommun.prototype.msgTraduction = function( cle ) { |
var msg = 'N/A'; |
let msg = 'N/A'; |
if ( this.msgs ) { |
if ( this.langue in this.msgs && cle in this.msgs[this.langue] ) { |
msg = this.msgs[this.langue][cle]; |
} else if ( cle in this.msgs['fr'] ) { |
msg = this.msgs['fr'][cle]; |
if ( utils.msgs ) { |
if ( this.langue in utils.msgs && cle in utils.msgs[this.langue] ) { |
msg = utils.msgs[this.langue][cle]; |
} else if ( cle in utils.msgs['fr'] ) { |
msg = utils.msgs['fr'][cle]; |
} |
} |
return msg; |
1737,10 → 1758,11 |
* @returns {String} |
*/ |
WidgetsSaisiesCommun.prototype.extraireEnteteDebug = function( jqXHR ) { |
var msgDebug = ''; |
let msgDebug = ''; |
if ( '' !== jqXHR.getResponseHeader( 'X-DebugJrest-Data' ) ) { |
var debugInfos = jQuery.parseJSON( jqXHR.getResponseHeader( 'X-DebugJrest-Data' ) ); |
const debugInfos = jQuery.parseJSON( jqXHR.getResponseHeader( 'X-DebugJrest-Data' ) ); |
if ( null !== debugInfos ) { |
$.each( debugInfos, function( cle, valeur ) { |
msgDebug += valeur + '\n'; |
1761,14 → 1783,6 |
}); |
}; |
WidgetsSaisiesCommun.prototype.valOk = function ( valeur, sensComparaison = true, comparer = undefined ) { |
return utils.valOk( valeur, sensComparaison, comparer ); |
}; |
WidgetsSaisiesCommun.prototype.activerModale = function ( label, content = '', buttons = [] ) { |
return utils.activerModale( label, content, buttons ); |
}; |
// Lib hors objet |
/* |
1782,11 → 1796,11 |
* Adaptation par Aurélien Peronnet pour la mise en gras des noms de taxons valides |
*/ |
( function( $ ) { |
var proto = $.ui.autocomplete.prototype, |
const proto = $.ui.autocomplete.prototype, |
initSource = proto._initSource; |
WidgetsSaisiesCommun.prototype.filter = function( array, term ) { |
var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), 'i' ); |
const matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), 'i' ); |
return $.grep( array, function( value ) { |
/trunk/widget/modules/saisie/squelettes/js/WidgetsSaisiesASL.js |
---|
1,3 → 1,7 |
import {WidgetsSaisiesCommun,utils} from './WidgetsSaisiesCommun.js'; |
import {initialiserModule} from './InitialisationASL.js'; |
import {valOk} from './Utils.js'; |
/** |
* Constructeur WidgetsSaisiesASL par défaut |
* S'applique au squelette apa.tpl.html |
4,31 → 8,32 |
* Squelette de base d'apa streets et lg |
*/ |
// ASL : APA, sTREETs, Lichen's Go! |
function WidgetsSaisiesASL( proprietes ) { |
if ( utils.valOk( proprietes ) ) { |
this.urlWidgets = proprietes.urlWidgets; |
this.projet = proprietes.projet; |
this.idProjet = proprietes.idProjet; |
this.tagsMotsCles = proprietes.tagsMotsCles; |
this.mode = proprietes.mode; |
this.langue = proprietes.langue; |
this.serviceObsImgs = proprietes.serviceObsImgs; |
this.serviceObsImgUrl = proprietes.serviceObsImgUrl; |
this.serviceAnnuaireIdUrl = proprietes.serviceAnnuaireIdUrl; |
this.serviceNomCommuneUrl = proprietes.serviceNomCommuneUrl; |
this.serviceNomCommuneUrlAlt = proprietes.serviceNomCommuneUrlAlt; |
this.debug = proprietes.debug; |
this.html5 = proprietes.html5; |
this.serviceSaisieUrl = proprietes.serviceSaisieUrl; |
this.serviceObsUrl = proprietes.serviceObsUrl; |
this.chargementImageIconeUrl = proprietes.chargementImageIconeUrl; |
this.pasDePhotoIconeUrl = proprietes.pasDePhotoIconeUrl; |
this.autocompletionElementsNbre = proprietes.autocompletionElementsNbre; |
this.serviceAutocompletionNomSciUrl = proprietes.serviceAutocompletionNomSciUrl; |
this.serviceAutocompletionNomSciUrlTpl = proprietes.serviceAutocompletionNomSciUrlTpl; |
this.dureeMessage = proprietes.dureeMessage; |
this.obsMaxNbre = proprietes.obsMaxNbre; |
this.msgs = utils.msgs; |
export function WidgetsSaisiesASL() { |
WidgetsSaisiesCommun.call(this); |
if ( valOk( widgetProp ) ) { |
this.urlWidgets = widgetProp.urlWidgets; |
this.projet = widgetProp.projet; |
this.idProjet = widgetProp.idProjet; |
this.tagsMotsCles = widgetProp.tagsMotsCles; |
this.mode = widgetProp.mode; |
this.langue = widgetProp.langue; |
this.serviceObsImgs = widgetProp.serviceObsImgs; |
this.serviceObsImgUrl = widgetProp.serviceObsImgUrl; |
this.serviceAnnuaireIdUrl = widgetProp.serviceAnnuaireIdUrl; |
this.serviceNomCommuneUrl = widgetProp.serviceNomCommuneUrl; |
this.serviceNomCommuneUrlAlt = widgetProp.serviceNomCommuneUrlAlt; |
this.debug = widgetProp.debug; |
this.html5 = widgetProp.html5; |
this.serviceSaisieUrl = widgetProp.serviceSaisieUrl; |
this.serviceObsUrl = widgetProp.serviceObsUrl; |
this.chargementImageIconeUrl = widgetProp.chargementImageIconeUrl; |
this.pasDePhotoIconeUrl = widgetProp.pasDePhotoIconeUrl; |
this.autocompletionElementsNbre = widgetProp.autocompletionElementsNbre; |
this.serviceAutocompletionNomSciUrl = widgetProp.serviceAutocompletionNomSciUrl; |
this.serviceAutocompletionNomSciUrlTpl = widgetProp.serviceAutocompletionNomSciUrlTpl; |
this.dureeMessage = widgetProp.dureeMessage; |
this.obsMaxNbre = widgetProp.obsMaxNbre; |
} |
this.urlRacine = window.location.origin; |
this.isASL = true; |
47,30 → 52,32 |
this.idUtilisateur = null; |
this.sujet = null; |
this.isTaxonListe = false; |
this.geoloc = {}; |
} |
WidgetsSaisiesASL.prototype = new WidgetsSaisiesCommun(); |
WidgetsSaisiesASL.prototype = Object.create(WidgetsSaisiesCommun.prototype); |
WidgetsSaisiesASL.prototype.constructor = WidgetsSaisiesASL; |
/** |
* Initialise le formulaire, les validateurs, les listes de complétion... |
*/ |
WidgetsSaisiesASL.prototype.initForm = function() { |
this.initFormConnection(); |
}; |
WidgetsSaisiesASL.prototype.initEvts = function() { |
const lthis = this; |
// initialisation des fonctions connexion utilisateur |
this.initEvtsConnection(); |
// chargement plantes ou lichens |
if ( this.valOk( $( '.charger-releve' ) ) ) { |
var btnChargementForm = this.determinerBtnsChargementForm( '.' ); |
if ( valOk( $( '.charger-releve' ) ) ) { |
const btnChargementForm = this.determinerBtnsChargementForm( '.' ); |
// #releve-data n'est pas modifié, bouton dans #releves-utilisateur |
this.btnsChargerForm( btnChargementForm, false ); |
} |
}; |
/** |
* Initialise le formulaire, les validateurs, les listes de complétion... |
*/ |
WidgetsSaisiesASL.prototype.initForm = function() { |
this.initFormConnection(); |
}; |
WidgetsSaisiesASL.prototype.determinerBtnsChargementForm = function( typeSelecteur, ajouterBtnPoursuivre = false ) { |
var complement = '', |
let complement = '', |
selecteurDefault = '', |
separateur = ','; |
107,21 → 114,21 |
}; |
WidgetsSaisiesASL.prototype.btnsChargerForm = function( btn, modifierReleveData = true, dansRelevesUtilisateur = true ) { |
const lthis = this; |
var bloc = ( dansRelevesUtilisateur ) ? '#releves-utilisateur' : '#charger-form'; |
const lthis = this, |
bloc = ( dansRelevesUtilisateur ) ? '#releves-utilisateur' : '#charger-form'; |
$( btn, bloc ).off().on( 'click', function( event ) { |
event.preventDefault(); |
var thisWidgetObs = ( lthis.valOk( $( '#' + lthis.projet + '-obs' ).val() ) ) ? $.parseJSON( $( '#' + lthis.projet + '-obs' ).val() ) : []; |
var nomSquelette = $( this ).data( 'load' ), |
releveDatas = ''; |
const thisWidgetObs = ( valOk( $( '#' + lthis.projet + '-obs' ).val() ) ) ? $.parseJSON( $( '#' + lthis.projet + '-obs' ).val() ) : [], |
nomSquelette = $( this ).data( 'load' ); |
let releveDatas = ''; |
$( '#charger-form' ).data( 'load', nomSquelette ); |
if ( modifierReleveData ) { |
if ( '#bouton-nouveau-releve' !== btn ) { |
$( '#bouton-nouveau-releve' ).removeClass( 'hidden' ); |
if ( lthis.valOk( thisWidgetObs ) ) { |
if ( valOk( thisWidgetObs ) ) { |
releveDatas = JSON.stringify( thisWidgetObs[ $( this ).data( 'releve' ) ] ); |
} |
} else { |
130,7 → 137,7 |
$( '#releve-data' ).val( releveDatas ); |
} |
lthis.chargerForm( nomSquelette, lthis ); |
if ( lthis.valOk( thisWidgetObs ) ) { |
if ( valOk( thisWidgetObs ) ) { |
$( '#bouton-list-releves' ).removeClass( 'hidden' ); |
} |
$( '#table-releves' ).addClass( 'hidden' ); |
138,15 → 145,14 |
}; |
WidgetsSaisiesASL.prototype.chargerForm = function( nomSquelette, formObj ) { |
const lthis = this; |
const lthis = this, |
urlSquelette = this.urlWidgets + 'saisie?projet=' + this.projet + '&squelette=' + nomSquelette; |
var urlSquelette = this.urlWidgets + 'saisie?projet=' + this.projet + '&squelette=' + nomSquelette; |
$.ajax({ |
url: urlSquelette, |
type: 'get', |
success: function( squelette ) { |
if ( lthis.valOk( squelette ) ) { |
if ( valOk( squelette ) ) { |
formObj.chargerSquelette( squelette, nomSquelette ); |
} |
}, |
169,7 → 175,7 |
break; |
case 'arbres' : |
default : |
if ( this.valOk( this.sujet ) ) { |
if ( valOk( this.sujet ) ) { |
this.reinitialiserWidget( squelette ); |
} else { |
this.chargerObsUtilisateur( squelette ); |
179,13 → 185,15 |
}; |
WidgetsSaisiesASL.prototype.chargerFormPlantesOuLichens = function( squelette, nomSquelette ) { |
if ( this.valOk( $( '#releve-data' ).val() ) ) { |
if ( valOk( $( '#releve-data' ).val() ) ) { |
$( '#charger-form' ).html( squelette ); |
initialiserModule(nomSquelette); |
this.confirmerSortie(); |
const releveDatas = $.parseJSON( $( '#releve-data' ).val() ); |
const nbArbres = releveDatas.length -1; |
for ( var i = 1; i <= nbArbres ; i++ ) { |
for ( let i = 1; i <= nbArbres ; i++ ) { |
$( '#choisir-arbre' ).append( |
'<option value="' + i + '">'+ |
this.msgTraduction( 'arbre' ) + ' ' + i + |
198,7 → 206,8 |
WidgetsSaisiesASL.prototype.reinitialiserWidget = function( squelette ) { |
$( '#charger-form' ).html( squelette ); |
if ( this.valOk( $( '#releve-data' ).val() ) ) { |
initialiserModule(); |
if ( valOk( $( '#releve-data' ).val() ) ) { |
this.rechargerFormulaire(); |
} |
}; |
207,10 → 216,10 |
* Infos des obs arbres de cet utilisateur |
*/ |
WidgetsSaisiesASL.prototype.chargerObsUtilisateur = function( formReleve ) { |
const lthis = this; |
var tagsMotsCles = this.tagsMotsCles.split( ',' ), |
reprereAjoutTags = tagsMotsCles.length - 1, |
queryStringMotsCles = ''; |
const lthis = this, |
tagsMotsCles = this.tagsMotsCles.split( ',' ), |
reprereAjoutTags = tagsMotsCles.length - 1; |
let queryStringMotsCles = ''; |
$.each( tagsMotsCles , function( i, tag ) { |
queryStringMotsCles += 'mots_cles=' + tagsMotsCles[i]; |
227,17 → 236,18 |
url: urlObs, |
type: 'GET', |
success: function( dataObs, textStatus, jqXHR ) { |
if ( !lthis.valOk( dataObs ) ) { |
if ( !valOk( dataObs ) ) { |
dataObs = ''; |
} |
lthis.preformaterDonneesObs( dataObs ); |
}, |
error: function( jqXHR, textStatus, errorThrown ) { |
lthis.activerModale( lthis.msgTraduction( 'erreur-chargement-obs-utilisateur' ) ); |
utils.activerModale( lthis.msgTraduction( 'erreur-chargement-obs-utilisateur' ) ); |
} |
}) |
.always( function() { |
$( '#charger-form' ).html( formReleve ); |
initialiserModule(); |
}); |
}; |
247,13 → 257,13 |
WidgetsSaisiesASL.prototype.preformaterDonneesObs = function( dataObs ) { |
const lthis = this; |
if ( this.valOk( dataObs ) ) { |
var projetObs = [], |
if ( valOk( dataObs ) ) { |
const tagsMotsCles = this.tagsMotsCles.split( ',' ); |
let projetObs = [], |
datRuComun = [], |
obsArbres = [], |
projetObsE = {}, |
count = 0, |
tagsMotsCles = this.tagsMotsCles.split( ',' ); |
count = 0; |
$.each( dataObs, function( i, obs ) { |
if ( |
261,7 → 271,7 |
new RegExp( tagsMotsCles[1] ).test( obs.mots_cles_texte ) && |
!/(:?plantes|lichens(?!go))/.test( obs.mots_cles_texte ) |
) { |
if ( lthis.valOk( obs.obs_etendue ) ) { |
if ( valOk( obs.obs_etendue ) ) { |
$.each( obs.obs_etendue, function( indice, obsE ) { |
projetObsE[obsE.cle] = obsE.valeur; |
}); |
279,13 → 289,13 |
// on insert les arbres dans les relevés en fonction de la date et la rue d'observation |
// car les arbres pour un relevé (date/rue) n'ont pas forcément été enregistrés dans l'ordre ni le même jour |
$.each( obsArbres, function( indexArbre, arbre ) { |
for ( var indexReleve = 0; indexReleve < datRuComun.length; indexReleve++ ) { |
for ( let indexReleve = 0; indexReleve < datRuComun.length; indexReleve++ ) { |
if ( arbre.date_rue_commune === datRuComun[indexReleve] ) { |
projetObs[indexReleve].push( arbre ); |
} |
} |
}); |
if ( this.valOk( projetObs ) ) { |
if ( valOk( projetObs ) ) { |
this.prechargerLesObs( projetObs ); |
$( '#' + this.projet + '-obs' ).val( JSON.stringify( projetObs ) ); |
$( '#bouton-list-releves' ).removeClass( 'hidden' ); |
298,9 → 308,9 |
* Stocke en Json les valeurs du relevé dans en value d'un input hidden |
*/ |
WidgetsSaisiesASL.prototype.formaterReleveData = function( releveDatas ) { |
var releve = [], |
obs = releveDatas.obs, |
obsE = releveDatas.obsE; |
const obs = releveDatas.obs, |
obsE = releveDatas.obsE; |
let releve = []; |
releve[0] = { |
utilisateur : obs.ce_utilisateur, |
315,10 → 325,12 |
'altitude-releve' : obsE['altitude-releve'], |
commentaires : obs.commentaire |
}; |
if ( 'tb_lichensgo' !== this.projet ) { |
releve[0]['zone-pietonne'] = obsE['zone-pietonne']; |
releve[0]['pres-lampadaires'] = obsE['pres-lampadaires']; |
} |
return releve; |
}; |
326,13 → 338,14 |
* Stocke en Json les valeurs d'une obs |
*/ |
WidgetsSaisiesASL.prototype.formaterArbreData = function( arbresDatas ) { |
var retour = {}, |
obs = arbresDatas.obs, |
obsE = arbresDatas.obsE, |
const obs = arbresDatas.obs, |
obsE = arbresDatas.obsE; |
let retour = {}, |
miniatureImg = []; |
if( this.valOk( obs['miniature-img'] ) ) { |
if( valOk( obs['miniature-img'] ) ) { |
miniatureImg = obs['miniature-img']; |
} else if ( this.valOk( obsE['miniature-img'] ) ) { |
} else if ( valOk( obsE['miniature-img'] ) ) { |
miniatureImg = $.parseJSON( obsE['miniature-img'] ); |
} |
372,11 → 385,11 |
}; |
WidgetsSaisiesASL.prototype.prechargerLesObs = function( thisWidgetObs ) { |
const lthis = this; |
const $listReleve = $( '#list-releves' ); |
const TEXT_ARBRE = ' ' + this.msgTraduction( 'arbre' ).toLowerCase(); |
const lthis = this, |
$listReleve = $( '#list-releves' ), |
TEXT_ARBRE = ' ' + this.msgTraduction( 'arbre' ).toLowerCase(); |
var nbArbres = '', |
let nbArbres = '', |
texteArbre = '', |
releveHtml = ''; |
388,11 → 401,11 |
$( this ).addClass( 'hidden' ); |
}); |
function boutonsChargerReleve( lthis, squelette, indice ) { |
var boutonLichens = |
const boutonLichens = |
'<a href="" class="saisir-lichens btn btn-sm btn-info" data-releve="' + indice + '" data-load="lichens">'+ |
'<i class="far fa-snowflake"></i> ' + lthis.msgTraduction( 'saisir-lichens' )+ |
'</a> ', |
boutonPlantes = |
boutonPlantes = |
'<a href="" class="saisir-plantes btn btn-sm btn-info mb-1" data-releve="' + indice + '" data-load="plantes">'+ |
'<i class="fas fa-seedling"></i> ' + lthis.msgTraduction( 'saisir-plantes' )+ |
'</a> '; |
408,6 → 421,7 |
} |
return ''; |
} |
$.each( thisWidgetObs, function( i, releve ) { |
nbArbres = releve.length - 1; |
texteArbre = ( 1 < nbArbres ) ? ( TEXT_ARBRE + 's' ) : TEXT_ARBRE; |
430,9 → 444,11 |
'</td>'+ |
'</tr>'; |
}); |
$listReleve.append( releveHtml ); |
$( '#nb-releves-bienvenue' ) |
.removeClass( 'hidden' ) |
.find( 'span.nb-releves' ) |
.text( thisWidgetObs.length ); |
}; |
}; |
/trunk/widget/modules/saisie/squelettes/js/Utils.js |
---|
1,9 → 1,7 |
"use strict"; |
function Utils(){ |
export function Utils() { |
this.cheminFichiers = $( '#zone-appli' ).data( 'url-fichiers' ); |
// système de traduction minimaliste |
this.msgs = { |
this.msgs = { |
fr: { |
'arbre' : 'Arbre', |
'dupliquer' : 'Dupliquer', |
73,8 → 71,6 |
}; |
}; |
var lthis = Utils.prototype; |
Utils.prototype.init = function() { |
// Modale "aide" du projet |
this.projetHelpModale(); |
92,61 → 88,24 |
this.collectOtherOption(); |
}; |
/** |
* Permet à la fois de vérifier qu'une valeur ou objet existe et n'est pas vide |
* et de comparer à une autre valeur : |
* Vérifie qu'une variable ou objet n'est pas : vide, null, undefined, NaN |
* Si comparer est défini on le compare à valeur en fonction de sensComparaison |
* Un booléen est une variable valide : on retourne true |
* @param { string || number || object || undefined } valeur |
* @param { boolean } sensComparaison : true = rechercher, false = refuser |
* @param { string || number || object || undefined || boolean } comparer :valeur à comparer |
* @returns {boolean} |
*/ |
Utils.prototype.valOk = function (valeur, sensComparaison = true, comparer = undefined ) { |
var retour = true; |
if ( 'boolean' !== typeof valeur ) { |
switch( typeof valeur ) { |
case 'string' : |
retour = ( '' !== valeur ); |
break; |
case 'number' : |
retour = ( NaN !== valeur ); |
break; |
case 'object' : |
retour = ( null !== valeur && undefined !== valeur && !$.isEmptyObject( valeur ) ); |
if ( null !== valeur && undefined !== valeur.length ) { |
retour = ( retour && 0 < valeur.length ); |
} |
break; |
case 'undefined' : |
default : |
retour = false; |
} |
if ( retour && comparer !== undefined ) { |
var resultComparaison = ( comparer === valeur ); |
retour = ( sensComparaison ) ? resultComparaison : !resultComparaison ; |
} |
// aide dans le titre du projet |
Utils.prototype.projetHelpModale = function() { |
const lthis = this; |
return retour; |
$( '#top' ).on ( 'click', '#info-button', function ( event ) { |
const fileMimeType = $( this ).data( 'mime-info' ), |
label = 'Aide du projet : ' + $( '#titre-projet' ).text(); |
} else { |
// Un booléen est une valeur valable |
return true; |
} |
if( fileMimeType.match( 'image' ) ) { |
const extention = fileMimeType.replace( /(?:imag)?e\/?/g , '' ), |
content = '<img id="modale-aide-img" src="' + lthis.cheminFichiers + 'info.' + extention + '" style="" alt="info projet" />'; |
} |
lthis.activerModale( label, content ); |
}); |
}; |
/************************************* |
* Fonctions de Style et Affichage * |
* des éléments "spéciaux" * |
*************************************/ |
// Logique d'affichage pour le input type=file |
Utils.prototype.inputFile = function() { |
// Initialisation des variables |
var $fileInput = $( '.input-file' ), |
$button = $( '.label-file' ); |
// Action lorsque la "barre d'espace" ou "Entrée" est pressée |
$( '#formulaire' ).on( 'keydown', '.label-file', function( event ) { |
if ( event.keyCode == 13 || event.keyCode == 32 ) { |
162,7 → 121,7 |
// _ S'assurer de bien viser la bonne list-checkbox |
// _ Au click sur un autre champ remballer la list-checkbox |
$( document ).click( function( event ) { |
var target = event.target; |
const target = event.target; |
if ( !$( target ).is( '.overSelect' ) && 0 === $( target ).closest( '.checkboxes' ).length ) { |
$( '.checkboxes' ).each( function () { |
179,12 → 138,13 |
$( this ).find( 'select' ).toggleClass( 'focus' ); |
// Cacher le volet des autres checkboxes et retirer leur focus |
var $checkboxes = $( this ).next(), |
count = $( '.checkboxes' ).length; |
const $checkboxes = $( this ).next(), |
count = $( '.checkboxes' ).length; |
for ( var i = 0; i < count; i++ ) { |
for ( let i = 0; i < count; i++ ) { |
if ( $( '.checkboxes' )[i] !== $checkboxes[0] && !$checkboxes.hasClass( 'hidden' ) ) { |
var $otherListCheckboxes = $( '.checkboxes' )[i]; |
const $otherListCheckboxes = $( '.checkboxes' )[i]; |
if ( !$otherListCheckboxes.classList.contains( 'hidden' ) ) { |
$otherListCheckboxes.classList.add( 'hidden' ); |
} |
206,9 → 166,7 |
}); |
$( '#top' ).on( 'click', '#ajouter-obs', function() { |
$( '.range-live-value' ).each( function() { |
var $this = $( this ); |
$this.text( '' ); |
$( this ).text( '' ); |
}); |
}); |
}; |
219,41 → 177,25 |
const lthis = this; |
$( '#zone-appli' ).on( 'click' , '.help-button' , function ( event ) { |
var thisFieldKey = $( this ).data( 'key' ), |
fileMimeType = $( this ).data( 'mime-type' ), |
label = 'Aide pour : ' + $( this ).data( 'name' ); |
const thisFieldKey = $( this ).data( 'key' ), |
fileMimeType = $( this ).data( 'mime-type' ), |
label = 'Aide pour : ' + $( this ).data( 'name' ); |
if( fileMimeType.match( 'image' ) ) { |
var extention = fileMimeType.replace( /(?:imag)?e\/?/g , '' ), |
content = '<img id="modale-aide-img" src="' + lthis.cheminFichiers + thisFieldKey + '.' + extention + '" style="" alt="' + thisFieldKey + '" />'; |
const extention = fileMimeType.replace( /(?:imag)?e\/?/g , '' ), |
content = '<img id="modale-aide-img" src="' + lthis.cheminFichiers + thisFieldKey + '.' + extention + '" style="" alt="' + thisFieldKey + '" />'; |
} |
lthis.activerModale( label, content ); |
}); |
}; |
// aide dans le titre du projet |
Utils.prototype.projetHelpModale = function() { |
const lthis = this; |
$( '#top' ).on ( 'click', '#info-button', function ( event ) { |
var fileMimeType = $( this ).data( 'mime-info' ), |
label = 'Aide du projet : ' + $( '#titre-projet' ).text(); |
if( fileMimeType.match( 'image' ) ) { |
var extention = fileMimeType.replace( /(?:imag)?e\/?/g , '' ), |
content = '<img id="modale-aide-img" src="' + lthis.cheminFichiers + 'info.' + extention + '" style="" alt="info projet" />'; |
} |
lthis.activerModale( label, content ); |
}); |
}; |
// Activation/Desactivation et contenu de la modale Bootstrap |
// https://getbootstrap.com/docs/3.3/javascript/#modals |
Utils.prototype.activerModale = function( label, content = '', buttons = [] ) { |
var dismiss = '', |
buttonsHtmlBase = '<button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>', |
buttonsHtml = buttonsHtmlBase; |
const lthis = this, |
buttonsHtmlBase = '<button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>'; |
let dismiss = '', |
buttonsHtml = buttonsHtmlBase; |
// Titre |
$( '#fenetre-modal-label' ).text( label ); |
293,11 → 235,11 |
}; |
Utils.prototype.redimentionnerImgAide = function() { |
var espHorizDisp = $( '.modal-dialog' ).innerWidth() <= 1200 ? $( '.modal-dialog' ).innerWidth() - 30 : 1200, |
cssImg = { |
'width': espHorizDisp, |
'height' : 'auto' |
}; |
const espHorizDisp = $( '.modal-dialog' ).innerWidth() <= 1200 ? $( '.modal-dialog' ).innerWidth() - 30 : 1200, |
cssImg = { |
'width': espHorizDisp, |
'height' : 'auto' |
}; |
$( '#modale-aide-img' ).css(cssImg).show(50); |
}; |
304,52 → 246,58 |
// Faire apparaitre un champ text "Autre" |
Utils.prototype.onOtherOption = function() { |
const PREFIX = 'collect-other-'; |
const lthis = this, |
PREFIX = 'collect-other-'; |
// Ajouter un champ texte pour "Autre" |
function optionAdd( otherId, $target, element, dataName, dataLabel ) { |
$target.after( |
'<div class="control-group">'+ |
'<label'+ |
' for="' + otherId + '"'+ |
' class="' + otherId + '"'+ |
'>'+ |
'Autre option "' + dataLabel.toLowerCase() + '" :'+ |
'</label>'+ |
'<input'+ |
' type="text"'+ |
' id="' + otherId + '"'+ |
' name="' + otherId + '"'+ |
' class="collect-other form-control"'+ |
' data-name="' + dataName + '"'+ |
' data-element="' + element + '"'+ |
'>'+ |
'</div>' |
); |
$( '#' + otherId ).focus(); |
} |
const optionAdd = ( |
otherId, |
$target, |
element, |
dataName, |
dataLabel |
) => { |
$target.after( |
'<div class="control-group">'+ |
'<label'+ |
' for="' + otherId + '"'+ |
' class="' + otherId + '"'+ |
'>'+ |
'Autre option "' + dataLabel.toLowerCase() + '" :'+ |
'</label>'+ |
'<input'+ |
' type="text"'+ |
' id="' + otherId + '"'+ |
' name="' + otherId + '"'+ |
' class="collect-other form-control"'+ |
' data-name="' + dataName + '"'+ |
' data-element="' + element + '"'+ |
'>'+ |
'</div>' |
); |
$( '#' + otherId ).focus(); |
}; |
// Supprimer un champ texte pour "Autre" |
function optionRemove( otherId ) { |
$( '#' + otherId ).closest('.control-group').remove(); |
} |
const optionRemove = otherId => $( '#' + otherId ).closest('.control-group').remove(); |
let dataName = '', |
otherId = '', |
dataLabel = '', |
element = ''; |
$( '.other', '#formulaire' ).each( function() { |
if( $( this ).hasClass( 'is-select' ) ) { |
var dataName = $( this ).data( 'name' ), |
otherId = PREFIX + dataName, |
dataLabel = $( '.select' ).data( 'label' ); |
dataName = $( this ).data( 'name' ); |
otherId = PREFIX + dataName; |
dataLabel = $( '.select' ).data( 'label' ); |
// Insertion du champ "Autre" après les boutons |
if ( !lthis.valOk( $( '#'+otherId ) ) ) { |
optionAdd( otherId, $( this ).parent( '.add-field-select' ), 'select', dataName, dataLabel ); |
} |
} else if ( $( this ).is( ':checked' ) ) { |
var dataName = $( this ).data( 'name' ), |
otherId = PREFIX + dataName, |
element = $( this ).data( 'element' ), |
dataLabel = $( this ).data( 'label' ); |
dataName = $( this ).data( 'name' ); |
otherId = PREFIX + dataName; |
dataLabel = $( this ).data( 'label' ); |
element = $( this ).data( 'element' ); |
// Insertion du champ "Autre" après les boutons |
if ( !lthis.valOk( $( '#'+ otherId ) ) ) { |
optionAdd( otherId, $( this ).parent( 'label' ), element, dataName, dataLabel ); |
358,10 → 306,9 |
}); |
$( '#formulaire' ).on( 'change', '.select', function () { |
var dataName = $( this ).data( 'name' ), |
otherId = PREFIX + dataName, |
dataLabel = $( this ).data( 'label' ); |
dataName = $( this ).data( 'name' ); |
otherId = PREFIX + dataName; |
dataLabel = $( this ).data( 'label' ); |
if( 'other' === $( this ).val() ) { |
// Insertion du champ "Autre" après les boutons |
if ( !lthis.valOk( $( '#'+otherId ) ) ) { |
375,10 → 322,9 |
}); |
$( '#formulaire' ).on( 'change', 'input[type=radio]', function () { |
var dataName = $( this ).data( 'name' ), |
otherId = PREFIX + dataName, |
dataLabel = $( this ).data( 'label' ); |
dataName = $( this ).data( 'name' ); |
otherId = PREFIX + dataName; |
dataLabel = $( this ).data( 'label' ); |
if( 'other' === $( this ).val() ) { |
// Insertion du champ "Autre" après les boutons |
if ( !lthis.valOk( $( '#'+otherId ) ) ) { |
392,11 → 338,10 |
}); |
$( '#formulaire' ).on( 'click', '.list-checkbox .other,.checkbox .other', function () { |
var dataName = $( this ).data( 'name' ), |
otherId = PREFIX + dataName, |
element = $( this ).data( 'element' ), |
dataLabel = $( this ).data( 'label' ); |
dataName = $( this ).data( 'name' ); |
otherId = PREFIX + dataName; |
dataLabel = $( this ).data( 'label' ); |
element = $( this ).data( 'element' ); |
if( $( this ).is( ':checked' ) ) { |
// Insertion du champ "Autre" après les boutons |
if ( !lthis.valOk( $( '#'+otherId ) ) ) { |
412,8 → 357,8 |
Utils.prototype.collectOtherOption = function() { |
$( '#formulaire' ).on( 'change', '.collect-other', function () { |
var otherIdSuffix = $( this ).data( 'name' ).replace( '[]', '' ); |
var element = $( this ).data( 'element' ); |
const otherIdSuffix = $( this ).data( 'name' ).replace( '[]', '' ), |
element = $( this ).data( 'element' ); |
if ( '' === $( this ).val() ){ |
if ( 'select' === element ) { |
440,3 → 385,52 |
}); |
}; |
/** |
* Permet à la fois de vérifier qu'une valeur ou objet existe et n'est pas vide |
* et de comparer à une autre valeur : |
* Vérifie qu'une variable ou objet n'est pas : vide, null, undefined, NaN |
* Si comparer est défini on le compare à valeur en fonction de sensComparaison |
* Un booléen est une variable valide : on retourne true |
* @param { string || number || object || undefined } valeur |
* @param { boolean } sensComparaison : true = rechercher, false = refuser |
* @param { string || number || object || undefined || boolean } comparer :valeur à comparer |
* @returns {boolean} |
*/ |
export const valOk = ( |
valeur, |
sensComparaison = true, |
comparer = undefined |
) => { |
let retour = true; |
if ( 'boolean' !== typeof valeur ) { |
switch( typeof valeur ) { |
case 'string' : |
retour = ( '' !== valeur ); |
break; |
case 'number' : |
retour = ( NaN !== valeur ); |
break; |
case 'object' : |
retour = ( null !== valeur && undefined !== valeur && !$.isEmptyObject( valeur ) ); |
if ( null !== valeur && undefined !== valeur.length ) { |
retour = ( retour && 0 < valeur.length ); |
} |
break; |
case 'undefined' : |
default : |
retour = false; |
} |
if ( retour && comparer !== undefined ) { |
const resultComparaison = ( comparer === valeur ); |
retour = ( sensComparaison ) ? resultComparaison : !resultComparaison ; |
} |
return retour; |
} else { |
// Un booléen est une valeur valable |
return true; |
} |
}; |
/trunk/widget/modules/saisie/squelettes/js/WidgetSaisie.js |
---|
1,38 → 1,39 |
import {WidgetsSaisiesCommun,utils} from './WidgetsSaisiesCommun.js'; |
import {valOk} from './Utils.js'; |
/** |
* Constructeur WidgetSaisie par défaut |
*/ |
function WidgetSaisie( proprietes ) { |
if ( valOk(proprietes) ) { |
this.urlWidgets = proprietes.urlWidgets; |
this.projet = proprietes.projet; |
this.idProjet = proprietes.idProjet; |
this.tagsMotsCles = proprietes.tagsMotsCles; |
this.mode = proprietes.mode; |
this.langue = proprietes.langue; |
this.serviceAnnuaireIdUrl = proprietes.serviceAnnuaireIdUrl; |
this.serviceNomCommuneUrl = proprietes.serviceNomCommuneUrl; |
this.serviceNomCommuneUrlAlt = proprietes.serviceNomCommuneUrlAlt; |
this.debug = proprietes.debug; |
this.html5 = proprietes.html5; |
this.serviceSaisieUrl = proprietes.serviceSaisieUrl; |
this.serviceObsUrl = proprietes.serviceObsUrl; |
this.chargementImageIconeUrl = proprietes.chargementImageIconeUrl; |
this.pasDePhotoIconeUrl = proprietes.pasDePhotoIconeUrl; |
this.autocompletionElementsNbre = proprietes.autocompletionElementsNbre; |
this.serviceAutocompletionNomSciUrl = proprietes.serviceAutocompletionNomSciUrl; |
this.serviceAutocompletionNomSciUrlTpl = proprietes.serviceAutocompletionNomSciUrlTpl; |
this.dureeMessage = proprietes.dureeMessage; |
this.obsMaxNbre = proprietes.obsMaxNbre; |
this.tagImg = proprietes.tagImg; |
this.tagObs = proprietes.tagObs; |
this.obsId = proprietes.obsId; |
this.nomSciReferentiel = proprietes.nomSciReferentiel; |
this.especeImposee = proprietes.especeImposee; |
this.infosEspeceImposee = proprietes.infosEspeceImposee; |
this.referentielImpose = proprietes.referentielImpose; |
this.isTaxonListe = proprietes.isTaxonListe; |
this.utils = utils; |
this.msgs = utils.msgs; |
function WidgetSaisie( ) { |
if ( valOk(widgetProp) ) { |
this.urlWidgets = widgetProp.urlWidgets; |
this.projet = widgetProp.projet; |
this.idProjet = widgetProp.idProjet; |
this.tagsMotsCles = widgetProp.tagsMotsCles; |
this.mode = widgetProp.mode; |
this.langue = widgetProp.langue; |
this.serviceAnnuaireIdUrl = widgetProp.serviceAnnuaireIdUrl; |
this.serviceNomCommuneUrl = widgetProp.serviceNomCommuneUrl; |
this.serviceNomCommuneUrlAlt = widgetProp.serviceNomCommuneUrlAlt; |
this.debug = widgetProp.debug; |
this.html5 = widgetProp.html5; |
this.serviceSaisieUrl = widgetProp.serviceSaisieUrl; |
this.serviceObsUrl = widgetProp.serviceObsUrl; |
this.chargementImageIconeUrl = widgetProp.chargementImageIconeUrl; |
this.pasDePhotoIconeUrl = widgetProp.pasDePhotoIconeUrl; |
this.autocompletionElementsNbre = widgetProp.autocompletionElementsNbre; |
this.serviceAutocompletionNomSciUrl = widgetProp.serviceAutocompletionNomSciUrl; |
this.serviceAutocompletionNomSciUrlTpl = widgetProp.serviceAutocompletionNomSciUrlTpl; |
this.dureeMessage = widgetProp.dureeMessage; |
this.obsMaxNbre = widgetProp.obsMaxNbre; |
this.tagImg = widgetProp.tagImg; |
this.tagObs = widgetProp.tagObs; |
this.obsId = widgetProp.obsId; |
this.nomSciReferentiel = widgetProp.nomSciReferentiel; |
this.especeImposee = widgetProp.especeImposee; |
this.infosEspeceImposee = widgetProp.infosEspeceImposee; |
this.referentielImpose = widgetProp.referentielImpose; |
this.isTaxonListe = widgetProp.isTaxonListe; |
} |
this.urlRacine = window.location.origin; |
this.obsNbre = 0; |
41,19 → 42,16 |
this.nbObsTransmises = 0; |
this.observer = null; |
this.isASL = false; |
this.geoloc = {}; |
} |
WidgetSaisie.prototype = new WidgetsSaisiesCommun(); |
var valOk = WidgetSaisie.prototype.valOk; |
/** |
* Initialise le formulaire, les validateurs, les listes de complétion... |
*/ |
WidgetSaisie.prototype.initForm = function() { |
const lthis = this; |
this.initFormConnection(); |
if ( this.valOk( this.obsId ) ) { |
if ( valOk( this.obsId ) ) { |
this.chargerInfoObs(); |
} |
if( this.isTaxonListe ) { |
66,7 → 64,7 |
// c'est voulu après la création d'une obs mais pas quand la page est actualisée |
// Déjà tenté: onbeforeunload avec un location.reload(true) n'a pas permis de le faire |
$( 'input[type=date]' ).each( function () { |
( lthis.valOk( $( this ).data( 'default' ) ) ) ? $( this ).val( $( this ).data( 'default' ) ) : $( this ).val( '' ); |
( valOk( $( this ).data( 'default' ) ) ) ? $( this ).val( $( this ).data( 'default' ) ) : $( this ).val( '' ); |
}); |
this.configurerFormValidator(); |
this.definirReglesFormValidator(); |
75,14 → 73,15 |
$( '#taxon' ).attr( 'disabled', 'disabled' ); |
$( '#taxon-input-groupe' ).attr( 'title', '' ); |
// Bricolage cracra pour avoir le nom retenu avec auteur (nom_retenu.libelle ne le mentionne pas) |
var infosEspeceImposee = $.parseJSON( this.infosEspeceImposee ); |
nomRetenuComplet = infosEspeceImposee.nom_retenu_complet, |
debutAnneRefBiblio = nomRetenuComplet.indexOf( ' [' ); |
const infosEspeceImposee = $.parseJSON( this.infosEspeceImposee ); |
let nomRetenuComplet = infosEspeceImposee.nom_retenu_complet; |
const debutAnneRefBiblio = nomRetenuComplet.indexOf( ' [' ); |
if ( -1 !== debutAnneRefBiblio ) { |
nomRetenuComplet = nomRetenuComplet.substr( 0, debutAnneRefBiblio ); |
} |
// fin bricolage cracra |
var infosAssociee = { |
const infosAssociee = { |
label : infosEspeceImposee.nom_sci_complet, |
value : infosEspeceImposee.nom_sci_complet, |
nt : infosEspeceImposee.num_taxonomique, |
102,8 → 101,6 |
* Initialise les écouteurs d'événements |
*/ |
WidgetSaisie.prototype.initEvts = function() { |
const lthis = this; |
// identité |
this.initEvtsConnection(); |
// on location, initialisation de la géoloc |
123,12 → 120,11 |
// Identité Observateur par courriel |
WidgetSaisie.prototype.requeterIdentiteCourriel = function() { |
const lthis = this; |
const lthis = this, |
courriel = $( '#courriel' ).val(), |
urlAnnuaire = this.serviceAnnuaireIdUrl + courriel; |
var courriel = $( '#courriel' ).val(); |
var urlAnnuaire = this.serviceAnnuaireIdUrl + courriel; |
if ( this.valOk( courriel ) ) { |
if ( valOk( courriel ) ) { |
$.ajax({ |
url : urlAnnuaire, |
type : 'GET', |
136,8 → 132,8 |
if ( lthis.debug ) { |
console.log( 'SUCCESS: ' + textStatus ); |
} |
if ( lthis.valOk( data ) && lthis.valOk( data[courriel] ) ) { |
var infos = data[courriel]; |
if ( valOk( data ) && valOk( data[courriel] ) ) { |
const infos = data[courriel]; |
lthis.surSuccesCompletionCourriel( infos, courriel ); |
} else { |
lthis.surErreurCompletionCourriel(); |
161,7 → 157,7 |
// se déclanche quand on choisit "Observation sans inscription" mais que le mail entré est incrit à Tela |
WidgetSaisie.prototype.surSuccesCompletionCourriel = function( infos, courriel ) { |
if ( $( '#utilisateur-connecte' ).hasClass( 'hidden' ) ) {// si quelque chose a foiré après actualisation |
if ( !this.valOk( $( '#warning-identite' ) ) ) { |
if ( !valOk( $( '#warning-identite' ) ) ) { |
$( '#zone-courriel' ).before( '<p id="warning-identite" class="warning"><i class="fas fa-exclamation-triangle"></i> ' + this.msgTraduction( 'courriel-connu' ) + '</p>' ); |
} |
$( '#inscription, #zone-prenom-nom, #zone-courriel-confirmation' ).addClass( 'hidden' ); |
179,7 → 175,7 |
}; |
WidgetSaisie.prototype.testerLancementRequeteIdentite = function( event ) { |
if ( this.valOk( event.which, true, 13 ) ) { |
if ( valOk( event.which, true, 13 ) ) { |
this.requeterIdentiteCourriel(); |
event.preventDefault(); |
event.stopPropagation(); |
191,7 → 187,7 |
$( '#bouton-connexion, #creation-compte' ).addClass( 'hidden' ); |
$( '#bienvenue').removeClass( 'hidden' ); |
$( '#inscription, #zone-courriel' ).addClass( 'hidden' ); |
if ( lthis.valOk( $( '#nom' ).val() ) && lthis.valOk( $( '#prenom' ).val() ) ) { |
if ( valOk( $( '#nom' ).val() ) && valOk( $( '#prenom' ).val() ) ) { |
$( '#zone-prenom-nom' ).addClass( 'hidden' ); |
$( '#bienvenue-prenom' ).text( ' ' + $( '#prenom' ).val() ); |
$( '#bienvenue-nom' ).text( ' ' + $( '#nom' ).val() ); |
211,25 → 207,28 |
}; |
WidgetSaisie.prototype.formaterPrenom = function() { |
var prenom = new Array(), |
const prenom = [], |
mots = $( '#prenom' ).val().split( ' ' ), |
motsLength = mots.length; |
for ( var i = 0; i < motsLength; i++ ) { |
var mot = mots[i]; |
for ( let i = 0; i < motsLength; i++ ) { |
let mot = mots[i], |
motMajuscule = ''; |
if ( 0 <= mot.indexOf( '-' ) ) { |
var prenomCompose = new Array(), |
motsComposes = mot.split( '-' ) |
const prenomCompose = new Array(), |
motsComposes = mot.split( '-' ), |
motsComposesLength = motsComposes.length; |
for ( var j = 0; j < motsComposesLength; j++ ) { |
var motSimple = motsComposes[j], |
motMajuscule = motSimple.charAt(0).toUpperCase() + motSimple.slice(1); |
for ( let j = 0; j < motsComposesLength; j++ ) { |
const motSimple = motsComposes[j]; |
motMajuscule = motSimple.charAt(0).toUpperCase() + motSimple.slice(1); |
prenomCompose.push( motMajuscule ); |
} |
prenom.push( prenomCompose.join( '-' ) ); |
} else { |
var motMajuscule = mot.charAt(0).toUpperCase() + mot.slice(1); |
motMajuscule = mot.charAt(0).toUpperCase() + mot.slice(1); |
prenom.push( motMajuscule ); |
} |
} |
238,20 → 237,20 |
WidgetSaisie.prototype.bloquerCopierCollerCourriel = function() { |
this.afficherPanneau( '#dialogue-bloquer-copier-coller' ); |
return false; |
}; |
// Préchargement des infos-obs ************************************************/ |
WidgetSaisie.prototype.chargerInfoObs = function() { |
const lthis = this; |
const lthis = this, |
urlObs = this.serviceObsUrl + '/' + this.obsId; |
var urlObs = this.serviceObsUrl + '/' + this.obsId; |
$.ajax({ |
url: urlObs, |
type: 'GET', |
success: function( data, textStatus, jqXHR ) { |
if ( lthis.valOk( data ) ) { |
if ( valOk( data ) ) { |
lthis.prechargerForm( data ); |
} else { |
lthis.surErreurChargementInfosObs.bind( lthis ); |
265,7 → 264,7 |
// @TODO faire mieux que ça ! |
WidgetSaisie.prototype.surErreurChargementInfosObs = function() { |
this.activerModale( this.msgTraduction( 'erreur-chargement' ) ); |
utils.activerModale( this.msgTraduction( 'erreur-chargement' ) ); |
}; |
WidgetSaisie.prototype.prechargerForm = function( data ) { |
281,11 → 280,12 |
// suffixe = '', |
// layer = 'osm', |
// zoomInit = 18 |
var typeLocalisation = $( '#top' ).data( 'type-loc' ), |
donnesResetCarto = { |
const typeLocalisation = $( '#top' ).data( 'type-loc' ), |
donnesResetCarto = { |
latitude : data.latitude, |
longitude : data.longitude, |
typeLocalisation : typeLocalisation |
typeLocalisation : typeLocalisation, |
zoom : 18 |
}; |
this.transfererCarto( donnesResetCarto ); |
} |
296,9 → 296,8 |
* Retourne un Array contenant les valeurs des champs étendus |
*/ |
WidgetSaisie.prototype.getObsChpSpecifiques = function() { |
const lthis = this; |
var champs = new Array(), |
const lthis = this, |
champs = [], |
$thisForm = $( '#form-supp' ), |
elements = |
'input[type=text]:not(.collect-other),'+ |
310,12 → 309,12 |
'input[type=date],'+ |
'textarea,'+ |
'.select', |
retour = new Array(); |
retour = []; |
$( elements, $thisForm ).each( function() { |
if ( lthis.valOk( $( this ).val() ) && ( lthis.valOk( $( this ).attr( 'name' ) ) || lthis.valOk( $( this ).data( 'name' ) ) ) ) { |
var valeur = $( this ).val(), |
cle = ( lthis.valOk( $( this ).attr( 'name' ) ) ) ? $( this ).attr( 'name' ) : $( this ).data( 'name' ); |
if ( valOk( $( this ).val() ) && ( valOk( $( this ).attr( 'name' ) ) || valOk( $( this ).data( 'name' ) ) ) ) { |
const valeur = $( this ).val(), |
cle = ( valOk( $( this ).attr( 'name' ) ) ) ? $( this ).attr( 'name' ) : $( this ).data( 'name' ); |
if ( cle in champs ) { |
champs[cle] += ';' + valeur; |
} else { |
323,10 → 322,10 |
} |
} |
}); |
for ( var key in champs ) { |
for ( let key in champs ) { |
retour.push({ 'cle' : key , 'valeur' : champs[key] }); |
} |
if ( this.valOk( $( '#coord-lineaire' ).val() ) ) { |
if ( valOk( $( '#coord-lineaire' ).val() ) ) { |
retour.push({ 'cle' : 'coordonnees-rue-ou-lineaire' , 'valeur' : $( '#coord-lineaire' ).val() }); |
} |
return retour; |
353,7 → 352,7 |
$('#taxon-autre').val(''); |
} |
} |
if ( this.valOk( $( '#form-supp' ) ) ) { |
if ( valOk( $( '#form-supp' ) ) ) { |
$( '#form-supp' ).validate().resetForm(); |
} |
}; |
363,43 → 362,34 |
* Fonction handler de l'évenement location du module tb-geoloc |
*/ |
WidgetSaisie.prototype.locationHandler = function( location ) { |
var locDatas = location.originalEvent.detail; |
const locDatas = location.originalEvent.detail; |
if ( this.valOk( locDatas ) ) { |
if ( valOk( locDatas ) ) { |
console.log( locDatas ); |
var geometry = JSON.stringify( locDatas.geometry ); |
var altitude = ( this.valOk( locDatas.elevation ) ) ? locDatas.elevation : ''; |
var pays = ( this.valOk( locDatas.osmCountryCode ) ) ? locDatas.osmCountryCode.toUpperCase() : 'FR'; |
var latitude = ''; |
var longitude = ''; |
var coordLineaire = ''; |
var nomCommune = ''; |
var communeInsee = ''; |
if ( this.valOk( locDatas.geometry.coordinates ) ) { |
if ( 'Point' === locDatas.geometry.type ) { |
if ( this.valOk( locDatas.geometry.coordinates[0] ) ) { |
longitude = locDatas.geometry.coordinates[0]; |
} |
if ( this.valOk( locDatas.geometry.coordinates[1] ) ) { |
latitude = locDatas.geometry.coordinates[1]; |
} |
} else if ( 'LineString' === locDatas.geometry.type && this.valOk( locDatas.centroid.coordinates ) ) { |
coordLineaire = JSON.stringify( locDatas.geometry.coordinates ); |
if ( this.valOk( locDatas.centroid.coordinates[0] ) ) { |
longitude = locDatas.centroid.coordinates[0]; |
} |
if ( this.valOk( locDatas.centroid.coordinates[1] ) ) { |
latitude = locDatas.centroid.coordinates[1]; |
} |
} |
const geometry = JSON.stringify( locDatas.geometry ), |
altitude = ( valOk( locDatas.elevation ) ) ? locDatas.elevation : '', |
pays = ( valOk( locDatas.osmCountryCode ) ) ? locDatas.osmCountryCode.toUpperCase() : 'FR'; |
let latitude = '', |
longitude = '', |
coordLineaire = '', |
nomCommune = '', |
communeInsee = ''; |
if ( valOk( locDatas.geometry.coordinates ) && |
valOk( locDatas.centroid.coordinates ) && |
valOk( locDatas.centroid.coordinates[0] ) && |
valOk( locDatas.centroid.coordinates[1] ) |
) { |
latitude = locDatas.centroid.coordinates[0]; |
longitude = locDatas.centroid.coordinates[1]; |
} |
if ( this.valOk( locDatas.inseeData ) ) { |
if ( valOk( locDatas.inseeData ) ) { |
nomCommune = locDatas.inseeData.nom; |
communeInsee = ( this.valOk( locDatas.inseeData.code ) ) ? locDatas.inseeData.code : ''; |
} else if ( this.valOk( locDatas.locality ) ) { |
communeInsee = ( valOk( locDatas.inseeData.code ) ) ? locDatas.inseeData.code : ''; |
} else if ( valOk( locDatas.locality ) ) { |
nomCommune = locDatas.locality; |
} else if ( this.valOk( locDatas.locality ) ) { |
} else if ( valOk( locDatas.locality ) ) { |
nomCommune = locDatas.osmCounty; |
} |
$( '#geometry' ).val( geometry ); |
410,21 → 400,20 |
$( '#commune-insee' ).val( communeInsee ); |
$( '#altitude' ).val( altitude ); |
$( '#pays' ).val( pays ); |
if ( this.valOk( $( '#latitude' ).val() ) && this.valOk( $( '#longitude' ).val() ) ) { |
if ( valOk( $( '#latitude' ).val() ) && valOk( $( '#longitude' ).val() ) ) { |
$( '#geoloc' ).closest( '.control-group' ).removeClass( 'error' ); |
} else { |
$( '#geoloc' ).closest( '.control-group' ).addClass( 'error' ); |
} |
} else { |
console.log( 'Error location' ); |
console.warn( 'Error location' ); |
} |
} |
// Form Validator *************************************************************/ |
WidgetSaisie.prototype.chpEtendusValidation = function() { |
const lthis = this; |
var $thisForm = $( '#form-supp' ), |
const lthis = this, |
$thisForm = $( '#form-supp' ), |
elements = |
'.checkbox,'+ |
'.radio,'+ |
444,18 → 433,17 |
minmax : [] |
}, |
errors = {}, |
namesListFields = [], |
picked = ''; |
namesListFields = []; |
let picked = ''; |
$( elements, $thisForm ).each( function() { |
for( var fieldsClass = 0; spefieldsCount > fieldsClass; fieldsClass++ ) { |
if ( lthis.valOk( $( this ).attr( 'required' ) ) && $( this ).hasClass( speFields[fieldsClass] ) && !lthis.valOk( chpSuppValidation.rules[ dataName ] ) ) { |
for( let fieldsClass = 0; spefieldsCount > fieldsClass; fieldsClass++ ) { |
const dataName = $( this ).data( 'name' ); |
var dataName = $( this ).data( 'name' ); |
if ( valOk( $( this ).attr( 'required' ) ) && $( this ).hasClass( speFields[fieldsClass] ) && !valOk( chpSuppValidation.rules[ dataName ] ) ) { |
namesListFields.push( dataName ); |
chpSuppValidation.rules[ dataName ] = { required : true }; |
if ( lthis.valOk( $( '.other', $( this ) ) ) ) { |
if ( valOk( $( '.other', $( this ) ) ) ) { |
picked = ( 'select' === speFields[fieldsClass] ) ? ':selected' : ':checked'; |
chpSuppValidation.rules[ 'collect-other-' + dataName.replace( '[]', '' ) ] = { |
required : '#other-' + dataName.replace( '[]', '' ) + picked, |
468,11 → 456,11 |
errors[dataName] = '.' + speFields[fieldsClass]; |
} |
} |
if ( lthis.valOk( $( this ).attr( 'name' ) ) && lthis.valOk ( $( this ).attr( 'required' ) ) && 0 > $.inArray( $( this ).attr( 'name' ) , namesListFields ) ) { |
if ( valOk( $( this ).attr( 'name' ) ) && valOk ( $( this ).attr( 'required' ) ) && 0 > $.inArray( $( this ).attr( 'name' ) , namesListFields ) ) { |
chpSuppValidation.rules[ $( this ).attr( 'name' ) ] = { required : true, minlength: 1 }; |
if( |
( lthis.valOk( $( this ).attr( 'type' ), true, 'number' ) || lthis.valOk( $( this ).attr( 'type' ), true, 'range' ) ) && |
( lthis.valOk( $( this )[0].min ) || lthis.valOk( $( this )[0].max ) ) |
( valOk( $( this ).attr( 'type' ), true, 'number' ) || valOk( $( this ).attr( 'type' ), true, 'range' ) ) && |
( valOk( $( this )[0].min ) || valOk( $( this )[0].max ) ) |
) { |
chpSuppValidation.rules[ $( this ).attr('name') ]['minMaxOk'] = true; |
chpSuppValidation.messages[ $( this ).attr('name') ] = lthis.validerMinMax( $( this )[0] ).message; |
479,9 → 467,9 |
} |
} |
}); |
if ( this.valOk( chpSuppValidation.rules ) ) { |
if ( valOk( chpSuppValidation.rules ) ) { |
$.each( chpSuppValidation.rules, function( key ) { |
if ( !lthis.valOk( chpSuppValidation.messages[key] ) ) { |
if ( !valOk( chpSuppValidation.messages[key] ) ) { |
chpSuppValidation.messages[key] = 'Ce champ est requis :\nVeuillez entrer une valeur valide.'; |
} |
}); |
493,15 → 481,15 |
}; |
WidgetSaisie.prototype.validerMinMax = function( element ) { |
var mMCond = new Boolean(), |
minCond = parseFloat( element.value ) >= parseFloat( element.min ), |
maxCond = parseFloat( element.value ) <= parseFloat( element.max ), |
messageMnMx = 'La valeur entrée doit être', |
returnMnMx = { cond : true , message : '' }; |
const minCond = parseFloat( element.value ) >= parseFloat( element.min ), |
maxCond = parseFloat( element.value ) <= parseFloat( element.max ), |
returnMnMx = { cond : true , message : '' }; |
let mnMxCond = new Boolean(), |
messageMnMx = 'La valeur entrée doit être'; |
if( |
( this.valOk( element.type, true, 'number' ) || this.valOk( element.type, true, 'range' ) ) && |
( this.valOk( element.min ) || this.valOk( element.max ) ) |
( valOk( element.type, true, 'number' ) || valOk( element.type, true, 'range' ) ) && |
( valOk( element.min ) || valOk( element.max ) ) |
) { |
if ( element.min && element.max ) { |
messageMnMx += ' comprise entre ' + element.min + ' et ' + element.max; |
521,21 → 509,20 |
}; |
WidgetSaisie.prototype.definirReglesFormValidator = function() { |
const lthis = this; |
const lthis = this, |
formSuppValidation = this.chpEtendusValidation(); |
var formSuppValidation = this.chpEtendusValidation(); |
$( '#form-supp' ).validate({ |
onclick : function( element ) { |
if ( |
( |
lthis.valOk( element.type, true, 'checkbox' ) || |
lthis.valOk( element.type, true, 'radio' ) |
valOk( element.type, true, 'checkbox' ) || |
valOk( element.type, true, 'radio' ) |
) && |
( |
!lthis.valOk( $( '.' + $( element ).attr( 'name' ).replace( '[]', '' ) + ':checked' ) ) || |
lthis.valOk( $( '.' + $( element ).attr( 'name' ).replace( '[]', '' ) + ':not(.other):checked' ) ) || |
!lthis.valOk( $( '#other-' + $( element ).attr( 'name' ).replace( '[]', '' ) ) ) || |
!valOk( $( '.' + $( element ).attr( 'name' ).replace( '[]', '' ) + ':checked' ) ) || |
valOk( $( '.' + $( element ).attr( 'name' ).replace( '[]', '' ) + ':not(.other):checked' ) ) || |
!valOk( $( '#other-' + $( element ).attr( 'name' ).replace( '[]', '' ) ) ) || |
$( '#other-' + $( element ).attr( 'name' ).replace( '[]', '' ) ).is( ':checked' ) || |
( |
$( '#other-' + $( element ).attr( 'name' ).replace( '[]', '' ) ).is( ':checked' ) && |
557,10 → 544,11 |
messages : formSuppValidation.messages, |
errorPlacement : function( error , element ) { |
if ( 0 < Object.keys( formSuppValidation.errors ).length ) { |
var errorsKeys = Object.keys( formSuppValidation.errors ), |
thisKey = '', |
const errorsKeys = Object.keys( formSuppValidation.errors ); |
let thisKey = '', |
errorsFlag = true; |
for ( i = 0 ; i < errorsKeys.length ; i++ ) { |
for ( let i = 0 ; i < errorsKeys.length ; i++ ) { |
thisKey = errorsKeys[i]; |
if( $( element ).attr( 'name' ) === thisKey ) { |
$( formSuppValidation.errors[thisKey] ).append( error ); |
583,8 → 571,9 |
}); |
// Validation Taxon si pas de miniature |
$( '#taxon' ).on( 'change', function() { |
var images = lthis.valOk( $( '#miniatures .miniature' ) ); |
lthis.validerTaxonImage( lthis.valOk( $( this ).val() ), images ); |
const images = valOk( $( '#miniatures .miniature' ) ); |
lthis.validerTaxonImage( valOk( $( this ).val() ), images ); |
}); |
// Validation miniatures avec MutationObserver |
this.surPresenceAbsenceMiniature(); |
625,8 → 614,9 |
}; |
WidgetSaisie.prototype.validerTaxonImage = function( taxon = false, images = false ) { |
var taxonOuImage = ( images || taxon ); |
if ( images || taxon ) { |
const taxonOuImage = images || taxon; |
if ( taxonOuImage ) { |
this.masquerPanneau( '#dialogue-taxon-or-image' ); |
$( '#bloc-taxon' ).removeClass( 'error' ) |
.find( 'span.error' ).hide(); |
639,20 → 629,20 |
$( '#fichier' ).parent( 'label.label-file' ).addClass( 'error' ); |
$( '#photos-conteneur').addClass( 'error' ).find( 'span.error' ).show(); |
} |
return ( images || taxon ); |
return taxonOuImage; |
}; |
WidgetSaisie.prototype.surPresenceAbsenceMiniature = function() { |
const lthis = this; |
// voir : https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/disconnect |
// Selectionne le noeud dont les mutations seront observées |
var targetNode = document.getElementById( 'miniatures' ); |
const targetNode = document.getElementById( 'miniatures' ); |
// Fonction callback à éxécuter quand une mutation est observée |
var callback = function( mutationsList ) { |
for( var mutation of mutationsList ) { |
var taxon = lthis.valOk( $( '#taxon' ).val() ); |
const callback = mutationsList => { |
let taxon; |
for( let mutation of mutationsList ) { |
taxon = valOk( $( '#taxon' ).val() ); |
images = ( 0 < mutation.target.childElementCount ); |
lthis.validerTaxonImage( taxon, images ); |
} |
664,31 → 654,31 |
}; |
WidgetSaisie.prototype.validerForm = function() { |
const lthis = this; |
const observateur = ( $( '#form-observateur' ).valid() && $( '#courriel' ).valid() && $( '#courriel_confirmation' ).valid() ), |
obs = $( '#form-observation' ).valid(), |
geoloc = ( valOk( $( '#latitude' ).val() ) && valOk( $( '#longitude' ).val() ) ) , |
images = valOk( $( '#miniatures .miniature' ) ), |
taxon = valOk( $( '#taxon' ).val() ), |
// validation et panneau taxon/images |
taxonOuImage = this.validerTaxonImage( taxon, images ); |
let chpsSupp = true; |
var observateur = ( $( '#form-observateur' ).valid() && $( '#courriel' ).valid() && $( '#courriel_confirmation' ).valid() ); |
var obs = $( '#form-observation' ).valid(); |
var geoloc = ( this.valOk( $( '#latitude' ).val() ) && this.valOk( $( '#longitude' ).val() ) ) ; |
var images = this.valOk( $( '#miniatures .miniature' ) ); |
var taxon = this.valOk( $( '#taxon' ).val() ); |
// validation et panneau taxon/images |
var taxonOuImage = this.validerTaxonImage( taxon, images ); |
var chpsSupp = new Boolean(); |
if ( this.valOk( $( '#form-supp' ) ) ) { |
if ( valOk( $( '#form-supp' ) ) ) { |
chpsSupp = ( function () { |
var otherFlag = $( '#form-supp' ).valid(); |
if( lthis.valOk( $( '.other', $( '#form-supp' ) ) ) ) { |
let otherFlag = $( '#form-supp' ).valid(); |
if( valOk( $( '.other', $( '#form-supp' ) ) ) ) { |
$( '.other', $( '#form-supp' ) ).each( function() { |
var picked = ( $( this ).data( 'element' ) !== 'select' ) ? ':checked' : ':selected'; |
if ( $( this ).is( picked ) && lthis.valOk( $( this ).val(), true, 'other' ) ) { |
const picked = ( $( this ).data( 'element' ) !== 'select' ) ? ':checked' : ':selected'; |
if ( $( this ).is( picked ) && valOk( $( this ).val(), true, 'other' ) ) { |
otherFlag = false; |
} |
}); |
} |
return otherFlag; |
})(); |
} else { |
chpsSupp = true; |
} |
// panneau geoloc |
if ( geoloc ) { |
717,3 → 707,11 |
$( '#taxon' ).val( '' ); |
$( '#taxon' ).data( 'numNomSel', '' ); |
}; |
$( document ).ready( function() { |
const widget = new WidgetSaisie(); |
widget.init(); |
// Fonctions de Style et Affichage des éléments "spéciaux" |
utils.init(); |
}); |
/trunk/widget/modules/saisie/squelettes/js/ReleveASL.js |
---|
1,3 → 1,6 |
import {WidgetsSaisiesASL} from './WidgetsSaisiesASL.js'; |
import {valOk} from './Utils.js'; |
/** |
* Constructeur ReleveASL par défaut |
* S'applique au squelette apaforms.tpl.html |
5,44 → 8,40 |
* Lors de la saisie du relevé et des arbres |
*/ |
// ASL : APA, sTREETs, Lichen's Go! |
function ReleveASL( proprietes, widgetProp ) { |
if ( utils.valOk( proprietes ) && utils.valOk( widgetProp ) ) { |
this.sujet = proprietes.sujet; |
this.tagImg = proprietes.tagImg; |
this.separationTagImg = proprietes.separationTagImg; |
this.tagImg = proprietes.tagImg; |
this.tagObs = proprietes.tagObs; |
this.separationTagObs = proprietes.separationTagObs; |
this.nomSciReferentiel = proprietes.nomSciReferentiel; |
this.referentielImpose = proprietes.referentielImpose; |
this.widgetProp = widgetProp; |
this.urlWidgets = widgetProp.urlWidgets; |
this.projet = widgetProp.projet; |
export function ReleveASL(arbresProp) { |
if ( valOk( arbresProp ) ) { |
this.sujet = arbresProp.sujet; |
this.tagImg = arbresProp.tagImg; |
this.separationTagImg = arbresProp.separationTagImg; |
this.tagImg = arbresProp.tagImg; |
this.tagObs = arbresProp.tagObs; |
this.separationTagObs = arbresProp.separationTagObs; |
this.nomSciReferentiel = arbresProp.nomSciReferentiel; |
this.referentielImpose = arbresProp.referentielImpose; |
} |
this.isTaxonListe = false; |
this.numArbre = 0; |
} |
ReleveASL.prototype = new WidgetsSaisiesASL( this.widgetProp ); |
ReleveASL.prototype = new WidgetsSaisiesASL(); |
/** |
* Initialise le formulaire, les validateurs, les listes de complétion... |
*/ |
ReleveASL.prototype.initForm = function() { |
const lthis = this; |
const idUtilisateur = $( '#id_utilisateur' ).val(); |
var idUtilisateur = $( '#id_utilisateur' ).val(); |
$('[type="date"]').prop('max', function(){ |
return new Date().toJSON().split('T')[0]; |
}); |
if( this.valOk( idUtilisateur ) ) { |
if ( this.valOk( $( '#releve-data' ).val() ) ) { |
const datRuComun = $.parseJSON( $( '#dates-rues-communes' ).val() ); |
if( valOk( idUtilisateur ) ) { |
if ( valOk( $( '#releve-data' ).val() ) ) { |
const datRuComun = $.parseJSON( $( '#dates-rues-communes' ).val() ), |
releveDatas = $.parseJSON( $( '#releve-data' ).val() ); |
var releveDatas = $.parseJSON( $( '#releve-data' ).val() ); |
if ( !this.valOk( releveDatas[1] ) || -1 === datRuComun.indexOf( releveDatas[1]['date_rue_commune'] ) ) { |
if ( !valOk( releveDatas[1] ) || -1 === datRuComun.indexOf( releveDatas[1]['date_rue_commune'] ) ) { |
this.releveDatas = releveDatas; |
if ( this.valOk( this.releveDatas[0].utilisateur, true, idUtilisateur ) ) { |
if ( valOk( this.releveDatas[0].utilisateur, true, idUtilisateur ) ) { |
$( '#releve-date' ).val( this.releveDatas[0].date ); |
this.rechargerFormulaire(); |
this.saisirArbres(); |
56,8 → 55,8 |
} |
} |
} |
if ( this.valOk( $( '.charger-releve' ) ) ) { |
var btnChargementForm = this.determinerBtnsChargementForm( '.' ); |
if ( valOk( $( '.charger-releve' ) ) ) { |
const btnChargementForm = this.determinerBtnsChargementForm( '.' ); |
// #releve-data est modifié, bouton dans #releves-utilisateur |
this.btnsChargerForm( btnChargementForm ); |
} |
74,7 → 73,7 |
const lthis = this; |
// comportement du bouton nouveau releve |
if ( this.valOk( $( '#id_utilisateur' ).val() ) ) { |
if ( valOk( $( '#id_utilisateur' ).val() ) ) { |
// #releve-data est modifié, bouton dans #releves-utilisateur |
this.btnsChargerForm( '#bouton-nouveau-releve' ); |
} |
106,7 → 105,7 |
$( this ).addClass( 'disabled' ); |
$( '.arbre-info' ).not( $( this ) ).removeClass( 'disabled' ); |
var numArbre = $( this ).data( 'arbre-info' ); |
const numArbre = $( this ).data( 'arbre-info' ); |
lthis.chargerInfosArbre( numArbre ); |
lthis.scrollFormTop( '#zone-arbres' ); |
115,7 → 114,7 |
$( '#retour' ).on( 'click', function( event ) { |
event.preventDefault(); |
var numArbre = lthis.numArbre + 1; |
const numArbre = lthis.numArbre + 1; |
// activation des champs et retour à la saisie |
lthis.modeArbresBasculerActivation( false, numArbre ); |
132,7 → 131,7 |
lthis.scrollFormTop( '#zone-arbres' ); |
}); |
// chargement plantes ou lichens |
var btnChargementForm = this.determinerBtnsChargementForm( '#' ); |
const btnChargementForm = this.determinerBtnsChargementForm( '#' ); |
// #releve-data n'est pas modifié, bouton dans #charger-form |
this.btnsChargerForm( btnChargementForm, false, false ); |
// Alertes et aides |
150,17 → 149,17 |
$.each( this.releveDatas[0], function( cle , valeur ) { |
if ( 'zone-pietonne' === cle || 'pres-lampadaires' === cle ) { |
$( 'input[name=' + cle + '][value=' + valeur + ']' , '#zone-observation' ).prop( 'checked', true ); |
} else if ( lthis.valOk( $( '#' + cle ) ) ) { |
} else if ( valOk( $( '#' + cle ) ) ) { |
$( '#' + cle ).val( valeur ); |
} |
}); |
if ( |
this.valOk( $( '#geometry-releve' ).val() ) && |
this.valOk( $( '#latitude-releve' ).val() ) && |
this.valOk( $( '#longitude-releve' ).val() ) && |
this.valOk( $( '#rue' ).val() ) && |
this.valOk( $( '#commune-nom' ).val() ) |
valOk( $( '#geometry-releve' ).val() ) && |
valOk( $( '#latitude-releve' ).val() ) && |
valOk( $( '#longitude-releve' ).val() ) && |
valOk( $( '#rue' ).val() ) && |
valOk( $( '#commune-nom' ).val() ) |
) { |
$( '#geoloc' ).addClass( 'hidden' ); |
$( '#geoloc-datas' ).removeClass( 'hidden' ); |
180,13 → 179,13 |
$( '.obs-nbre' ).triggerHandler( 'changement' ); |
$( '#arbre-nb' ).text( this.numArbre + 1 ); |
var infosArbre = { |
const infosArbre = { |
releve : this.releveDatas[0], |
obsNum : 0, |
sujet : {} |
}; |
for( var i = 1; i <= this.obsNbre; i ++ ) { |
for( let i = 1; i <= this.obsNbre; i ++ ) { |
infosArbre.obsNum = i; |
infosArbre.sujet = this.releveDatas[i]; |
this.lienArbreInfo( infosArbre.sujet['num-arbre'] ); |
222,8 → 221,6 |
* Etape formulaire avec transfert carto |
*/ |
ReleveASL.prototype.saisirArbres = function() { |
const lthis = this; |
if ( this.validerReleve() ) { |
$( '#soumettre-releve' ) |
.addClass( 'disabled' ) |
232,8 → 229,8 |
$( '#form-observation' ).find( 'input, textarea' ).prop( 'disabled', true ); |
$( '#zone-arbres,#geoloc-datas,#bouton-nouveau-releve' ).removeClass( 'hidden' ); |
this.confirmerSortie(); |
if ( !this.valOk( $( '#releve-data' ).val() ) ) { |
var releveDatasTmp = { |
if ( !valOk( $( '#releve-data' ).val() ) ) { |
const releveDatasTmp = { |
obs : { |
ce_utilisateur : $( '#id_utilisateur' ).val(), |
date_observation : $( '#releve-date' ).val(), |
265,7 → 262,7 |
this.releveDatas[0]['pres-lampadaires'] = $( '#pres-lampadaires input:checked' ).val(); |
} |
this.releveDatas[0].commentaires = $( '#commentaires' ).val().trim(); |
for ( var i = 1 ; i < this.releveDatas.length; i++ ) { |
for ( let i = 1 ; i < this.releveDatas.length; i++ ) { |
this.releveDatas[i]['date_rue_commune'] = ( |
this.releveDatas[0].date + |
this.releveDatas[0].rue + |
281,12 → 278,13 |
// $cartoRemplacee = $( '#tb-geolocation' ), |
// layer = 'osm', |
// zoomInit = 18 |
var donnesResetCarto = { |
const donnesResetCarto = { |
geometry : $( '#geometry-releve' ).val(), |
latitude : $( '#latitude-releve' ).val(), |
longitude : $( '#longitude-releve' ).val(), |
suffixe : 'arbres', |
layer : 'google hybrid' |
layer : 'googleHybrid', |
zoomInit : 18 |
}; |
this.transfererCarto( donnesResetCarto ); |
296,21 → 294,22 |
ReleveASL.prototype.chargerImgEnregistrees = function() { |
const releveL = this.releveDatas.length; |
var idArbre = 0, |
last = false; |
let idArbre = 0, |
last = false, |
urlImgObs = '', |
imgDatas = {}; |
for ( var i = 1; i < releveL; i++ ) { |
for ( let i = 1; i < releveL; i++ ) { |
idArbre = this.releveDatas[i]['id_observation']; |
urlImgObs = this.serviceObsImgs + idArbre; |
imgDatas = { |
'indice' : i, |
'idArbre' : idArbre, |
'numArbre' : this.releveDatas[i]['num-arbre'], |
'nomRet' : this.releveDatas[i].taxon.nomRet.replace( /\s/, '_' ), |
'releveDatas' : this.releveDatas |
}; |
var urlImgObs = this.serviceObsImgs + idArbre, |
imgDatas = { |
'indice' : i, |
'idArbre' : idArbre, |
'numArbre' : this.releveDatas[i]['num-arbre'], |
'nomRet' : this.releveDatas[i].taxon.nomRet.replace( /\s/, '_' ), |
'releveDatas' : this.releveDatas |
}; |
if ( ( releveL - 1) === i ) { |
last = true; |
} |
325,8 → 324,8 |
url: urlImgObs, |
type: 'GET', |
success: function( idsImg, textStatus, jqXHR ) { |
if ( lthis.valOk( idsImg ) ) { |
var urlImg = '', |
if ( valOk( idsImg ) ) { |
let urlImg = '', |
images = []; |
idsImg = idsImg[parseInt( imgDatas.idArbre )]; |
361,10 → 360,9 |
* dont les données seront transmises dans la table cel-obs-etendues |
*/ |
ReleveASL.prototype.getObsChpSpecifiques = function( datasArbres ) { |
const lthis = this; |
var retour = [], |
champs = [ |
const lthis = this, |
retour = [], |
champs = [ |
'rue', |
'geometry-releve', |
'latitude-releve', |
388,17 → 386,17 |
'circonference' |
); |
var cleValeur = ''; |
let cleValeur = ''; |
$.each( champs, function( i , value ) { |
cleValeur = ( 4 > i ) || ( 6 > i && 'tb_lichensgo' !== lthis.projet ) ? 'releve' : 'sujet'; |
if ( lthis.valOk( datasArbres[cleValeur][value] ) ) { |
if ( valOk( datasArbres[cleValeur][value] ) ) { |
retour.push({ cle : value, valeur : datasArbres[cleValeur][value] }); |
} |
}); |
if ( 'tb_streets' !== this.projet ) { |
var faceOmbre = '', |
faceOmbreLength = datasArbres.sujet['face-ombre'].length; |
const faceOmbreLength = datasArbres.sujet['face-ombre'].length; |
let faceOmbre = ''; |
if ( 'string' === typeof datasArbres.sujet['face-ombre'] ) { |
faceOmbre = datasArbres.sujet['face-ombre']; |
414,7 → 412,7 |
} |
retour.push({ cle : 'num_arbre' , valeur : datasArbres.obsNum }); |
var stockerImg = this.valOk( datasArbres.sujet['miniature-img'] ); |
let stockerImg = valOk( datasArbres.sujet['miniature-img'] ); |
if( stockerImg ) { |
$.each( datasArbres.sujet['miniature-img'], function( i, paramsImg ) { |
431,30 → 429,28 |
}; |
ReleveASL.prototype.chargerInfosArbre = function( numArbre ) { |
const lthis = this; |
const desactiverForm = ( parseInt( numArbre ) !== ( this.numArbre + 1 ) ); |
var desactiverForm = ( parseInt( numArbre ) !== ( this.numArbre + 1 ) ); |
if ( desactiverForm ) { |
var releveDatas = $.parseJSON( $( '#releve-data' ).val() ), |
arbreDatas = releveDatas[numArbre], |
taxon = {item:{}}, |
imgHtml = ''; |
const releveDatas = $.parseJSON( $( '#releve-data' ).val() ), |
arbreDatas = releveDatas[numArbre]; |
let taxon = {}, |
imgHtml = ''; |
$( '#arbre-nb' ).text( numArbre + ' (visualisation)' ); |
taxon.item = arbreDatas.taxon; |
this.surAutocompletionTaxon( {}, taxon ); |
var selects = [ 'certitude' ]; |
const selects = [ 'certitude' ]; |
if ( 'tb_lichensgo' !== this.projet ) { |
selects.push( 'equipement-pied-arbre', 'tassement' ); |
} |
$.each( selects, function( i, value ) { |
if( !lthis.valOk( arbreDatas[value] ) ) { |
if( !valOk( arbreDatas[value] ) ) { |
arbreDatas[value] = ''; |
} |
if ( $( this ).hasClass( 'other' ) && lthis.valOk( $( this ).val() ) ) { |
if ( $( this ).hasClass( 'other' ) && valOk( $( this ).val() ) ) { |
$( this ).text( $( this ).val() ); |
} |
$( '#' + value + ' option' ).each( function() { |
502,7 → 498,7 |
}; |
ReleveASL.prototype.modeArbresBasculerActivation = function( desactiver, numArbre = 0 ) { |
var selecteurs = |
let selecteurs = |
'#taxon,'+ |
'#certitude,'+ |
'#geometry-arbres,'+ |
535,14 → 531,16 |
// reset carto |
// typeLocalisation = 'point', |
// zoomInit = 18 |
var donnesResetCarto = { |
const donnesResetCarto = { |
cartoRemplacee : $( '#tb-geolocation-arbres' ), |
geometry : $( '#geometry-releve' ).val(), |
latitude : $( '#latitude-releve' ).val(), |
longitude : $( '#longitude-releve' ).val(), |
suffixe : 'arbres', |
layer : 'google hybrid' |
layer : 'googleHybrid', |
zoomInit : 18 |
}; |
this.transfererCarto( donnesResetCarto ); |
// retour aux valeurs par defaut |
selecteurs = '#certitude option'; |
601,46 → 599,37 |
* Fonction handler de l'évenement location du module tb-geoloc |
*/ |
ReleveASL.prototype.locationHandler = function( location ) { |
const lthis = this; |
var isGeolocArbres = ( 'tb-geolocation-arbres' === location.target.id ), |
const lthis = this, |
isGeolocArbres = ( 'tb-geolocation-arbres' === location.target.id ), |
locDatas = location.originalEvent.detail; |
if ( this.valOk( locDatas ) ) { |
if ( valOk( locDatas ) ) { |
console.dir( locDatas ); |
var rue = ( this.valOk( locDatas.osmRoad ) ) ? locDatas.osmRoad : ''; |
var altitude = ( this.valOk( locDatas.elevation ) ) ? locDatas.elevation : ''; |
var pays = ( this.valOk( locDatas.osmCountryCode ) ) ? locDatas.osmCountryCode.toUpperCase() : 'FR'; |
var geometry = JSON.stringify( locDatas.geometry ); |
var latitude = ''; |
var longitude = ''; |
var nomCommune = ''; |
var communeInsee = ''; |
const rue = ( valOk( locDatas.osmRoad ) ) ? locDatas.osmRoad : '', |
altitude = ( valOk( locDatas.elevation ) ) ? locDatas.elevation : '', |
pays = ( valOk( locDatas.osmCountryCode ) ) ? locDatas.osmCountryCode.toUpperCase() : 'FR', |
geometry = JSON.stringify( locDatas.geometry ); |
let latitude = '', |
longitude = '', |
nomCommune = '', |
communeInsee = ''; |
if ( this.valOk( locDatas.geometry.coordinates ) ) { |
if ( 'Point' === locDatas.geometry.type ) { |
if ( this.valOk( locDatas.geometry.coordinates[0] ) ) { |
longitude = locDatas.geometry.coordinates[0]; |
} |
if ( this.valOk( locDatas.geometry.coordinates[1] ) ) { |
latitude = locDatas.geometry.coordinates[1]; |
} |
} else if ( 'LineString' === locDatas.geometry.type && this.valOk( locDatas.centroid.coordinates ) ) { |
if ( this.valOk( locDatas.centroid.coordinates[0] ) ) { |
longitude = locDatas.centroid.coordinates[0]; |
} |
if ( this.valOk( locDatas.centroid.coordinates[1] ) ) { |
latitude = locDatas.centroid.coordinates[1]; |
} |
} |
if ( valOk( locDatas.geometry.coordinates ) && |
valOk( locDatas.centroid.coordinates ) && |
valOk( locDatas.centroid.coordinates[0] ) && |
valOk( locDatas.centroid.coordinates[1] ) |
) { |
latitude = locDatas.centroid.coordinates[0]; |
longitude = locDatas.centroid.coordinates[1]; |
} |
if ( !isGeolocArbres ) { |
if ( this.valOk( locDatas.inseeData ) ) { |
if ( valOk( locDatas.inseeData ) ) { |
nomCommune = locDatas.inseeData.nom; |
communeInsee = ( this.valOk( locDatas.inseeData.code ) ) ? locDatas.inseeData.code : ''; |
} else if ( this.valOk( locDatas.locality ) ) { |
communeInsee = ( valOk( locDatas.inseeData.code ) ) ? locDatas.inseeData.code : ''; |
} else if ( valOk( locDatas.locality ) ) { |
nomCommune = locDatas.locality; |
} else if ( this.valOk( locDatas.osmCounty ) ) { |
} else if ( valOk( locDatas.osmCounty ) ) { |
nomCommune = locDatas.osmCounty; |
} |
$( '#rue' ).val( rue ); |
651,7 → 640,7 |
$( '#commune-insee' ).val( communeInsee ); |
$( '#altitude-releve' ).val( altitude ); |
$( '#pays' ).val( pays ); |
if ( this.valOk( $( '#rue' ).val() ) && this.valOk( $( '#commune-nom' ).val() ) ) { |
if ( valOk( $( '#rue' ).val() ) && valOk( $( '#commune-nom' ).val() ) ) { |
$( '#geoloc-error' ).addClass( 'hidden' ); |
$( '#geoloc-datas' ).closest( '.control-group' ).removeClass( 'error' ); |
} else { |
669,7 → 658,7 |
.remove(); |
} |
$( '#rue,#commune-nom' ).change( function() { |
if ( lthis.valOk( $( '#rue' ).val() ) && lthis.valOk( $( '#commune-nom' ).val() ) ) { |
if ( valOk( $( '#rue' ).val() ) && valOk( $( '#commune-nom' ).val() ) ) { |
$( '#geoloc-error' ).addClass( 'hidden' ); |
} else { |
$( '#geoloc-error' ).removeClass( 'hidden' ); |
681,12 → 670,13 |
$( '#latitude-arbres' ).val( latitude ); |
$( '#longitude-arbres' ).val( longitude ); |
$( '#altitude-arbres' ).val( altitude ); |
if ( this.valOk( $( '#latitude-arbres' ).val() ) && this.valOk( $( '#longitude-arbres' ).val() ) ) { |
if ( valOk( $( '#latitude-arbres' ).val() ) && valOk( $( '#longitude-arbres' ).val() ) ) { |
$( '#geoloc-arbres' ).closest( '.control-group' ).removeClass( 'error' ); |
} else { |
$( '#geoloc-arbres' ).closest( '.control-group' ).addClass( 'error' ); |
} |
} |
this.geoloc.map.setView([latitude, longitude], 18); |
} else { |
console.dir( 'Error location' ); |
} |
694,15 → 684,15 |
// Form Validator *************************************************************/ |
ReleveASL.prototype.validerMinMax = function( element ) { |
var mMCond = new Boolean(), |
minCond = parseFloat( element.value ) >= parseFloat( element.min ), |
maxCond = parseFloat( element.value ) <= parseFloat( element.max ), |
const minCond = parseFloat( element.value ) >= parseFloat( element.min ), |
maxCond = parseFloat( element.value ) <= parseFloat( element.max ); |
let mnMxCond = new Boolean(), |
messageMnMx = 'La valeur entrée doit être', |
returnMnMx = { cond : true , message : '' }; |
if ( |
( this.valOk( element.type, true, 'number' ) || this.valOk( element.type, true, 'range' ) ) && |
( this.valOk( element.min ) || this.valOk( element.max ) ) |
( valOk( element.type, true, 'number' ) || valOk( element.type, true, 'range' ) ) && |
( valOk( element.min ) || valOk( element.max ) ) |
) { |
if ( element.min && element.max ) { |
726,16 → 716,17 |
* Valider date/rue/commune par rapport aux relevés précédents |
*/ |
ReleveASL.prototype.validerDateRueCommune = function( valeurDate, valeurRue, valeurCmn ) { |
var valide = true; |
let valide = true; |
if ( |
this.valOk( $( '#dates-rues-communes' ).val() ) && |
this.valOk( valeurDate ) && |
this.valOk( valeurRue ) && |
this.valOk( valeurCmn ) |
valOk( $( '#dates-rues-communes' ).val() ) && |
valOk( valeurDate ) && |
valOk( valeurRue ) && |
valOk( valeurCmn ) |
) { |
var valsEltDRC = $.parseJSON( $( '#dates-rues-communes' ).val() ), |
const valsEltDRC = $.parseJSON( $( '#dates-rues-communes' ).val() ), |
valeurDRC = valeurDate + valeurRue + valeurCmn; |
valide = ( -1 === valsEltDRC.indexOf( valeurDRC ) ); |
} |
746,9 → 737,9 |
* FormValidator pour les champs date/rue/Commune |
*/ |
ReleveASL.prototype.dateRueCommuneFormValidator = function() { |
var dateValid = ( /^(?:[0-9]{4}-[0-9]{2}-[0-9]{2})|(?:[0-9]{2}\/[0-9]{2}\/[0-9]{4})$/.test( $( '#releve-date' ).val() ) ), |
geolocValid = ( this.valOk( $( '#commune-nom' ).val() ) && this.valOk( $( '#rue' ).val() ) ); |
const errorDateRue = |
const dateValid = ( /^(?:[0-9]{4}-[0-9]{2}-[0-9]{2})|(?:[0-9]{2}\/[0-9]{2}\/[0-9]{4})$/.test( $( '#releve-date' ).val() ) ), |
geolocValid = ( valOk( $( '#commune-nom' ).val() ) && valOk( $( '#rue' ).val() ) ), |
errorDateRue = |
'<span id="error-drc" class="error">'+ |
this.msgTraduction( 'date-rue' )+ |
'</span> '; |
770,7 → 761,7 |
.addClass( 'erreur' ) |
.closest( '.control-group' ) |
.addClass( 'error' ); |
if ( !this.valOk( $( '#releve-date' ).closest( '.control-group' ).find( '#error-drc' ) ) ) { |
if ( !valOk( $( '#releve-date' ).closest( '.control-group' ).find( '#error-drc' ) ) ) { |
$( '#releve-date' ).after( errorDateRue ); |
} |
$( '#geoloc' ).closest( '.control-group' ).addClass( 'error' ); |
787,7 → 778,7 |
rules : { |
'zone-pietonne' : { |
required : function() { |
return( 'tb_lichensgo' !== this.projet ); |
return( 'tb_lichensgo' !== lthis.projet ); |
}, |
minlength : 1 |
}, |
842,7 → 833,7 |
}, |
'surface-pied' : { |
required : function() { |
return( 'tb_lichensgo' !== this.projet ); |
return( 'tb_lichensgo' !== lthis.projet ); |
}, |
minlength : 1, |
'minMaxOk' : true |
849,13 → 840,13 |
}, |
'equipement-pied-arbre' : { |
required : function() { |
return( 'tb_lichensgo' !== this.projet ); |
return( 'tb_lichensgo' !== lthis.projet ); |
}, |
minlength : 1 |
}, |
'face-ombre' : { |
required : function() { |
return( 'tb_streets' !== this.projet ); |
return( 'tb_streets' !== lthis.projet ); |
}, |
minlength : 1 |
} |
877,7 → 868,7 |
}); |
if ( 'tb_lichensgo' !== this.projet ) { |
$( '#equipement-pied-arbre' ).change( function() { |
if ( lthis.valOk( $( this ).val(), false, 'other' ) ) { |
if ( valOk( $( this ).val(), false, 'other' ) ) { |
$( this ) |
.closest( '.control-group' ) |
.removeClass( 'error' ) |
888,7 → 879,7 |
} |
if ( 'tb_streets' !== this.projet ) { |
$( '#face-ombre input' ).on( 'click', function() { |
var oneIsChecked = false; |
let oneIsChecked = false; |
$( '#face-ombre input' ).each( function() { |
if ( $( this ).is( ':checked' ) ) { |
oneIsChecked = true; |
917,19 → 908,20 |
* Valide le formulaire Relevé (= étape 1) au click sur un bouton "enregistrer" |
*/ |
ReleveASL.prototype.validerReleve = function() { |
const observateur = ( $( '#form-observateur' ).valid() && $( '#courriel' ).valid() ) |
const obs = $( '#form-observation' ).valid(); |
const geoloc = ( |
this.valOk( $( '#latitude-releve' ).val() ) && |
this.valOk( $( '#longitude-releve' ).val() ) && |
this.valOk( $( '#rue' ).val() ) && |
this.valOk( $( '#commune-nom' ).val() ) |
) ; |
var dateRue = true; |
if ( this.valOk( $( '#dates-rues-communes' ).val() ) ) { |
const observateur = ( $( '#form-observateur' ).valid() && $( '#courriel' ).valid() ), |
obs = $( '#form-observation' ).valid(), |
geoloc = ( |
valOk( $( '#latitude-releve' ).val() ) && |
valOk( $( '#longitude-releve' ).val() ) && |
valOk( $( '#rue' ).val() ) && |
valOk( $( '#commune-nom' ).val() ) |
); |
let dateRue = true; |
if ( valOk( $( '#dates-rues-communes' ).val() ) ) { |
dateRue = ( |
this.valOk( $( '#releve-date' ).val() ) && |
this.valOk( $( '#rue' ).val() ) && |
valOk( $( '#releve-date' ).val() ) && |
valOk( $( '#rue' ).val() ) && |
this.validerDateRueCommune( $( '#releve-date' ).val(), $( '#rue' ).val(), $( '#commune-nom' ).val() ) |
); |
} |
949,9 → 941,9 |
$( '#geoloc-datas' ).closest( '.control-group' ).removeClass( 'error' ); |
} else { |
if ( |
this.valOk( $( '#releve-date' ).val() ) && |
this.valOk( $( '#rue' ).val() ) && |
this.valOk( $( '#dates-rues-communes' ).val() ) |
valOk( $( '#releve-date' ).val() ) && |
valOk( $( '#rue' ).val() ) && |
valOk( $( '#dates-rues-communes' ).val() ) |
) { |
this.afficherPanneau( '#dialogue-date-rue-ko' ); |
} |
958,9 → 950,9 |
$( '#geoloc-datas' ).closest( '.control-group' ).addClass( 'error' ); |
} |
if ( |
!this.valOk( $( '#releve-date' ).val() ) || |
!this.valOk( $( '#rue' ).val() ) || |
!this.valOk( $( '#dates-rues-communes' ).val() ) |
!valOk( $( '#releve-date' ).val() ) || |
!valOk( $( '#rue' ).val() ) || |
!valOk( $( '#dates-rues-communes' ).val() ) |
) { |
this.masquerPanneau( '#dialogue-date-rue-ko' ); |
} |
981,16 → 973,16 |
* Valide le formulaire Arbres (= étape 2) au click sur un bouton "suivant" |
*/ |
ReleveASL.prototype.validerForm = function() { |
const validerReleve = this.validerReleve(); |
const geoloc = ( |
this.valOk( $( '#latitude-arbres' ).val() ) && |
this.valOk( $( '#longitude-arbres' ).val() ) |
); |
const taxon = this.valOk( $( '#taxon' ).val() ); |
var piedArbre = true; |
const validerReleve = this.validerReleve(), |
geoloc = ( |
valOk( $( '#latitude-arbres' ).val() ) && |
valOk( $( '#longitude-arbres' ).val() ) |
), |
taxon = valOk( $( '#taxon' ).val() ); |
let piedArbre = true; |
if ( 'tb_lichensgo' !== this.projet ) { |
piedArbre = this.valOk( $( '#equipement-pied-arbre' ).val(), false, 'other' ); |
piedArbre = valOk( $( '#equipement-pied-arbre' ).val(), false, 'other' ); |
if ( piedArbre ) { |
$( '#equipement-pied-arbre' ) |
.closest( '.control-group' ) |
1006,7 → 998,7 |
} |
} |
const obs = ( |
const obs = ( |
$( '#form-arbres' ).valid() && |
$( '#form-arbre-fs' ).valid() && |
piedArbre |