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 [
|
return [
|
||||||
[
|
[
|
||||||
'saisie' => 'input',
|
'saisie' => 'input',
|
||||||
'options' => array(
|
'options' => [
|
||||||
'nom' => 'type_intervention',
|
'nom' => 'type_intervention',
|
||||||
'libelle' => 'Type',
|
|
||||||
'label' => "Type d'intervention",
|
'label' => "Type d'intervention",
|
||||||
'obligatoire' => 'oui',
|
'obligatoire' => 'oui',
|
||||||
//'fonction' => 'ma_super_fonction'
|
//'fonction' => 'ma_super_fonction'
|
||||||
//'modifier' => 'ma_super_fonction_pour_modifier'
|
//'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',
|
'saisie' => 'input',
|
||||||
'options' => array(
|
'options' => [
|
||||||
'nom' => 'desc_type_intervention',
|
'nom' => 'desc_type_intervention',
|
||||||
'libelle' => 'Description',
|
'libelle' => 'Description',
|
||||||
'label' => 'Description',
|
'label' => 'Description',
|
||||||
'obligatoire' => 'oui',
|
'obligatoire' => 'oui',
|
||||||
//'fonction' => 'ma_super_fonction'
|
//'fonction' => 'ma_super_fonction'
|
||||||
)
|
],
|
||||||
|
'gamutable' => [
|
||||||
|
'header' => 'Compétition',
|
||||||
|
'classes' => 'w200p',
|
||||||
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'saisie' => 'radio',
|
'saisie' => 'radio',
|
||||||
'options' => array(
|
'options' => [
|
||||||
'nom' => 'controle_ok',
|
'nom' => 'controle_ok',
|
||||||
'libelle' => 'Contrôle OK',
|
'libelle' => 'Contrôle OK',
|
||||||
'label' => 'Contrôle OK',
|
'label' => 'Contrôle OK',
|
||||||
'data' => ['oui' => 'Oui', '' => 'Non']
|
'data' => ['oui' => 'Oui', '' => 'Non']
|
||||||
//'fonction' => 'ma_super_fonction'
|
//'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 $objet
|
||||||
* @param String $champ
|
* @param String $champ
|
||||||
|
@ -29,9 +30,9 @@ function gamufiltre($objet, $champ, $valeur) {
|
||||||
foreach ($T as $s) {
|
foreach ($T as $s) {
|
||||||
if (
|
if (
|
||||||
$s['options']['nom'] === $champ
|
$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) ?? '';
|
return $filtre($valeur) ?? '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,16 +83,14 @@ function gamuform_nom_objet($objet):string {
|
||||||
}
|
}
|
||||||
return $nom;
|
return $nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* recuperation des champs de l'objet que l'on veut traiter
|
* recuperation des champs de l'objet
|
||||||
*
|
*
|
||||||
* @param String $objet
|
* @param String $objet
|
||||||
* @param Bool $keys (optional) le type de sortie que l'on souhaite
|
|
||||||
*
|
*
|
||||||
* @return Array
|
* @return Array
|
||||||
*/
|
*/
|
||||||
function gamuform_recup_champ(string $objet, bool $keys = false):array {
|
function gamuform_recup_champs(string $objet):array {
|
||||||
$c = [];
|
$c = [];
|
||||||
|
|
||||||
if (gamuform_objet_autoriser($objet)) {
|
if (gamuform_objet_autoriser($objet)) {
|
||||||
|
@ -99,16 +98,107 @@ function gamuform_recup_champ(string $objet, bool $keys = false):array {
|
||||||
|
|
||||||
if (!empty($T)) {
|
if (!empty($T)) {
|
||||||
foreach ($T as $s) {
|
foreach ($T as $s) {
|
||||||
if ($keys) {
|
$c[] = $s['options']['nom'];
|
||||||
$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;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* recuperation de(s) ligne(s) de l'objet
|
* recuperation de(s) ligne(s) de l'objet
|
||||||
|
@ -123,7 +213,7 @@ function gamuform_recup_valeurs($objet, $id_objet = 0):array {
|
||||||
if (gamuform_objet_autoriser($objet)) {
|
if (gamuform_objet_autoriser($objet)) {
|
||||||
$table = table_objet_sql($objet);
|
$table = table_objet_sql($objet);
|
||||||
$id = id_table_objet($objet);
|
$id = id_table_objet($objet);
|
||||||
$s = gamuform_recup_champ($objet, true);
|
$s = gamuform_recup_champs($objet);
|
||||||
|
|
||||||
$s[] = $id;
|
$s[] = $id;
|
||||||
if (intval($id_objet)) {
|
if (intval($id_objet)) {
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
#HTTP_HEADER{Content-Type: application/json; charset=#CHARSET}
|
#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":{
|
"header":{
|
||||||
"id": "id",
|
"id": "id",
|
||||||
|
@ -12,10 +17,19 @@
|
||||||
"sup": ""
|
"sup": ""
|
||||||
},
|
},
|
||||||
"crayons":{
|
"crayons":{
|
||||||
|
<BOUCLE_crayons(DATA){source table,#GET{crayons}}{','}>
|
||||||
|
[(#CLE|json_encode)] : [(#VALEUR|json_encode)]
|
||||||
|
</BOUCLE_crayons>
|
||||||
},
|
},
|
||||||
"filtreCol" : {
|
"filtreCol" : {
|
||||||
|
<BOUCLE_filtreCol(DATA){source table,#GET{filtreCol}}{','}>
|
||||||
|
[(#CLE|json_encode)] : [(#VALEUR|json_encode)]
|
||||||
|
</BOUCLE_filtreCol>
|
||||||
},
|
},
|
||||||
"classes" : {
|
"classes" : {
|
||||||
|
<BOUCLE_classes(DATA){source table,#GET{classes}}>
|
||||||
|
[(#CLE|json_encode)] : [(#VALEUR|json_encode)],
|
||||||
|
</BOUCLE_classes>
|
||||||
"id": "w80p",
|
"id": "w80p",
|
||||||
"edit": "w50p",
|
"edit": "w50p",
|
||||||
"sup": "w50p"
|
"sup": "w50p"
|
||||||
|
@ -42,17 +56,17 @@
|
||||||
"html": {
|
"html": {
|
||||||
"id": #GET{ligne/id},
|
"id": #GET{ligne/id},
|
||||||
"edit": [(#GET{edit}|json_encode)],
|
"edit": [(#GET{edit}|json_encode)],
|
||||||
<BOUCLE_headerB(DATA){source table,#GET{header}}>
|
<BOUCLE_champsA(DATA){source table,#GET{champs}}>
|
||||||
[(#CLE|json_encode)] : [(#ENV{objet}|gamufiltre{#CLE,#GET{ligne/#CLE}}|json_encode)],
|
[(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne/#VALEUR}}|json_encode)],
|
||||||
</BOUCLE_headerB>
|
</BOUCLE_champsA>
|
||||||
"sup": [(#GET{sup}|json_encode)]
|
"sup": [(#GET{sup}|json_encode)]
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"id": #GET{ligne/id},
|
"id": #GET{ligne/id},
|
||||||
"edit": "",
|
"edit": "",
|
||||||
<BOUCLE_headerC(DATA){source table,#GET{header}}>
|
<BOUCLE_champsB(DATA){source table,#GET{champs}}>
|
||||||
[(#CLE|json_encode)] : [(#GET{ligne/#CLE}|textebrut|json_encode)],
|
[(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne/#VALEUR}}|textebrut|json_encode)],
|
||||||
</BOUCLE_headerC>
|
</BOUCLE_champsB>
|
||||||
"sup":""
|
"sup":""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<paquet
|
<paquet
|
||||||
prefix="gamuform"
|
prefix="gamuform"
|
||||||
categorie="outil"
|
categorie="outil"
|
||||||
version="1.0.1"
|
version="1.1.0"
|
||||||
etat="dev"
|
etat="dev"
|
||||||
compatibilite="[4.0.0;4.0.*]"
|
compatibilite="[4.0.0;4.0.*]"
|
||||||
logo="prive/themes/spip/images/gamuform-xx.svg"
|
logo="prive/themes/spip/images/gamuform-xx.svg"
|
||||||
|
|
Loading…
Add table
Reference in a new issue