Skip to content

Commit

Permalink
Filter processes on profile page.
Browse files Browse the repository at this point in the history
  • Loading branch information
amyjko committed Oct 12, 2024
1 parent 0a71c2d commit 1613703
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/lib/ProfileView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@

<Header>Roles</Header>

<Paragraph>Roles and duties this person has.</Paragraph>
<Paragraph>Roles and recurring processes this person is accountable or responsible for.</Paragraph>
{#if roles.length > 0}
{#each roles as role}
<RoleLink roleID={role.id} />
<RoleProcesses {role} processes={$org.getRoleProcesses(role.id)} />
<RoleProcesses {role} processes={$org.getRoleProcesses(role.id)} onlyPeriodic />
{/each}
{:else}
<Notice>This person has no roles in this organization.</Notice>
Expand Down
58 changes: 29 additions & 29 deletions src/lib/RoleProcesses.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,26 @@
import ProcessLink from './ProcessLink.svelte';
import type { HowRow, ProcessRow, RoleRow } from '$database/OrganizationsDB';
import { getOrg } from './contexts';
import {
formatNextDate,
getNextPeriodDate,
getNextProcessDate,
sortProcessesByNextDate
} from '$database/Period';
import Note from './Note.svelte';
import { sortProcessesByNextDate } from '$database/Period';
import ProcessDate from './ProcessDate.svelte';
export let role: RoleRow;
export let processes: ProcessRow[];
export let onlyPeriodic = false;
$: sorted = sortProcessesByNextDate(processes);
const org = getOrg();
$: hows = sorted
.map((process) => $org.getHow(process.id))
.filter((how): how is HowRow => how !== undefined);
$: accountable = sorted.filter((process) => role.id === process.accountable);
$: accountable = sorted.filter(
(process) => role.id === process.accountable && (!onlyPeriodic || process.repeat.length > 0)
);
$: responsible = sorted.filter((process) =>
$org.getProcessHows(process.id).some((how) => how.responsible.includes(role.id))
$org
.getProcessHows(process.id)
.some(
(how) => how.responsible.includes(role.id) && (!onlyPeriodic || process.repeat.length > 0)
)
);
$: consulted = sorted.filter((process) =>
$org.getProcessHows(process.id).some((how) => how.consulted.includes(role.id))
Expand Down Expand Up @@ -53,21 +51,23 @@
</Flow>
{/each}
{/if}
{#if consulted.length > 0}
<Subheader>Consulted</Subheader>
{#each consulted as process}
<Flow>
<ProcessLink processID={process.id} />
<ProcessDate {process} />
</Flow>
{/each}
{/if}
{#if informed.length > 0}
<Subheader>Informed</Subheader>
{#each informed as process}
<Flow>
<ProcessLink processID={process.id} />
<ProcessDate {process} />
</Flow>
{/each}
{#if !onlyPeriodic}
{#if consulted.length > 0}
<Subheader>Consulted</Subheader>
{#each consulted as process}
<Flow>
<ProcessLink processID={process.id} />
<ProcessDate {process} />
</Flow>
{/each}
{/if}
{#if informed.length > 0}
<Subheader>Informed</Subheader>
{#each informed as process}
<Flow>
<ProcessLink processID={process.id} />
<ProcessDate {process} />
</Flow>
{/each}
{/if}
{/if}

0 comments on commit 1613703

Please sign in to comment.