Skip to content

A self-hosted media server and file management system

fix: resource sorting options are not consistent between pages

aminnausin0c539a25a17c
diff --git a/resources/js/components/dashboard/DashboardLibraries.vue b/resources/js/components/dashboard/DashboardLibraries.vue
index b9625e48..f5a6eb14 100644
--- a/resources/js/components/dashboard/DashboardLibraries.vue
+++ b/resources/js/components/dashboard/DashboardLibraries.vue
@@ -2,6 +2,7 @@
import type { CategoryResource, FolderResource } from '@/types/resources';
import type { BreadCrumbItem } from '@/types/types';
+import { folderSortingOptions, librarySortingOptions } from '@/constants/sortingOptions';
import { computed, ref, watchEffect } from 'vue';
import { startScanFilesTask } from '@/service/siteAPI';
import { useDashboardStore } from '@/stores/DashboardStore';
@@ -25,56 +26,6 @@ import ProiconsLibrary from '~icons/proicons/library';
import ProiconsHome2 from '~icons/proicons/home-2';
import ProiconsAdd from '~icons/proicons/add';
-const sortingOptions = ref([
- {
- title: 'Title',
- value: 'name',
- disabled: false,
- },
- {
- title: 'Date',
- value: 'created_at',
- disabled: false,
- },
- {
- title: 'Folders',
- value: 'folders_count',
- disabled: false,
- },
- {
- title: 'Files',
- value: 'videos_count',
- disabled: false,
- },
- {
- title: 'Size',
- value: 'total_size',
- disabled: false,
- },
-]);
-
-const folderSortingOptions = ref([
- {
- title: 'Title',
- value: 'name',
- disabled: false,
- },
- {
- title: 'Date',
- value: 'created_at',
- disabled: false,
- },
- {
- title: 'Videos',
- value: 'file_count',
- disabled: false,
- },
- {
- title: 'Total Size',
- value: 'total_size',
- },
-]);
-
const { stateLibraries, isLoadingLibraries, stateLibraryId, stateLibraryFolders, isLoadingLibraryFolders } = storeToRefs(useDashboardStore());
const { pageTitle } = storeToRefs(useAppStore());
@@ -242,7 +193,7 @@ watchEffect(() => {
:click-action="handleDelete"
:loading="isLoadingLibraries"
:sort-action="handleSort"
- :sorting-options="sortingOptions"
+ :sorting-options="librarySortingOptions"
v-model="searchQuery"
/>
<ModalBase :modalData="confirmModal" :action="submitDelete">
diff --git a/resources/js/components/panels/FolderSidebar.vue b/resources/js/components/panels/FolderSidebar.vue
index 2ce8464c..b3ff25f7 100644
--- a/resources/js/components/panels/FolderSidebar.vue
+++ b/resources/js/components/panels/FolderSidebar.vue
@@ -1,7 +1,8 @@
<script setup lang="ts">
-import type { GenericSortOption, SortDir } from '@/types/types';
import type { FolderResource } from '@/types/resources';
+import type { SortDir } from '@/types/types';
+import { folderSortingOptions } from '@/constants/sortingOptions';
import { useContentStore } from '@/stores/ContentStore';
import { formatFileSize } from '@/service/util';
import { useModalStore } from '@/stores/ModalStore';
@@ -23,29 +24,6 @@ import ProiconsFilter from '~icons/proicons/filter';
const stickyFilters = true;
-const folderSortingOptions: GenericSortOption<FolderResource>[] = [
- {
- title: 'Title',
- value: 'name',
- },
- {
- title: 'Date Created',
- value: 'created_at',
- },
- {
- title: 'Date Updated',
- value: 'updated_at',
- },
- {
- title: 'Size',
- value: 'total_size',
- },
- {
- title: 'File Count',
- value: 'file_count',
- },
-];
-
const modal = useModalStore();
const folderSearchQuery = ref<string>('');
diff --git a/resources/js/constants/sortingOptions.ts b/resources/js/constants/sortingOptions.ts
new file mode 100644
index 00000000..cde60792
--- /dev/null
+++ b/resources/js/constants/sortingOptions.ts
@@ -0,0 +1,48 @@
+import type { GenericSortOption } from '@/types/types';
+import type { CategoryResource, FolderResource } from '@/contracts/media';
+
+export const librarySortingOptions: GenericSortOption<CategoryResource>[] = [
+ {
+ title: 'Title',
+ value: 'name',
+ },
+ {
+ title: 'Date',
+ value: 'created_at',
+ },
+ {
+ title: 'Folders',
+ value: 'folders_count',
+ },
+ {
+ title: 'Files',
+ value: 'videos_count',
+ },
+ {
+ title: 'Size',
+ value: 'total_size',
+ },
+];
+
+export const folderSortingOptions: GenericSortOption<FolderResource>[] = [
+ {
+ title: 'Title',
+ value: 'name',
+ },
+ {
+ title: 'Date Created',
+ value: 'created_at',
+ },
+ {
+ title: 'Date Updated',
+ value: 'updated_at',
+ },
+ {
+ title: 'Size',
+ value: 'total_size',
+ },
+ {
+ title: 'File Count',
+ value: 'file_count',
+ },
+];