added display for stock items to TagUses
All checks were successful
Build Docker Image / Docker-Build (push) Successful in 2m18s
Build Docker Image / Clean-Registry (push) Successful in -8s

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-03-16 09:12:12 +01:00
parent b71fd4492c
commit 3e6ee91041
3 changed files with 49 additions and 2 deletions

View File

@@ -0,0 +1,37 @@
<script>
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api, get } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
let {module, id} = $props();
let item = $state(null);
let router = useTinyRouter();
function onclick(e){
e.preventDefault();
var target = e.target;
while (target && !target.href) target=target.parentNode;
let href = target.getAttribute('href');
if (href) router.navigate(href);
return false;
}
async function loadItem(){
let url = api(`stock/item/${id}`);
let res = await get(url);
if (res.ok) {
yikes();
item = await res.json();
} else error();
}
onMount(loadItem);
</script>
{#if item}
<a href="/stock/{id}/view" {onclick} >({item.code}) {item.name}</a>
{/if}

View File

@@ -6,6 +6,8 @@
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte.js';
import ItemDisplay from '../stock/display.svelte';
let { module, id } = $props();
let object = $state(null);
let router = useTinyRouter();
@@ -44,7 +46,9 @@
{:else if module=='wiki'}
<span onclick={go}>{object.title}</span>
{:else if module=='document'}
<span onclick={go}>{t(object.type)} ${object.number} (${object.customer.name.split('\n')[0]})</span>
<span onclick={go}>{t('type_'+object.type)} {object.number} ({object.customer.name.split('\n')[0]})</span>
{:else if module=='stock'}
<ItemDisplay {module} {id} />
{:else}
<span class="error">No display defined in Reference.svelte for entities of type {module}.</span>
{/if}

View File

@@ -12,6 +12,12 @@
let router = useTinyRouter();
let uses = $state(null);
function headline(module){
if (module == 'stock') return t(module);
if (module.endsWith('s')) return t(`${module}s`);
return t(module);
}
async function loadUses(){
const url = api(`tags/uses/${tag}`);
const resp = await fetch(url,{credentials:'include'});
@@ -36,7 +42,7 @@
</legend>
{#if uses}
{#each Object.entries(uses) as [module,ids]}
<h2>{t(module.endsWith('s') ? module : `${module}s`)}</h2>
<h2>{headline(module)}</h2>
<ul>
{#each ids as id}
<li><Reference {module} {id} /></li>