aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-01-26 14:21:32 +0100
committerFerdinand Thiessen <opensource@fthiessen.de>2024-01-27 14:23:47 +0100
commit2cea4d7b8d7440ef5e4d5ffea9b06e643b08e84c (patch)
tree345506d7465dafbfcd4f120b225832ee85ae3a2c /apps
parent5044ed712f99eb300a9a23810410ba49f613a885 (diff)
downloadnextcloud-server-2cea4d7b8d7440ef5e4d5ffea9b06e643b08e84c.tar.gz
nextcloud-server-2cea4d7b8d7440ef5e4d5ffea9b06e643b08e84c.zip
fix(files): Consistent sorting for folders before files (user configurable)
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/lib/Service/UserConfig.php6
-rw-r--r--apps/files/src/store/userconfig.ts5
-rw-r--r--apps/files/src/views/FilesList.vue4
-rw-r--r--apps/files/src/views/Settings.vue4
4 files changed, 15 insertions, 4 deletions
diff --git a/apps/files/lib/Service/UserConfig.php b/apps/files/lib/Service/UserConfig.php
index 00569dc6aeb..b6755836b0f 100644
--- a/apps/files/lib/Service/UserConfig.php
+++ b/apps/files/lib/Service/UserConfig.php
@@ -48,6 +48,12 @@ class UserConfig {
'allowed' => [true, false],
],
[
+ // Whether to sort folders before files in the list or not
+ 'key' => 'sort_folders_first',
+ 'default' => true,
+ 'allowed' => [true, false],
+ ],
+ [
// Whether to show the files list in grid view or not
'key' => 'grid_view',
'default' => false,
diff --git a/apps/files/src/store/userconfig.ts b/apps/files/src/store/userconfig.ts
index cbd3f71600a..c5f34c2dbe0 100644
--- a/apps/files/src/store/userconfig.ts
+++ b/apps/files/src/store/userconfig.ts
@@ -27,12 +27,13 @@ import { loadState } from '@nextcloud/initial-state'
import axios from '@nextcloud/axios'
import Vue from 'vue'
-const userConfig = loadState('files', 'config', {
+const userConfig = loadState<UserConfig>('files', 'config', {
show_hidden: false,
crop_image_previews: true,
sort_favorites_first: true,
+ sort_folders_first: true,
grid_view: false,
-}) as UserConfig
+})
export const useUserConfigStore = function(...args) {
const store = defineStore('userconfig', {
diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue
index fabfccd6ca1..d57dece60d3 100644
--- a/apps/files/src/views/FilesList.vue
+++ b/apps/files/src/views/FilesList.vue
@@ -257,7 +257,7 @@ export default defineComponent({
// 1: Sort favorites first if enabled
...(this.userConfig.sort_favorites_first ? [v => v.attributes?.favorite !== 1] : []),
// 2: Sort folders first if sorting by name
- ...(this.sortingMode === 'basename' ? [v => v.type !== 'folder'] : []),
+ ...(this.userConfig.sort_folders_first ? [v => v.type !== 'folder'] : []),
// 3: Use sorting mode if NOT basename (to be able to use displayName too)
...(this.sortingMode !== 'basename' ? [v => v[this.sortingMode]] : []),
// 4: Use displayName if available, fallback to name
@@ -269,7 +269,7 @@ export default defineComponent({
// (for 1): always sort favorites before normal files
...(this.userConfig.sort_favorites_first ? ['asc'] : []),
// (for 2): always sort folders before files
- ...(this.sortingMode === 'basename' ? ['asc'] : []),
+ ...(this.userConfig.sort_folders_first ? ['asc'] : []),
// (for 3): Reverse if sorting by mtime as mtime higher means edited more recent -> lower
...(this.sortingMode === 'mtime' ? [this.isAscSorting ? 'desc' : 'asc'] : []),
// (also for 3 so make sure not to conflict with 2 and 3)
diff --git a/apps/files/src/views/Settings.vue b/apps/files/src/views/Settings.vue
index d3eb318d4fa..cefbdab4eec 100644
--- a/apps/files/src/views/Settings.vue
+++ b/apps/files/src/views/Settings.vue
@@ -30,6 +30,10 @@
@update:checked="setConfig('sort_favorites_first', $event)">
{{ t('files', 'Sort favorites first') }}
</NcCheckboxRadioSwitch>
+ <NcCheckboxRadioSwitch :checked="userConfig.sort_folders_first"
+ @update:checked="setConfig('sort_folders_first', $event)">
+ {{ t('files', 'Sort folders before files') }}
+ </NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked="userConfig.show_hidden"
@update:checked="setConfig('show_hidden', $event)">
{{ t('files', 'Show hidden files') }}