From f408677cd80b25cc83e4cbb3efa65a81f1b24780 Mon Sep 17 00:00:00 2001 From: Filip Iulian Pacurar Date: Thu, 17 Oct 2019 15:30:49 +0300 Subject: [PATCH 1/7] initial version of sorting versions --- assets/less/builder.less | 4 ++++ lang/en/lang.php | 2 ++ widgets/VersionList.php | 16 ++++++++++++++++ widgets/versionlist/partials/_sort.htm | 8 ++++++++ .../versionlist/partials/_widget-contents.htm | 1 + 5 files changed, 31 insertions(+) create mode 100644 widgets/versionlist/partials/_sort.htm diff --git a/assets/less/builder.less b/assets/less/builder.less index 45e8ba52..924dfa9c 100644 --- a/assets/less/builder.less +++ b/assets/less/builder.less @@ -195,4 +195,8 @@ div.control-table .toolbar a.builder-custom-table-button { background: white; } } +} + +.sidepanel-content-header a.white { + color: #fff; } \ No newline at end of file diff --git a/lang/en/lang.php b/lang/en/lang.php index 92c566cf..8a0cea27 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -548,6 +548,8 @@ 'hint_apply' => 'Applying a version will also apply all older unapplied versions of the plugin.', 'dont_show_again' => 'Don\'t show again', 'save_unapplied_version' => 'Save unapplied version', + 'sort_ascending' => 'Sort ascending', + 'sort_descending' => 'Sort descending', ], 'menu' => [ 'menu_label' => 'Backend Menu', diff --git a/widgets/VersionList.php b/widgets/VersionList.php index eb487ecf..0d6660a8 100644 --- a/widgets/VersionList.php +++ b/widgets/VersionList.php @@ -23,6 +23,9 @@ public function __construct($controller, $alias) $this->alias = $alias; parent::__construct($controller, []); + + $this->config->sort = $this->getSession('sort', 'asc'); + $this->bindToController(); } @@ -60,6 +63,15 @@ public function onSearch() return $this->updateList(); } + public function onSort() + { + $this->config->sort = request()->sort; + + $this->putSession('sort', $this->config->sort); + + return ['#'.$this->getId('body') => $this->makePartial('widget-contents', $this->getRenderData())]; + } + /* * Methods for the internal use */ @@ -97,6 +109,10 @@ protected function getRenderData() $items = $result; } + if($this->getConfig('sort', 'asc') == 'desc') { + $items = array_reverse($items, false); + } + $versionManager = VersionManager::instance(); $unappliedVersions = $versionManager->listNewVersions($activePluginVector->pluginCodeObj->toCode()); return [ diff --git a/widgets/versionlist/partials/_sort.htm b/widgets/versionlist/partials/_sort.htm new file mode 100644 index 00000000..3b5982bf --- /dev/null +++ b/widgets/versionlist/partials/_sort.htm @@ -0,0 +1,8 @@ +
+ getConfig('sort', 'asc') === 'asc'): ?> + + + + +
\ No newline at end of file diff --git a/widgets/versionlist/partials/_widget-contents.htm b/widgets/versionlist/partials/_widget-contents.htm index 77031c4e..b3804d6f 100644 --- a/widgets/versionlist/partials/_widget-contents.htm +++ b/widgets/versionlist/partials/_widget-contents.htm @@ -2,6 +2,7 @@
getPluginName())) ?> + makePartial('sort'); ?> From 478f3b8a903a1b84697d11354961ded13b375c4e Mon Sep 17 00:00:00 2001 From: Filip Iulian Pacurar Date: Thu, 17 Oct 2019 16:13:50 +0300 Subject: [PATCH 2/7] required changes --- assets/less/builder.less | 4 ---- widgets/VersionList.php | 4 ++-- widgets/versionlist/partials/_sort.htm | 19 +++++++++++-------- widgets/versionlist/partials/_toolbar.htm | 7 ++++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/assets/less/builder.less b/assets/less/builder.less index 924dfa9c..1b64f63f 100644 --- a/assets/less/builder.less +++ b/assets/less/builder.less @@ -196,7 +196,3 @@ div.control-table .toolbar a.builder-custom-table-button { } } } - -.sidepanel-content-header a.white { - color: #fff; -} \ No newline at end of file diff --git a/widgets/VersionList.php b/widgets/VersionList.php index 0d6660a8..47234b4b 100644 --- a/widgets/VersionList.php +++ b/widgets/VersionList.php @@ -65,7 +65,7 @@ public function onSearch() public function onSort() { - $this->config->sort = request()->sort; + $this->config->sort = Input::input('sort'); $this->putSession('sort', $this->config->sort); @@ -109,7 +109,7 @@ protected function getRenderData() $items = $result; } - if($this->getConfig('sort', 'asc') == 'desc') { + if ($this->getConfig('sort', 'asc') == 'desc') { $items = array_reverse($items, false); } diff --git a/widgets/versionlist/partials/_sort.htm b/widgets/versionlist/partials/_sort.htm index 3b5982bf..6005676a 100644 --- a/widgets/versionlist/partials/_sort.htm +++ b/widgets/versionlist/partials/_sort.htm @@ -1,8 +1,11 @@ -
- getConfig('sort', 'asc') === 'asc'): ?> - - - - -
\ No newline at end of file +getConfig('sort', 'asc') === 'asc'): ?> + + + + \ No newline at end of file diff --git a/widgets/versionlist/partials/_toolbar.htm b/widgets/versionlist/partials/_toolbar.htm index 3e49d707..f0197389 100644 --- a/widgets/versionlist/partials/_toolbar.htm +++ b/widgets/versionlist/partials/_toolbar.htm @@ -2,7 +2,7 @@
-
@@ -31,4 +32,4 @@ />
-
\ No newline at end of file +
From ef6be0c0cacf1f1805cc6d2a80ad5e3a96d9d1ab Mon Sep 17 00:00:00 2001 From: Filip Iulian Pacurar Date: Thu, 17 Oct 2019 18:08:16 +0300 Subject: [PATCH 3/7] Update widgets/VersionList.php Co-Authored-By: Luke Towers --- widgets/VersionList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/VersionList.php b/widgets/VersionList.php index 47234b4b..7f8b383b 100644 --- a/widgets/VersionList.php +++ b/widgets/VersionList.php @@ -69,7 +69,7 @@ public function onSort() $this->putSession('sort', $this->config->sort); - return ['#'.$this->getId('body') => $this->makePartial('widget-contents', $this->getRenderData())]; + return ['#' . $this->getId('body') => $this->makePartial('widget-contents', $this->getRenderData())]; } /* From ab28e7ab0a2627f083898540783e8bb10b0c484e Mon Sep 17 00:00:00 2001 From: Filip Iulian Pacurar Date: Thu, 17 Oct 2019 18:08:28 +0300 Subject: [PATCH 4/7] Update widgets/VersionList.php Co-Authored-By: Luke Towers --- widgets/VersionList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/VersionList.php b/widgets/VersionList.php index 7f8b383b..a58be2cf 100644 --- a/widgets/VersionList.php +++ b/widgets/VersionList.php @@ -109,7 +109,7 @@ protected function getRenderData() $items = $result; } - if ($this->getConfig('sort', 'asc') == 'desc') { + if ($this->getConfig('sort', 'asc') === 'desc') { $items = array_reverse($items, false); } From 536539a47b51493c5652a2b9d31de949f3a585f3 Mon Sep 17 00:00:00 2001 From: Filip Iulian Pacurar Date: Thu, 17 Oct 2019 18:09:46 +0300 Subject: [PATCH 5/7] ident --- widgets/versionlist/partials/_sort.htm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/widgets/versionlist/partials/_sort.htm b/widgets/versionlist/partials/_sort.htm index 6005676a..d84feb05 100644 --- a/widgets/versionlist/partials/_sort.htm +++ b/widgets/versionlist/partials/_sort.htm @@ -1,11 +1,11 @@ getConfig('sort', 'asc') === 'asc'): ?> + data-request-data="sort: 'desc'" + class="btn btn-default empty last oc-icon-sort-numeric-desc" + title=""> - \ No newline at end of file + data-request-data="sort: 'asc'" + class="btn btn-default empty last oc-icon-sort-numeric-asc" + title=""> + From a6bd206e7809ffcf91fdd0670744de84ae176448 Mon Sep 17 00:00:00 2001 From: Filip Iulian Pacurar Date: Tue, 22 Oct 2019 12:45:15 +0300 Subject: [PATCH 6/7] fix --- widgets/versionlist/partials/_widget-contents.htm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/widgets/versionlist/partials/_widget-contents.htm b/widgets/versionlist/partials/_widget-contents.htm index b3804d6f..56ba6f9a 100644 --- a/widgets/versionlist/partials/_widget-contents.htm +++ b/widgets/versionlist/partials/_widget-contents.htm @@ -2,7 +2,7 @@
getPluginName())) ?> - makePartial('sort'); ?> + makePartial('sort'); ?> @@ -26,4 +26,4 @@
- \ No newline at end of file + From a0336e00e65f1c176cbf10e2a033ffde72b82314 Mon Sep 17 00:00:00 2001 From: Filip Iulian Pacurar Date: Mon, 4 Nov 2019 23:11:20 +0200 Subject: [PATCH 7/7] remove double button --- widgets/versionlist/partials/_widget-contents.htm | 1 - 1 file changed, 1 deletion(-) diff --git a/widgets/versionlist/partials/_widget-contents.htm b/widgets/versionlist/partials/_widget-contents.htm index 56ba6f9a..a2813ef7 100644 --- a/widgets/versionlist/partials/_widget-contents.htm +++ b/widgets/versionlist/partials/_widget-contents.htm @@ -2,7 +2,6 @@
getPluginName())) ?> - makePartial('sort'); ?>