From 6af048dc93a303d6b62b022664006d84897c5ebe Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Thu, 1 Dec 2022 18:21:49 -0900 Subject: [PATCH] feat: present loc/labels based on route (#162) --- frontend/components/Item/CreateModal.vue | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/frontend/components/Item/CreateModal.vue b/frontend/components/Item/CreateModal.vue index 2a2aec3..cf65f03 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); + } } );