Subversion Repositories eFlore/Applications.cel

Rev

Rev 3328 | Rev 3345 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3328 Rev 3334
Line 671... Line 671...
671
 
671
 
672
/**
672
/**
673
 * Fonction handler de l'évenement location du module tb-geoloc
673
 * Fonction handler de l'évenement location du module tb-geoloc
674
 */
674
 */
-
 
675
ReleveLg.prototype.locationHandler = function( location ) {
675
ReleveLg.prototype.locationHandler = function( location ) {
676
	const lthis = this;
Line 676... Line 677...
676
	var locDatas = location.originalEvent.detail;
677
	var locDatas = location.originalEvent.detail;
677
 
678
 
Line 706... Line 707...
706
		if ( this.utils.valOk( locDatas.inseeData ) ) {
707
		if ( this.utils.valOk( locDatas.inseeData ) ) {
707
			nomCommune = locDatas.inseeData.nom;
708
			nomCommune = locDatas.inseeData.nom;
708
			communeInsee = ( this.utils.valOk( locDatas.inseeData.code ) ) ? locDatas.inseeData.code : '';
709
			communeInsee = ( this.utils.valOk( locDatas.inseeData.code ) ) ? locDatas.inseeData.code : '';
709
		} else if ( this.utils.valOk( locDatas.locality ) ) {
710
		} else if ( this.utils.valOk( locDatas.locality ) ) {
710
			nomCommune = locDatas.locality;
711
			nomCommune = locDatas.locality;
711
		} else if ( this.utils.valOk( locDatas.locality ) ) {
712
		} else if ( this.utils.valOk( locDatas.osmCounty ) ) {
712
			nomCommune = locDatas.osmCounty;
713
			nomCommune = locDatas.osmCounty;
713
		}
714
		}
714
		$( '#rue' ).val( rue );
715
		$( '#rue' ).val( rue );
715
		$( '#latitude' ).val( latitude );
716
		$( '#latitude' ).val( latitude );
716
		$( '#longitude' ).val( longitude );
717
		$( '#longitude' ).val( longitude );
717
		$( '#commune-nom' ).val( nomCommune );
718
		$( '#commune-nom' ).val( nomCommune );
718
		$( '#commune-insee' ).val( communeInsee );
719
		$( '#commune-insee' ).val( communeInsee );
719
		$( '#altitude' ).val( altitude );
720
		$( '#altitude' ).val( altitude );
720
		$( '#pays' ).val( pays );
721
		$( '#pays' ).val( pays );
721
		if ( this.utils.valOk( $( '#rue' ).val() ) && this.utils.valOk( $( '#commune-nom' ).val() ) ) {
722
		if ( this.utils.valOk( $( '#rue' ).val() ) && this.utils.valOk( $( '#commune-nom' ).val() ) ) {
722
			if( !this.utils.valOk( $( '#geoloc #error-drc' ) ) ) {
-
 
723
				$( '#geoloc' ).closest( '.control-group' ).removeClass( 'error' );
-
 
724
			}
-
 
725
			$( '#geoloc-error' ).addClass( 'hidden' );
723
			$( '#geoloc-error' ).addClass( 'hidden' );
726
		} else {
724
		} else {
-
 
725
			$( '#geoloc' ).addClass( 'hidden' );
-
 
726
			$( '#rue,#commune-nom' ).prop( 'disabled', false );
-
 
727
			$( '#geoloc-datas' ).removeClass( 'hidden' );
727
			$( '#geoloc' ).closest( '.control-group' ).addClass( 'error' );
728
			$( '#geoloc-datas' ).closest( '.control-group' ).addClass( 'error' );
728
			$( '#geoloc-error' ).removeClass( 'hidden' );
729
			$( '#geoloc-error' ).removeClass( 'hidden' );
729
			$( '#releve-date' ).removeClass( 'erreur' ).closest( '.control-group' ).removeClass( 'error' ).find( '#error-drc' ).remove();
730
			$( '#releve-date' ).removeClass( 'erreur' ).closest( '.control-group' ).removeClass( 'error' ).find( '#error-drc' ).remove();
730
			$( '#geoloc #error-drc' ).remove();
-
 
731
		}
731
		}
-
 
732
		$( '#rue,#commune-nom' ).change( function() {
-
 
733
			if ( lthis.utils.valOk( $( '#rue' ).val() ) && lthis.utils.valOk( $( '#commune-nom' ).val() ) ) {
-
 
734
				$( '#geoloc-error' ).addClass( 'hidden' );
-
 
735
			} else {
-
 
736
				$( '#geoloc-error' ).removeClass( 'hidden' );
-
 
737
			}
-
 
738
		});
732
	} else {
739
	} else {
733
		console.log( 'Error location' );
740
		console.log( 'Error location' );
734
	}
741
	}
735
}
742
}
Line 812... Line 819...
812
		arbreData['date_rue_commune']  = obsData.releve.date + obsData.releve.rue + obsData.releve['commune-nom'];
