1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-04-19 08:51:03 +00:00

67 lines
1.4 KiB
Svelte
Raw Normal View History

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}>
<!-- <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>
<div class="actions">
2023-01-20 13:54:57 +01:00
<button type="submit" class="btn danger">
<Icon name="-" /> Remove
</button>
<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;
grid-template-rows: 1fr auto;
2023-01-13 16:56:48 +01:00
gap: 0.5rem;
}
.many {
display: inline-flex;
2023-01-17 15:56:55 +01:00
}
textarea {
resize: none;
2023-01-10 17:28:27 +01:00
}
</style>