diff --git a/assets/less/builder.less b/assets/less/builder.less index 45e8ba52..1b64f63f 100644 --- a/assets/less/builder.less +++ b/assets/less/builder.less @@ -195,4 +195,4 @@ div.control-table .toolbar a.builder-custom-table-button { background: white; } } -} \ 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..a58be2cf 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 = Input::input('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..d84feb05 --- /dev/null +++ b/widgets/versionlist/partials/_sort.htm @@ -0,0 +1,11 @@ +getConfig('sort', 'asc') === 'asc'): ?> + + + + 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 @@
\ No newline at end of file + diff --git a/widgets/versionlist/partials/_widget-contents.htm b/widgets/versionlist/partials/_widget-contents.htm index 77031c4e..a2813ef7 100644 --- a/widgets/versionlist/partials/_widget-contents.htm +++ b/widgets/versionlist/partials/_widget-contents.htm @@ -25,4 +25,4 @@ - \ No newline at end of file +