/trunk/widget/modules/apa/squelettes/js/ReleveApa.js |
---|
680,6 → 680,7 |
* Fonction handler de l'évenement location du module tb-geoloc |
*/ |
ReleveApa.prototype.locationHandler = function( location ) { |
const lthis = this; |
var locDatas = location.originalEvent.detail; |
if ( this.utils.valOk( locDatas ) ) { |
715,7 → 716,7 |
communeInsee = ( this.utils.valOk( locDatas.inseeData.code ) ) ? locDatas.inseeData.code : ''; |
} else if ( this.utils.valOk( locDatas.locality ) ) { |
nomCommune = locDatas.locality; |
} else if ( this.utils.valOk( locDatas.locality ) ) { |
} else if ( this.utils.valOk( locDatas.osmCounty ) ) { |
nomCommune = locDatas.osmCounty; |
} |
$( '#rue' ).val( rue ); |
726,16 → 727,22 |
$( '#altitude' ).val( altitude ); |
$( '#pays' ).val( pays ); |
if ( this.utils.valOk( $( '#rue' ).val() ) && this.utils.valOk( $( '#commune-nom' ).val() ) ) { |
if( !this.utils.valOk( $( '#geoloc #error-drc' ) ) ) { |
$( '#geoloc' ).closest( '.control-group' ).removeClass( 'error' ); |
} |
$( '#geoloc-error' ).addClass( 'hidden' ); |
} else { |
$( '#geoloc' ).closest( '.control-group' ).addClass( 'error' ); |
$( '#geoloc' ).addClass( 'hidden' ); |
$( '#rue,#commune-nom' ).prop( 'disabled', false ); |
$( '#geoloc-datas' ).removeClass( 'hidden' ); |
$( '#geoloc-datas' ).closest( '.control-group' ).addClass( 'error' ); |
$( '#geoloc-error' ).removeClass( 'hidden' ); |
$( '#releve-date' ).removeClass( 'erreur' ).closest( '.control-group' ).removeClass( 'error' ).find( '#error-drc' ).remove(); |
$( '#geoloc #error-drc' ).remove(); |
} |
$( '#rue,#commune-nom' ).change( function() { |
if ( lthis.utils.valOk( $( '#rue' ).val() ) && lthis.utils.valOk( $( '#commune-nom' ).val() ) ) { |
$( '#geoloc-error' ).addClass( 'hidden' ); |
} else { |
$( '#geoloc-error' ).removeClass( 'hidden' ); |
} |
}); |
} else { |
console.log( 'Error location' ); |
} |
821,25 → 828,7 |
this.releveDatas = $.parseJSON( $( '#releve-data' ).val() ); |
this.releveDatas[this.obsNbre] = arbreData; |
$( '#releve-data' ).val( JSON.stringify( this.releveDatas ) ); |
this.supprimerMiniatures(); |
$( '#taxon' ).val( '' ); |
$( '#taxon' ).data( 'numNomSel', '' ) |
.data( 'nomRet','' ) |
.data( 'numNomRet', '' ) |
.data( 'nt', '' ) |
.data( 'famille', '' ); |
if( this.isTaxonListe ) { |
$( '#taxon-liste' ).find( 'option' ).each( function() { |
if ( $( this ).hasClass( 'choisir' ) ) { |
$( this ).attr( 'selected', true ); |
} else { |
$( this ).attr( 'selected', false ); |
} |
}); |
$( '#taxon-input-groupe' ).addClass( 'hidden' ); |
$('#taxon-autre').val(''); |
} |
this.modeArbresBasculerActivation( false ); |
$( '#barre-progression-upload' ).attr( 'aria-valuemax', this.obsNbre ); |
$( '#barre-progression-upload .sr-only' ).text( '0/' + this.obsNbre + ' ' + this.utils.msgTraduction( 'observations-transmises' ) ); |
} else { |
1310,7 → 1299,6 |
} |
}); |
} |
this.modeArbresBasculerActivation( desactiverForm, numArbre ); |
}; |
1340,7 → 1328,6 |
$( '#geoloc-datas-arbres,#retour' ).addClass( 'hidden' ); |
// retour aux valeurs par defaut |
$( '#equipement-pied-arbre .other' ).text( 'Autre' ).val( 'other' ); |
// $( '#equipement-pied-arbre .other' ).val( 'other' ); |
$( |
'#certitude option,'+ |
'#equipement-pied-arbre option,'+ |
1352,15 → 1339,9 |
$( this ).prop( 'selected', false ); |
} |
}); |
$( '#taxon' ).data( 'numNomSel', '' ) |
.data( 'nomRet','' ) |
.data( 'numNomRet', '' ) |
.data( 'nt', '' ) |
.data( 'famille', '' ); |
this.supprimerMiniatures(); |
$( '#dejections,#face-ombre' ).find( 'input' ).prop( 'checked', false ); |
$( |
'#taxon,'+ |
'#circonference,'+ |
'#surface-pied,'+ |
'#com-arbres,'+ |
1371,9 → 1352,11 |
'#equipement-pied-arbre,'+ |
'#tassement' |
).val( '' ); |
$( '#arbre-nb' ).text( numArbre ); |
$( '#arbre-info-lien-' + numArbre ).addClass( 'disabled' ); |
$( '.arbre-info' ).not( '#arbre-info-lien-' + numArbre ).removeClass( 'disabled' ); |
if( 0 < numArbre ) { |
$( '#arbre-nb' ).text( numArbre ); |
$( '#arbre-info-lien-' + numArbre ).addClass( 'disabled' ); |
$( '.arbre-info' ).not( '#arbre-info-lien-' + numArbre ).removeClass( 'disabled' ); |
} |
} |
}; |
1436,7 → 1419,8 |
exId = 0, |
indexObs = '', |
exIndexObs = '', |
arbreExId = 0; |
arbreExId = 0, |
arbreId = 0; |
for ( var id = obsId; id <= ( this.obsNbre + 1 ); id++ ) { |
exId = parseInt(id) + 1; |
1779,7 → 1763,6 |
.closest( '.control-group' ) |
.removeClass( 'error' ); |
} |
$( '#geoloc #error-drc' ).remove(); |
} else { |
$( '#releve-date' ) |
.addClass( 'erreur' ) |
1789,9 → 1772,6 |
$( '#releve-date' ).after( errorDateRue ); |
} |
$( '#geoloc' ).closest( '.control-group' ).addClass( 'error' ); |
if ( !this.utils.valOk( $( '#geoloc' ).find( '#error-drc' ) ) ) { |
$( '#geoloc' ).prepend( errorDateRue ); |
} |
} |
if ( dateValid ) { |
$( '#releve-date' ).closest( '.control-group span.error' ).not( '#error-drc' ).remove(); |
/trunk/widget/modules/apa/squelettes/js/LichensApa.js |
---|
39,7 → 39,12 |
LichensApa.prototype.initForm = function() { |
const lthis = this; |
this.ajouterAutocompletionNoms(); |
this.surChangementTaxonListe(); |
$( '#taxon-liste' ).on( 'change', lthis.surChangementTaxonListe ); |
$( '#taxon-liste' ).on( 'change', lthis.surChangementValeurTaxon.bind( lthis ) ); |
if ( this.debug ) { |
console.log( 'Selected taxon:' + $( '#taxon-liste option:selected' ).val()); |
} |
this.configurerFormValidator(); |
this.definirReglesFormValidator(); |
}; |
165,6 → 170,73 |
} |
}; |
// uniquement utilisé si taxon-liste ******************************************/ |
// Affiche/Cache le champ taxon |
LichensApa.prototype.surChangementTaxonListe = function() { |
const utils = new UtilsApa(); |
if ( utils.valOk( $( '#taxon-liste' ).val() ) ) { |
if ( 'autre' !== $( '#taxon-liste' ).val() ) { |
$( '#taxon-input-groupe' ) |
.hide( 200, function () { |
$( this ).addClass( 'hidden' ).show(); |
}) |
.find( '#taxon-autre' ).val( '' ); |
} else { |
$( '#taxon-input-groupe' ) |
.hide() |
.removeClass( 'hidden' ) |
.show(200) |
.find( '#taxon-autre' ) |
.focus() |
.on( 'change', function() { |
if( !utils.valOk( $( '#taxon-autre' ).data( 'numNomSel' ) ) ) { |
$( '#taxon' ).val( $( '#taxon-autre' ).val() ); |
$( '#taxon' ).removeData( 'value' ) |
.removeData( 'numNomSel' ) |
.removeData( 'nomRet' ) |
.removeData( 'numNomRet' ) |
.removeData( 'nt' ) |
.removeData( 'famille' ); |
} |
$( '#taxon' ).trigger( 'change' ); |
}); |
} |
} |
}; |
LichensApa.prototype.surChangementValeurTaxon = function() { |
var numNomSel = 0; |
if( this.utils.valOk( $( '#taxon-liste' ).val() ) ) { |
if( 'autre' === $( '#taxon-liste' ).val() ) { |
this.ajouterAutocompletionNoms(); |
} else { |
var optionRetenue = $( '#taxon-liste' ).find( 'option[value="' + $( '#taxon-liste' ).val() + '"]' ); |
// $( '#taxon' ).val( $( '#taxon-liste' ).val() ); |
$( '#taxon' ).val( $( '#taxon-liste' ).val() ) |
.data( 'value', $( '#taxon-liste' ).val() ) |
.data( 'numNomSel', optionRetenue.data( 'num-nom-sel' ) ) |
.data( 'nomRet', optionRetenue.data( 'nom-ret' ) ) |
.data( 'numNomRet', optionRetenue.data( 'num-nom-ret' ) ) |
.data( 'nt', optionRetenue.data( 'nt' ) ) |
.data( 'famille', optionRetenue.data( 'famille' ) ); |
$( '#taxon' ).trigger( 'change' ); |
numNomSel = $( '#taxon' ).data( 'numNomSel' ); |
// Si l'espèce est mal déterminée la certitude est "à déterminer" |
if( !this.utils.valOk( numNomSel ) ) { |
$( '#certitude' ).find( 'option' ).each( function() { |
if ( $( this ).hasClass( 'aDeterminer' ) ) { |
$( this ).attr( 'selected', true ); |
} else { |
$( this ).attr( 'selected', false ); |
} |
}); |
} |
} |
} |
}; |
// Autocompletion taxons ******************************************************/ |
/** |
* Initialise l'autocompletion taxons |
172,7 → 244,12 |
LichensApa.prototype.ajouterAutocompletionNoms = function() { |
const lthis = this; |
$( '#taxon' ).autocomplete({ |
var taxonSelecteur = '#taxon'; |
if ( this.utils.valOk( $( '#taxon-liste' ).val(), true, 'autre' ) ) { |
taxonSelecteur += '-autre'; |
} |
$( taxonSelecteur ).autocomplete({ |
source: function( requete, add ) { |
// la variable de requête doit être vidée car sinon le parametre "term" est ajouté |
requete = ''; |
195,11 → 272,15 |
}, |
html: true |
}); |
$( '#taxon' ).on( 'autocompleteselect', this.surAutocompletionTaxon ); |
$( taxonSelecteur ).on( 'autocompleteselect', this.surAutocompletionTaxon ); |
}; |
LichensApa.prototype.getUrlAutocompletionNomsSci = function() { |
var mots = $( '#taxon' ).val(); |
var taxonSelecteur = '#taxon'; |
if ( this.utils.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 ); |
210,8 → 291,12 |
* Objet taxons pour autocompletion en fonction de la recherche |
*/ |
LichensApa.prototype.traiterRetourNomsSci = function( data ) { |
var taxonSelecteur = '#taxon'; |
var suggestions = []; |
if ( this.utils.valOk ( $( '#taxon-liste' ).val(), true, 'autre' ) ) { |
taxonSelecteur += '-autre'; |
} |
if ( undefined != data.resultat ) { |
$.each( data.resultat, function( i, val ) { |
val.nn = i; |
230,7 → 315,7 |
}; |
if ( suggestions.length >= this.autocompletionElementsNbre ) { |
nom.label = '...'; |
nom.value = $( '#taxon' ).val(); |
nom.value = $( taxonSelecteur ).val(); |
suggestions.push( nom ); |
return false; |
} else { |
394,14 → 479,7 |
// Résumé obs et stockage en data de "#list-obs" pour envoi |
this.afficherObs( obsData ); |
this.stockerObsData( obsData ); |
this.supprimerMiniatures(); |
$( '#taxon' ).val( '' ); |
$( '#taxon' ).removeData( 'value' ) |
.removeData( 'numNomSel' ) |
.removeData( 'nomRet' ) |
.removeData( 'numNomRet' ) |
.removeData( 'nt' ) |
.removeData( 'famille' ); |
this.reinitialiserFormLichens(); |
$( '#barre-progression-upload' ).attr( 'aria-valuemax', this.obsNbre ); |
$( '#barre-progression-upload .sr-only' ).text( '0/' + this.obsNbre + ' ' + this.utils.msgTraduction( 'observations-transmises' ) ); |
} else { |
409,6 → 487,28 |
} |
}; |
LichensApa.prototype.reinitialiserFormLichens = function() { |
this.supprimerMiniatures(); |
$( '#taxon,#taxon-autre,#commentaire' ).val( '' ); |
$( '#taxon' ).removeData( 'value' ) |
.removeData( 'numNomSel' ) |
.removeData( 'nomRet' ) |
.removeData( 'numNomRet' ) |
.removeData( 'nt' ) |
.removeData( 'famille' ); |
$( '#taxon-liste,#certitude' ).find( 'option' ).each( function() { |
if ( $( this ).hasClass( 'choisir' ) ) { |
$( this ).attr( 'selected', true ); |
} else { |
$( this ).attr( 'selected', false ); |
} |
}); |
$( '#taxon-input-groupe' ).addClass( 'hidden' ); |
$( 'input[name=lichens-tronc]:checked' ).each( function() { |
$( this ).prop( 'checked', false ); |
}); |
}; |
/** |
* Formatage des données du formulaire pour stockage et envoi |
*/ |
1044,10 → 1144,6 |
const taxonOuImage = this.validerTaxonImage( taxon, images ); |
const observateur = ( $( '#form-observateur' ).valid() && $( '#courriel' ).valid() ) |
const obs = $( '#form-lichens' ).valid(); |
console.log('images : ' + images); |
console.log('taxon : ' + taxon); |
console.log('taxonOuImage : ' + taxonOuImage); |
console.log(obs); |
// panneau observateur |
if ( observateur ) { |
/trunk/widget/modules/apa/squelettes/js/PlantesApa.js |
---|
479,23 → 479,7 |
// Résumé obs et stockage en data de "#list-obs" pour envoi |
this.afficherObs( obsData ); |
this.stockerObsData( obsData ); |
this.supprimerMiniatures(); |
$( '#taxon' ).val( '' ); |
$( '#taxon' ).removeData( 'value' ) |
.removeData( 'numNomSel' ) |
.removeData( 'nomRet' ) |
.removeData( 'numNomRet' ) |
.removeData( 'nt' ) |
.removeData( 'famille' ); |
$( '#taxon-liste' ).find( 'option' ).each( function() { |
if ( $( this ).hasClass( 'choisir' ) ) { |
$( this ).attr( 'selected', true ); |
} else { |
$( this ).attr( 'selected', false ); |
} |
}); |
$( '#taxon-input-groupe' ).addClass( 'hidden' ); |
$( '#taxon-autre' ).val( '' ); |
this.reinitialiserFormPlantes(); |
$( '#barre-progression-upload' ).attr( 'aria-valuemax', this.obsNbre ); |
$( '#barre-progression-upload .sr-only' ).text( '0/' + this.obsNbre + ' ' + this.utils.msgTraduction( 'observations-transmises' ) ); |
} else { |
503,6 → 487,25 |
} |
}; |
PlantesApa.prototype.reinitialiserFormPlantes = function() { |
this.supprimerMiniatures(); |
$( '#taxon,#taxon-autre,#commentaire' ).val( '' ); |
$( '#taxon' ).removeData( 'value' ) |
.removeData( 'numNomSel' ) |
.removeData( 'nomRet' ) |
.removeData( 'numNomRet' ) |
.removeData( 'nt' ) |
.removeData( 'famille' ); |
$( '#taxon-liste,#certitude' ).find( 'option' ).each( function() { |
if ( $( this ).hasClass( 'choisir' ) ) { |
$( this ).attr( 'selected', true ); |
} else { |
$( this ).attr( 'selected', false ); |
} |
}); |
$( '#taxon-input-groupe' ).addClass( 'hidden' ); |
}; |
/** |
* Formatage des données du formulaire pour stockage et envoi |
*/ |