ejpri...@users.adullact.net
unread,Jun 24, 2024, 6:07:51 AM (5 days ago) Jun 24Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to openmairi...@googlegroups.com
Author: ejpritchard
Date: 2024-06-24 12:07:48 +0200 (Mon, 24 Jun 2024)
New Revision: 18048
Modified:
branches/6.6.0-develop--ihm-ajout_module/app/findModuleDeclencheurs.php
branches/6.6.0-develop--ihm-ajout_module/app/js/script.js
branches/6.6.0-develop--ihm-ajout_module/obj/lien_module.class.php
Log:
chore : Cacher le champ declencheur si : le module n'as pas de declencheur, ou aucun declencheur n'est selectionner.
Modified: branches/6.6.0-develop--ihm-ajout_module/app/findModuleDeclencheurs.php
===================================================================
--- branches/6.6.0-develop--ihm-ajout_module/app/findModuleDeclencheurs.php 2024-06-24 08:03:04 UTC (rev 18047)
+++ branches/6.6.0-develop--ihm-ajout_module/app/findModuleDeclencheurs.php 2024-06-24 10:07:48 UTC (rev 18048)
@@ -32,18 +32,10 @@
$object_id_escaped = $f->db->escapeSimple($object_id);
$f->log(__METHOD__, "object id: ".var_export($object_id, true));
-// recherche l'objet métier et l'objet lien_module
-$object = null;
-$lien_module_inst = null;
-if (! empty($object_name) && ! empty($object_id)) {
- $object = $f->findObjectById($object_name, $object_id);
- $lien_module_inst = $f->findObjectByCondition('lien_module', "module = '$module_name_escaped' AND object_name = '$object_name_escaped' AND object_id = '$object_id_escaped'");
-}
-
$declencheurs = array();
// instancie le module
-$module_inst = $f->module_manager->get_module_instance($module_name, $lien_module_inst, $object);
+$module_inst = $f->module_manager->get_module_instance($module_name);
if (! empty($module_inst)) {
$declencheurs = $module_inst->get_supported_hooks(true);
Modified: branches/6.6.0-develop--ihm-ajout_module/app/js/script.js
===================================================================
--- branches/6.6.0-develop--ihm-ajout_module/app/js/script.js 2024-06-24 08:03:04 UTC (rev 18047)
+++ branches/6.6.0-develop--ihm-ajout_module/app/js/script.js 2024-06-24 10:07:48 UTC (rev 18048)
@@ -7644,6 +7644,11 @@
var ownProps = Object.keys( hooks ),
i = ownProps.length,
resArray = new Array(i); // preallocate the Array
+ if (i == 0){
+ declencheur_field.parent().parent().hide();
+ return;
+ }
+ declencheur_field.parent().parent().show();
while (i--) {
resArray[i] = [ownProps[i], hooks[ownProps[i]]];
let option = $('<option></option>').attr("value", ownProps[i]).text(hooks[ownProps[i]]);
Modified: branches/6.6.0-develop--ihm-ajout_module/obj/lien_module.class.php
===================================================================
--- branches/6.6.0-develop--ihm-ajout_module/obj/lien_module.class.php 2024-06-24 08:03:04 UTC (rev 18047)
+++ branches/6.6.0-develop--ihm-ajout_module/obj/lien_module.class.php 2024-06-24 10:07:48 UTC (rev 18048)
@@ -29,11 +29,24 @@
$form->setType('module', 'select');
$form->setType('declencheur', 'select');
+
+ if ($maj == 1) { // modification
+ $form->setType('module', 'textreadonly');
+ $form->setType('declencheur', 'select');
+ $module_inst = $this->f->module_manager->get_module_instance($this->getVal('module'));
+ if (! empty($module_inst)) {
+ $hooks = $module_inst->get_supported_hooks(true);
+ if (empty($hooks)) $form->setType('declencheur', 'hidden');
+ }
+ }
}
- if ( $maj == 2 || $maj == 3) { // consultation
+ if ($maj == 2 || $maj == 3) { // consultation et supression
$form->setType('module', 'selectstatic');
$form->setType('declencheur', 'selectstatic');
+ if (empty($this->getVal('declencheur'))){
+ $form->setType('declencheur', 'hidden');
+ }
}
$this->f->log(__METHOD__, 'END');
}
@@ -121,7 +134,6 @@
}
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) {
- $hooks = $this->f->module_manager->get_all_available_hooks();
$hooks_select_options = array(
0 => array(''), // liste des identifiants
1 => array( // liste des libellés
@@ -129,13 +141,26 @@
),
);
- //modification afficher le déclencheur séléctionné
+ // Pour la consultation, modification et suppression gerer l'affichage des délencheurs
if ($maj == 1 || $maj == 2 || $maj == 3 ) {
- $index_declencheur = array_search('declencheur', $this->champs);
- foreach($hooks as $name => $desc) {
- if ( $name == $this->val[$index_declencheur] ) {
- $hooks_select_options[0][] = $name;
- $hooks_select_options[1][] = $desc;
+ // instancie le module
+ $module_inst = $this->f->module_manager->get_module_instance($this->getVal('module'));
+ if (! empty($module_inst)) {
+ $hooks = $module_inst->get_supported_hooks(true);
+ foreach($hooks as $name => $desc) {
+ // modification afficher tous les déclencheurs
+ if ($maj == 1) {
+ $hooks_select_options[0][] = $name;
+ $hooks_select_options[1][] = $desc;
+ }
+ // consultation, suppression afficher les déclencheurs séléctionné
+ if (
+ ($maj == 2 || $maj == 3)
+ && $name == $this->getVal('declencheur')
+ ) {
+ $hooks_select_options[0][] = $name;
+ $hooks_select_options[1][] = $desc;
+ }
}
}
}