From c2f68a4716895e00b6075d0da5fffe44d77baa2d Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Thu, 9 Apr 2020 22:53:24 +0200 Subject: [PATCH] Supprimer le bouton trier --- module/gallery/gallery.php | 54 +++++++++++------------- module/gallery/view/config/config.js.php | 30 ++++++++++--- module/gallery/view/config/config.php | 12 +----- 3 files changed, 50 insertions(+), 46 deletions(-) diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 7b3d4aaf..db2878c4 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -18,6 +18,7 @@ class gallery extends common { 'config' => self::GROUP_MODERATOR, 'delete' => self::GROUP_MODERATOR, 'dirs' => self::GROUP_MODERATOR, + 'sort' => self::GROUP_MODERATOR, 'edit' => self::GROUP_MODERATOR, 'index' => self::GROUP_VISITOR ]; @@ -45,39 +46,34 @@ class gallery extends common { const GALLERY_VERSION = '2.1'; + /** + * Tri sans bouton + */ + public function sort () { + if($_POST['response']) { + $data = explode('&',$_POST['response']); + $data = str_replace('galleryTable%5B%5D=','',$data); + for($i=0;$isetData(['module', $this->getUrl(0), $data[$i], [ + 'config' => [ + 'name' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','name']), + 'directory' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','directory']), + 'homePicture' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','homePicture']), + 'sort' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','sort']), + 'position' => $i + ], + 'legend' => $this->getData(['module',$this->getUrl(0),$data[$i],'legend']) + ]]); + } + } + } + + /** * Configuration */ public function config() { - - // Le traitement du tri s'effectue en début de fonction - // Soumission du formulaire - if($this->isPost()) { - if ($this->getInput('galleryConfigFilterResponse')) { - $data = explode('&',($this->getInput('galleryConfigFilterResponse'))); - $data = str_replace('galleryTable%5B%5D=','',$data); - for($i=0;$isetData(['module', $this->getUrl(0), $data[$i], [ - 'config' => [ - 'name' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','name']), - 'directory' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','directory']), - 'homePicture' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','homePicture']), - 'sort' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','sort']), - 'position' => $i - ], - 'legend' => $this->getData(['module',$this->getUrl(0),$data[$i],'legend']) - ]]); - } - } - // Valeurs en sortie - //header('Refresh: 0;url='. helper::baseUrl() . $this->getUrl() . '#galleryConfigFilterForm' ); - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl() /* . '#galleryConfigFilterForm'*/, - 'notification' => 'Modifications enregistrées', - 'state' => true - ]); - } - // Tri pour l'affichage de la galerie + //Affichage de la galerie triée $g = $this->getData(['module', $this->getUrl(0)]); $p = helper::arrayCollumn(helper::arrayCollumn($g,'config'),'position'); asort($p,SORT_NUMERIC); diff --git a/module/gallery/view/config/config.js.php b/module/gallery/view/config/config.js.php index 64ae388a..75f3a8a9 100644 --- a/module/gallery/view/config/config.js.php +++ b/module/gallery/view/config/config.js.php @@ -12,26 +12,27 @@ * @link http://zwiicms.com/ */ - $( document ).ready(function() { + /** - * Tri dynamique de la galerie + * Tri de la galerie avec drag and drop */ - $("#galleryTable").tableDnD({ - onDrop: function(table, row) { - // Stocke dans un champ caché l'ordre de tri modifié + $("#galleryTable").tableDnD({ + onDrop: function(table, row) { $("#galleryConfigFilterResponse").val($.tableDnD.serialize()); }, onDragStop : function(table, row) { // Affiche le bouton de tri après un déplacement $(":input[type='submit']").prop('disabled', false); + // Sauvegarde le tri + sort(); }, // Supprime le tiret des séparateurs serializeRegexp: "[^\_]*$" }); - + /** * Confirmation de suppression @@ -84,3 +85,20 @@ setInterval(function() { directoryDOM.on("change", function() { directoryOldDOM.val($(this).val()); }); + + +/** + * Tri dynamique des galeries + */ + +function sort() { + var url = "getUrl(0) . '/sort'; ?>"; + var data = $("#galleryConfigFilterResponse").val(); + $.ajax({ + type: "POST", + url: url , + data: { + response : data + } + }); +} \ No newline at end of file diff --git a/module/gallery/view/config/config.php b/module/gallery/view/config/config.php index 59fe7d85..636b863a 100644 --- a/module/gallery/view/config/config.php +++ b/module/gallery/view/config/config.php @@ -51,19 +51,9 @@

Galeries installées

-
- 'Trier', - 'disabled' => true, - 'class' => 'gallerySubmit' - ]); ?> -
'galleryTable'],$module::$galleriesId); ?> - - false - ]); ?> +