parent
bdf179175a
commit
d55c758ad3
2 changed files with 47 additions and 20 deletions
|
@ -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}
|
||||
|
|
|
@ -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,9 +203,10 @@
|
|||
{#if address}
|
||||
<div class="add">
|
||||
{#if adding}
|
||||
<div class="main">
|
||||
<Selector
|
||||
bind:this={addSelector}
|
||||
placeholder={$i18n.t('Search database or paste an URL') || ''}
|
||||
placeholder={$i18n.t('Add or create an entry') || ''}
|
||||
types={['Address', 'NewAddress']}
|
||||
on:input={addEntity}
|
||||
on:focus={(ev) => {
|
||||
|
@ -213,7 +215,9 @@
|
|||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="main">
|
||||
<IconButton
|
||||
name="plus-circle"
|
||||
outline
|
||||
|
@ -222,6 +226,16 @@
|
|||
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}
|
||||
|
@ -317,8 +331,14 @@
|
|||
}
|
||||
|
||||
.add {
|
||||
display: flex;
|
||||
gap: 0.5em;
|
||||
|
||||
& .main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.entitylist.style-grid .add {
|
||||
|
|
Loading…
Reference in a new issue