Browse Source

completed list of tag uses (for now)

feature/entityId
Stephan Richter 3 months ago
parent
commit
c5f7fd8ec0
  1. 5
      frontend/src/routes/document/View.svelte
  2. 29
      frontend/src/routes/tags/Reference.svelte
  3. 12
      frontend/src/routes/tags/TagUses.svelte
  4. 7
      tags/src/main/java/de/srsoftware/umbrella/tags/SqliteDb.java

5
frontend/src/routes/document/View.svelte

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
import PositionList from './PositionList.svelte';
import PositionSelector from './PositionSelector.svelte';
import StateSelector from './StateSelector.svelte';
import Tags from '../tags/TagList.svelte';
import TemplateSelector from './TemplateSelector.svelte';
@ -226,6 +227,10 @@ @@ -226,6 +227,10 @@
<legend>{t('footer')}</legend>
<MarkdownEditor bind:value={doc.footer} editable={editable} onSet={(val) => update('footer',val)} />
</fieldset>
<fieldset>
<legend>{t('tags')}</legend>
<Tags module="document" {id} user_list={[+user.id]} />
</fieldset>
<fieldset>
<legend>{t('actions')}</legend>
<button onclick={render} disabled={pdfDisabled}>{t('create_pdf')}</button>

29
frontend/src/routes/tags/Reference.svelte

@ -0,0 +1,29 @@ @@ -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}

12
frontend/src/routes/tags/TagUses.svelte

@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
import { api } from '../../urls.svelte.js';
import { t } from '../../translations.svelte.js';
import Reference from './Reference.svelte';
let { tag } = $props();
let error = $state(null);
let router = useTinyRouter();
@ -34,10 +36,12 @@ @@ -34,10 +36,12 @@
{/if}
{#if uses}
{#each Object.entries(uses) as [module,ids]}
<h2>{t(module)}</h2>
{#each ids as id}
<button onclick={() => go(module,id)}>{t(module)} {id}</button>
{/each}
<h2>{t(module.endsWith('s') ? module : `${module}s`)}</h2>
<ul>
{#each ids as id}
<li onclick={() => go(module,id)}><Reference {module} {id} /></li>
{/each}
</ul>
{/each}
{/if}
</fieldset>

7
tags/src/main/java/de/srsoftware/umbrella/tags/SqliteDb.java

@ -120,6 +120,13 @@ CREATE TABLE IF NOT EXISTS "{0}" ( @@ -120,6 +120,13 @@ CREATE TABLE IF NOT EXISTS "{0}" (
result.computeIfAbsent(module, k -> new ArrayList<>()).add(entityId);
}
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;
} catch (SQLException e){
throw new UmbrellaException("Failed to load uses of tag \"{0}\"!",tag);

Loading…
Cancel
Save