aboutsummaryrefslogtreecommitdiffstats
path: root/old-apps/projects/src/app/pages/views/settings-labels-tile.svelte
diff options
context:
space:
mode:
Diffstat (limited to 'old-apps/projects/src/app/pages/views/settings-labels-tile.svelte')
-rw-r--r--old-apps/projects/src/app/pages/views/settings-labels-tile.svelte111
1 files changed, 111 insertions, 0 deletions
diff --git a/old-apps/projects/src/app/pages/views/settings-labels-tile.svelte b/old-apps/projects/src/app/pages/views/settings-labels-tile.svelte
new file mode 100644
index 0000000..3d5a567
--- /dev/null
+++ b/old-apps/projects/src/app/pages/views/settings-labels-tile.svelte
@@ -0,0 +1,111 @@
+<script>
+ import {IconNames} from "$shared/lib/configuration";
+ import {onMount} from "svelte";
+ import labels, {reload_labels, delete_label_async} from "$app/lib/stores/labels";
+ import Button from "$shared/components/button.svelte";
+ import Tile from "$shared/components/tile.svelte";
+ import {Table, THead, TBody, TCell, TRow} from "$shared/components/table";
+ import LL from "$app/lib/i18n/i18n-svelte";
+
+ let isLoadingLabels = true;
+
+ $: active_labels = $labels.filter(c => !c.archived);
+ $: archived_labels = $labels.filter(c => c.archived);
+
+ async function load_labels() {
+ isLoadingLabels = true;
+ await reload_labels();
+ isLoadingLabels = false;
+ }
+
+ async function handle_edit_label_click(event) {
+ }
+
+ async function handle_delete_label_click(event) {
+ const row = event.target.closest("tr");
+ if (
+ row &&
+ row.dataset.id &&
+ confirm($LL.views.settingsLabelsTile.deleteAllConfirm())
+ ) {
+ await delete_label_async({id: row.dataset.id});
+ row.classList.add("d-none");
+ }
+ }
+
+ onMount(() => {
+ load_labels();
+ });
+</script>
+
+<Tile class="col-6@md col-12 {isLoadingLabels ? 'c-disabled loading' : ''}">
+ <h2 class="margin-bottom-xxs">{$LL.views.settingsLabelsTile.labels()}</h2>
+ {#if active_labels.length > 0 && archived_labels.length > 0}
+ <nav class="s-tabs text-sm">
+ <ul class="s-tabs__list">
+ <li><a class="s-tabs__link s-tabs__link--current"
+ href="#0">{$LL.views.settingsLabelsTile.active()} ({active_labels.length})</a></li>
+ <li><a class="s-tabs__link"
+ href="#0">{$LL.views.settingsLabelsTile.archived()} ({archived_labels.length})</a></li>
+ </ul>
+ </nav>
+ {/if}
+ <div class="max-width-100% overflow-auto">
+ <Table class="text-sm width-100%">
+ <THead class="text-left">
+ <TCell type="th"
+ thScope="row">
+ {$LL.views.settingsLabelsTile.name()}
+ </TCell>
+ <TCell type="th"
+ thScope="row">
+ {$LL.views.settingsLabelsTile.color()}
+ </TCell>
+ <TCell type="th"
+ thScope="row"
+ style="width: 50px;">
+ </TCell>
+ </THead>
+ <TBody class="text-left">
+ {#if $labels.length > 0}
+ {#each $labels as label}
+ <TRow class="text-nowrap"
+ dataId={label.id}>
+ <TCell>
+ {label.name}
+ </TCell>
+ <TCell>
+ <span style="border-left: 3px solid {label.color}; background-color:{label.color}25;">
+ {label.color}
+ </span>
+ </TCell>
+ <TCell>
+ <Button icon="{IconNames.pencilSquare}"
+ variant="reset"
+ icon_width="1.2rem"
+ class="hide"
+ icon_height="1.2rem"
+ on:click={handle_edit_label_click}
+ title="{$LL.views.settingsLabelsTile.editEntry()}"/>
+ <Button icon="{IconNames.trash}"
+ variant="reset"
+ icon_width="1.2rem"
+ icon_height="1.2rem"
+ on:click={handle_delete_label_click}
+ title="{$LL.views.settingsLabelsTile.deleteEntry()}"/>
+ </TCell>
+ </TRow>
+ {/each}
+ {:else}
+ <TRow>
+ <TCell type="th"
+ thScope="row"
+ colspan="3">
+ {$LL.views.settingsLabelsTile.noLabels()}
+ </TCell>
+ </TRow>
+ {/if}
+ </TBody>
+ </Table>
+ </div>
+</Tile>