Grosse amélioration de la partie affichage dans le gamutable :
* Dans l'array des saisies, on ajoute une entrée : gamutable qui reprend le nom des clé de gamutable : header / classes / filtreCol / crayons * et on ajoute la clé : fonction => pour le filtrage de la valeur à afficher via un filtre Perte de compatibilite, mais c'est maintenant qu'il faut le faire
This commit is contained in:
parent
9532ff2547
commit
eb0b20b959
4 changed files with 141 additions and 27 deletions
|
@ -8,34 +8,44 @@ function gamuform_exemple_dist(){
|
|||
return [
|
||||
[
|
||||
'saisie' => 'input',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'nom' => 'type_intervention',
|
||||
'libelle' => 'Type',
|
||||
'label' => "Type d'intervention",
|
||||
'obligatoire' => 'oui',
|
||||
//'fonction' => 'ma_super_fonction'
|
||||
//'modifier' => 'ma_super_fonction_pour_modifier'
|
||||
)
|
||||
],
|
||||
'gamutable' => [
|
||||
'header' => 'Type',
|
||||
'classes' => 'w200p',
|
||||
'filtreCol' => 'select',
|
||||
'crayons' => 'nom_objet_SPIP', // nom de l'objet du crayons
|
||||
'fonction' => 'Majuscules', // fonction php pour filtre le contenu d'une cellule
|
||||
]
|
||||
],
|
||||
[
|
||||
'saisie' => 'input',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'nom' => 'desc_type_intervention',
|
||||
'libelle' => 'Description',
|
||||
'label' => 'Description',
|
||||
'obligatoire' => 'oui',
|
||||
//'fonction' => 'ma_super_fonction'
|
||||
)
|
||||
],
|
||||
'gamutable' => [
|
||||
'header' => 'Compétition',
|
||||
'classes' => 'w200p',
|
||||
]
|
||||
],
|
||||
[
|
||||
'saisie' => 'radio',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'nom' => 'controle_ok',
|
||||
'libelle' => 'Contrôle OK',
|
||||
'label' => 'Contrôle OK',
|
||||
'data' => ['oui' => 'Oui', '' => 'Non']
|
||||
//'fonction' => 'ma_super_fonction'
|
||||
)
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ if (!defined('_ECRIRE_INC_VERSION')) {
|
|||
}
|
||||
|
||||
/**
|
||||
* filtre generale qui appelle un filtre spécifique, déclaré dans l'array saisies avec la cle : filtrer
|
||||
* filtre generale qui appelle un filtre spécifique, déclaré dans l'array saisies avec la cle : gamutable/filtre
|
||||
* cf gamuform/exemple.php
|
||||
*
|
||||
* @param String $objet
|
||||
* @param String $champ
|
||||
|
@ -29,9 +30,9 @@ function gamufiltre($objet, $champ, $valeur) {
|
|||
foreach ($T as $s) {
|
||||
if (
|
||||
$s['options']['nom'] === $champ
|
||||
and !empty($s['options']['filtrer'])
|
||||
and !empty($s['gamutable']['fonction'])
|
||||
) {
|
||||
$filtre = $s['options']['filtrer'];
|
||||
$filtre = $s['gamutable']['fonction'];
|
||||
return $filtre($valeur) ?? '';
|
||||
}
|
||||
}
|
||||
|
@ -82,16 +83,14 @@ function gamuform_nom_objet($objet):string {
|
|||
}
|
||||
return $nom;
|
||||
}
|
||||
|
||||
/**
|
||||
* recuperation des champs de l'objet que l'on veut traiter
|
||||
* recuperation des champs de l'objet
|
||||
*
|
||||
* @param String $objet
|
||||
* @param Bool $keys (optional) le type de sortie que l'on souhaite
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_champ(string $objet, bool $keys = false):array {
|
||||
function gamuform_recup_champs(string $objet):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
|
@ -99,13 +98,104 @@ function gamuform_recup_champ(string $objet, bool $keys = false):array {
|
|||
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
if ($keys) {
|
||||
$c[] = $s['options']['nom'];
|
||||
} else {
|
||||
$c[$s['options']['nom']] = $s['options']['libelle'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* recuperation du header de l'objet que l'on veut afficher dans gamutable
|
||||
*
|
||||
* @param String $objet
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_header(string $objet):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_saisies($objet);
|
||||
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
$c[$s['options']['nom']] = $s['gamutable']['header'] ?? $s['options']['nom'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
/**
|
||||
* recuperation des filtreCol de l'objet que l'on veut afficher dans gamutable
|
||||
*
|
||||
* @param String $objet
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_crayons(string $objet):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_saisies($objet);
|
||||
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
if (
|
||||
!empty($s['gamutable']['crayons'])
|
||||
) {
|
||||
$c[$s['options']['nom']] = $s['gamutable']['crayons'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
/**
|
||||
* recuperation des filtreCol de l'objet que l'on veut afficher dans gamutable
|
||||
*
|
||||
* @param String $objet
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_filtreCol(string $objet):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_saisies($objet);
|
||||
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
if (
|
||||
!empty($s['gamutable']['filtreCol'])
|
||||
and in_array($s['gamutable']['filtreCol'], ['input', 'select'])
|
||||
) {
|
||||
$c[$s['options']['nom']] = $s['gamutable']['filtreCol'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* recuperation des classes de l'objet que l'on veut afficher dans gamutable
|
||||
*
|
||||
* @param String $objet
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_classes(string $objet):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_saisies($objet);
|
||||
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
$c[$s['options']['nom']] = $s['gamutable']['classes'] ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
@ -123,7 +213,7 @@ function gamuform_recup_valeurs($objet, $id_objet = 0):array {
|
|||
if (gamuform_objet_autoriser($objet)) {
|
||||
$table = table_objet_sql($objet);
|
||||
$id = id_table_objet($objet);
|
||||
$s = gamuform_recup_champ($objet, true);
|
||||
$s = gamuform_recup_champs($objet);
|
||||
|
||||
$s[] = $id;
|
||||
if (intval($id_objet)) {
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#HTTP_HEADER{Content-Type: application/json; charset=#CHARSET}
|
||||
|
||||
|
||||
#SET{header,#ENV{objet}|gamuform_recup_champ}
|
||||
#SET{header,#ENV{objet}|gamuform_recup_header}
|
||||
#SET{champs,#ENV{objet}|gamuform_recup_champs}
|
||||
#SET{classes,#ENV{objet}|gamuform_recup_classes}
|
||||
#SET{filtreCol,#ENV{objet}|gamuform_recup_filtreCol}
|
||||
#SET{crayons,#ENV{objet}|gamuform_recup_crayons}
|
||||
|
||||
[{
|
||||
"header":{
|
||||
"id": "id",
|
||||
|
@ -12,10 +17,19 @@
|
|||
"sup": ""
|
||||
},
|
||||
"crayons":{
|
||||
<BOUCLE_crayons(DATA){source table,#GET{crayons}}{','}>
|
||||
[(#CLE|json_encode)] : [(#VALEUR|json_encode)]
|
||||
</BOUCLE_crayons>
|
||||
},
|
||||
"filtreCol" : {
|
||||
<BOUCLE_filtreCol(DATA){source table,#GET{filtreCol}}{','}>
|
||||
[(#CLE|json_encode)] : [(#VALEUR|json_encode)]
|
||||
</BOUCLE_filtreCol>
|
||||
},
|
||||
"classes" : {
|
||||
<BOUCLE_classes(DATA){source table,#GET{classes}}>
|
||||
[(#CLE|json_encode)] : [(#VALEUR|json_encode)],
|
||||
</BOUCLE_classes>
|
||||
"id": "w80p",
|
||||
"edit": "w50p",
|
||||
"sup": "w50p"
|
||||
|
@ -42,17 +56,17 @@
|
|||
"html": {
|
||||
"id": #GET{ligne/id},
|
||||
"edit": [(#GET{edit}|json_encode)],
|
||||
<BOUCLE_headerB(DATA){source table,#GET{header}}>
|
||||
[(#CLE|json_encode)] : [(#ENV{objet}|gamufiltre{#CLE,#GET{ligne/#CLE}}|json_encode)],
|
||||
</BOUCLE_headerB>
|
||||
<BOUCLE_champsA(DATA){source table,#GET{champs}}>
|
||||
[(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne/#VALEUR}}|json_encode)],
|
||||
</BOUCLE_champsA>
|
||||
"sup": [(#GET{sup}|json_encode)]
|
||||
},
|
||||
"search": {
|
||||
"id": #GET{ligne/id},
|
||||
"edit": "",
|
||||
<BOUCLE_headerC(DATA){source table,#GET{header}}>
|
||||
[(#CLE|json_encode)] : [(#GET{ligne/#CLE}|textebrut|json_encode)],
|
||||
</BOUCLE_headerC>
|
||||
<BOUCLE_champsB(DATA){source table,#GET{champs}}>
|
||||
[(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne/#VALEUR}}|textebrut|json_encode)],
|
||||
</BOUCLE_champsB>
|
||||
"sup":""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<paquet
|
||||
prefix="gamuform"
|
||||
categorie="outil"
|
||||
version="1.0.1"
|
||||
version="1.1.0"
|
||||
etat="dev"
|
||||
compatibilite="[4.0.0;4.0.*]"
|
||||
logo="prive/themes/spip/images/gamuform-xx.svg"
|
||||
|
|
Loading…
Add table
Reference in a new issue