|
|
|
|
@ -34,10 +34,14 @@
@@ -34,10 +34,14 @@
|
|
|
|
|
}); |
|
|
|
|
if (res.ok){ |
|
|
|
|
yikes(); |
|
|
|
|
unlistLocation(loc); |
|
|
|
|
} else error(res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function unlistLocation(loc){ |
|
|
|
|
for (var owner of top_level){ |
|
|
|
|
if (owner.locations && dropNestedLocation(owner.locations,loc)) break; |
|
|
|
|
} |
|
|
|
|
} else error(res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function drag_item(item){ |
|
|
|
|
@ -72,11 +76,7 @@
@@ -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 @@
@@ -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 @@
@@ -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)} /> |
|
|
|
|
|