Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 3330 → Rev 3331

/trunk/widget/modules/saisie2/squelettes/js/champs-supp.js
158,7 → 158,7
const PREFIX = 'collect-other-';
 
// Ajouter un champ texte pour "Autre"
function optionAdd( otherId, $target, element, dataName ) {
function optionAdd( otherId, $target, element, dataName, dataLabel ) {
$target.after(
'<div class="control-group">'+
'<label'+
165,7 → 165,7
' for="' + otherId + '"'+
' class="' + otherId + '"'+
'>'+
'Autre option :'+
'Autre option "' + dataLabel.toLowerCase() + '" :'+
'</label>'+
'<input'+
' type="text"'+
185,29 → 185,32
$( '.' + otherId + ', #' + otherId ).remove();
}
 
$( '#form-supp .other' ).each( function() {
$( '#formulaire .other' ).each( function() {
if( $( this ).hasClass( 'is-select' ) ) {
var dataName = $( this ).data( 'name' ),
otherId = PREFIX + dataName;
var dataName = $( this ).data( 'name' ),
otherId = PREFIX + dataName,
dataLabel = $( '.select' ).data( 'label' );
 
// Insertion du champ "Autre" après les boutons
optionAdd( otherId, $( this ).parent( '.add-field-select' ), 'select', dataName );
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' );
var dataName = $( this ).data( 'name' ),
otherId = PREFIX + dataName,
element = $( this ).data( 'element' ),
dataLabel = $( this ).data( 'label' );
// Insertion du champ "Autre" après les boutons
optionAdd( otherId, $( this ).parent( 'label' ), element, dataName );
optionAdd( otherId, $( this ).parent( 'label' ), element, dataName, dataLabel );
}
});
 
$( '#form-supp .select' ).change( function () {
var dataName = $( this ).data( 'name' ),
otherId = PREFIX + dataName;
$( '#formulaire .select' ).change( function () {
var dataName = $( this ).data( 'name' ),
otherId = PREFIX + dataName,
dataLabel = $( this ).data( 'label' );
 
if( 'other' === $( this ).val() ) {
// Insertion du champ "Autre" après les boutons
optionAdd( otherId, $( this ).parent( '.add-field-select' ), 'select', dataName );
optionAdd( otherId, $( this ).parent( '.add-field-select' ), 'select', dataName, dataLabel );
} else {
// Suppression du champ autre
optionRemove( otherId );
215,13 → 218,14
}
});
 
$( '#form-supp input[type=radio]' ).change( function () {
var dataName = $( this ).data( 'name' ),
otherId = PREFIX + dataName;
$( '#formulaire input[type=radio]' ).change( function () {
var dataName = $( this ).data( 'name' ),
otherId = PREFIX + dataName,
dataLabel = $( this ).data( 'label' );
 
if( 'other' === $( this ).val() ) {
// Insertion du champ "Autre" après les boutons
optionAdd( otherId, $( this ).parent( 'label' ), 'radio', dataName );
optionAdd( otherId, $( this ).parent( 'label' ), 'radio', dataName, dataLabel );
} else {
// Suppression du champ autre
optionRemove( otherId );
229,14 → 233,15
}
});
 
$( '#form-supp .list-checkbox .other, #form-supp .checkbox .other' ).click( function () {
var dataName = $( this ).data( 'name' ),
otherId = PREFIX + dataName,
element = $( this ).data( 'element' );
$( '#formulaire .list-checkbox .other, #formulaire .checkbox .other' ).click( function () {
var dataName = $( this ).data( 'name' ),
otherId = PREFIX + dataName,
element = $( this ).data( 'element' ),
dataLabel = $( this ).data( 'label' );
 
if( $( this ).is( ':checked' ) ) {
// Insertion du champ "Autre" après les boutons
optionAdd( otherId, $( this ).parent( 'label' ), element, dataName );
optionAdd( otherId, $( this ).parent( 'label' ), element, dataName, dataLabel );
} else {
// Suppression du champ autre
optionRemove( otherId );
246,7 → 251,7
}
 
function collectOtherOption() {
$( '#form-supp' ).on( 'change', '.collect-other', function () {
$( '#formulaire' ).on( 'change', '.collect-other', function () {
var otherIdSuffix = $( this ).data( 'name' ).replace( '[]', '' );
var element = $( this ).data( 'element' );
 
/trunk/widget/modules/saisie2/squelettes/saisie.tpl.html
338,12 → 338,18
</label>
<div class="col-sm-8 mb-3">
<?php if ( 0 < count( (array) $widget['milieux'] ) ) :?>
<select id="milieu" class="form-control custom-select has-tooltip" data-toggle="tooltip" title="<?php echo $observation['liste-milieu-title']; ?>">
<option class="choisir" value="" selected hidden><?php echo $general['choisir']; ?></option>
<?php foreach ( $widget['milieux'] as $milieu ) :?>
<option value="<?php echo $milieu; ?>"><?php echo $milieu; ?></option>
<?php endforeach; ?>
</select>
<div class="select-wrapper add-field-select">
<select id="milieu" class="form-control milieu select custom-select has-tooltip mb-2" data-toggle="tooltip" title="<?php echo $observation['liste-milieu-title']; ?>" data-name="milieu" data-label="milieu">
<option class="choisir" value="" selected hidden><?php echo $general['choisir']; ?></option>
<?php foreach ( $widget['milieux'] as $milieu ) :?>
<?php if ( 'autre' !== strtolower( $milieu ) ) :?>
<option value="<?php echo $milieu; ?>" data-name="milieu"><?php echo $milieu; ?></option>
<?php else :?>
<option id="other-milieu" class="other form-control is-select" value="other" data-element="select" data-name="milieu"><?php echo $milieu; ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<?php else : ?>
<input id="milieu" name="milieu" class="form-control has-tooltip" data-toggle="tooltip" type="text" placeholder="<?php echo $observation['milieu-ph']; ?>" title="<?php echo $observation['milieu-title']; ?>">
<?php endif; ?>
493,7 → 499,7
case 'select': ?>
<div class="control-group mb-3">
<label for="<?php echo $champ['key']; ?>" class="col-sm-8<?php echo $mandatory; ?>"><?php echo $champ['name'] . $help_button; ?></label>
<div class="champ col-sm-8 mb-3">
<div class="col-sm-8 mb-3">
<div class="select-wrapper add-field-select <?php echo $help; ?>">
<select id="<?php echo $champ['key']; ?>" class="<?php echo $champ['key'] . ' ' . $champ['element']; ?> form-control has-tooltip custom-select mb-2"<?php echo $required; ?> data-label="<?php echo $champ['name']; ?>" data-name="<?php echo $champ['key']; ?>" <?php echo $description; ?>>