Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

feat: present loc/labels based on route (#162)

Hayden6af048dc93a3
diff --git a/frontend/components/Item/CreateModal.vue b/frontend/components/Item/CreateModal.vue
index 2a2aec30..cf65f039 100644
--- a/frontend/components/Item/CreateModal.vue
+++ b/frontend/components/Item/CreateModal.vue
@@ -37,6 +37,22 @@
},
});
+ const route = useRoute();
+
+ const labelId = computed(() => {
+ if (route.fullPath.includes("/label/")) {
+ return route.params.id;
+ }
+ return null;
+ });
+
+ const locationId = computed(() => {
+ if (route.fullPath.includes("/location/")) {
+ return route.params.id;
+ }
+ return null;
+ });
+
const api = useUserApi();
const toast = useNotifier();
@@ -72,6 +88,14 @@
() => modal.value,
() => {
focused.value = true;
+
+ if (locationId.value) {
+ form.location = locations.value.find(l => l.id === locationId.value);
+ }
+
+ if (labelId.value) {
+ form.labels = labels.value.filter(l => l.id === labelId.value);
+ }
}
);