Appearance
useCollageDetails Composable ​
File Information ​
- Path:
app/composables/core/pages/useCollageDetails.ts - Purpose: Collage details page logic and asset management
- Type: Core Composable
Overview ​
Collage details page logic and asset management
Features ​
Invalid or missing collage handling (ee26b58) ​
Mount order (onMounted):
isValidResourceId(route.params.id)fails:snackbar.showError("Collage not found."),navigateTo('/<brand_name>/collage', { replace: true }), stop.- Set
collageParamsto{ page: 1, url_workspace_id, total_record: 36, sort_value, sort_by }, wait a tick. - Only if
collageDetailsQuery.datahas no cached value:await loadCollageAssets("onload"); if it returnsfalse, stop. With a cached value, the query watcher fills the page and no fetch is made here. fetchSearchData(), then register themittBusdownload listeners (download-all-folder,download-file-collage, ...).
loadCollageAssets(flag = "default") now returns Promise<boolean>:
| Case | Result |
|---|---|
route.params.id fails isValidResourceId | false, no request |
| Request succeeds | true |
Request fails on the initial load ("onload") with API code === 402 or a message matching /not found/i | snackbar "Collage not found.", navigateTo('/<brand_name>/collage', { replace: true }), false |
| Request fails on the initial load for another reason | collageNotFound = true (in-page empty state), false |
| Request fails on a later page or sort | false, no redirect |
The error code is read from error.data.code, then error.response._data.code, then error.code; the message the same way. Because onMounted stops on false, a failed initial load no longer goes on to call fetchSearchData() or register listeners for a page that has no collage.
Snackbars with the same text are de-duplicated by the snackbar plugin, so both paths showing "Collage not found." do not stack.
Sorting a fully loaded collage (PR #137) ​
loadCollageAssets returns true early when a page load is running (loadMore) or currentPage >= lastPage, except for a sort (flag === "sort" with sort_loader set). Before PR #137 the sort check came after this guard, so sorting a collage whose pages were all loaded did nothing.
Gallery quick view (PR #137) ​
| Member | Behaviour |
|---|---|
galleryDialog, galleryStartId | Open state and asset to show first |
galleryAssets | computed over a swappable source function |
galleryPagination | GalleryPagination or null |
openGallery(file) | Source = live displayFiles without parent_id; pagination = null during inner search, else { fetchPage: fetchGalleryPage, loadedPages: max(currentPage, 1), lastPage, total: assetList.assets_id.length }; starts at file.id |
openGalleryForSelection() | Snapshot of loaded selected rows (returns if empty), starts at the first. Without select-all or during search: no pagination. With select-all: fetchPage keeps only ids in selectedItemAssets, total = their count |
closeGallery() | Closes and clears galleryStartId |
fetchGalleryPage(page) calls queryClient.fetchQuery with queryKeys.collections.details(collectionId, params) and collectionApi.getCollageDetails, params { page, url_workspace_id, total_record: COLLAGE_ASSETS_PER_PAGE (36), sort_value, sort_by }, and returns { items: assets.data, total: assetList.assets_id.length, lastPage: assets.last_page }. See Asset Management - Gallery Quick View.
Return Type ​
Refer to the composable source code for return type definitions. Composables use TypeScript for type-safe return values.
Parameters ​
Refer to the composable source code for parameter definitions. Composables use TypeScript for type-safe parameters.
Usage Example ​
typescript
import { useCollageDetails } from '~/composables/core/pages/useCollageDetails'
const { /* destructured return values */ } = useCollageDetails()Related Composables ​
- See Composables Overview for all composables
Related Documentation ​
- Composables Overview - All composables
- Types - TypeScript type definitions
- Components - Components using this composable