completed list of tag uses (for now)
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
import PositionList from './PositionList.svelte';
|
import PositionList from './PositionList.svelte';
|
||||||
import PositionSelector from './PositionSelector.svelte';
|
import PositionSelector from './PositionSelector.svelte';
|
||||||
import StateSelector from './StateSelector.svelte';
|
import StateSelector from './StateSelector.svelte';
|
||||||
|
import Tags from '../tags/TagList.svelte';
|
||||||
import TemplateSelector from './TemplateSelector.svelte';
|
import TemplateSelector from './TemplateSelector.svelte';
|
||||||
|
|
||||||
|
|
||||||
@@ -226,6 +227,10 @@
|
|||||||
<legend>{t('footer')}</legend>
|
<legend>{t('footer')}</legend>
|
||||||
<MarkdownEditor bind:value={doc.footer} editable={editable} onSet={(val) => update('footer',val)} />
|
<MarkdownEditor bind:value={doc.footer} editable={editable} onSet={(val) => update('footer',val)} />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>{t('tags')}</legend>
|
||||||
|
<Tags module="document" {id} user_list={[+user.id]} />
|
||||||
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{t('actions')}</legend>
|
<legend>{t('actions')}</legend>
|
||||||
<button onclick={render} disabled={pdfDisabled}>{t('create_pdf')}</button>
|
<button onclick={render} disabled={pdfDisabled}>{t('create_pdf')}</button>
|
||||||
|
|||||||
29
frontend/src/routes/tags/Reference.svelte
Normal file
29
frontend/src/routes/tags/Reference.svelte
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<script>
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
|
import { api } from '../../urls.svelte.js';
|
||||||
|
import { t } from '../../translations.svelte.js';
|
||||||
|
|
||||||
|
let { module, id } = $props();
|
||||||
|
|
||||||
|
let task = $state(null);
|
||||||
|
let caption = $state(`${t(module)} ${id}`);
|
||||||
|
|
||||||
|
async function loadDefault(){
|
||||||
|
const url = api(`${module}/${id}`);
|
||||||
|
const resp = await fetch(url,{credentials:'include'});
|
||||||
|
if (resp.ok){
|
||||||
|
var json = await resp.json();
|
||||||
|
if (json.name) caption = json.name;
|
||||||
|
if (json.type && json.number) caption = `${t(json.type)} ${json.number} (${json.customer.name.split('\n')[0]})`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function load(){
|
||||||
|
loadDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(load);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{caption}
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
import { api } from '../../urls.svelte.js';
|
import { api } from '../../urls.svelte.js';
|
||||||
import { t } from '../../translations.svelte.js';
|
import { t } from '../../translations.svelte.js';
|
||||||
|
|
||||||
|
import Reference from './Reference.svelte';
|
||||||
|
|
||||||
let { tag } = $props();
|
let { tag } = $props();
|
||||||
let error = $state(null);
|
let error = $state(null);
|
||||||
let router = useTinyRouter();
|
let router = useTinyRouter();
|
||||||
@@ -34,10 +36,12 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#if uses}
|
{#if uses}
|
||||||
{#each Object.entries(uses) as [module,ids]}
|
{#each Object.entries(uses) as [module,ids]}
|
||||||
<h2>{t(module)}</h2>
|
<h2>{t(module.endsWith('s') ? module : `${module}s`)}</h2>
|
||||||
{#each ids as id}
|
<ul>
|
||||||
<button onclick={() => go(module,id)}>{t(module)} {id}</button>
|
{#each ids as id}
|
||||||
{/each}
|
<li onclick={() => go(module,id)}><Reference {module} {id} /></li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -120,6 +120,13 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
|||||||
result.computeIfAbsent(module, k -> new ArrayList<>()).add(entityId);
|
result.computeIfAbsent(module, k -> new ArrayList<>()).add(entityId);
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
|
rs = select(ALL).from(TABLE_TAGS).where(TAG,equal(tag)).where(USER_ID,isNull()).exec(db);
|
||||||
|
while (rs.next()){
|
||||||
|
var module = rs.getString(MODULE);
|
||||||
|
var entityId = rs.getLong(ID);
|
||||||
|
result.computeIfAbsent(module, k -> new ArrayList<>()).add(entityId);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
return result;
|
return result;
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw new UmbrellaException("Failed to load uses of tag \"{0}\"!",tag);
|
throw new UmbrellaException("Failed to load uses of tag \"{0}\"!",tag);
|
||||||
|
|||||||
Reference in New Issue
Block a user