2023-01-10 17:28:27 +01:00
|
|
|
<script>
|
2023-01-17 15:56:55 +01:00
|
|
|
import { RemoveItems } from '../../../../wailsjs/go/app/App';
|
2023-01-16 20:03:56 +01:00
|
|
|
import CodeExample from '../../../components/code-example.svelte';
|
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}>
|
|
|
|
<div class="options">
|
|
|
|
<CodeExample {code} />
|
|
|
|
<label class="field">
|
|
|
|
<span class="label">Many</span>
|
|
|
|
<span class="checkbox">
|
|
|
|
<input type="checkbox" bind:checked={many} />
|
|
|
|
</span>
|
|
|
|
</label>
|
|
|
|
</div>
|
2023-01-10 17:28:27 +01:00
|
|
|
|
|
|
|
<label class="field">
|
2023-01-17 15:56:55 +01:00
|
|
|
<textarea cols="30" rows="10" bind:value={json} placeholder={'{}'} class="code"></textarea>
|
2023-01-10 17:28:27 +01:00
|
|
|
</label>
|
|
|
|
|
|
|
|
<div class="flex">
|
2023-01-17 15:56:55 +01:00
|
|
|
<div>
|
|
|
|
{#key result}
|
|
|
|
{#if typeof result === 'number'}
|
|
|
|
<span class="flash-green">Removed {result} item{result === 1 ? '' : 's'}</span>
|
|
|
|
{/if}
|
|
|
|
{/key}
|
|
|
|
</div>
|
|
|
|
<button type="submit" class="btn">Remove</button>
|
2023-01-10 17:28:27 +01:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<style>
|
2023-01-13 16:56:48 +01:00
|
|
|
form {
|
|
|
|
display: grid;
|
|
|
|
grid-template-rows: auto 1fr auto;
|
|
|
|
gap: 0.5rem;
|
|
|
|
}
|
|
|
|
|
2023-01-17 15:56:55 +01:00
|
|
|
.options {
|
|
|
|
display: grid;
|
|
|
|
gap: 0.5rem;
|
|
|
|
grid-template: 1fr / 1fr auto;
|
|
|
|
}
|
|
|
|
|
2023-01-10 17:28:27 +01:00
|
|
|
.flex {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
|
|
|
</style>
|