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

Signee List Component #2807

Open
wants to merge 23 commits into
base: feature/signing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
30e28eb
WIP
cammiida Dec 5, 2024
e808612
adds zod
cammiida Dec 9, 2024
91a81a1
returns null instead of throwing in old rendersummary functions for o…
cammiida Dec 9, 2024
353b0cb
adds start of signee list component
cammiida Dec 9, 2024
674fd97
makes app table type generic
cammiida Dec 9, 2024
a8f2abc
renders tag in table for signee status
cammiida Dec 9, 2024
c20aff0
adds header styling to signee list table
cammiida Dec 9, 2024
e295e4f
adds todos and some error handling
cammiida Dec 9, 2024
9799c14
removes fake prop in schema to trigger parsing error
cammiida Dec 10, 2024
63421ec
moves signee state tag component to its own file
cammiida Dec 10, 2024
38ee950
adds language and error message when process task is not a signing task
cammiida Dec 10, 2024
e2cd8dd
fixes caption helptext display
cammiida Dec 10, 2024
77f94e0
added support for caption, description and helptext and sized table t…
cammiida Dec 10, 2024
6816d6b
adds support for organisation signature
cammiida Dec 10, 2024
0c83e81
adds lang texts for table header
cammiida Dec 10, 2024
136c3e2
adds sorting on name column
cammiida Dec 10, 2024
3b276ab
updates todos and removes unnecessary accessors
cammiida Dec 10, 2024
aec5055
right aligns the last column
cammiida Dec 11, 2024
d315c95
updates TODOs
cammiida Dec 11, 2024
808a6df
removes not found and unnecessary caption font-size
cammiida Dec 11, 2024
cfe07cc
smaller improvement to error handling
cammiida Dec 11, 2024
ac9919d
adds custom error message to refine
cammiida Dec 12, 2024
3eef8f7
simplifies error handling
cammiida Dec 16, 2024
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"typescript": "5.7.2",
"typescript-eslint": "8.18.0",
"uuid": "11.0.3",
"zod": "^3.23.8",
"zustand": "5.0.2"
},
"packageManager": "[email protected]",
Expand Down
31 changes: 18 additions & 13 deletions src/app-components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,36 @@ import { pick } from 'dot-object';
import type { JSONSchema7 } from 'json-schema';

import classes from 'src/app-components/Table/Table.module.css';
import type { FormDataObject, FormDataValue } from 'src/app-components/DynamicForm/DynamicForm';
import type { FormDataValue } from 'src/app-components/DynamicForm/DynamicForm';

