improving moving around locations
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -34,12 +34,16 @@
|
||||
});
|
||||
if (res.ok){
|
||||
yikes();
|
||||
for (var owner of top_level){
|
||||
if (owner.locations && dropNestedLocation(owner.locations,loc)) break;
|
||||
}
|
||||
unlistLocation(loc);
|
||||
} 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;
|
||||
@@ -72,11 +76,7 @@
|
||||
if (res.ok){
|
||||
yikes();
|
||||
location = new_loc;
|
||||
if (!draggedItem){
|
||||
for (var owner of top_level){
|
||||
if (owner.locations && dropNestedLocation(owner.locations,draggedLocation)) break;
|
||||
}
|
||||
}
|
||||
if (!draggedItem) unlistLocation(draggedLocation);
|
||||
draggedItem = null;
|
||||
draggedLocation = null;
|
||||
} else {
|
||||
@@ -124,6 +124,18 @@
|
||||
loadProperties();
|
||||
}
|
||||
|
||||
function moveToTop(loc){
|
||||
if (patchLocation(location,'parent_location_id',0)){
|
||||
loc.parent_location_id = 0;
|
||||
for (var owner of top_level){
|
||||
if (owner.locations && dropNestedLocation(owner.locations,loc)) {
|
||||
owner.locations.push(loc);
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function patchLocation(location,field,newValue){
|
||||
const data = {};
|
||||
data[field] = newValue;
|
||||
@@ -172,7 +184,7 @@
|
||||
<LineEditor editable={true} bind:value={location.name} type="span" onSet={newName => patchLocation(location,'name',newName)} />
|
||||
<button class="symbol" title={t('delete_object',{object:t('location')})} onclick={e => deleteLocation(location)}></button>
|
||||
{#if location.parent_location_id}
|
||||
<button class="symbol" title={t('move_to_top')} onclick={e => patchLocation(location,'parent_location_id',0)}></button>
|
||||
<button class="symbol" title={t('move_to_top')} onclick={e => moveToTop(location)}></button>
|
||||
{/if}
|
||||
</h3>
|
||||
<MarkdownEditor editable={true} value={location.description} type="div" onSet={newDesc => patchLocation(location,'description',newDesc)} />
|
||||
|
||||
Reference in New Issue
Block a user