Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 3329 → Rev 3330

/trunk/widget/modules/saisie2/Saisie2.php
160,7 → 160,7
}
$tableau['chpSupp'] = $tab;
$langue_projet_url = ( isset ( $this->parametres['langue'] ) && $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
$tableau['chemin_fichiers'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], $this->config['manager']['dossierTmp'] . $tableau['projet'] . $langue_projet_url . '/' );
$tableau['chemin_fichiers'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], $this->config['manager']['imgProjet'] . $tableau['projet'] . $langue_projet_url . '/' );
return $tableau;
}
 
174,7 → 174,6
 
foreach ( $retour[$projet]['champs-supp'] as $key => $chsup ) {
 
 
$retour[$projet]['champs-supp'][$key]['name'] = $this->clean_string( $chsup['name'] );
$retour[$projet]['champs-supp'][$key]['description'] = $this->clean_string( $chsup['description']);
$retour[$projet]['champs-supp'][$key]['unit'] = $this->clean_string( $chsup['unit'] );
212,8 → 211,6
return $clean_string;
}
 
 
 
// remplace certains parametres définis en bd par les parametres définis dans l'url
private function traiterParametres($estProjetDefini, $tableau) {
$criteres = array('tag-obs', 'tag-img', 'projet', 'titre', 'logo');
228,7 → 225,6
return $tableau;
}
 
 
private function rechercherInfosEspeces( $infos_projets ) { //print_r($infos_projets);exit;
$retour = array();
$referentiel = $infos_projets['referentiel'];
271,8 → 267,7
$infos = json_decode( file_get_contents( $url_service_infos ) );
// trop de champs injectés dans les infos espèces peuvent
// faire planter javascript
$champs_a_garder = array( 'id', 'nom_sci','nom_sci_complet', 'nom_complet',
'famille','nom_retenu.id', 'nom_retenu_complet', 'num_taxonomique' );
$champs_a_garder = array( 'id', 'nom_sci','nom_sci_complet', 'nom_complet', 'famille','nom_retenu.id', 'nom_retenu_complet', 'num_taxonomique' );
$resultat = array();
$retour = array();
if ( isset( $infos ) && !empty( $infos ) ) {
/trunk/widget/modules/saisie2/config.defaut.ini
7,4 → 7,4
languesUrl = "http://api-test.tela-botanica.org/service:eflore:0.1/iso-639-1/langues"
authTpl = "https://beta.tela-botanica.org/widget:reseau:auth?origine=http://localhost/cel/widget/saisie2"
cheminDos = "modules/saisie2/squelettes/"
dossierTmp = "modules/manager/squelettes/img/images_projets/"
imgProjet = "modules/manager/squelettes/img/images_projets/"
/trunk/widget/modules/saisie2/squelettes/js/WidgetSaisie.js
40,6 → 40,7
this.msgs = {
fr: {
'format-non-supporte': 'Le format de fichier n\'est pas supporté, les formats acceptés sont',
'image-deja-chargee' : 'Cette image a déjà été utilisée',
'date-incomplete': 'Format : jj/mm/aaaa. Date incomplète, utiliser 0, exemple : 00/12/2011.',
'observations-transmises': 'observations transmises',
'taxon-ou-image' : 'Veuillez transmettre au moins, soit une image, soit une espèce',
61,6 → 62,7
},
en: {
'format-non-supporte': 'The file format is not supported, the accepted formats are',
'image-deja-chargee' : 'This image has already been used',
'date-incomplete': 'Format: dd / mm / yyyy. Incomplete date, use 0, example: 00/12/2011.',
'observations-transmises': 'observations transmitted',
'taxon-ou-image' : 'Please transmit at least one image or one species',
95,9 → 97,8
* Initialise le formulaire, les validateurs, les listes de complétion...
*/
WidgetSaisie.prototype.initForm = function() {
const lthis = this;
 
var lthis = this;
 
this.chargerStatutSSO();
 
if ( valeurOk( this.obsId ) ) {
155,12 → 156,14
* Initialise les écouteurs d'événements
*/
WidgetSaisie.prototype.initEvts = function() {
var lthis = this;
const lthis = this;
 
// Empêcher que le module carto ne bind ses events partout
$( '#tb-geolocation' ).on( 'submit blur click focus mousedown mouseleave mouseup touchend touchstart change', '*', function( event ) {
$( '#tb-geolocation' ).on( 'submit blur click focus mousedown mouseleave mouseup change', '*', function( event ) {
event.preventDefault();
return false;
});
$( '#tb-geolocation' ).on( 'location' , lthis.locationHandler.bind( lthis ) );
 
// identité
$( '#bouton-inscription' ).attr( 'href', this.urlSiteTb() + 'inscription' );
194,12 → 197,21
resetForm: true // reset the form after successful submit
};
$( '#miniature' ).append( '<img id="miniature-chargement" class="miniature" alt="chargement" src="' + this.chargementImageIconeUrl + '"/>' );
$( '#ajouter-obs' ).attr( 'disabled', 'disabled' );
if( lthis.verifierFormat( $( '#fichier' ).val() ) ) {
 
var imgCheminTmp = $( '#fichier' ).val(),
formatImgOk = lthis.verifierFormat( imgCheminTmp ),
imgNonDupliquee = lthis.verifierDuplication( imgCheminTmp );
 
if( formatImgOk && imgNonDupliquee ) {
$( '#form-upload' ).ajaxSubmit( options );
} else {
$( '#form-upload' )[0].reset();
window.alert( lthis.msgTraduction( 'format-non-supporte' ) + ' ' + $( '#fichier' ).attr( 'accept' ) );
if ( !formatImgOk ) {
window.alert( lthis.msgTraduction( 'format-non-supporte' ) + ' ' + $( '#fichier' ).attr( 'accept' ) );
}
if ( !imgNonDupliquee ) {
window.alert( lthis.msgTraduction( 'image-deja-chargee' ) );
}
}
return false;
});
242,10 → 254,11
* à droite de la barre en fonction
*/
WidgetSaisie.prototype.chargerStatutSSO = function() {
const lthis = this;
var urlAuth = this.urlBaseAuth + '/identite';
 
$( '#form-observateur' )[0].reset();
var lthis = this;
 
var urlAuth = this.urlBaseAuth + '/identite';
 
if( 'local' !== this.mode ) {
this.connexion( urlAuth, true );
262,19 → 275,19
* Déconnecte l'utilisateur du SSO
*/
WidgetSaisie.prototype.deconnecterUtilisateur = function() {
var urlAuth = this.urlBaseAuth + '/deconnexion';
 
if( 'local' === this.mode ) {
this.definirUtilisateur();
window.location.reload();
return;
}
 
var urlAuth = this.urlBaseAuth + '/deconnexion';
 
this.connexion( urlAuth, false );
};
 
WidgetSaisie.prototype.connexion = function( urlAuth, connexionOnOff ) {
var lthis = this;
const lthis = this;
 
$.ajax({
url: urlAuth,
type: "GET",
373,9 → 386,11
 
// Identité Observateur par courriel
WidgetSaisie.prototype.requeterIdentiteCourriel = function() {
var lthis = this;
const lthis = this;
 
var courriel = $( '#courriel' ).val();
var urlAnnuaire = this.serviceAnnuaireIdUrl + courriel;
 
if ( valeurOk( courriel ) ) {
$.ajax({
url : urlAnnuaire,
441,19 → 456,19
};
 
WidgetSaisie.prototype.formaterPrenom = function() {
var prenom = new Array(),
mots = $( this ).val().split( ' ' ),
motsLength = mots.length;
var prenom = new Array(),
mots = $( this ).val().split( ' ' ),
motsLength = mots.length;
 
for ( var i = 0; i < motsLength; i++ ) {
var mot = mots[i];
if ( 0 <= mot.indexOf( '-' ) ) {
var prenomCompose = new Array(),
motsComposes = mot.split( '-' )
motsComposesLength = motsComposes.length;
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);
var motSimple = motsComposes[j],
motMajuscule = motSimple.charAt(0).toUpperCase() + motSimple.slice(1);
 
prenomCompose.push( motMajuscule );
}
473,8 → 488,10
 
// Préchargement des infos-obs ************************************************/
WidgetSaisie.prototype.chargerInfoObs = function() {
const lthis = this;
 
var urlObs = this.serviceObsUrl + '/' + this.obsId;
var lthis = this;
 
$.ajax({
url: urlObs,
type: 'GET',
548,7 → 565,6
}
};
 
 
WidgetSaisie.prototype.surChangementValeurTaxon = function() {
var numNomSel = 0;
 
584,10 → 600,11
 
// Autocompletion taxons ******************************************************/
WidgetSaisie.prototype.ajouterAutocompletionNoms = function() {
var lthis = this;
const lthis = this;
 
var taxonSelecteur = '#taxon';
if ( valeurOk ( $( '#taxon-liste' ).val(), true, 'autre' ) ) {
 
if ( valeurOk( $( '#taxon-liste' ).val(), true, 'autre' ) ) {
taxonSelecteur += '-autre';
}
$( taxonSelecteur ).autocomplete({
618,18 → 635,21
 
WidgetSaisie.prototype.getUrlAutocompletionNomsSci = function() {
var taxonSelecteur = '#taxon';
if ( valeurOk ( $( '#taxon-liste' ).val(), true, 'autre' ) ) {
 
if ( valeurOk( $( '#taxon-liste' ).val(), true, 'autre' ) ) {
taxonSelecteur += '-autre';
}
 
var mots = $( taxonSelecteur ).val();
var url = this.serviceAutocompletionNomSciUrlTpl.replace( '{referentiel}', this.nomSciReferentiel );
 
url = url.replace( '{masque}', mots );
return url;
};
 
WidgetSaisie.prototype.traiterRetourNomsSci = function( data ) {
var taxonSelecteur = '#taxon';
 
var taxonSelecteur = '#taxon';
if ( valeurOk ( $( '#taxon-liste' ).val(), true, 'autre' ) ) {
taxonSelecteur += '-autre';
}
689,7 → 709,6
} else {
$( '#taxon' ).removeClass( 'ns-retenu' );
}
 
// Si l'espèce est mal déterminée la certitude est "à déterminer"
if( !valeurOk( $( '#taxon' ).data( 'numNomSel' ) ) ) {
$( '#certitude' ).find( 'option' ).each( function() {
704,9 → 723,70
$( '#taxon' ).trigger( 'change' );
};
 
 
// Géolocalisation *************************************************************/
/**
* Fonction handler de l'évenement location du module tb-geoloc
*/
WidgetSaisie.prototype.locationHandler = function( location ) {
var locDatas = location.originalEvent.detail;
 
if ( valeurOk( locDatas ) ) {
console.log( locDatas );
var altitude = ( valeurOk( locDatas.elevation ) ) ? locDatas.elevation : '';
var pays = ( valeurOk( locDatas.osmCountryCode ) ) ? locDatas.osmCountryCode.toUpperCase() : 'FR';
var latitude = '';
var longitude = '';
var coordLineaire = '';
var nomCommune = '';
var communeInsee = '';
 
if ( valeurOk( locDatas.geometry.coordinates ) ) {
if ( 'Point' === locDatas.geometry.type ) {
if ( valeurOk( locDatas.geometry.coordinates[0] ) ) {
longitude = locDatas.geometry.coordinates[0];
}
if ( valeurOk( locDatas.geometry.coordinates[1] ) ) {
latitude = locDatas.geometry.coordinates[1];
}
} else if ( 'LineString' === locDatas.geometry.type ) {// on a besoin que d'un point de la rue
coordLineaire = JSON.stringify( locDatas.geometry.coordinates );
if ( valeurOk( locDatas.geometry.coordinates[0][0] ) ) {
longitude = locDatas.geometry.coordinates[0][0];
}
if ( valeurOk( locDatas.geometry.coordinates[0][1] ) ){
latitude = locDatas.geometry.coordinates[0][1];
}
}
}
if ( valeurOk( locDatas.inseeData ) ) {
nomCommune = locDatas.inseeData.nom;
communeInsee = ( valeurOk( locDatas.inseeData.code ) ) ? locDatas.inseeData.code : '';
} else if ( valeurOk( locDatas.locality ) ) {
nomCommune = locDatas.locality;
} else if ( valeurOk( locDatas.locality ) ) {
nomCommune = locDatas.osmCounty;
}
$( '#coord-lineaire' ).val( coordLineaire );
$( '#latitude' ).val( latitude );
$( '#longitude' ).val( longitude );
$( '#commune-nom' ).val( nomCommune );
$( '#commune-insee' ).val( communeInsee );
$( '#altitude' ).val( altitude );
$( '#pays' ).val( pays );
if ( valeurOk( $( '#latitude' ).val() ) && valeurOk( $( '#longitude' ).val() ) ) {
$( '#geoloc' ).closest( '.control-group' ).removeClass( 'error' );
} else {
$( '#geoloc' ).closest( '.control-group' ).addClass( 'error' );
}
} else {
console.log( 'Error location' );
}
}
 
// Form Validator *************************************************************/
WidgetSaisie.prototype.configurerFormValidator = function() {
var lthis = this;
const lthis = this;
 
$.validator.addMethod(
'dateCel',
715,7 → 795,6
},
lthis.msgTraduction( 'date-incomplete' )
);
 
$.validator.addMethod(
'userEmailOk',
function ( value, element ) {
723,7 → 802,6
},
''
);
 
$.validator.addMethod(
'minMaxOk',
function ( value, element, param ) {
732,7 → 810,6
},
$.validator.messages.minMaxOk
);
 
$.validator.addMethod(
'listFields',
function ( value, element ) {
740,7 → 817,6
},
''
);
 
$.extend( $.validator.defaults, {
errorElement: 'span',
onfocusout: function( element ) {
773,38 → 849,39
};
 
WidgetSaisie.prototype.chpEtendusValidation = function() {
var lthis = this;
const lthis = this;
 
var $thisForm = $( '#form-supp' ),
elements =
'.checkbox,'+
'.radio,'+
'.checkboxes,'+
'.select,'+
'textarea,'+
'input[type=text]:not(.collect-other),'+
'input[type=email],'+
'input[type=number],'+
'input[type=range],'+
'input[type=date]',
speFields = ['checkbox','radio','checkboxes','select'],
spefieldsCount = speFields.length,
chpSuppValidation = {
rules : {},
messages : {},
minmax : []
},
errors = {},
namesListFields = [],
picked = '';
elements =
'.checkbox,'+
'.radio,'+
'.checkboxes,'+
'.select,'+
'textarea,'+
'input[type=text]:not(.collect-other),'+
'input[type=email],'+
'input[type=number],'+
'input[type=range],'+
'input[type=date]',
speFields = ['checkbox','radio','checkboxes','select'],
spefieldsCount = speFields.length,
chpSuppValidation = {
rules : {},
messages : {},
minmax : []
},
errors = {},
namesListFields = [],
picked = '';
 
$( elements, $thisForm ).each( function() {
for( var fieldsClass = 0; spefieldsCount > fieldsClass; fieldsClass++ ) {
if ( valeurOk( $( this ).attr( 'required' ) ) && $( this ).hasClass( speFields[fieldsClass] ) && !valeurOk( chpSuppValidation.rules[ dataName ] ) ) {
 
var dataName = $( this ).data( 'name' );
 
namesListFields.push( dataName );
chpSuppValidation.rules[ dataName ] = { required : true };
 
if ( valeurOk( $( '.other', $( this ) ) ) ) {
picked = ( 'select' === speFields[fieldsClass] ) ? ':selected' : ':checked';
chpSuppValidation.rules[ 'collect-other-' + dataName.replace( '[]', '' ) ] = {
821,9 → 898,9
if ( valeurOk( $( this ).attr( 'name' ) ) && valeurOk ( $( this ).attr( 'required' ) ) && 0 > $.inArray( $( this ).attr( 'name' ) , namesListFields ) ) {
chpSuppValidation.rules[ $( this ).attr( 'name' ) ] = { required : true, minlength: 1 };
if(
( valeurOk( $( this ).attr( 'type' ), true, 'number' ) || valeurOk( $( this ).attr( 'type' ), true, 'range' ) ) &&
( valeurOk( $( this )[0].min ) || valeurOk( $( this )[0].max ) )
) {
( valeurOk( $( this ).attr( 'type' ), true, 'number' ) || valeurOk( $( this ).attr( 'type' ), true, 'range' ) ) &&
( valeurOk( $( this )[0].min ) || valeurOk( $( this )[0].max ) )
) {
chpSuppValidation.rules[ $( this ).attr('name') ]['minMaxOk'] = true;
chpSuppValidation.messages[ $( this ).attr('name') ] = lthis.validerMinMax( $( this )[0] ).message;
}
845,15 → 922,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 : '' };
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 : '' };
 
if(
( valeurOk( element.type, true, 'number' ) || valeurOk( element.type, true, 'range' ) ) &&
( valeurOk( element.min ) || valeurOk( element.max ) )
) {
( valeurOk( element.type, true, 'number' ) || valeurOk( element.type, true, 'range' ) ) &&
( valeurOk( element.min ) || valeurOk( element.max ) )
) {
if ( element.min && element.max ) {
messageMnMx += ' comprise entre ' + element.min + ' et ' + element.max;
mnMxCond = ( minCond && maxCond );
873,8 → 950,8
 
 
WidgetSaisie.prototype.definirReglesFormValidator = function() {
var formSuppValidation = this.chpEtendusValidation(),
lthis = this;
const lthis = this;
var formSuppValidation = this.chpEtendusValidation();
 
$( '#form-supp' ).validate({
onclick : function( element ) {
909,8 → 986,8
errorPlacement : function( error , element ) {
if ( 0 < Object.keys( formSuppValidation.errors ).length ) {
var errorsKeys = Object.keys( formSuppValidation.errors ),
thisKey = '',
errorsFlag = true;
thisKey = '',
errorsFlag = true;
for ( i = 0 ; i < errorsKeys.length ; i++ ) {
thisKey = errorsKeys[i];
if( $( element ).attr( 'name' ) === thisKey ) {
926,24 → 1003,19
}
}
});
 
$( '#form-supp .select' ).change( function() {
$( this ).valid();
});
 
$( 'input[type=date]' ).on( 'input', function() {
$( this ).valid();
});
 
// Validation Taxon si pas de miniature
$( '#taxon' ).on( 'change', function() {
var images = valeurOk( $( '#miniatures .miniature' ) );
lthis.validerTaxonImage( valeurOk( $( this ).val() ), images );
});
 
// Validation miniatures avec MutationObserver
this.surPresenceAbsenceMiniature();
 
$( '#form-observation' ).validate({
rules : {
date_releve : {
962,7 → 1034,6
}
}
});
 
$( '#form-observateur' ).validate({
rules : {
courriel : {
976,7 → 1047,6
}
}
});
 
$( '#connexion,#bouton-inscription,#bouton-anonyme' ).click( function( event ) {
$( '.nav.control-group' ).removeClass( 'error' );
});
1001,7 → 1071,7
};
 
WidgetSaisie.prototype.surPresenceAbsenceMiniature = function() {
var lthis = this;
const lthis = this;
 
// voir : https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/disconnect
// Selectionne le noeud dont les mutations seront observées
1010,6 → 1080,7
var callback = function( mutationsList ) {
for( var mutation of mutationsList ) {
var taxon = valeurOk( $( '#taxon' ).val() );
 
images = ( 0 < mutation.target.childElementCount );
lthis.validerTaxonImage( taxon, images );
}
1062,7 → 1133,6
this.afficherPanneau( '#dialogue-utilisateur-non-identifie' );
$( '.nav.control-group' ).addClass( 'error' );
}
 
return ( observateur && obs && geoloc && taxonOuImage && chpsSupp );
};
 
1075,7 → 1145,9
var debogage = $( 'debogage', reponse ).text();
//console.log( 'Débogage upload : '+debogage);
}
 
var message = $( 'message', reponse ).text();
 
if ( valeurOk( message ) ) {
$( '#miniature-msg' ).append( message );
} else {
1089,12 → 1161,13
*/
WidgetSaisie.prototype.creerWidgetMiniature = function( reponse ) {
var miniatureUrl = $( 'miniature-url', reponse ).text();
var imgNom = $( 'image-nom', reponse ).text();
var html =
var imgNom = $( 'image-nom', reponse ).text();
var html =
'<div class="miniature mb-3 mr-3">'+
'<img class="miniature-img" class="miniature img-rounded" alt="' + imgNom + '" src="' + miniatureUrl + '"/>'+
'<a class="effacer-miniature"><i class="far fa-trash-alt"></i></a>'+
'</div>';
 
return html;
};
 
1103,11 → 1176,41
*/
WidgetSaisie.prototype.verifierFormat = function( nom ) {
var parts = nom.split( '.' );
 
extension = parts[ parts.length - 1 ];
return ( 'jpeg' === extension.toLowerCase() || 'jpg' === extension.toLowerCase() );
};
 
/**
* Check les miniatures déjà téléchargées
* renvoie false si le même nom est rencontré 2 fois
* renvoie true sinon
*/
WidgetSaisie.prototype.verifierDuplication = function( cheminTmp ) {
var parts = cheminTmp.split( '\\' ),
nomImage = parts[ parts.length - 1 ],
thisSrcParts = [],
thisNomImage = '',
nonDupliquee = true;
 
$( 'img.miniature-img,img.miniature' ).each( function() {
// vérification avec alt de l'image
if ( valeurOk( $( this ).attr ( 'alt' ), true, 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', '' );
if ( valeurOk( thisNomImage, true, nomImage ) ) {
nonDupliquee = false;
return false;
}
}
});
return nonDupliquee;
};
 
/**
* Efface une miniature (formulaire)
*/
WidgetSaisie.prototype.supprimerMiniature = function( miniature ) {
1121,8 → 1224,6
//réinitialise taxon.val
$( '#taxon' ).val( '' );
$( '#taxon' ).data( 'numNomSel', '' );
// this.initialiserAutocompleteCommune();
// this.initialiserGoogleMap( false );
};
 
// Ajouter Obs ****************************************************************/
1134,7 → 1235,6
// @WARNING TEST
$( '#dialogue-obs-transaction-ko' ).addClass( 'hidden' );
$( '#dialogue-obs-transaction-ok' ).addClass( 'hidden' );
 
if ( this.validerFormulaire() ) {
this.masquerPanneau( '#dialogue-form-invalide' );
this.obsNbre = this.obsNbre + 1;
1177,16 → 1277,15
* Affiche une observation dans la liste des observations à transmettre
*/
WidgetSaisie.prototype.afficherObs = function() {
 
var numNomSel = $( '#taxon' ).data( 'numNomSel' ),
taxon = $( '#taxon' ).val(),
referentiel = '',
commune = '',
inseeLatitudeLongitude = '',
lieudit = '',
station = '',
milieu = '',
commentaires = '';
taxon = $( '#taxon' ).val(),
referentiel = '',
commune = '',
inseeLatitudeLongitude = '',
lieudit = '',
station = '',
milieu = '',
commentaires = '';
 
if ( valeurOk( numNomSel ) ) {
referentiel = '<span class="referentiel-obs">' + '[' + this.nomSciReferentiel + ']' + '</span>';
1207,15 → 1306,15
milieu = '<span>' + this.msgTraduction( 'milieu' ) + ' :</span> ' + $( '#milieu' ).val() + ' ';
}
if ( valeurOk( $( '#notes' ).val() ) ) {
commentaires = this.msgTraduction( 'commentaires' ) + ' : <span class="discretion">' + $( '#notes' ).val() + '</span>' + ' ';
commentaires = this.msgTraduction( 'commentaires' ) + ' : <span>' + $( '#notes' ).val() + '</span>' + ' ';
}
 
var responsivDiff1 = '',
responsivDiff2 = '',
responsivDiff3 = '',
responsivDiff4 = '',
responsivDiff5 = '',
responsivDiff6 = '';
responsivDiff2 = '',
responsivDiff3 = '',
responsivDiff4 = '',
responsivDiff5 = '',
responsivDiff6 = '';
if ( window.matchMedia( '(min-width: 576px)' ).matches ) {
/* La largeur minimum de l'affichage est 600 px inclus */
responsivDiff1 = ' droite';
1283,28 → 1382,30
'<img class="miniature align-middle" alt="Aucune photo" src="' + this.pasDePhotoIconeUrl + '" width="80%" />'+
'</figure>'+
'</div>',
miniatures = '',
premiere = true,
centre = '';
defilVisible = '';
miniatures = '',
premiere = true,
centre = '';
defilVisible = '';
 
if ( valeurOk( $( '#miniatures img' ) ) ) {
$( '#miniatures img' ).each( function() {
var imgVisible = ( premiere ) ? 'miniature-selectionnee' : 'miniature-cachee';
 
var imgVisible = ( premiere ) ? 'miniature-selectionnee' : 'miniature-cachee',
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%" />';
 
premiere = false;
 
var 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%" />';
 
miniatures += miniature;
});
if ( 1 === $( '#miniatures img' ).length ) {
centre = 'centre';
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 + '">'+
1337,15 → 1438,15
 
 
WidgetSaisie.prototype.stockerObsData = function() {
var lthis = this;
const lthis = this;
 
var numNomSel = $( '#taxon' ).data( 'numNomSel' ),
nomSel = $( '#taxon' ).val(),
nomRet = $( '#taxon' ).data( 'nomRet' ),
numNomRet = $( '#taxon' ).data( 'numNomRet' ),
numTaxon = $( '#taxon' ).data( 'nt' ),
famille = $( '#taxon' ).data( 'famille' ),
referentiel = ( !valeurOk( numNomSel ) ) ? 'autre' : this.nomSciReferentiel;
nomSel = $( '#taxon' ).val(),
nomRet = $( '#taxon' ).data( 'nomRet' ),
numNomRet = $( '#taxon' ).data( 'numNomRet' ),
numTaxon = $( '#taxon' ).data( 'nt' ),
famille = $( '#taxon' ).data( 'famille' ),
referentiel = ( !valeurOk( numNomSel ) ) ? 'autre' : this.nomSciReferentiel;
 
$( '#liste-obs' ).data( 'obsId' + this.obsNbre, {
'num_nom_sel' : numNomSel,
1364,13 → 1465,6
'latitude' : $( '#latitude' ).val(),
'longitude' : $( '#longitude' ).val(),
'altitude' : $( '#altitude' ).val(),
// début valeurs pour test:
// 'commune_nom' : 'Montpellier',
// 'commune_code_insee' : '34172',
// 'latitude' : '43.608320',
// 'longitude' : '3.880196',
// 'altitude' : '0',
//fin valeurs pour test
'lieudit' : $( '#lieudit' ).val(),
'station' : $( '#station' ).val(),
'milieu' : $( '#milieu' ).val(),
1384,6 → 1478,7
 
WidgetSaisie.prototype.getNomsImgsOriginales = function() {
var noms = new Array();
 
$( '.miniature-img' ).each( function() {
noms.push( $( this ).attr( 'alt' ) );
});
1392,6 → 1487,7
 
WidgetSaisie.prototype.getB64ImgsOriginales = function() {
var b64 = new Array();
 
$( '.miniature-img' ).each( function() {
if ( $( this ).hasClass( 'b64' ) ) {
b64.push( $( this ).attr( 'src' ) );
1407,23 → 1503,23
*/
WidgetSaisie.prototype.getObsChpEtendus = function() {
var champs = new Array(),
$thisForm = $( '#form-supp' ),
elements =
'input[type=text]:not(.collect-other),'+
'input[type=checkbox]:checked,'+
'input[type=radio]:checked,'+
'input[type=email],'+
'input[type=number],'+
'input[type=range],'+
'input[type=date],'+
'textarea,'+
'.select',
retour = new Array();
$thisForm = $( '#form-supp' ),
elements =
'input[type=text]:not(.collect-other),'+
'input[type=checkbox]:checked,'+
'input[type=radio]:checked,'+
'input[type=email],'+
'input[type=number],'+
'input[type=range],'+
'input[type=date],'+
'textarea,'+
'.select',
retour = new Array();
 
$( elements, $thisForm ).each( function() {
if ( valeurOk( $( this ).val() ) && ( valeurOk( $( this ).attr( 'name' ) ) || valeurOk( $( this ).data( 'name' ) ) ) ) {
var valeur = $( this ).val(),
cle = ( valeurOk( $( this ).attr( 'name' ) ) ) ? $( this ).attr( 'name' ) : $( this ).data( 'name' );
cle = ( valeurOk( $( this ).attr( 'name' ) ) ) ? $( this ).attr( 'name' ) : $( this ).data( 'name' );
if ( cle in champs ) {
champs[cle] += ';' + valeur;
} else {
1431,9 → 1527,12
}
}
});
for( var key in champs ) {
for ( var key in champs ) {
retour.push({ 'cle' : key , 'valeur' : champs[key] });
};
}
if ( valeurOk( $( '#coord-lineaire' ).val() ) ) {
retour.push({ 'cle' : 'coordonnees-rue-ou-lineaire' , 'valeur' : $( '#coord-lineaire' ).val() });
}
return retour;
};
 
1463,8 → 1562,8
};
 
WidgetSaisie.prototype.defilerMiniatures = function( element ) {
var miniatureSelectionne = element.siblings( 'figure' ).find( 'img.miniature-selectionnee' );
 
var miniatureSelectionne = element.siblings( 'figure' ).find( 'img.miniature-selectionnee' );
miniatureSelectionne.removeClass( 'miniature-selectionnee' );
miniatureSelectionne.addClass( 'miniature-cachee' );
 
1489,6 → 1588,7
 
WidgetSaisie.prototype.supprimerObs = function( selector ) {
var obsId = $( selector ).val();
 
// Problème avec IE 6 et 7
if ( 'Supprimer' === obsId ) {
obsId = $( selector ).attr( 'title' );
1501,11 → 1601,37
$( '.obs-nbre' ).text( this.obsNbre );
$( '.obs-nbre' ).triggerHandler( 'changement' );
$( '.obs' + obsId ).remove();
$( '#liste-obs' ).removeData( 'obsId' + obsId );
obsId = parseInt( obsId );
 
var listObsData = $( '#liste-obs' ).data(),
exId = 0,
indexObs = '',
exIndexObs = '';
 
for ( var id = obsId; id <= ( this.obsNbre + 1 ); id++ ) {
exId = parseInt( id ) + 1;
indexObs = 'obsId' + id;
exIndexObs = 'obsId' + exId;
$( '#liste-obs' ).removeData( indexObs );
if ( valeurOk( listObsData[ exIndexObs ] ) ) {
$( '#liste-obs' ).data( indexObs, listObsData[ exIndexObs ] );
}
$( '#obs' + exId )
.attr( 'id', 'obs' + id )
.removeClass( 'obs' + exId )
.addClass( 'obs' + id )
.find( '.supprimer-obs' )
.attr( 'title', 'Observation n°' + id )
.val( id );
if ( parseInt( id ) !== this.obsNbre ) {
id = parseInt( id );
}
}
};
 
WidgetSaisie.prototype.transmettreObs = function() {
var observations = $( '#liste-obs' ).data();
 
if ( this.debug ) {
console.log( observations );
}
1524,6 → 1650,7
 
WidgetSaisie.prototype.depilerObsPourEnvoi = function() {
var 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
1535,15 → 1662,18
'tag-obs' : this.tagObs,
'tag-img' : this.tagImg
};
var utilisateur = {
var 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', '' );
 
if( '' !== idObsNumerique ) {
this.envoyerObsAuCel( idObsNumerique, obsATransmettre );
}
1552,9 → 1682,10
};
 
WidgetSaisie.prototype.envoyerObsAuCel = function( idObs, observation ) {
var lthis = this;
const lthis = this;
 
var erreurMsg = '';
 
$.ajax({
url : lthis.serviceSaisieUrl,
type : 'POST',
1606,14 → 1737,12
$( '#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?'+
'subject=Dysfonctionnement du widget de saisie ' + lthis.tagProjet+
'&body=' + erreurMsg + '%0D%0ADébogage :%0D%0A' + debugMsg;
 
// mise en valeur de l'obs en erreur + scroll vers celle ci en changeant le hash
$( '#obs' + idObs + ' div div' ).addClass( 'obs-erreur' );
window.location.hash = 'obs' + idObs;
 
$( '#dialogue-obs-transaction-ko .alert-txt' ).append(
$( '#tpl-transmission-ko' ).clone()
.find( '.courriel-erreur' )
1633,7 → 1762,6
$( '#chargement' ).addClass( 'hidden' );
$( '#dialogue-obs-transaction-ok .alert-txt' ).append( $( '#tpl-transmission-ok' ).clone().html() );
$( '#dialogue-obs-transaction-ok' ).removeClass( 'hidden' );
window.location.hash = 'dialogue-obs-transaction-ok';
lthis.initialiserObs.bind( lthis );
}, 1500 );
}
1702,6 → 1830,7
*/
WidgetSaisie.prototype.msgTraduction = function( cle ) {
var msg = 'N/A';
 
if ( this.msgs ) {
if ( this.langue in this.msgs && cle in this.msgs[this.langue] ) {
msg = this.msgs[this.langue][cle];
1726,7 → 1855,6
* @returns {boolean}
*/
function valeurOk( valeur, sensComparaison = true, comparer = undefined ) {
 
if ( 'boolean' !== typeof valeur ) {
switch( typeof valeur ) {
case 'string' :
1777,8 → 1905,10
*/
function extraireEnteteDebug( jqXHR ) {
var msgDebug = '';
 
if ( '' !== jqXHR.getResponseHeader( 'X-DebugJrest-Data' ) ) {
var debugInfos = jQuery.parseJSON( jqXHR.getResponseHeader( 'X-DebugJrest-Data' ) );
 
if ( null !== debugInfos ) {
$.each( debugInfos, function( cle, valeur ) {
msgDebug += valeur + '\n';
1804,6 → 1934,7
 
WidgetSaisie.prototype.filter = function( array, term ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), 'i' );
 
return $.grep( array, function( value ) {
return matcher.test( $( '<div>' ).html( value.label || value.value || value ).text() );
});
/trunk/widget/modules/saisie2/squelettes/saisie.tpl.html
86,7 → 86,7
<div id="bouton-connexion" class="volet col-md-6 col-sm-8">
<label for="bouton-connexion"><?php echo $observateur['compte']; ?></label>
<a id="connexion" href="<?php echo $authTpl; ?>" class="btn btn-success mr-1 mb-1" taget="_blank"><?php echo $observateur['connexion']; ?></a>
<a id="bouton-inscription" href="https://beta.tela-botanica.org/test/inscription" class="btn btn-primary mr-1 mb-1" taget="_blank"><?php echo $observateur['inscription']; ?></a>
<a id="bouton-inscription" href="" class="btn btn-primary mr-1 mb-1" taget="_blank"><?php echo $observateur['inscription']; ?></a>
</div>
<div id="creation-compte" class="volet col-md-6 col-sm-8">
<label for="creation-compte"><?php echo $observateur['noninscription']; ?></label>
99,7 → 99,7
</a>
<div class="volet-menu hidden">
<div id="profil-utilisateur">
<a href="https://beta.tela-botanica.org/test/inscription" taget="_blank"><?php echo $observateur['profil']; ?></a>
<a href="" taget="_blank"><?php echo $observateur['profil']; ?></a>
</div>
<div id="deconnexion"><a href=""><?php echo $observateur['deconnexion']; ?></a></div>
</div>
187,6 → 187,7
<input type="hidden" id="longitude" name="longitude" value="" style="display:none">
<input type="hidden" id="altitude" name="altitude" value="" style="display:none">
<input type="hidden" id="commune-insee" name="commune-insee" value="" style="display:none">
<input type="hidden" id="coord-lineaire" name="coord-lineaire" value="" style="display:none">
</div>
<div id="geoloc" class="col-sm-8">
<tb-geolocation-element
279,7 → 280,7
</div>
</div>
 
<?php elseif ( isset( $widget['especes']['taxons'] ) && count( (array) $widget['especes']['taxons'] ) > 0 ) : ?>
<?php elseif ( $isTaxonListe ) : ?>
<?php ksort( $widget['especes']['taxons'] ); ?>
<select id="taxon-liste" name="taxon-liste" class="form-control custom-select taxon-validation has-tooltip" data-toggle="tooltip" title="<?php echo $observation['liste-espece-title']; ?>">
<option class="choisir" value="inconnue" selected hidden><?php echo $general['choisir']; ?></option>
602,7 → 603,7
 
<form id="form-upload" class="form-horizontal bloc-top" action="<?php echo $url_ws_upload ?>" method="post" enctype="multipart/form-data">
<h2><?php echo $image['titre']; ?></h2>
<p class="miniature-info" class="discretion help-inline">
<p id="miniature-info">
<?php echo $image['aide']; ?>
</p>
<div id ="photos-conteneur" class="control-group">
719,33 → 720,6
</div>
<!-- carto -->
<script type="text/javascript" src="<?php echo $url_base; ?>js/tb-geoloc/tb-geoloc-lib-app.js"></script>
<script type="text/javascript">
var tbGeolocation = document.getElementById( 'tb-geolocation' );
 
tbGeolocation.addEventListener( 'location', function( location ) {
console.log( location.detail );
 
var secVal = location.detail.geometry.coordinates[1],
firstVal = location.detail.geometry.coordinates[0],
latitude = '',
longitude = '',
nomCommune = ( undefined !== location.detail.inseeData ) ? location.detail.inseeData.nom : location.detail.locality;
 
if ( 'object' === typeof secVal && 'object' === typeof firstVal ) {// rue
latitude = ( ( firstVal[1] + secVal[1] ) / 2 ).toFixed( 6 );
longitude = ( ( firstVal[0] + secVal[0] ) / 2 ).toFixed( 6 );
} else if ( 'number' === typeof secVal && 'number' === typeof firstVal ) {// point
latitude = secVal;
longitude = firstVal;
}
document.getElementById( 'latitude' ).value = latitude;
document.getElementById( 'longitude' ).value = longitude;
document.getElementById( 'pays' ).value = location.detail.osmCountry;
document.getElementById( 'commune-nom' ).value = nomCommune;
document.getElementById( 'altitude' ).value = location.detail.elevation;
document.getElementById( 'commune-insee' ).value = location.detail.inseeData.code;
});
</script>
<!-- Jquery -->
<script type="text/javascript" src="https://resources.tela-botanica.org/jquery/1.11.1/jquery-1.11.1.min.js"></script>
<!-- Jquery UI : nécessaire pour le minicalendrier et l'auto-complétion -->