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(example-form): update example form #17028

Merged
merged 38 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b084b55
feat: update reference template
jonnigs Nov 6, 2024
556b8c9
feat: showcare date, radio, checkbox, select
jonnigs Nov 7, 2024
5432a13
feat: more fields added to reference template
jonnigs Nov 8, 2024
d9fdb4f
feat: display bank account section
jonnigs Nov 12, 2024
20f61e7
feat: added section common actions
jonnigs Nov 12, 2024
046b13d
feat: custom components and overview
jonnigs Nov 21, 2024
9ee1f9c
feat: diagram and use default events
jonnigs Nov 22, 2024
b948d80
chore: update dataSchema
jonnigs Nov 25, 2024
36e9174
chore: move some fields from sections to subsections
jonnigs Dec 11, 2024
162562b
feat: order and add more description
jonnigs Dec 16, 2024
1e99d54
Merge branch 'main' into feat/update-example-form-2
jonnigs Dec 16, 2024
27ba7f5
Merge branch 'main' into feat/update-example-form-2
jonnigs Dec 16, 2024
780b59e
chore: update text to Icelandic
jonnigs Dec 16, 2024
f8eda5d
feat: make tables and repeater section
jonnigs Dec 17, 2024
f4d043f
feat: display field and repeaters
jonnigs Dec 17, 2024
99fb4f0
Merge branch 'main' into feat/update-example-form-2
jonnigs Dec 17, 2024
7c80bf4
chore: move large to the repeaterItems
jonnigs Dec 17, 2024
99e953a
chore: update readme files
jonnigs Dec 17, 2024
4f43bc2
chore: remove unused import
jonnigs Dec 17, 2024
ce7304a
chore: remove fieldsRepeater from ignored half types
jonnigs Dec 17, 2024
3ccc972
chore: add space to comment
jonnigs Dec 17, 2024
dd74772
chore: update folder structure
jonnigs Dec 17, 2024
5aa66eb
chore: document tabtitle
jonnigs Dec 17, 2024
355d230
chore: update readme
jonnigs Dec 17, 2024
3a12514
chore: unique ids
jonnigs Dec 17, 2024
6787717
chore: update readme
jonnigs Dec 17, 2024
264a281
fix: build
jonnigs Dec 17, 2024
5c4030d
Update libs/application/templates/reference-template/src/forms/README.md
jonnigs Dec 18, 2024
5503e0c
chore: remove console.log
jonnigs Dec 18, 2024
9222a2d
chore: use destructed values in slider field
jonnigs Dec 18, 2024
b38d597
chore: remove unused import
jonnigs Dec 18, 2024
adf14a5
chore: transleat all to english
jonnigs Dec 18, 2024
85da65b
Merge branch 'main' into feat/update-example-form-2
jonnigs Dec 18, 2024
c211325
chore: remove unused imports
jonnigs Dec 18, 2024
272b890
Merge branch 'feat/update-example-form-2' of github.com:island-is/isl…
jonnigs Dec 18, 2024
56e5b1d
chore: fix imports
jonnigs Dec 18, 2024
928765f
fix: errors
jonnigs Dec 18, 2024
f33f86a
Merge branch 'main' into feat/update-example-form-2
kodiakhq[bot] Dec 18, 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
21 changes: 11 additions & 10 deletions libs/application/core/src/lib/fieldBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
FormTextArray,
KeyValueField,
LinkField,
MaybeWithApplicationAndField,
MessageWithLinkButtonField,
Option,
PaymentChargeOverviewField,
Expand Down Expand Up @@ -586,6 +585,7 @@ export const buildExpandableDescriptionField = (
component: FieldComponents.EXPANDABLE_DESCRIPTION,
}
}

