mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-02-01 10:39:28 +00:00
40 lines
861 B
Svelte
40 lines
861 B
Svelte
|
<script>
|
||
|
import { PerformInsert } from '../../../wailsjs/go/main/App';
|
||
|
|
||
|
export let collection;
|
||
|
|
||
|
let input = '';
|
||
|
let insertedIds;
|
||
|
|
||
|
$: if (collection) {
|
||
|
insertedIds = undefined;
|
||
|
}
|
||
|
|
||
|
async function insert() {
|
||
|
insertedIds = await PerformInsert(collection.hostKey, collection.dbKey, collection.key, input);
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<form on:submit|preventDefault={insert}>
|
||
|
<label class="field">
|
||
|
<textarea cols="30" rows="10" bind:value={input} placeholder="[]" class="code"></textarea>
|
||
|
</label>
|
||
|
|
||
|
<div class="flex">
|
||
|
<div>
|
||
|
{#if insertedIds}
|
||
|
Success! {insertedIds.length} document{insertedIds.length > 1 ? 's' : ''} inserted
|
||
|
{/if}
|
||
|
</div>
|
||
|
<button type="submit" class="btn">Insert</button>
|
||
|
</div>
|
||
|
</form>
|
||
|
|
||
|
<style>
|
||
|
.flex {
|
||
|
display: flex;
|
||
|
justify-content: space-between;
|
||
|
margin-top: 0.5rem;
|
||
|
}
|
||
|
</style>
|