ui: Working on works
This commit is contained in:
parent
b9acaa798b
commit
197c23736d
12 changed files with 475 additions and 10 deletions
39
ui/src/routes/works/[wid]/__layout.svelte
Normal file
39
ui/src/routes/works/[wid]/__layout.svelte
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<script context="module">
|
||||
import { getWork } from '../../../lib/works';
|
||||
|
||||
export async function load({ params, stuff }) {
|
||||
const work = getWork(params.wid);
|
||||
|
||||
return {
|
||||
props: {
|
||||
work,
|
||||
},
|
||||
stuff: {
|
||||
...stuff,
|
||||
work,
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
export let work;
|
||||
</script>
|
||||
|
||||
{#await work}
|
||||
<div class="text-center">
|
||||
<div class="spinner-border text-primary mx-3" role="status"></div>
|
||||
<span>Chargement du rendu …</span>
|
||||
</div>
|
||||
{:then}
|
||||
<slot></slot>
|
||||
{:catch error}
|
||||
<div class="text-center">
|
||||
<h2>
|
||||
<a href="works/" class="text-muted" style="text-decoration: none"><</a>
|
||||
Travail introuvable
|
||||
</h2>
|
||||
<span>{error}</span>
|
||||
</div>
|
||||
{/await}
|
||||
34
ui/src/routes/works/[wid]/index.svelte
Normal file
34
ui/src/routes/works/[wid]/index.svelte
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<script context="module">
|
||||
import { getWork } from '../../../lib/works';
|
||||
|
||||
export async function load({ params, stuff }) {
|
||||
return {
|
||||
props: {
|
||||
work: stuff.work,
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
import { user } from '../../../stores/user';
|
||||
import SurveyBadge from '../../../components/SurveyBadge.svelte';
|
||||
import WorkAdmin from '../../../components/WorkAdmin.svelte';
|
||||
|
||||
export let work = null;
|
||||
</script>
|
||||
|
||||
{#await work then w}
|
||||
<div class="d-flex align-items-center">
|
||||
<h2>
|
||||
<a href="works/" class="text-muted" style="text-decoration: none"><</a>
|
||||
{w.title}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
{#if $user && $user.is_admin}
|
||||
<WorkAdmin work={w} on:saved={() => edit = false} />
|
||||
{/if}
|
||||
{/await}
|
||||
Reference in a new issue