Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a Nodes.filter property for items #184

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/layouts/Nodes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@
/>
</Col>
{/if}
{#each data as item (item.id)}
{#each data.filter(filter) as item (item.id)}
<slot {item} />
{:else}
<div class="text-center distant_msg">Nothing found &mdash; maybe <span class="link" on:click={() => goto('/import')}>add data</span>?</div>
<div class="text-center distant_msg">
Nothing found &mdash; maybe <span class="link" on:click={() => goto('/import')}
>add data</span
>?
</div>
{/each}
{:catch _error}
<Col>
Expand All @@ -53,6 +57,7 @@
</script>

<script lang="ts">
export let filter = (item) => item != null;
export let add: boolean;
export let addTooltip: string;
export let addAction = () => (add = !add);
Expand Down
61 changes: 35 additions & 26 deletions src/pages/Materials.svelte
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
<Main>
<Nodes asyncData={$collectionsAsync} paginate={false}>
<Nodes
asyncData={$collectionsAsync}
paginate={false}
filter={(item) => item.typeSlug === 'phases'}
>
<div slot="filter">
<!-- no filter panel -->
</div>
<svelte:fragment let:item>
{#if item.typeSlug === 'phases'}
<Col col="12">
<Collection
id={item.id}
title={item.title}
description={item.description}
visibility={item.visibility}
userId={item.userId}
userFirstName={item.userFirstName}
userLastName={item.userLastName}
typeSlug={item.typeSlug}
typeLabel={item.typeLabel}
typeFlavor={item.typeFlavor}
>
<IconButton
slot="action"
icon="forward"
variant="link"
size="xxl"
tooltip="Show all matching data"
on:click={() => goto('/?collectionIds=' + item.id + '&limit=' + PAGE_LIMIT + '&visibility=&type=')}
/>
</Collection>
</Col>
{/if}
<Col col="12">
<Collection
id={item.id}
title={item.title}
description={item.description}
visibility={item.visibility}
userId={item.userId}
userFirstName={item.userFirstName}
userLastName={item.userLastName}
typeSlug={item.typeSlug}
typeLabel={item.typeLabel}
typeFlavor={item.typeFlavor}
>
<IconButton
slot="action"
icon="forward"
variant="link"
size="xxl"
tooltip="Show all matching data"
on:click={() =>
goto(
'/?collectionIds=' +
item.id +
'&limit=' +
PAGE_LIMIT +
'&visibility=&type='
)}
/>
</Collection>
</Col>
</svelte:fragment>
</Nodes>
</Main>
Expand Down
52 changes: 27 additions & 25 deletions src/pages/Tasks.svelte
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
<Main>
<Nodes asyncData={$collectionsAsync} paginate={false}>
<Nodes
asyncData={$collectionsAsync}
paginate={false}
filter={(item) => item.typeSlug === 'requests' && item.userId === SERVICE_UID}
>
<div slot="filter">
<!-- no filter panel -->
</div>
<svelte:fragment let:item>
{#if item.typeSlug === 'requests' && item.userId === SERVICE_UID}
<Col col="12">
<Collection
id={item.id}
title={item.title}
description={item.description}
visibility={item.visibility}
userId={item.userId}
userFirstName={item.userFirstName}
userLastName={item.userLastName}
typeLabel={item.typeLabel}
typeFlavor={item.typeFlavor}
>
<IconButton
slot="action"
icon="download"
variant="link"
size="xxl"
tooltip="Take on this request"
on:click={() => processCollection(item.id)}
/>
</Collection>
</Col>
{/if}
<Col col="12">
<Collection
id={item.id}
title={item.title}
description={item.description}
visibility={item.visibility}
userId={item.userId}
userFirstName={item.userFirstName}
userLastName={item.userLastName}
typeLabel={item.typeLabel}
typeFlavor={item.typeFlavor}
>
<IconButton
slot="action"
icon="download"
variant="link"
size="xxl"
tooltip="Take on this request"
on:click={() => processCollection(item.id)}
/>
</Collection>
</Col>
</svelte:fragment>
</Nodes>
</Main>
Expand Down