This commit is contained in:
j3d1 2026-08-23 15:55:08 +02:00
parent 54374abf86
commit 8f3236b5b4
8 changed files with 156 additions and 160 deletions

View file

@ -13,7 +13,6 @@ import GroupDetail from '@/views/GroupDetail.vue';
import Inventory from '@/views/Inventory.vue';
import Search from '@/views/Search.vue';
import InventoryDetail from '@/views/InventoryDetail.vue';
import InventoryDetailForeign from '@/views/InventoryDetailForeign.vue';
import InventoryNew from '@/views/InventoryNew.vue';
import InventoryEdit from '@/views/InventoryEdit.vue';
import StorageLocation from '@/views/StorageLocation.vue';
@ -47,9 +46,18 @@ export function decodeHandleFromUrl(segment) {
return segment.replace(/\+/g, "#");
}
// Both item-ish kinds land on the same /inventory/:handle/:id shape - only how they resolve
// their owner's handle differs (a personal owner vs. a group, see identityHandleById/
// groupHandleById in store.js), so that resolution is the only part that stays separate.
function itemDetailRoute(handle, item_local_id) {
return handle ? `/inventory/${encodeHandleForUrl(handle)}/${item_local_id}` : null;
}
const EXPANDED_ROUTE_BUILDERS = {
item: ({item_local_id}) => `/inventory/${item_local_id}`,
group_item: ({item_local_id}) => `/inventory/${item_local_id}`,
item: ({owner_identity_id, item_local_id}) =>
itemDetailRoute(store.getters.identityHandleById[owner_identity_id], item_local_id),
group_item: ({owner_group_id, item_local_id}) =>
itemDetailRoute(store.getters.groupHandleById[owner_group_id], item_local_id),
group: ({group_id}) => `/groups/${group_id}`,
storage_location: ({storage_location_id}) => `/storage-locations/${storage_location_id}`,
workflow: ({workflow_id}) => `/workflows/${workflow_id}`,
@ -69,27 +77,24 @@ const routes = [{path: '/', component: Dashboard, meta: {requiresAuth: true}}, {
component: Inventory,
meta: {requiresAuth: true}
}, {
path: '/inventory/:id',
path: '/inventory/:handle/:id',
component: InventoryDetail,
meta: {requiresAuth: true},
props: true
}, {
path: '/inventory/:id/edit',
path: '/inventory/:handle/:id/edit',
component: InventoryEdit,
meta: {requiresAuth: true},
props: true
}, {
path: '/inventory/shared/:user/:id',
component: InventoryDetailForeign,
meta: {requiresAuth: true, foreign: true},
props: true
}, {
// The self-contained label/short-link entry point (see label.js's LABEL_CONTENT_BUILDERS
// and docs/design-in-progress/items-labels.md) - :handle is already URL-escaped the same
// way /inventory/:handle/:id expects it, so this is just a shorter alias for that route,
// with no owner-is-the-viewer special case: get_shared_item (and friends_or_self()) already
// treat "it's the viewer's own item" as one case of "the viewer may see this owner's item",
// not a separate path.
path: '/i/:handle/:id',
redirect: to => {
const handle = decodeHandleFromUrl(to.params.handle)
const {id} = to.params
return handle === store.state.user ? '/inventory/' + id : '/inventory/shared/' + encodeHandleForUrl(handle) + '/' + id
}
redirect: to => `/inventory/${to.params.handle}/${to.params.id}`
}, {
path: '/:short_id',
redirect: to => {