From 10010fc532a02958804667e1cb3acee8e9556394 Mon Sep 17 00:00:00 2001 From: John Molakvoæ Date: Tue, 21 Mar 2023 09:53:31 +0100 Subject: feat(files): sorting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files/lib/Controller/ApiController.php | 2 +- apps/files/lib/Controller/ViewController.php | 6 +++ apps/files/src/components/FilesListHeader.vue | 41 ++++++++++----- apps/files/src/mixins/fileslist-row.scss | 6 +++ apps/files/src/store/sorting.ts | 73 +++++++++++++++++++++++++++ apps/files/src/views/FilesList.vue | 33 +++++++----- 6 files changed, 135 insertions(+), 26 deletions(-) create mode 100644 apps/files/src/store/sorting.ts (limited to 'apps') diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 85507132edd..c7da9b2c118 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -285,7 +285,7 @@ class ApiController extends Controller { * @throws \OCP\PreConditionNotMetException */ public function updateFileSorting($mode, $direction) { - $allowedMode = ['name', 'size', 'mtime']; + $allowedMode = ['basename', 'size', 'mtime']; $allowedDirection = ['asc', 'desc']; if (!in_array($mode, $allowedMode) || !in_array($direction, $allowedDirection)) { $response = new Response(); diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 5133661d725..6047ad81808 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -249,6 +249,12 @@ class ViewController extends Controller { $this->initialState->provideInitialState('navigation', $navItems); $this->initialState->provideInitialState('config', $this->userConfig->getConfigs()); + // File sorting user config + $defaultFileSorting = $this->config->getUserValue($userId, 'files', 'file_sorting', 'basename'); + $defaultFileSortingDirection = $this->config->getUserValue($userId, 'files', 'file_sorting_direction', 'asc'); + $this->initialState->provideInitialState('defaultFileSorting', $defaultFileSorting === 'name' ? 'basename' : $defaultFileSorting); + $this->initialState->provideInitialState('defaultFileSortingDirection', $defaultFileSortingDirection === 'desc' ? 'desc' : 'asc'); + // render the container content for every navigation item foreach ($navItems as $item) { $content = ''; diff --git a/apps/files/src/components/FilesListHeader.vue b/apps/files/src/components/FilesListHeader.vue index 8376a30d55c..b09feae04f2 100644 --- a/apps/files/src/components/FilesListHeader.vue +++ b/apps/files/src/components/FilesListHeader.vue @@ -29,8 +29,13 @@ - + {{ t('files', 'Name') }} + @@ -40,18 +45,24 @@