Skip to content

Commit

Permalink
Merge pull request #184 from pyoner/issue-182
Browse files Browse the repository at this point in the history
feat: add a Nodes.filter property for items
  • Loading branch information
blokhin authored Jan 11, 2024
2 parents 7430d5b + 4341158 commit 5aca4a3
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 53 deletions.
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

0 comments on commit 5aca4a3

Please sign in to comment.