From b72331c4d08997414ff06efa64536c12b6156ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3n=20Bjarni=20=C3=93lafsson?= Date: Tue, 3 Dec 2024 13:45:22 +0000 Subject: [PATCH 1/7] Updating select inputs to filter from the start. --- .../src/components/input/OJOISelectController.tsx | 2 ++ .../src/fields/Publishing.tsx | 3 +++ .../src/lib/SelectController/SelectController.tsx | 10 +++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/application/templates/official-journal-of-iceland/src/components/input/OJOISelectController.tsx b/libs/application/templates/official-journal-of-iceland/src/components/input/OJOISelectController.tsx index 808d92713bc2..0e792fa30d8b 100644 --- a/libs/application/templates/official-journal-of-iceland/src/components/input/OJOISelectController.tsx +++ b/libs/application/templates/official-journal-of-iceland/src/components/input/OJOISelectController.tsx @@ -78,6 +78,8 @@ export const OJOISelectController = ({ options={options} defaultValue={defaultValue} disabled={disabled} + isSearchable={true} + filterConfig={{ matchFrom: 'start' }} onSelect={(opt) => handleChange(opt.label, opt.value)} /> ) diff --git a/libs/application/templates/official-journal-of-iceland/src/fields/Publishing.tsx b/libs/application/templates/official-journal-of-iceland/src/fields/Publishing.tsx index b2f7d27726a9..cf620c2d5521 100644 --- a/libs/application/templates/official-journal-of-iceland/src/fields/Publishing.tsx +++ b/libs/application/templates/official-journal-of-iceland/src/fields/Publishing.tsx @@ -127,6 +127,9 @@ export const Publishing = ({ application }: OJOIFieldBaseProps) => { defaultValue={defaultCategory} options={mappedCategories} onChange={(opt) => onCategoryChange(opt?.value)} + filterConfig={{ + matchFrom: 'start', + }} /> { rules?: RegisterOptions size?: 'xs' | 'sm' | 'md' internalKey?: string + filterConfig?: SelectProps['filterConfig'] } export const SelectController = ({ @@ -47,6 +53,7 @@ export const SelectController = ({ rules, size, internalKey, + filterConfig, }: SelectControllerProps & TestSupport) => { const { clearErrors } = useFormContext() @@ -91,6 +98,7 @@ export const SelectController = ({ placeholder={placeholder} value={getValue(value)} isSearchable={isSearchable} + filterConfig={filterConfig} isMulti={isMulti} isClearable={isClearable} size={size} From d15b67833a9bb12910ae22a9cc3aac74fcf658af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3n=20Bjarni=20=C3=93lafsson?= Date: Tue, 3 Dec 2024 14:49:36 +0000 Subject: [PATCH 2/7] Updated the UI header component to support larger titles. --- .../src/components/input/OJOIInputController.tsx | 3 +++ .../official-journal-of-iceland/src/fields/Advert.tsx | 1 + libs/island-ui/core/src/lib/Header/Header.css.ts | 4 ++++ libs/island-ui/core/src/lib/Header/Header.tsx | 11 ++++++----- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libs/application/templates/official-journal-of-iceland/src/components/input/OJOIInputController.tsx b/libs/application/templates/official-journal-of-iceland/src/components/input/OJOIInputController.tsx index 44bee990cc2e..900fc1a17b11 100644 --- a/libs/application/templates/official-journal-of-iceland/src/components/input/OJOIInputController.tsx +++ b/libs/application/templates/official-journal-of-iceland/src/components/input/OJOIInputController.tsx @@ -15,6 +15,7 @@ type Props = { applicationId: string disabled?: boolean textarea?: boolean + maxLength?: number onChange?: (value: string) => void } @@ -27,6 +28,7 @@ export const OJOIInputController = ({ applicationId, disabled, textarea, + maxLength, onChange, }: Props) => { const { formatMessage: f } = useLocale() @@ -71,6 +73,7 @@ export const OJOIInputController = ({ disabled={disabled} textarea={textarea} rows={4} + maxLength={maxLength} required={false} onChange={(e) => debouncedOnUpdateApplicationHandler( diff --git a/libs/application/templates/official-journal-of-iceland/src/fields/Advert.tsx b/libs/application/templates/official-journal-of-iceland/src/fields/Advert.tsx index fe9cc36440ae..593b11297ee0 100644 --- a/libs/application/templates/official-journal-of-iceland/src/fields/Advert.tsx +++ b/libs/application/templates/official-journal-of-iceland/src/fields/Advert.tsx @@ -105,6 +105,7 @@ export const Advert = ({ application, timeStamp }: Props) => { defaultValue={application.answers?.advert?.title} placeholder={advert.inputs.title.placeholder} textarea={true} + maxLength={600} /> diff --git a/libs/island-ui/core/src/lib/Header/Header.css.ts b/libs/island-ui/core/src/lib/Header/Header.css.ts index cf8a3492b455..c580b98e9c28 100644 --- a/libs/island-ui/core/src/lib/Header/Header.css.ts +++ b/libs/island-ui/core/src/lib/Header/Header.css.ts @@ -21,10 +21,14 @@ export const infoDescription = style({ fontWeight: 300, lineHeight: 1.5, fontSize: 14, + maxHeight: 40, + position: 'relative', + overflow: 'auto', ...themeUtils.responsiveStyle({ md: { fontSize: 18, + maxHeight: 66, }, }), }) diff --git a/libs/island-ui/core/src/lib/Header/Header.tsx b/libs/island-ui/core/src/lib/Header/Header.tsx index 15a28c13f892..1d6a01230f6d 100644 --- a/libs/island-ui/core/src/lib/Header/Header.tsx +++ b/libs/island-ui/core/src/lib/Header/Header.tsx @@ -93,6 +93,7 @@ export const Header = ({ height="full" marginLeft={[1, 1, 2, 4]} marginRight="auto" + paddingRight={[1, 1, 2, 4]} > {info.title} @@ -128,14 +129,14 @@ export const Header = ({ alignItems="center" justifyContent="spaceBetween" > - - {renderLogo()} + + {renderLogo()} {renderInfo()} - - + + {renderOldDropdown()} {headerItems} - + ) } From c4a356738c6745333e9602396a4753d87b6372f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3n=20Bjarni=20=C3=93lafsson?= Date: Wed, 4 Dec 2024 09:10:38 +0000 Subject: [PATCH 3/7] Signatures are now hyphenated and max length for each field set to 100. --- .../src/components/signatures/Institution.tsx | 1 + .../src/components/signatures/Member.tsx | 1 + .../src/lib/utils.ts | 25 +++++++++++++------ libs/island-ui/core/src/lib/Hyphen/Hyphen.tsx | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/libs/application/templates/official-journal-of-iceland/src/components/signatures/Institution.tsx b/libs/application/templates/official-journal-of-iceland/src/components/signatures/Institution.tsx index 1f73a2f8f921..89e2f41c6e1c 100644 --- a/libs/application/templates/official-journal-of-iceland/src/components/signatures/Institution.tsx +++ b/libs/application/templates/official-journal-of-iceland/src/components/signatures/Institution.tsx @@ -141,6 +141,7 @@ export const InstitutionSignature = ({ ) diff --git a/libs/application/templates/official-journal-of-iceland/src/lib/utils.ts b/libs/application/templates/official-journal-of-iceland/src/lib/utils.ts index 2e6f17b53156..14bc250aa62c 100644 --- a/libs/application/templates/official-journal-of-iceland/src/lib/utils.ts +++ b/libs/application/templates/official-journal-of-iceland/src/lib/utils.ts @@ -17,6 +17,8 @@ import is from 'date-fns/locale/is' import { SignatureTypes, OJOI_DF, FAST_TRACK_DAYS } from './constants' import { MessageDescriptor } from 'react-intl' import { v4 as uuid } from 'uuid' +import Hypher from 'hypher' +import { hyphenateText } from '@island.is/island-ui/core' export const countDaysAgo = (date: Date) => { const now = new Date() @@ -184,6 +186,8 @@ export const getRegularAnswers = (answers: OJOIApplication['answers']) => { signature: null, } } +const hypenate = (text = '') => + hyphenateText(text, { locale: 'is', minLeft: 4, minRight: 4 }) const getMembersMarkup = (member: z.infer) => { if (!member.name) return '' @@ -192,18 +196,21 @@ const getMembersMarkup = (member: z.infer) => { marginBottom: member.below ? '0' : '1.5em', } - const aboveMarkup = member.above - ? `

${member.above}

` - : '' - const afterMarkup = member.after ? ` ${member.after}` : '' - const belowMarkup = member.below - ? `

${member.below}

` + const name = hypenate(member.name) + const above = hypenate(member.above) + const after = hypenate(member.after) + const below = hypenate(member.below) + + const aboveMarkup = above + ? `

${above}

` : '' + const afterMarkup = after ? ` ${after}` : '' + const belowMarkup = below ? `

${below}

` : '' return `
${aboveMarkup} -

${member.name}${afterMarkup}

+

${name}${afterMarkup}

${belowMarkup}
` @@ -255,7 +262,9 @@ const signatureTemplate = ( .join('') const additionalMarkup = additionalSignature - ? `

${additionalSignature}

` + ? `

${hypenate( + additionalSignature, + )}

` : '' return `${markup}${additionalMarkup}` as HTMLText diff --git a/libs/island-ui/core/src/lib/Hyphen/Hyphen.tsx b/libs/island-ui/core/src/lib/Hyphen/Hyphen.tsx index 9af8249a592e..d6f0a607b944 100644 --- a/libs/island-ui/core/src/lib/Hyphen/Hyphen.tsx +++ b/libs/island-ui/core/src/lib/Hyphen/Hyphen.tsx @@ -12,7 +12,7 @@ type HyphenateText = ( ) => string // TODO: import patterns dynamically -const hyphenateText: HyphenateText = ( +export const hyphenateText: HyphenateText = ( content, { minLeft, minRight, locale = 'is' }, ) => { From 55e9ea1906b78646456a2e7945157f37a270f3ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3n=20Bjarni=20=C3=93lafsson?= Date: Wed, 4 Dec 2024 10:33:30 +0000 Subject: [PATCH 4/7] Fixed state issue when users changed the type of additions --- .../src/components/additions/Additions.tsx | 18 ++++---- .../src/fields/Attachments.tsx | 45 ++++++++++++++----- .../src/lib/dataSchema.ts | 2 + .../src/lib/messages/attachments.ts | 2 +- .../src/lib/types.ts | 2 + 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/libs/application/templates/official-journal-of-iceland/src/components/additions/Additions.tsx b/libs/application/templates/official-journal-of-iceland/src/components/additions/Additions.tsx index fc94f0a5f275..072b2aca724e 100644 --- a/libs/application/templates/official-journal-of-iceland/src/components/additions/Additions.tsx +++ b/libs/application/templates/official-journal-of-iceland/src/components/additions/Additions.tsx @@ -33,7 +33,9 @@ type Props = { type Addition = z.infer[number] export const Additions = ({ application }: Props) => { - const [asRoman, setAsRoman] = useState(false) + const [asRoman, setAsRoman] = useState( + application.answers.misc?.asRoman ?? false, + ) const { formatMessage: f } = useLocale() const { setValue } = useFormContext() @@ -57,8 +59,6 @@ export const Additions = ({ application }: Props) => { const onRemoveAddition = (index: number) => { const filtered = additions.filter((_, i) => i !== index) const mapped = filtered.map((addition, i) => { - if (addition.type !== 'html') return addition - const title = f(attachments.additions.title, { index: asRoman ? convertNumberToRoman(i + 1) : i + 1, }) @@ -83,10 +83,8 @@ export const Additions = ({ application }: Props) => { const onRomanChange = (val: boolean) => { const handleTitleChange = (addition: Addition, i: number) => { - if (addition.type !== 'html') return addition - const title = f(attachments.additions.title, { - index: asRoman ? convertNumberToRoman(i + 1) : i + 1, + index: val ? convertNumberToRoman(i + 1) : i + 1, }) return { ...addition, @@ -97,14 +95,17 @@ export const Additions = ({ application }: Props) => { const currentAnswers = structuredClone(currentApplication.answers) const updatedAdditions = additions.map(handleTitleChange) - const updatedAnswers = set( + let updatedAnswers = set( currentAnswers, InputFields.advert.additions, updatedAdditions, ) + updatedAnswers = set(updatedAnswers, InputFields.misc.asRoman, val) + setAsRoman(val) setValue(InputFields.advert.additions, updatedAdditions) + setValue(InputFields.misc.asRoman, val) updateApplication(updatedAnswers) } @@ -206,7 +207,8 @@ export const Additions = ({ application }: Props) => {
- {!asAddition ? ( - - ) : ( + {asDocument ? ( { icon: 'blue200', }} /> + ) : ( + )} ) diff --git a/libs/application/templates/official-journal-of-iceland/src/lib/dataSchema.ts b/libs/application/templates/official-journal-of-iceland/src/lib/dataSchema.ts index f617921467b5..aaeae761df93 100644 --- a/libs/application/templates/official-journal-of-iceland/src/lib/dataSchema.ts +++ b/libs/application/templates/official-journal-of-iceland/src/lib/dataSchema.ts @@ -78,6 +78,8 @@ const miscSchema = z .object({ signatureType: z.string().optional(), selectedTemplate: z.string().optional(), + asDocument: z.boolean().optional(), + asRoman: z.boolean().optional(), }) .partial() diff --git a/libs/application/templates/official-journal-of-iceland/src/lib/messages/attachments.ts b/libs/application/templates/official-journal-of-iceland/src/lib/messages/attachments.ts index 0046056207a4..e8a0f839b7b6 100644 --- a/libs/application/templates/official-journal-of-iceland/src/lib/messages/attachments.ts +++ b/libs/application/templates/official-journal-of-iceland/src/lib/messages/attachments.ts @@ -34,7 +34,7 @@ export const attachments = { }, asAttachment: { id: 'ojoi.application:attachments.buttons.additionType.asAttachment', - defaultMessage: 'Hlaða upp skjölum', + defaultMessage: 'Bæta við viðauka', description: 'Label of the button to upload attachments', }, removeAddition: { diff --git a/libs/application/templates/official-journal-of-iceland/src/lib/types.ts b/libs/application/templates/official-journal-of-iceland/src/lib/types.ts index ccae26abdb38..291c0a62c160 100644 --- a/libs/application/templates/official-journal-of-iceland/src/lib/types.ts +++ b/libs/application/templates/official-journal-of-iceland/src/lib/types.ts @@ -34,6 +34,8 @@ export const InputFields = { [Routes.MISC]: { signatureType: 'misc.signatureType', selectedTemplate: 'misc.selectedTemplate', + asDocument: 'misc.asDocument', + asRoman: 'misc.asRoman', }, } From 1b9b4021b1008d0bcb0687bc48d4826ab8d9353e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3n=20Bjarni=20=C3=93lafsson?= Date: Wed, 4 Dec 2024 11:00:09 +0000 Subject: [PATCH 5/7] Fixed 0 rendering in an conditional check --- apps/web/components/OfficialJournalOfIceland/OJOIAdvertCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/components/OfficialJournalOfIceland/OJOIAdvertCard.tsx b/apps/web/components/OfficialJournalOfIceland/OJOIAdvertCard.tsx index fe375bbe25fa..089ebaf2630a 100644 --- a/apps/web/components/OfficialJournalOfIceland/OJOIAdvertCard.tsx +++ b/apps/web/components/OfficialJournalOfIceland/OJOIAdvertCard.tsx @@ -66,7 +66,7 @@ export const OJOIAdvertCard = ({ marginTop={2} rowGap={1} > - {categories && categories.length && ( + {categories && categories.length > 0 && ( {categories.map((cat) => { return ( From 1363ccb0a79219505b7e0c3e228d5aed3128664f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3n=20Bjarni=20=C3=93lafsson?= Date: Wed, 4 Dec 2024 12:01:36 +0000 Subject: [PATCH 6/7] Fixed issue where date parameters were not properly working. --- .../OfficialJournalOfIceland/OJOISearch.tsx | 24 +++++-------------- .../hooks/useAdverts.ts | 4 ++-- .../src/lib/models/advert.input.ts | 4 ++-- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/apps/web/screens/OfficialJournalOfIceland/OJOISearch.tsx b/apps/web/screens/OfficialJournalOfIceland/OJOISearch.tsx index 86a586ccc44d..a3c4371e88d3 100644 --- a/apps/web/screens/OfficialJournalOfIceland/OJOISearch.tsx +++ b/apps/web/screens/OfficialJournalOfIceland/OJOISearch.tsx @@ -105,12 +105,8 @@ const OJOISearchPage: CustomScreen = ({ category: [defaultSearchParams.malaflokkur], involvedParty: [defaultSearchParams.stofnun], type: [defaultSearchParams.tegund], - dateFrom: defaultSearchParams.dagsFra - ? new Date(defaultSearchParams.dagsFra) - : undefined, - dateTo: defaultSearchParams.dagsTil - ? new Date(defaultSearchParams.dagsTil) - : undefined, + dateFrom: defaultSearchParams.dagsFra, + dateTo: defaultSearchParams.dagsTil, search: defaultSearchParams.q, page: defaultSearchParams.sida, pageSize: defaultSearchParams.staerd, @@ -176,12 +172,8 @@ const OJOISearchPage: CustomScreen = ({ category: [searchValues.malaflokkur], involvedParty: [searchValues.stofnun], type: [searchValues.tegund], - dateFrom: searchValues.dagsFra - ? new Date(searchValues.dagsFra) - : undefined, - dateTo: searchValues.dagsTil - ? new Date(searchValues.dagsTil) - : undefined, + dateFrom: searchValues.dagsFra, + dateTo: searchValues.dagsTil, search: searchValues.q, page: searchValues.sida, pageSize: searchValues.staerd, @@ -596,12 +588,8 @@ OJOISearch.getProps = async ({ apolloClient, locale, query }) => { variables: { input: { category: [defaultParams.malaflokkur], - dateFrom: defaultParams.dagsFra - ? new Date(defaultParams.dagsFra) - : undefined, - dateTo: defaultParams.dagsTil - ? new Date(defaultParams.dagsTil) - : undefined, + dateFrom: defaultParams.dagsFra, + dateTo: defaultParams.dagsTil, department: [defaultParams.deild], involvedParty: [defaultParams.stofnun], page: defaultParams.sida, diff --git a/apps/web/screens/OfficialJournalOfIceland/hooks/useAdverts.ts b/apps/web/screens/OfficialJournalOfIceland/hooks/useAdverts.ts index 0d4c3092886b..235c26397441 100644 --- a/apps/web/screens/OfficialJournalOfIceland/hooks/useAdverts.ts +++ b/apps/web/screens/OfficialJournalOfIceland/hooks/useAdverts.ts @@ -20,8 +20,8 @@ export type UseAdvertsVariables = { type?: Array category?: Array involvedParty?: Array - dateFrom?: Date - dateTo?: Date + dateFrom?: string + dateTo?: string } export type UseAdvertsInput = { diff --git a/libs/api/domains/official-journal-of-iceland/src/lib/models/advert.input.ts b/libs/api/domains/official-journal-of-iceland/src/lib/models/advert.input.ts index c00db538679f..868f78ae3130 100644 --- a/libs/api/domains/official-journal-of-iceland/src/lib/models/advert.input.ts +++ b/libs/api/domains/official-journal-of-iceland/src/lib/models/advert.input.ts @@ -28,10 +28,10 @@ export class AdvertsInput { @Field(() => [String], { nullable: true }) involvedParty?: string[] - @Field(() => Date, { nullable: true }) + @Field(() => String, { nullable: true }) dateFrom?: string - @Field(() => Date, { nullable: true }) + @Field(() => String, { nullable: true }) dateTo?: string } From 4ca82ffc1b0b056ccdd76ad82f081277324390c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3n=20Bjarni=20=C3=93lafsson?= Date: Wed, 4 Dec 2024 13:05:52 +0000 Subject: [PATCH 7/7] Fix typo --- .../official-journal-of-iceland/src/lib/utils.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/application/templates/official-journal-of-iceland/src/lib/utils.ts b/libs/application/templates/official-journal-of-iceland/src/lib/utils.ts index 14bc250aa62c..f813ff21954b 100644 --- a/libs/application/templates/official-journal-of-iceland/src/lib/utils.ts +++ b/libs/application/templates/official-journal-of-iceland/src/lib/utils.ts @@ -186,7 +186,7 @@ export const getRegularAnswers = (answers: OJOIApplication['answers']) => { signature: null, } } -const hypenate = (text = '') => +const hyphenate = (text = '') => hyphenateText(text, { locale: 'is', minLeft: 4, minRight: 4 }) const getMembersMarkup = (member: z.infer) => { @@ -196,10 +196,10 @@ const getMembersMarkup = (member: z.infer) => { marginBottom: member.below ? '0' : '1.5em', } - const name = hypenate(member.name) - const above = hypenate(member.above) - const after = hypenate(member.after) - const below = hypenate(member.below) + const name = hyphenate(member.name) + const above = hyphenate(member.above) + const after = hyphenate(member.after) + const below = hyphenate(member.below) const aboveMarkup = above ? `

${above}

` @@ -262,7 +262,7 @@ const signatureTemplate = ( .join('') const additionalMarkup = additionalSignature - ? `

${hypenate( + ? `

${hyphenate( additionalSignature, )}

` : ''