export const buildAlertMessageField = (
data: Omit<AlertMessageField, 'type' | 'component' | 'children'>,
): AlertMessageField => {
Expand Down Expand Up @@ -842,7 +842,6 @@ export const buildFieldsRepeaterField = (
): FieldsRepeaterField => {
const {
fields,
table,
title,
titleVariant,
formTitle,
Expand All @@ -861,7 +860,6 @@ export const buildFieldsRepeaterField = (
type: FieldTypes.FIELDS_REPEATER,
component: FieldComponents.FIELDS_REPEATER,
fields,
table,
title,
titleVariant,
formTitle,
Expand Down Expand Up @@ -923,38 +921,42 @@ export const buildStaticTableField = (
}

export const buildSliderField = (
data: Omit<SliderField, 'type' | 'component' | 'children' | 'title'>,
data: Omit<SliderField, 'type' | 'component' | 'children'>,
): SliderField => {
const {
id,
title,
titleVariant = 'h2',
condition,
min = 0,
max = 10,
step = 1,
snap = true,
trackStyle,
calculateCellStyle,
showLabel = false,
showMinMaxLabels = false,
showRemainderOverlay = true,
showProgressOverlay = true,
showToolTip = false,
label,
showLabel = false,
showMinMaxLabels = false,
rangeDates,
currentIndex,
onChange,
onChangeEnd,
labelMultiplier = 1,
id,
saveAsString,
marginTop,
marginBottom,
} = data
return {
title: '',
component: FieldComponents.SLIDER,
id,
title,
titleVariant,
condition,
children: undefined,
type: FieldTypes.SLIDER,
component: FieldComponents.SLIDER,
min,
max,
step,
Expand All @@ -972,7 +974,6 @@ export const buildSliderField = (
onChange,
onChangeEnd,
labelMultiplier,
condition,
saveAsString,
marginTop,
marginBottom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const FundingGovernmentProjectsForm: Form = buildForm({
}),
buildSliderField({
id: 'project.refundableYears',
title: '',
jonnigs marked this conversation as resolved.
Show resolved Hide resolved
label: {
singular: shared.yearSingular,
plural: shared.yearPlural,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,7 @@ export const ParentalLeaveForm: Form = buildForm({
children: [
buildSliderField({
id: 'multipleBirthsRequestDays',
title: '',
label: {
singular: parentalLeaveFormMessages.shared.day,
plural: parentalLeaveFormMessages.shared.days,
Expand Down Expand Up @@ -1317,6 +1318,7 @@ export const ParentalLeaveForm: Form = buildForm({
children: [
buildSliderField({
id: 'requestRights.requestDays',
title: '',
label: {
singular: parentalLeaveFormMessages.shared.day,
plural: parentalLeaveFormMessages.shared.days,
Expand Down Expand Up @@ -1365,6 +1367,7 @@ export const ParentalLeaveForm: Form = buildForm({
children: [
buildSliderField({
id: 'giveRights.giveDays',
title: '',
label: {
singular: parentalLeaveFormMessages.shared.day,
plural: parentalLeaveFormMessages.shared.days,
Expand Down
48 changes: 48 additions & 0 deletions libs/application/templates/reference-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,51 @@ To access the list of national ids for applicantActors that have come in contact
```ts
const applicantActors = application.applicantActors
```

## Coding guidelines

The aim is to have all applications to be coded in a similar way, so that every developer that is familiar with the application system can open any application and everything is consistent and feels familiar.

- Reduce the amount of custom components to a minimum.
- Reduce the use of the "as" and "any" keywords as much as possible. Both of those keywords are tricking the linter to accept code that would otherwise throw errors and might cause hard to trace bugs.
- Try to use the `getValueViaPath` function to access the answers of the application. It makes accessing nested values easier and the code more readable. Note that this function is generic and a type can be provided to make sure the type of the value is correct E.g:

`getValueViaPath<string>(application.answers, 'some.nested.value', 'optional fallback')`

- Don't use fake steps, stepper should only be showing steps of the current form. On the first step in the main form, there shouldn't be a back button or the illusion that you can go back to the prerequsites step.

## Folder structure

|-- assets/--------------------------------# optional folder for assets like images, icons, etc.
|
|-- components/----------------------------# optional folder for React components that are used by custom components.
|
|-- dataProviders/-------------------------# folder for data providers.
|
|-- fields/--------------------------------# optional folder for custom components if the application needs any.
|-- |-- index.ts---------------------------# Exports all fields from the folder.
|-- |-- myCustomComponent/-----------------# Folder for a custom component, camelCase.
|-- |-- |-- MyCustomComponent.tsx----------# React component file, PascalCase.
|-- |-- |-- MyCustomComponent.css.ts-------# CSS file, PascalCase.
|
|-- forms/---------------------------------# folder for forms. More about form folder structure in the form folder README.
|-- |-- prerequisitesForm/
|-- |-- mainForm/
|-- |-- conclusionForm/--------------------# More forms if needed
|
|-- graphql/-------------------------------# optional folder for graphql queries and mutations.
|
|-- lib/-----------------------------------# folder for data schema, messages, and the main template file.
|-- |-- dataScema.ts-----------------------# Validation for the application.
|-- |-- mainTemplate.ts--------------------# Main template file. State machine for the application, mapUsersToRole and more
|-- |-- messages.ts------------------------# File for all text that appears on the screen, synced with Contentful.
|-- |-- messages/--------------------------# optional folder for messages if there is a need to have the messages more organized.
|
|-- shared/--------------------------------# optional folder for code that might be needed in the template-api-modules or
|------------------------------------------# other places outside the template.
|
|-- utils/---------------------------------# folder for utility functions, constants, enums and types.
|-- |-- constants.ts-----------------------# Constants for the application.
|-- |-- enums.ts---------------------------# Enums for the application.
|-- |-- types.ts---------------------------# Types for the application.
|-- |-- helperFunctions.ts-----------------# Helper functions for the application, this can be many files.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Assets

This folder is optional and can be used to store assets like images, icons, etc.
Organization within this folder id up to the developer.
Loading
Loading