feat(webui): upload to groups via EntityList
ci/woodpecker/push/woodpecker Pipeline was successful Details

(finishes #21)
main
Tomáš Mládek 2024-04-21 22:02:24 +02:00
parent 426c584215
commit 7e9d4349af
2 changed files with 47 additions and 20 deletions

View File

@ -1,10 +1,12 @@
<script context="module" lang="ts">
import mitt from 'mitt';
import type { Address } from '@upnd/upend/types';
export type AddEvents = {
choose: void;
files: File[];
urls: string[];
destination: Address;
};
export const addEmitter = mitt<AddEvents>();
</script>
@ -44,6 +46,10 @@
});
});
addEmitter.on('destination', (ev) => {
destination = ev;
});
function onDestinationSelected(ev: CustomEvent<SelectorValue | undefined>) {
if (ev.detail?.t === 'Address') {
destination = ev.detail.c;
@ -180,6 +186,7 @@
<div class="controls-destination">
<div class="label"><Icon plain name="download" /> {$i18n.t('Destination')}</div>
<Selector
initial={destination ? { t: 'Address', c: destination } : undefined}
types={['Address', 'NewAddress']}
placeholder={$i18n.t('Choose automatically') || ''}
on:input={onDestinationSelected}

View File

@ -11,6 +11,7 @@
import Selector, { type SelectorValue } from '../utils/Selector.svelte';
import { createEventDispatcher } from 'svelte';
import type { WidgetChange } from '$lib/types/base';
import { addEmitter } from '$lib/components/AddModal.svelte';
import debug from 'debug';
const dispatch = createEventDispatcher();
const dbg = debug(`kestrel:EntityList`);
@ -202,26 +203,39 @@
{#if address}
<div class="add">
{#if adding}
<Selector
bind:this={addSelector}
placeholder={$i18n.t('Search database or paste an URL') || ''}
types={['Address', 'NewAddress']}
on:input={addEntity}
on:focus={(ev) => {
if (!ev.detail) {
adding = false;
}
}}
/>
<div class="main">
<Selector
bind:this={addSelector}
placeholder={$i18n.t('Add or create an entry') || ''}
types={['Address', 'NewAddress']}
on:input={addEntity}
on:focus={(ev) => {
if (!ev.detail) {
adding = false;
}
}}
/>
</div>
{:else}
<IconButton
name="plus-circle"
outline
subdued
on:click={() => {
adding = true;
}}
/>
<div class="main">
<IconButton
name="plus-circle"
outline
subdued
on:click={() => {
adding = true;
}}
/>
</div>
{#if address}
<IconButton
outline
subdued
name="upload"
title={$i18n.t('Upload a file') || ''}
on:click={() => addEmitter.emit('destination', address || '')}
/>
{/if}
{/if}
</div>
{/if}
@ -318,7 +332,13 @@
.add {
display: flex;
flex-direction: column;
gap: 0.5em;
& .main {
display: flex;
flex-direction: column;
flex-grow: 1;
}
}
.entitylist.style-grid .add {