@motor-cms/ui-media 2.0.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -73,9 +73,12 @@ const hasMore = computed(() => currentPage.value < lastPage.value)
|
|
|
73
73
|
|
|
74
74
|
// Build fetch params combining filters with internal page
|
|
75
75
|
function buildParams(page: number): GridParams {
|
|
76
|
+
const sortField = gridState.state.sort ?? 'created_at'
|
|
77
|
+
const sortDirection = gridState.state.sort ? gridState.state.direction : 'desc'
|
|
76
78
|
const params: GridParams = {
|
|
77
79
|
page,
|
|
78
|
-
per_page: props.perPage
|
|
80
|
+
per_page: props.perPage,
|
|
81
|
+
sort: sortDirection === 'desc' ? `${sortField}:desc` : sortField
|
|
79
82
|
}
|
|
80
83
|
if (gridState.state.search) params.search = gridState.state.search
|
|
81
84
|
Object.entries(gridState.state.filters).forEach(([key, value]) => {
|
|
@@ -146,9 +149,11 @@ const { error: ssrError } = await useAsyncData(
|
|
|
146
149
|
if (ssrError.value) fetchError.value = ssrError.value
|
|
147
150
|
initialLoading.value = false
|
|
148
151
|
|
|
149
|
-
// Watch filter/search changes — reset accumulated data
|
|
152
|
+
// Watch filter/search/sort changes — reset accumulated data
|
|
150
153
|
const filterKey = computed(() => JSON.stringify({
|
|
151
154
|
search: gridState.state.search,
|
|
155
|
+
sort: gridState.state.sort,
|
|
156
|
+
direction: gridState.state.direction,
|
|
152
157
|
filters: gridState.state.filters
|
|
153
158
|
}))
|
|
154
159
|
|
|
@@ -120,7 +120,7 @@ const fetchFiles = useGridFetch<File>('/api/v2/files')
|
|
|
120
120
|
<!-- Gallery view -->
|
|
121
121
|
<MediaGallery
|
|
122
122
|
v-if="viewMode === 'gallery'"
|
|
123
|
-
id="files
|
|
123
|
+
id="files"
|
|
124
124
|
:fetch="fetchFiles"
|
|
125
125
|
:filters="filters"
|
|
126
126
|
:bulk-actions="bulkActions"
|
|
@@ -140,7 +140,7 @@ const fetchFiles = useGridFetch<File>('/api/v2/files')
|
|
|
140
140
|
<!-- Table view -->
|
|
141
141
|
<GridBase
|
|
142
142
|
v-else
|
|
143
|
-
id="files
|
|
143
|
+
id="files"
|
|
144
144
|
:fetch="fetchFiles"
|
|
145
145
|
:columns="columns"
|
|
146
146
|
:filters="filters"
|
|
@@ -150,6 +150,8 @@ const fetchFiles = useGridFetch<File>('/api/v2/files')
|
|
|
150
150
|
:row-actions="rowActions"
|
|
151
151
|
write-permission="files.write"
|
|
152
152
|
delete-permission="files.delete"
|
|
153
|
+
default-sort="created_at"
|
|
154
|
+
default-direction="desc"
|
|
153
155
|
:row-click-to="(row: any) => `/motor-media/files/${row.id}/edit`"
|
|
154
156
|
/>
|
|
155
157
|
</GridPage>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motor-cms/ui-media",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@vueuse/core": "^14.0.0"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@motor-cms/ui-core": ">=
|
|
16
|
+
"@motor-cms/ui-core": ">=3.0.1",
|
|
17
17
|
"nuxt": "^4.0.0",
|
|
18
18
|
"vue": "^3.5.0"
|
|
19
19
|
}
|