formulaire de configuration HTML (sans #SAISIES) et pas la peine d'implementer charge...
authorCerdic <cedric@yterium.com>
Thu, 5 Dec 2013 15:17:30 +0000 (16:17 +0100)
committerCerdic <cedric@yterium.com>
Thu, 5 Dec 2013 15:24:44 +0000 (16:24 +0100)
+ toujours preferer une case a cocher plutot qu'un radio avec des labels oui/non car ceux ci sont non signifiants hors contexte et degradent l'accessibilite de la saisie

formulaires/configurer_souscription.html
formulaires/configurer_souscription.php

index 54cec63..012f162 100644 (file)
        <div>
                #ACTION_FORMULAIRE{#ENV{action}}
 
-                <ul>
-                 #GENERER_SAISIES{#ENV{_saisies}}
+               #SET{fl,souscription}
+               <ul>
+                       #SET{name,adhesion_activer}#SET{obli,''}#SET{defaut,'off'}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
+                       <li class="editer pleine_largeur editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">[
+                               <span class='erreur_message'>(#GET{erreurs})</span>
+                               ]
+                               #SET{val,off}
+                               <input type="hidden" name="#GET{name}" value="#GET{val}" />
+                               #SET{val,on}
+                               <div class="choix">
+                                       <input type="checkbox" name="#GET{name}" class="checkbox" id="#GET{name}_#GET{val}" value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)checked="checked"] />
+                                       <label for="#GET{name}_#GET{val}"><:souscription:label_activer_adhesion:></label>
+                               </div>
+                       </li>
+                       <li class="suite fieldset[(#ENV{adhesion_activer,off}|=={on}|non)none]">
+                               <fieldset>
+                                       <legend><:souscription:label_adhesion_groupe:></legend>
+                                       <ul>
+                                               #SET{name,adhesion_type_saisie}#SET{obli,''}#SET{defaut,''}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
+                                               <li class="editer long_label editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
+                                                       <label for="#GET{name}"><:souscription:label_type_saisie:></label>[
+                                                       <span class='erreur_message'>(#GET{erreurs})</span>
+                                                       ]<select name="#GET{name}" class="select" id="#GET{name}">
+                                                               #SET{val,input}
+                                                               <option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]><:souscription:configurer_type_saisie_input:></option>
+                                                               #SET{val,radio}
+                                                               <option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]><:souscription:configurer_type_saisie_radio:></option>
+                                                               #SET{val,selection}
+                                                               <option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]><:souscription:configurer_type_saisie_selection:></option>
+                                                       </select>
+                                               </li>
+                                               #SET{name,adhesion_montants_label}#SET{obli,''}#SET{defaut,''}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
+                                               <li class="editer long_label editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
+                                                       <label for="#GET{name}"><:souscription:label_montants_label:></label>[
+                                                       <span class='erreur_message'>(#GET{erreurs})</span>
+                                                       ]<input type="text" name="#GET{name}" class="text" value="#ENV*{#GET{name},#GET{defaut}}" id="#GET{name}" [(#HTML5|et{#GET{obli}})required='required']/>
+                                               </li>
+                                               #SET{name,adhesion_montants}#SET{obli,''}#SET{defaut,''}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
+                                               <li class="editer pleine_largeur editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
+                                                       <label for="#GET{name}"><:souscription:label_montants:></label>[
+                                                       <span class='erreur_message'>(#GET{erreurs})</span>
+                                                       ]<textarea name="#GET{name}" class="textarea" rows="4">
+#ENV*{#GET{name},#GET{defaut}}</textarea>
+                                                       <p class="explication"><:souscription:explication_montants:></p>
+                                               </li>
+                                               #SET{name,adhesion_montants_description}#SET{obli,''}#SET{defaut,''}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
+                                               <li class="editer pleine_largeur editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
+                                                       <label for="#GET{name}"><:souscription:label_montants_explication:></label>[
+                                                       <span class='erreur_message'>(#GET{erreurs})</span>
+                                                       ]<textarea name="#GET{name}" class="textarea" rows="4">
+#ENV*{#GET{name},#GET{defaut}}</textarea>
+                                               </li>
+                                       </ul>
+                               </fieldset>
+                       </li>
+
+                       #SET{name,don_activer}#SET{obli,''}#SET{defaut,''}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
+                       <li class="editer pleine_largeur editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">[
+                               <span class='erreur_message'>(#GET{erreurs})</span>
+                               ]
+                               #SET{val,off}
+                               <input type="hidden" name="#GET{name}" value="#GET{val}" />
+                               #SET{val,on}
+                               <div class="choix">
+                                       <input type="checkbox" name="#GET{name}" class="checkbox" id="#GET{name}_#GET{val}" value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)checked="checked"] />
+                                       <label for="#GET{name}_#GET{val}"><:souscription:label_activer_don:></label>
+                               </div>
+                       </li>
+                       <li class="suite fieldset[(#ENV{don_activer,off}|=={on}|non)none]">
+                               <fieldset>
+                                       <legend><:souscription:label_don_groupe:></legend>
+                                       <ul>
+                                               #SET{name,don_type_saisie}#SET{obli,''}#SET{defaut,''}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
+                                               <li class="editer long_label editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
+                                                       <label for="#GET{name}"><:souscription:label_type_saisie:></label>[
+                                                       <span class='erreur_message'>(#GET{erreurs})</span>
+                                                       ]<select name="#GET{name}" class="select" id="#GET{name}">
+                                                               #SET{val,input}
+                                                               <option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]><:souscription:configurer_type_saisie_input:></option>
+                                                               #SET{val,radio}
+                                                               <option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]><:souscription:configurer_type_saisie_radio:></option>
+                                                               #SET{val,selection}
+                                                               <option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]><:souscription:configurer_type_saisie_selection:></option>
+                                                       </select>
+                                               </li>
+                                               #SET{name,don_montants_label}#SET{obli,''}#SET{defaut,''}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
+                                               <li class="editer long_label editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
+                                                       <label for="#GET{name}"><:souscription:label_montants_label:></label>[
+                                                       <span class='erreur_message'>(#GET{erreurs})</span>
+                                                       ]<input type="text" name="#GET{name}" class="text" value="#ENV*{#GET{name},#GET{defaut}}" id="#GET{name}" [(#HTML5|et{#GET{obli}})required='required']/>
+                                               </li>
+                                               #SET{name,don_montants}#SET{obli,''}#SET{defaut,''}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
+                                               <li class="editer pleine_largeur editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
+                                                       <label for="#GET{name}"><:souscription:label_montants:></label>[
+                                                       <span class='erreur_message'>(#GET{erreurs})</span>
+                                                       ]<textarea name="#GET{name}" class="textarea" rows="4">
+#ENV*{#GET{name},#GET{defaut}}</textarea>
+                                                       <p class="explication"><:souscription:explication_montants:></p>
+                                               </li>
+                                               #SET{name,don_montants_description}#SET{obli,''}#SET{defaut,''}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
+                                               <li class="editer pleine_largeur editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
+                                                       <label for="#GET{name}"><:souscription:label_montants_explication:></label>[
+                                                       <span class='erreur_message'>(#GET{erreurs})</span>
+                                                       ]<textarea name="#GET{name}" class="textarea" rows="4">
+#ENV*{#GET{name},#GET{defaut}}</textarea>
+                                               </li>
+                                       </ul>
+                               </fieldset>
+                       </li>
+
+
                </ul>
+               <fieldset>
+                       <legend><:souscription:label_general_groupe:></legend>
+                       <ul>
+                               #SET{name,dispositions_fiscales_explications}#SET{obli,''}#SET{defaut,''}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
+                               <li class="editer pleine_largeur editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
+                                       <label for="#GET{name}"><:souscription:label_dispositions_fiscales_explications:></label>[
+                                       <span class='erreur_message'>(#GET{erreurs})</span>
+                                       ]<textarea name="#GET{name}" class="textarea" rows="4">
+#ENV*{#GET{name},#GET{defaut}}</textarea>
+                               </li>
+                       </ul>
+               </fieldset>
 
                <input type="hidden" name="_meta_casier" value="souscription" />
                <p class="boutons"><span class="image_loading">&nbsp;</span><input type="submit" class="submit" value="<:bouton_enregistrer:>" /></p>
        </div>
        </form>
 </div>
+<script type="text/javascript">
+       jQuery(function(){
+               jQuery(".suite.fieldset").each(function(){
+                       var me=this;
+                       jQuery(me).prev(".editer").find("input.checkbox").click(function(){
+                               if (jQuery(this).prop("checked"))
+                                       jQuery(me).show('fast');
+                               else
+                                       jQuery(me).hide('fast');
+                       })
+               })
+       })
+</script>
+<style>
+input.checkbox:checked+label {font-weight: bold;}
+</style>
\ No newline at end of file
index ea779e8..8fe2c9b 100644 (file)
@@ -3,75 +3,6 @@ if (!defined('_ECRIRE_INC_VERSION')) return;
 
 include_spip('inc/config');
 
-function formulaires_configurer_souscription_charger_dist() {
-  /* Configuration des saisies */
-  $liste_saisies = array('input' => _T('souscription:configurer_type_saisie_input'),
-                        'radio' => _T('souscription:configurer_type_saisie_radio'),
-                        'selection' => _T('souscription:configurer_type_saisie_selection'));
-
-  $saisies = array();
-  foreach(array('adhesion', 'don') as $type) {
-    $saisies[] = array("saisie" => "oui_non",
-                      "options" => array("nom" => "${type}_activer",
-                                         "label" => _T("souscription:label_activer_${type}"))
-                      );
-    $saisies[] = array("saisie" => "fieldset",
-                      "options" => array("nom" => "${type}_groupe",
-                                         "label" => _T("souscription:label_${type}_groupe"),
-                                         "afficher_si" => "@${type}_activer@ == 'on'"),
-                      "saisies" => array(array("saisie" => "selection",
-                                               "options" => array("nom" => "${type}_type_saisie",
-                                                                  "label" => _T("souscription:label_type_saisie"),
-                                                                  "cacher_option_intro" => "oui",
-                                                                  "datas" => $liste_saisies)
-                                               ),
-                                         array("saisie" => "input",
-                                               "options" => array("nom" => "${type}_montants_label",
-                                                                  "label" => _T("souscription:label_montants_label"))
-                                               ),
-                                         array("saisie" => "textarea",
-                                               "options" => array("nom" => "${type}_montants",
-                                                                  "rows" => "4",
-                                                                  "label" => _T("souscription:label_montants"),
-                                                                  "explication" => _T("souscription:explication_montants"))
-                                               ),
-                                         array("saisie" => "textarea",
-                                               "options" => array("nom" => "${type}_montants_description",
-                                                                  "rows" => "4",
-                                                                  "label" => _T("souscription:label_montants_explication")))
-                                         )
-                      );
-  }
-
-  $saisies[] = array("saisie" => "fieldset",
-                    "options" => array("nom" => "general_groupe",
-                                       "label" => _T("souscription:label_general_groupe")),
-                    "saisies" => array(array('saisie' => 'textarea',
-                                             'options' => array('nom' => 'dispositions_fiscales_explications',
-                                                                'rows' => '4',
-                                                                'label' => _T('souscription:label_dispositions_fiscales_explications')))));
-
-
-
-  $valeurs = array('adhesion_montants' => lire_config("souscription/adhesion_montants"),
-                   'adhesion_type_saisie' => lire_config("souscription/adhesion_type_saisie"),
-                   "adhesion_activer" => lire_config("souscription/adhesion_activer"),
-                   "adhesion_montants_description" => lire_config("souscription/adhesion_montants_description"),
-                   "adhesion_montants_label" => lire_config("souscription/adhesion_montants_label"),
-
-                   'don_montants' => lire_config("souscription/don_montants"),
-                   'don_type_saisie' => lire_config("souscription/don_type_saisie"),
-                   "don_activer" => lire_config("souscription/don_activer"),
-                   "don_montants_description" => lire_config("souscription/don_montants_description"),
-                   "don_montants_label" => lire_config("souscription/don_montants_label"),
-
-                  "dispositions_fiscales_explications" => lire_config("souscription/dispositions_fiscales_explications"),
-                  '_saisies' => $saisies
-                   );
-
-  return $valeurs;
-}
-
 function formulaires_configurer_souscription_verifier_dist() {
   /* FIXME: vĂ©rifier le format de 'adhesion_montants' et 'don_montants' */
 
@@ -101,24 +32,3 @@ function formulaires_configurer_souscription_verifier_dist() {
 
   return $erreurs;
 }
-
-function formulaires_configurer_souscription_traiter_dist() {
-
-  ecrire_config("souscription/adhesion_montants", _request("adhesion_montants"));
-  ecrire_config("souscription/adhesion_type_saisie", _request("adhesion_type_saisie"));
-  ecrire_config("souscription/adhesion_activer", _request("adhesion_activer"));
-  ecrire_config("souscription/adhesion_montants_description", _request("adhesion_montants_description"));
-  ecrire_config("souscription/adhesion_montants_label", _request("adhesion_montants_label"));
-
-  ecrire_config("souscription/don_montants", _request("don_montants"));
-  ecrire_config("souscription/don_type_saisie", _request("don_type_saisie"));
-  ecrire_config("souscription/don_activer", _request("don_activer"));
-  ecrire_config("souscription/don_montants_description", _request("don_montants_description"));
-  ecrire_config("souscription/don_montants_label", _request("don_montants_label"));
-
-  ecrire_config("souscription/dispositions_fiscales_explications", _request("dispositions_fiscales_explications"));
-
-  $res = array('message_ok'=>_T('souscription:config_info_enregistree'));
-
-  return $res;
-}