From c4302701507e3c068c88af3a30f9409bfbac959b Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 16 Jul 2016 12:41:21 +0200 Subject: [PATCH] =?UTF-8?q?Gestion=20du=20choix=20du=20groupe=20par=20d?= =?UTF-8?q?=C3=A9faut=20sur=20la=20page=20'groups/filter'=20si=20aucun=20p?= =?UTF-8?q?aram=C3=A8tre=20n'est=20dans=20l'URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/view/group/groupChoice.php | 85 ++++++++++++++++++++++++++++++ view/groups.php | 12 ++++- view/js/groups-min.js | 28 +++++----- view/js/groups.js | 67 ++++++++++++++++++++++- 4 files changed, 175 insertions(+), 17 deletions(-) create mode 100644 manager/view/group/groupChoice.php diff --git a/manager/view/group/groupChoice.php b/manager/view/group/groupChoice.php new file mode 100644 index 0000000..5f0dc11 --- /dev/null +++ b/manager/view/group/groupChoice.php @@ -0,0 +1,85 @@ +@name (@type)"; + break; + + + default: return " +
+ + + +
"; + break; + + } + } + + public static function view($params){ + /* [0] Initialisation des variables (vues) + =========================================================*/ + $view = ''; + $cluster_view = ''; + + + + /* [1] On récupére tous les groupes + =========================================================*/ + /* (1) On récupère les groupe */ + $getClustersRequest = new ModuleRequest('clusterDefault/getAll'); + $getClustersResponse = $getClustersRequest->dispatch(); + + /* (2) Si on ne le trouve pas, on retourne une erreur */ + if( $getClustersResponse->error != ManagerError::Success ) + return View::$htmlError; + + /* (3) On récupère les données du groupe */ + $CLUSTERLIST = $getClustersResponse->get('clusters'); + + /* (4) On ajoute le type de groupe textuel */ + foreach($CLUSTERLIST as $c=>$cluster) + $CLUSTERLIST[$c]['type'] = ($cluster['class']==clusterRepo::USER_CLASS) ? 'utilisateurs' : 'machines'; + + + /* [2] On construit la vue des groupes + =========================================================*/ + $cluster_view = View::replaceMultiple( + self::template('clusterlist'), + $CLUSTERLIST + ); + + + + return View::replaceSingle( + self::template(), [ + 'clusters' => $cluster_view + ] + ); + } + + + + + + + + + } + + +?> diff --git a/view/groups.php b/view/groups.php index b91e983..eb40610 100755 --- a/view/groups.php +++ b/view/groups.php @@ -173,13 +173,21 @@ =========================================================*/ echo "
"; + /* (1) Si on a un ID_CLUSTER, on affiche la composition + ---------------------------------------------------------*/ if( isset($post[1]) && is_numeric($post[1]) ){ - $userForGroup = new View('group.membersChoice', [ + $membersChoice = new View('group.membersChoice', [ 'id_cluster' => $post[1] ]); - $userForGroup->view(); + $membersChoice->view(); + + }else{ + + $groupChoice = new View('group.groupChoice', []); + + $groupChoice->view(); } diff --git a/view/js/groups-min.js b/view/js/groups-min.js index 81b1972..26a073c 100644 --- a/view/js/groups-min.js +++ b/view/js/groups-min.js @@ -1,22 +1,24 @@ var section={view:{text:'#CONTAINER > section[data-sublink="view"] ',element:document.querySelector('#CONTAINER > section[data-sublink="view"]'),searchbar:document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar')},create:{text:'#CONTAINER > section[data-sublink="create"] ',element:document.querySelector('#CONTAINER > section[data-sublink="create"]')},remove:{text:'#CONTAINER > section[data-sublink="remove"] ',element:document.querySelector('#CONTAINER > section[data-sublink="remove"]')}, -edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')},filter:{text:'#CONTAINER > section[data-sublink="filter"] ',element:document.querySelector('#CONTAINER > section[data-sublink="filter"]')},permissions:{text:'#CONTAINER > section[data-sublink="permissions"] ',element:document.querySelector('#CONTAINER > section[data-sublink="permissions"]')}}; +edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')},filter:{text:'#CONTAINER > section[data-sublink="filter"] ',element:document.querySelector('#CONTAINER > section[data-sublink="filter"]'),chooser:{text:'#CONTAINER > section[data-sublink="filter"] form#choose-cluster ',element:document.querySelector('#CONTAINER > section[data-sublink="filter"] form#choose-cluster')}},permissions:{text:'#CONTAINER > section[data-sublink="permissions"] ', +element:document.querySelector('#CONTAINER > section[data-sublink="permissions"]')}}; if(null!=section.view.element){1 article.inline-box[id]");for(c=0;c article.inline-box[id]");for(b=0;b section[data-sublink="filter"] ', - element: document.querySelector('#CONTAINER > section[data-sublink="filter"]') + element: document.querySelector('#CONTAINER > section[data-sublink="filter"]'), + + chooser: { + text: '#CONTAINER > section[data-sublink="filter"] form#choose-cluster ', + element: document.querySelector('#CONTAINER > section[data-sublink="filter"] form#choose-cluster') + } }, permissions: { @@ -613,10 +618,68 @@ if( section.edit.element != null ){ + + + + +/* GESTION DU CHOIX DU GROUPE AUQUEL MODIFIER LA COMPOSITION DES MEMBRES +* +*/ +if( section.filter.element != null && section.filter.chooser.element != null ){ + + /* [1] Initialisation et gestion statique + =========================================================*/ + /* (1) On initialise le deflater */ + section.filter.chooser.deflater = new FormDeflater( + section.filter.chooser.element, + ['select'], + ['data-name'] + ); + + /* (2) On récupère le bouton */ + section.filter.chooser.submit = document.querySelector(section.filter.chooser.text+'#choose-cluster'); + + + + /* [2] Gestion de l'évènement + =========================================================*/ + section.filter.chooser.submit.addEventListener('click', function(e){ + + /* (0) On annule l'action par défaut (PHP) */ + e.preventDefault(); + + /* (1) On récupère les données */ + var data = section.filter.chooser.deflater.deflate()['cluster']; + + // Vérification du type + if( isNaN(data) ) + return; + + /* (2) Redirection */ + pageManager.vars[1] = data; + pageManager.refresh(); + document.location = ''; + + }, false); + + + +} + + + + + + + + + + + /* GESTION DE LA MODIFICATION DES MEMBRES * */ -if( section.filter.element != null ){ +if( section.filter.element != null && section.filter.chooser.element == null ){ /* (1) On initialise le Deflater() */ section.filter.deflater = new FormDeflater(