|
4 | 4 | import IconButton, { Icon } from '@smui/icon-button';
|
5 | 5 | import { getContext } from 'svelte';
|
6 | 6 | import type { Token } from '$lib/models/keycloak';
|
7 |
| - import RoleTag from '../RoleTag.svelte'; |
8 | 7 | import type { MetadataCollection } from '$lib/models/metadata';
|
9 | 8 | import { popconfirm } from '$lib/context/PopConfirmContex.svelte';
|
10 | 9 | import { Set } from '@smui/chips';
|
|
19 | 18 |
|
20 | 19 | const { sub: userId } = getContext<Token>('user_token');
|
21 | 20 | const assignedToMe = $derived(metadata.assignedUserId === userId);
|
| 21 | + const assignedToSomeoneElse = $derived((metadata.assignedUserId && metadata.assignedUserId !== userId) || false); |
22 | 22 | const isTeamMember = $derived(metadata.teamMemberIds?.includes(userId));
|
23 | 23 | let previewNotAvailable = $state(!metadata.isoMetadata?.preview);
|
24 | 24 |
|
|
129 | 129 | >
|
130 | 130 | <Icon class="material-icons">preview</Icon>
|
131 | 131 | </IconButton>
|
132 |
| - <IconButton |
133 |
| - toggle |
134 |
| - class="assign-button" |
135 |
| - aria-label={assignedToMe |
136 |
| - ? 'Mir zugewiesen.\nKlicken um Zuordnung zu entfernen.' |
137 |
| - : 'Mir zuweisen'} |
138 |
| - title={assignedToMe ? 'Mir zugeordnet.\nKlicken um Zuordnung zu entfernen.' : 'Mir zuordnen'} |
139 |
| - onclick={assignedToMe ? removeAssignment : assignToMe} |
140 |
| - pressed={assignedToMe} |
141 |
| - > |
142 |
| - <Icon class="material-icons-filled assigned-to-me" on>person_remove</Icon> |
143 |
| - <Icon class="material-icons-filled">person_check</Icon> |
144 |
| - </IconButton> |
| 132 | + {#if !assignedToSomeoneElse} |
| 133 | + <IconButton |
| 134 | + toggle |
| 135 | + class="assign-button" |
| 136 | + disabled={assignedToSomeoneElse} |
| 137 | + aria-label={assignedToMe |
| 138 | + ? 'Mir zugewiesen.\nKlicken um Zuordnung zu entfernen.' |
| 139 | + : 'Mir zuweisen'} |
| 140 | + title={assignedToMe ? 'Mir zugeordnet.\nKlicken um Zuordnung zu entfernen.' : 'Mir zuordnen'} |
| 141 | + onclick={assignedToMe ? removeAssignment : assignToMe} |
| 142 | + pressed={assignedToMe} |
| 143 | + > |
| 144 | + <Icon class="material-icons-filled assigned-to-me" on>person_remove</Icon> |
| 145 | + <Icon class="material-icons-filled">person_check</Icon> |
| 146 | + </IconButton> |
| 147 | + {/if} |
145 | 148 | </ActionIcons>
|
146 | 149 | </Card>
|
147 | 150 |
|
|
0 commit comments