interface Column {
interface Column<T> {
header: React.ReactNode;
accessors: string[];
renderCell?: (values: FormDataValue[], rowData: FormDataObject, rowIndex: number) => React.ReactNode;
renderCell?: (values: FormDataValue[], rowData: T, rowIndex: number) => React.ReactNode;
enableInlineEditing?: boolean;
}

export interface TableActionButton {
onClick: (rowIdx: number, rowData: FormDataObject) => void;
export interface TableActionButton<T = unknown> {
onClick: (rowIdx: number, rowData: T) => void;
buttonText: React.ReactNode;
icon: React.ReactNode;
color?: 'first' | 'second' | 'success' | 'danger';
variant?: 'tertiary' | 'primary' | 'secondary';
}

interface DataTableProps {
data: FormDataObject[];
schema: JSONSchema7;
columns: Column[];
interface DataTableProps<T> {
data: T[];
schema?: JSONSchema7;
columns: Column<T>[];
caption?: React.ReactNode;
actionButtons?: TableActionButton[];
actionButtons?: TableActionButton<T>[];
actionButtonHeader?: React.ReactNode;
mobile?: boolean;
size?: 'sm' | 'md' | 'lg';
zebra?: boolean;
stickyHeader?: boolean;
tableClassName?: string;
headerClassName?: string;
}

function formatValue(value: FormDataValue): string {
Expand Down Expand Up @@ -63,7 +65,7 @@ function formatValue(value: FormDataValue): string {
return String(value);
}

export function AppTable({
export function AppTable<T>({
caption,
data,
columns,
Expand All @@ -73,12 +75,14 @@ export function AppTable({
size,
zebra,
stickyHeader,
}: DataTableProps) {
tableClassName,
headerClassName,
}: DataTableProps<T>) {
const defaultButtonVariant = mobile ? 'secondary' : 'tertiary';
return (
<Table
size={size || 'sm'}
className={cn(classes.table, { [classes.mobileTable]: mobile })}
className={cn(classes.table, tableClassName, { [classes.mobileTable]: mobile })}
zebra={zebra}
stickyHeader={stickyHeader}
>
Expand All @@ -88,6 +92,7 @@ export function AppTable({
{columns.map((col, index) => (
<Table.HeaderCell
style={stickyHeader ? { zIndex: 2 } : {}}
className={headerClassName}
key={index}
>
{col.header}
Expand Down
6 changes: 6 additions & 0 deletions src/components/form/caption/Caption.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@
.description {
padding-bottom: var(--fds-spacing-3);
}

.titleAndHelpWrapper {
display: flex;
gap: var(--fds-spacing-2);
align-items: center;
}
42 changes: 22 additions & 20 deletions src/components/form/caption/Caption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,29 @@ export const Caption = ({
{...rest}
className={cn(classes.tableCaption, className)}
>
<DesignsystemetLabel
asChild
className={classes.captionTitle}
{...designSystemLabelProps}
>
<div>
{title}
<RequiredIndicator required={required} />
<OptionalIndicator
readOnly={false}
required={required}
showOptionalMarking={!!labelSettings?.optionalIndicator}
<div className={classes.titleAndHelpWrapper}>
<DesignsystemetLabel
asChild
className={classes.captionTitle}
{...designSystemLabelProps}
>
<div>
{title}
<RequiredIndicator required={required} />
<OptionalIndicator
readOnly={false}
required={required}
showOptionalMarking={!!labelSettings?.optionalIndicator}
/>
</div>
</DesignsystemetLabel>
{helpText && (
<HelpTextContainer
helpText={helpText.text}
title={helpText.accessibleTitle}
/>
</div>
</DesignsystemetLabel>
{helpText && (
<HelpTextContainer
helpText={helpText.text}
title={helpText.accessibleTitle}
/>
)}
)}
</div>
{description && (
<Description
className={classes.description}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function InvalidSubformLayoutError({ error }: { error: InvalidSubformLayo
<br />
<br />
<Lang
id='config_error.layoutset_subform_config_error_customer_support'
id='general.customer_service_error_message'
params={[
<Lang
key={0}
Expand Down
17 changes: 15 additions & 2 deletions src/language/texts/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export function en() {
customer_service_phone_number: '+47 75 00 60 00',
customer_service_slack: 'https://altinn.slack.com/',
customer_service_email: '[email protected]',
customer_service_error_message:
'If you need help resolving this issue, reach out to Altinn via our support lines<br/><br/><ul><li>Phone: <a href="tel:{0}">{0}</a></li><li>Email: {1}</li><li>Slack: {2}</li></ul>',
delete: 'Delete',
download: 'Download {0}',
disabled: 'Disabled',
Expand Down Expand Up @@ -343,6 +345,19 @@ export function en() {
validation_invalid_response_from_server: 'An error occurred. Please try again later.',
unknown_error: 'An unknown error occurred. Please try again later.',
},
signee_list: {
parse_error: 'Error loading signee list.',
wrong_task_error: 'This component is only available in a signing task.',
unknown_api_error: 'An error occurred when fetching signees.',
api_error_display: 'An error occurred when fetching signees. See devtool logs for more information.',
signee_status_signed: 'Signed',
signee_status_waiting: 'Waiting for signing',
signee_status_delegation_failed: 'Delegation failed',
signee_status_notification_failed: 'Notification failed',
header_name: 'Name',
header_on_behalf_of: 'On behalf of',
header_status: 'Status',
},
helptext: {
button_title: 'Help',
button_title_prefix: 'Helptext for',
Expand Down Expand Up @@ -412,8 +427,6 @@ export function en() {
navigateLastPage: 'Navigate to the last page in the table',
},
config_error: {
layoutset_subform_config_error_customer_support:
'If you need help resolving this issue, reach out to Altinn via our support lines<br/><br/><ul><li>Phone: <a href="tel:{0}">{0}</a></li><li>Email: {1}</li><li>Slack: {2}</li></ul>',
layoutset_subform_config_error:
'Layout set with id <strong>{0}</strong> is configured incorrectly.<br /><br />The layout set cannot have both <strong>type</strong> <em>and</em> <strong>tasks</strong> defined.',
layoutset_error: 'Layout set error',
Expand Down
17 changes: 15 additions & 2 deletions src/language/texts/nb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export function nb(): FixedLanguageList {
customer_service_phone_number: '+47 75 00 60 00',
customer_service_slack: 'https://altinn.slack.com/',
customer_service_email: '[email protected]',
customer_service_error_message:
'Hvis du har behov for assistanse kan du nå Altinn på<br/><br/><li>Telefon: <a href="tel:{0}">{0}</a></li><li>E-post: {1}</li><li>Slack: {2}</li></ul>',
delete: 'Slett',
download: 'Nedlasting {0}',
disabled: 'Deaktivert',
Expand Down Expand Up @@ -344,6 +346,19 @@ export function nb(): FixedLanguageList {
validation_invalid_response_from_server: 'Det oppstod en feil. Vennligst prøv igjen senere.',
unknown_error: 'Ukjent feil. Vennligst prøv igjen senere.',
},
signee_list: {
parse_error: 'Feil ved lasting av signatarliste.',
wrong_task_error: 'Denne komponenten er kun tilgjengelig i et signeringssteg.',
unknown_api_error: 'En feil oppstod under henting av signatarer.',
api_error_display: 'En feil oppstod under henting av signatarer. Se devtool-loggene for mer informasjon.',
signee_status_signed: 'Signert',
signee_status_waiting: 'Venter på signering',
signee_status_delegation_failed: 'Delegasjon mislyktes',
signee_status_notification_failed: 'Varsling mislyktes',
header_name: 'Navn',
header_on_behalf_of: 'På vegne av',
header_status: 'Status',
},
helptext: {
button_title: 'Hjelp',
button_title_prefix: 'Hjelpetekst for',
Expand Down Expand Up @@ -413,8 +428,6 @@ export function nb(): FixedLanguageList {
navigateLastPage: 'Naviger til siste side i tabell',
},
config_error: {
layoutset_subform_config_error_customer_support:
'Hvis du har behov for assistanse kan du nå Altinn på<br/><br/><li>Telefon: <a href="tel:{0}">{0}</a></li><li>E-post: {1}</li><li>Slack: {2}</li></ul>',
layoutset_subform_config_error:
'Layout set med id <strong>{0}</strong> er konfigurert feil.<br /><br />Layout set kan ikke ha både <strong>type</strong> <em>og</em> <strong>tasks</strong> definert.',
layoutset_error: 'Layout set error',
Expand Down
17 changes: 15 additions & 2 deletions src/language/texts/nn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export function nn(): FixedLanguageList {
customer_service_phone_number: '+47 75 00 60 00',
customer_service_slack: 'https://altinn.slack.com/',
customer_service_email: '[email protected]',
customer_service_error_message:
'Om du treng hjelp kan du nå Altinn på:<br/><br/>Telefon: <a href="tel:{0}">{0}</a><br/>E-post: {1}<br/>Slack: {2}',
delete: 'Slett',
download: 'Nedlasting {0}',
disabled: 'Deaktivert',
Expand Down Expand Up @@ -344,6 +346,19 @@ export function nn(): FixedLanguageList {
validation_invalid_response_from_server: 'Det oppstod ein feil. Ver venleg, prøv igjen seinare.',
unknown_error: 'Det oppstod ein feil. Ver venleg, prøv igjen seinare.',
},
signee_list: {
parse_error: 'Feil ved lasting av signatarliste.',
wrong_task_error: 'Denne komponenten er berre tilgjengeleg i eit signeringssteg.',
unknown_api_error: 'Ein feil oppstod under henting av signatarar.',
api_error_display: 'Ein feil oppstod under henting av signatarar. Sjå devtool-loggane for meir informasjon.',
signee_status_signed: 'Signert',
signee_status_waiting: 'Ventar på signering',
signee_status_delegation_failed: 'Delegasjon mislukkast',
signee_status_notification_failed: 'Varsling mislukkast',
header_name: 'Namn',
header_on_behalf_of: 'På vegne av',
header_status: 'Status',
},
helptext: {
button_title: 'Hjelp',
button_title_prefix: 'Hjelpetekst for',
Expand Down Expand Up @@ -413,8 +428,6 @@ export function nn(): FixedLanguageList {
navigateLastPage: 'Naviger til siste side i tabell',
},
config_error: {
layoutset_subform_config_error_customer_support:
'Om du treng hjelp kan du nå Altinn på:<br/><br/>Telefon: <a href="tel:{0}">{0}</a><br/>E-post: {1}<br/>Slack: {2}',
layoutset_subform_config_error:
'Layout set med id <strong>{0}</strong> er feilkonfigurert.<br /><br />Layout set kan ikkje ha både <strong>type</strong> <em>og</em> <strong>tasks</strong> definert.',
layoutset_error: 'Layout set error',
Expand Down
2 changes: 1 addition & 1 deletion src/layout/OrganisationLookup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class OrganisationLookup extends OrganisationLookupDef {
}

renderSummary(_props: SummaryRendererProps<'OrganisationLookup'>): JSX.Element | null {
throw new Error('Method not implemented.');
return null;
}

validateDataModelBindings(_ctx: LayoutValidationCtx<'OrganisationLookup'>): string[] {
Expand Down
2 changes: 1 addition & 1 deletion src/layout/PersonLookup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class PersonLookup extends PersonLookupDef {
);

renderSummary(_props: SummaryRendererProps<'PersonLookup'>): JSX.Element | null {
throw new Error('Method not implemented.');
return null;
}

renderSummary2(props: Summary2Props<'PersonLookup'>): JSX.Element | null {
Expand Down
13 changes: 13 additions & 0 deletions src/layout/SigneeList/SigneeListComponent.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.signeeListHeader {
background-color: var(--fds-semantic-surface-action-subtle);
font-weight: 400;
border-bottom-color: var(--fds-semantic-border-action-hover);
}

.signeeListCaption {
font: var(--fds-typography-paragraph-large);
}

.signeeListTable tr td:last-child {
width: 1%;
}
Loading
Loading