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 ) { |