Browse Source

preparing to make items/locations referencable

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
module/stock
Stephan Richter 2 days ago
parent
commit
8e10909c81
  1. 2
      frontend/src/App.svelte
  2. 2
      frontend/src/routes/project/Kanban.svelte
  3. 35
      frontend/src/routes/stock/Index.svelte

2
frontend/src/App.svelte

@ -99,6 +99,8 @@
<Route path="/project/:id/view" component={ViewPrj} /> <Route path="/project/:id/view" component={ViewPrj} />
<Route path="/search" component={Search} /> <Route path="/search" component={Search} />
<Route path="/stock" component={Stock} /> <Route path="/stock" component={Stock} />
<Route path="/stock/location/:location_id" component={Stock} />
<Route path="/stock/:owner/:owner_id/item/:item_id" component={Stock} />
<Route path="/tags" component={TagList} /> <Route path="/tags" component={TagList} />
<Route path="/tags/use/:tag" component={TagUses} /> <Route path="/tags/use/:tag" component={TagUses} />
<Route path="/task" component={TaskList} /> <Route path="/task" component={TaskList} />

2
frontend/src/routes/project/Kanban.svelte

@ -47,7 +47,7 @@
function updateUrl(){ function updateUrl(){
let url = window.location.origin + window.location.pathname; let url = window.location.origin + window.location.pathname;
if (filter_input) url += '?filter=' + encodeURI(filter_input); 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){ async function create(name,user_id,state){

35
frontend/src/routes/stock/Index.svelte

@ -20,7 +20,14 @@
$effect(() => { $effect(() => {
// This effect runs whenever `location` changes // 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 properties = $state(null);
let top_level = $state(null); let top_level = $state(null);
@ -38,12 +45,6 @@
} else error(res); } else error(res);
} }
function unlistLocation(loc){
for (var owner of top_level){
if (owner.locations && dropNestedLocation(owner.locations,loc)) break;
}
}
function drag_item(item){ function drag_item(item){
draggedLocation = null; draggedLocation = null;
draggedItem = item; 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); onMount(load);
</script> </script>

Loading…
Cancel
Save