This commit is contained in:
j3d1 2026-08-22 23:29:02 +02:00
parent 3299c97392
commit de7d9426be
10 changed files with 259 additions and 99 deletions

View file

@ -40,7 +40,7 @@
<a :href="`/inventory/${item.id}/delete`" @click.prevent="deleteInventoryItem(item)">
<b-icon-trash></b-icon-trash>
</a>
<router-link :to="shortIdLink(item)">
<router-link v-if="shortIdLink(item)" :to="shortIdLink(item)">
<b-icon-link></b-icon-link>
</router-link>
</td>
@ -73,7 +73,8 @@
<router-link :to="`/inventory/${item.id}/edit`"
class="btn btn-primary btn-sm">Edit
</router-link>
<router-link :to="shortIdLink(item)" class="btn btn-secondary btn-sm">
<router-link v-if="shortIdLink(item)" :to="shortIdLink(item)"
class="btn btn-secondary btn-sm">
<b-icon-link></b-icon-link>
</router-link>
</div>
@ -100,7 +101,7 @@ import {mapActions, mapGetters, mapMutations, mapState} from "vuex";
import * as BIcons from "bootstrap-icons-vue";
import BaseLayout from "@/components/BaseLayout.vue";
import AuthenticatedImage from "../components/AuthenticatedImage.vue";
import {encodeShortId, serializeShortId} from "@/short-id";
import {shortenedRoute} from "@/router";
export default {
name: "Inventory",
@ -115,11 +116,11 @@ export default {
...BIcons
},
computed: {
...mapGetters(["inventory_items", "loaded_items"]),
...mapGetters(["inventory_items", "loaded_items", "identityIdByHandle", "groupIdByHandle"]),
...mapState(["user", "storage_locations"]),
},
methods: {
...mapActions(["fetchInventoryItems", "deleteInventoryItem", "fetchStorageLocations"]),
...mapActions(["fetchInventoryItems", "deleteInventoryItem", "fetchStorageLocations", "fetchIdMap"]),
only_images(files) {
return files.filter(file => file.mime_type.startsWith("image/"));
},
@ -128,16 +129,20 @@ export default {
return loc ? loc.path : null
},
shortIdLink(item) {
// owner_identity_id is a placeholder until the backend exposes a KnownIdentity pk
// per item (see docs/handles-and-shortids.md) - it doesn't decode to a
// meaningful owner yet.
const ints = serializeShortId({kind: 'item', owner_identity_id: 0, item_local_id: item.id});
return '/' + encodeShortId(ints);
if (item.owner_group) {
const owner_group_id = this.groupIdByHandle[item.owner_group]
if (owner_group_id === undefined) return null
return shortenedRoute({kind: 'group_item', owner_group_id, item_local_id: item.id})
}
const owner_identity_id = this.identityIdByHandle[item.owner]
if (owner_identity_id === undefined) return null
return shortenedRoute({kind: 'item', owner_identity_id, item_local_id: item.id})
},
},
async mounted() {
await this.fetchInventoryItems()
await this.fetchStorageLocations()
await this.fetchIdMap()
}
}
</script>