preparing to make items/locations referencable
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -99,6 +99,8 @@
|
||||
<Route path="/project/:id/view" component={ViewPrj} />
|
||||
<Route path="/search" component={Search} />
|
||||
<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/use/:tag" component={TagUses} />
|
||||
<Route path="/task" component={TaskList} />
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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);
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user