819
		arbreData['date_rue_commune']  = obsData.releve.date + obsData.releve.rue + obsData.releve['commune-nom'];
813
		arbreData['id_observation']    = 0;
820
		arbreData['id_observation']    = 0;
814
		this.releveDatas               = $.parseJSON( $( '#releve-data' ).val() );
821
		this.releveDatas               = $.parseJSON( $( '#releve-data' ).val() );
815
		this.releveDatas[this.obsNbre] = arbreData;
822
		this.releveDatas[this.obsNbre] = arbreData;
816
		$( '#releve-data' ).val( JSON.stringify( this.releveDatas ) );
823
		$( '#releve-data' ).val( JSON.stringify( this.releveDatas ) );
817
 
-
 
818
		this.supprimerMiniatures();
-
 
819
		$( '#taxon' ).val( '' );
-
 
820
		$( '#taxon' ).data( 'numNomSel', '' )
-
 
821
			.data( 'nomRet','' )
-
 
822
			.data( 'numNomRet', '' )
-
 
823
			.data( 'nt', '' )
-
 
824
			.data( 'famille', '' );
-
 
825
		if( this.isTaxonListe ) {
-
 
826
			$( '#taxon-liste' ).find( 'option' ).each( function() {
-
 
827
				if ( $( this ).hasClass( 'choisir' ) ) {
-
 
828
					$( this ).attr( 'selected', true );
-
 
829
				} else {
-
 
830
					$( this ).attr( 'selected', false );
824
		this.modeArbresBasculerActivation( false );
831
				}
-
 
832
			});
-
 
833
			$( '#taxon-input-groupe' ).addClass( 'hidden' );
-
 
834
			$('#taxon-autre').val('');
-
 
835
		}
-
 
836
		$( '#barre-progression-upload' ).attr( 'aria-valuemax', this.obsNbre );
825
		$( '#barre-progression-upload' ).attr( 'aria-valuemax', this.obsNbre );
837
		$( '#barre-progression-upload .sr-only' ).text( '0/' + this.obsNbre + ' ' + this.utils.msgTraduction( 'observations-transmises' ) );
826
		$( '#barre-progression-upload .sr-only' ).text( '0/' + this.obsNbre + ' ' + this.utils.msgTraduction( 'observations-transmises' ) );
838
	} else {
827
	} else {
839
		this.afficherPanneau( '#dialogue-form-invalide' );
828
		this.afficherPanneau( '#dialogue-form-invalide' );
840
	}
829
	}
Line 1239... Line 1228...
1239
			arbreDatas  = releveDatas[numArbre],
1228
			arbreDatas  = releveDatas[numArbre],
1240
			taxon       = {item:{}},
1229
			taxon       = {item:{}},
1241
			imgHtml     = '';
1230
			imgHtml     = '';
Line 1242... Line 1231...
1242
 
1231
 
1243
		$( '#arbre-nb').text( numArbre );
-
 
1244
 
1232
		$( '#arbre-nb').text( numArbre );
1245
		taxon.item = arbreDatas.taxon;
1233
		taxon.item = arbreDatas.taxon;
1246
		this.surAutocompletionTaxon( {}, taxon );
-
 
1247
 
1234
		this.surAutocompletionTaxon( {}, taxon );
1248
		$.each( 'certitude', function( i, value ) {
1235
		$.each( 'certitude', function( i, value ) {
1249
			if( !lthis.utils.valOk( arbreDatas[value] ) ) {
1236
			if( !lthis.utils.valOk( arbreDatas[value] ) ) {
1250
				arbreDatas[value] = '';
1237
				arbreDatas[value] = '';
1251
			}
1238
			}
Line 1278... Line 1265...
1278
			} else {
1265
			} else {
1279
				$( this ).prop( 'checked', false );
1266
				$( this ).prop( 'checked', false );
1280
			}
1267
			}
1281
		});
1268
		});
1282
	}
1269
	}
1283
 
-
 
1284
	this.modeArbresBasculerActivation( desactiverForm, numArbre );
1270
	this.modeArbresBasculerActivation( desactiverForm, numArbre );
1285
};
1271
};
Line 1286... Line 1272...
1286
 
1272
 
1287
ReleveLg.prototype.modeArbresBasculerActivation = function( desactiver, numArbre = 0 ) {
1273
ReleveLg.prototype.modeArbresBasculerActivation = function( desactiver, numArbre = 0 ) {
Line 1310... Line 1296...
1310
				$( this ).prop( 'selected', true );
1296
				$( this ).prop( 'selected', true );
1311
			} else {
1297
			} else {
1312
				$( this ).prop( 'selected', false );
1298
				$( this ).prop( 'selected', false );
1313
			}
1299
			}
1314
		});
1300
		});
1315
		$( '#taxon' ).data( 'numNomSel', '' )
-
 
1316
			.data( 'nomRet','' )
-
 
1317
			.data( 'numNomRet', '' )
