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

73 lines
1.6 KiB
Svelte
Raw Normal View History

2023-01-10 17:28:27 +01:00
<script>
2023-02-14 17:51:00 +01:00
import { input } from '../../../lib/actions';
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-20 13:54:57 +01:00
import Icon from '../../../components/icon.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 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="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>
2023-01-20 13:54:57 +01:00
<button type="submit" class="btn danger">
<Icon name="-" /> 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>