From e5eaeb79f6ce3aeb8dc41e385eca5ea8cb4714a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be>
Date: Thu, 5 Oct 2017 13:58:52 +0200
Subject: [PATCH] :sparkles: feat(interface): activate sorting in snapshot list

Snapshot list can now be sorted if needed

issue #5708
---
 ihtml/themes/breezy/headers.tpl   |  2 +-
 include/class_SnapshotDialogs.inc | 23 ++++++++++++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/ihtml/themes/breezy/headers.tpl b/ihtml/themes/breezy/headers.tpl
index e2a0e709c..9753b1eae 100644
--- a/ihtml/themes/breezy/headers.tpl
+++ b/ihtml/themes/breezy/headers.tpl
@@ -25,8 +25,8 @@
   <script src="include/controls.js" type="text/javascript"></script>
   <script src="include/pulldown.js" type="text/javascript"></script>
   <script src="include/datepicker.js" type="text/javascript"></script>
-  <script src="include/tsorter.js" type="text/javascript"></script>
 {/if}
+  <script src="include/tsorter.js" type="text/javascript"></script>
 {foreach from=$js_files item=file}
   <script src="{$file}" type="text/javascript"></script>
 {/foreach}
diff --git a/include/class_SnapshotDialogs.inc b/include/class_SnapshotDialogs.inc
index ea499d6ca..50437cc9b 100644
--- a/include/class_SnapshotDialogs.inc
+++ b/include/class_SnapshotDialogs.inc
@@ -85,6 +85,27 @@ class SnapshotsAttribute extends OrderedArrayAttribute
     $this->setInLdap(FALSE);
   }
 
+  function setParent (&$plugin)
+  {
+    parent::setParent($plugin);
+    if (is_object($this->plugin)) {
+      if ($this->plugin->global) {
+        $this->setHeaders(array(
+          _('DN'),
+          _('Date'),
+          _('Description'),
+          ''
+        ));
+      } else {
+        $this->setHeaders(array(
+          _('Date'),
+          _('Description'),
+          ''
+        ));
+      }
+    }
+  }
+
   function loadPostValue ()
   {
     if ($this->isVisible()) {
@@ -193,10 +214,10 @@ class SnapshotRestoreDialog extends simplePlugin
 
   function __construct ($dn, $parent, $global, $aclCategory)
   {
+    $this->global       = $global;
     parent::__construct();
     $this->object_dn    = $dn;
     $this->parent       = $parent;
-    $this->global       = $global;
     $this->aclCategory  = $aclCategory;
     if ($this->global) {
       $this->attributesAccess['object_dn']->setVisible(FALSE);
-- 
GitLab