2023-01-10 17:28:27 +01:00
|
|
|
<script>
|
2023-02-15 19:27:51 +01:00
|
|
|
import Icon from '$components/icon.svelte';
|
|
|
|
import input from '$lib/actions/input';
|
|
|
|
import { RemoveItems } from '$wails/go/app/App';
|
2023-01-10 17:28:27 +01:00
|
|
|
|
|
|
|
export let collection;
|
|
|
|
|
2023-01-17 15:56:55 +01:00
|
|
|
let json = '';
|
|
|
|
let many = true;
|
|
|
|
let result = undefined;
|
|
|
|
$: code = `db.${collection.key}.remove(${json});`;
|
2023-01-10 17:28:27 +01:00
|
|
|
|
2023-01-17 15:56:55 +01:00
|
|
|
async function removeItems() {
|
|
|
|
result = await RemoveItems(collection.hostKey, collection.dbKey, collection.key, json, many);
|
|
|
|
}
|
2023-01-10 17:28:27 +01:00
|
|
|
</script>
|
|
|
|
|
2023-01-17 15:56:55 +01:00
|
|
|
<form on:submit|preventDefault={removeItems}>
|
2023-02-19 17:26:32 +01:00
|
|
|
<!-- <CodeExample {code} /> -->
|
2023-01-10 17:28:27 +01:00
|
|
|
|
|
|
|
<label class="field">
|
2023-01-17 17:03:11 +01:00
|
|
|
<textarea
|
|
|
|
cols="30"
|
|
|
|
rows="10"
|
|
|
|
placeholder={'{}'}
|
|
|
|
class="code"
|
|
|
|
bind:value={json}
|
2023-01-29 20:00:15 +01:00
|
|
|
use:input={{ type: 'json', autofocus: true }}
|
2023-01-17 17:03:11 +01:00
|
|
|
></textarea>
|
2023-01-10 17:28:27 +01:00
|
|
|
</label>
|
|
|
|
|
2023-02-19 17:26:32 +01:00
|
|
|
<div class="actions">
|
2023-01-20 13:54:57 +01:00
|
|
|
<button type="submit" class="btn danger">
|
|
|
|
<Icon name="-" /> Remove
|
|
|
|
</button>
|
2023-02-19 17:26:32 +01:00
|
|
|
|
|
|
|
<label class="field many">
|
|
|
|
<span class="label">Many</span>
|
|
|
|
<span class="checkbox">
|
|
|
|
<input type="checkbox" bind:checked={many} />
|
|
|
|
</span>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
{#key result}
|
|
|
|
{#if typeof result === 'number'}
|
|
|
|
<span class="flash-green">Removed {result} item{result === 1 ? '' : 's'}</span>
|
|
|
|
{/if}
|
|
|
|
{/key}
|
2023-01-10 17:28:27 +01:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<style>
|
2023-01-13 16:56:48 +01:00
|
|
|
form {
|
|
|
|
display: grid;
|
2023-02-19 17:26:32 +01:00
|
|
|
grid-template-rows: 1fr auto;
|
2023-01-13 16:56:48 +01:00
|
|
|
gap: 0.5rem;
|
|
|
|
}
|
|
|
|
|
2023-02-19 17:26:32 +01:00
|
|
|
.many {
|
|
|
|
display: inline-flex;
|
2023-01-17 15:56:55 +01:00
|
|
|
}
|
|
|
|
|
2023-02-19 17:26:32 +01:00
|
|
|
textarea {
|
|
|
|
resize: none;
|
2023-01-10 17:28:27 +01:00
|
|
|
}
|
|
|
|
</style>
|