diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 0a58431..c13dbac 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -99,6 +99,8 @@ + + diff --git a/frontend/src/routes/project/Kanban.svelte b/frontend/src/routes/project/Kanban.svelte index afc4045..54a09eb 100644 --- a/frontend/src/routes/project/Kanban.svelte +++ b/frontend/src/routes/project/Kanban.svelte @@ -47,7 +47,7 @@ function updateUrl(){ let url = window.location.origin + window.location.pathname; if (filter_input) url += '?filter=' + encodeURI(filter_input); - window.history.replaceState(history.state, '', url); + window.history.replaceState(window.history.state, '', url); } async function create(name,user_id,state){ diff --git a/frontend/src/routes/stock/Index.svelte b/frontend/src/routes/stock/Index.svelte index a6f5fed..fcc9fb9 100644 --- a/frontend/src/routes/stock/Index.svelte +++ b/frontend/src/routes/stock/Index.svelte @@ -20,7 +20,14 @@ $effect(() => { // This effect runs whenever `location` changes - if (location !== null) item = null; + if (location !== null) { + item = null; + setLocationUrl(); + } + }); + + $effect(() => { + if (item !== null) setItemUrl(); }); let properties = $state(null); let top_level = $state(null); @@ -38,12 +45,6 @@ } else error(res); } - function unlistLocation(loc){ - for (var owner of top_level){ - if (owner.locations && dropNestedLocation(owner.locations,loc)) break; - } - } - function drag_item(item){ draggedLocation = null; draggedItem = item; @@ -154,6 +155,26 @@ } } + function setItemUrl(){ + var owner = `/${item.owner.type}/${item.owner.id}` + var code = `/item/${item.owner_number}` + let url = window.location.origin + '/stock' + owner + code; + window.history.replaceState(window.history.state, '', url); + } + + function setLocationUrl(){ + let url = window.location.origin + '/stock/location/' + location.id; + window.history.replaceState(window.history.state, '', url); + } + + function unlistLocation(loc){ + for (var owner of top_level){ + if (owner.locations && dropNestedLocation(owner.locations,loc)) break; + } + } + + + onMount(load);