implemented deletion of locations
This commit is contained in:
@@ -39,6 +39,10 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
function reset(){
|
||||
new_location_name = '';
|
||||
}
|
||||
|
||||
async function onSet(new_location_name){
|
||||
const data = {
|
||||
name: new_location_name,
|
||||
@@ -54,6 +58,8 @@
|
||||
yikes;
|
||||
const saved = await res.json();
|
||||
locations.push(saved);
|
||||
show_location_form = false;
|
||||
setTimeout(reset,500);
|
||||
return true;
|
||||
} else {
|
||||
error(res);
|
||||
@@ -86,18 +92,6 @@
|
||||
</style>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
{#if show_location_form}
|
||||
<form {onsubmit}>
|
||||
<LineEditor simple={true} bind:value={new_location_name} {onSet} />
|
||||
</form>
|
||||
{:else}
|
||||
<a onclick={show_loc_form}>
|
||||
<span class="symbol"></span> {t('add_object',{object:t('location')})}
|
||||
</a>
|
||||
{/if}
|
||||
|
||||
</li>
|
||||
{#each locations as location}
|
||||
<li onclick={e => toggleChildren(e, location)}
|
||||
class="{location.locations?'expanded':'collapsed'} {location.highlight?'highlight':null}"
|
||||
@@ -110,5 +104,17 @@
|
||||
{/if}
|
||||
</li>
|
||||
{/each}
|
||||
<li>
|
||||
{#if show_location_form}
|
||||
<form {onsubmit}>
|
||||
<LineEditor simple={true} bind:value={new_location_name} {onSet} />
|
||||
</form>
|
||||
{:else}
|
||||
<a onclick={show_loc_form}>
|
||||
<span class="symbol"></span> {t('add_object',{object:t('location')})}
|
||||
</a>
|
||||
{/if}
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
<!-- <pre>{JSON.stringify(parent,null,2)}</pre> -->
|
||||
<!-- <pre>{JSON.stringify(parent,null,2)}</pre> -->
|
||||
|
||||
Reference in New Issue
Block a user