-
 
1318
			.data( 'nt', '' )
-
 
1319
			.data( 'famille', '' );
-
 
1320
		this.supprimerMiniatures();
1301
		this.supprimerMiniatures();
1321
		$( '#face-ombre' ).find( 'input' ).prop( 'checked', false );
1302
		$( '#face-ombre' ).find( 'input' ).prop( 'checked', false );
1322
		$(
1303
		$(
1323
			'#taxon,'+
-
 
1324
			'#circonference,'+
1304
			'#circonference,'+
1325
			'#com-arbres,'+
1305
			'#com-arbres,'+
1326
			'#rue-arbres,'+
1306
			'#rue-arbres,'+
1327
			'#latitude-arbres,'+
1307
			'#latitude-arbres,'+
1328
			'#longitude-arbres,'+
1308
			'#longitude-arbres,'+
1329
			'#certitude'
1309
			'#certitude'
1330
		).val( '' );
1310
		).val( '' );
-
 
1311
		if( 0 < numArbre ) {
1331
		$( '#arbre-nb' ).text( numArbre );
1312
			$( '#arbre-nb' ).text( numArbre );
1332
		$( '#arbre-info-lien-' + numArbre ).addClass( 'disabled' );
1313
			$( '#arbre-info-lien-' + numArbre ).addClass( 'disabled' );
1333
		$( '.arbre-info' ).not( '#arbre-info-lien-' + numArbre ).removeClass( 'disabled' );
1314
			$( '.arbre-info' ).not( '#arbre-info-lien-' + numArbre ).removeClass( 'disabled' );
-
 
1315
		}
1334
	}
1316
	}
1335
};
1317
};
Line 1336... Line 1318...
1336
 
1318
 
1337
ReleveLg.prototype.defilerMiniatures = function( element ) {
1319
ReleveLg.prototype.defilerMiniatures = function( element ) {
Line 1391... Line 1373...
1391
	obsId = parseInt(obsId);
1373
	obsId = parseInt(obsId);
1392
	var listObsData = $( '#liste-obs' ).data(),
1374
	var listObsData = $( '#liste-obs' ).data(),
1393
		exId        = 0,
1375
		exId        = 0,
1394
		indexObs    = '',
1376
		indexObs    = '',
1395
		exIndexObs  = '',
1377
		exIndexObs  = '',
1396
		arbreExId   = 0;
1378
		arbreExId   = 0,
-
 
1379
		arbreId     = 0;
Line 1397... Line 1380...
1397
 
1380
 
1398
	for ( var id = obsId; id <= ( this.obsNbre + 1 ); id++ ) {
1381
	for ( var id = obsId; id <= ( this.obsNbre + 1 ); id++ ) {
1399
		exId       = parseInt(id) + 1;
1382
		exId       = parseInt(id) + 1;
1400
		indexObs   = 'obsId' + id;
1383
		indexObs   = 'obsId' + id;
Line 1734... Line 1717...
1734
		if ( geolocValid ) {
1717
		if ( geolocValid ) {
1735
			$( '#geoloc' )
1718
			$( '#geoloc' )
1736
			.closest( '.control-group' )
1719
			.closest( '.control-group' )
1737
				.removeClass( 'error' );
1720
				.removeClass( 'error' );
1738
		}
1721
		}
1739
		$( '#geoloc #error-drc' ).remove();
-
 
1740
	} else {
1722
	} else {
1741
		$( '#releve-date' )
1723
		$( '#releve-date' )
1742
			.addClass( 'erreur' )
1724
			.addClass( 'erreur' )
1743
			.closest( '.control-group' )
1725
			.closest( '.control-group' )
1744
				.addClass( 'error' );
1726
				.addClass( 'error' );
1745
		if ( !this.utils.valOk( $( '#releve-date' ).closest( '.control-group' ).find( '#error-drc' ) ) ) {
1727
		if ( !this.utils.valOk( $( '#releve-date' ).closest( '.control-group' ).find( '#error-drc' ) ) ) {
1746
			$( '#releve-date' ).after( errorDateRue );
1728
			$( '#releve-date' ).after( errorDateRue );
1747
		}
1729
		}
1748
		$( '#geoloc' ).closest( '.control-group' ).addClass( 'error' );
1730
		$( '#geoloc' ).closest( '.control-group' ).addClass( 'error' );
1749
		if ( !this.utils.valOk( $( '#geoloc' ).find( '#error-drc' ) ) ) {
-
 
1750
			$( '#geoloc' ).prepend( errorDateRue );
-
 
1751
		}
-
 
1752
	}
1731
	}
1753
	if ( dateValid ) {
1732
	if ( dateValid ) {
1754
		$( '#releve-date' ).closest( '.control-group span.error' ).not( '#error-drc' ).remove();
1733
		$( '#releve-date' ).closest( '.control-group span.error' ).not( '#error-drc' ).remove();
1755
	}
1734
	}
1756
};
1735
};