From caf5c7fd497352d20010e581194c8b2f9e13de49 Mon Sep 17 00:00:00 2001 From: Daniel Eriksson Date: Mon, 13 Jan 2025 16:35:43 +0100 Subject: [PATCH] Fix signature checkbox wrap, don't include MU signature by default for finished behandlinger --- .../new-document/new-document.tsx | 4 +-- .../plate/components/signature/signature.tsx | 30 +++++++++++-------- frontend/src/plate/templates/helpers.ts | 4 +-- .../src/plate/templates/simple-templates.ts | 23 ++++++++++---- 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/frontend/src/components/smart-editor/new-document/new-document.tsx b/frontend/src/components/smart-editor/new-document/new-document.tsx index bf42729bd..63ab9f951 100644 --- a/frontend/src/components/smart-editor/new-document/new-document.tsx +++ b/frontend/src/components/smart-editor/new-document/new-document.tsx @@ -6,7 +6,7 @@ import { useHasDocumentsAccess } from '@app/hooks/use-has-documents-access'; import { useIsFeilregistrert } from '@app/hooks/use-is-feilregistrert'; import { useIsRol } from '@app/hooks/use-is-rol'; import { useIsSaksbehandler } from '@app/hooks/use-is-saksbehandler'; -import { GENERELT_BREV_TEMPLATE, NOTAT_TEMPLATE } from '@app/plate/templates/simple-templates'; +import { GENERELT_BREV_WITHOUT_MU_TEMPLATE, NOTAT_TEMPLATE } from '@app/plate/templates/simple-templates'; import { ANKE_I_TRYGDERETTEN_TEMPLATES, ANKE_TEMPLATES, @@ -112,7 +112,7 @@ const useTemplates = (oppgave: IOppgavebehandling | undefined) => { const { isAvsluttetAvSaksbehandler, typeId } = oppgave; if (isAvsluttetAvSaksbehandler) { - return [GENERELT_BREV_TEMPLATE, NOTAT_TEMPLATE]; + return [GENERELT_BREV_WITHOUT_MU_TEMPLATE, NOTAT_TEMPLATE]; } if (isSaksbehandler || isRol) { diff --git a/frontend/src/plate/components/signature/signature.tsx b/frontend/src/plate/components/signature/signature.tsx index fae7cfeca..dbdc29b19 100644 --- a/frontend/src/plate/components/signature/signature.tsx +++ b/frontend/src/plate/components/signature/signature.tsx @@ -31,6 +31,7 @@ export const Signature = (props: PlateElementProps) => { const showMedunderskriverCheckbox = hasMedunderskriver && !isRolAnswers; const showForkortedeNavnCheckbox = hasMedunderskriver || !signature.anonymous; const showSuffixCheckbox = !(signature.anonymous || isRolAnswers); + const showUseMyNameCheckbox = oppgave.avsluttetAvSaksbehandlerDate === null; const hideAll = !(showForkortedeNavnCheckbox || showSuffixCheckbox || hasMedunderskriver); @@ -92,18 +93,20 @@ export const Signature = (props: PlateElementProps) => { ) : null} - setOverriddenSaksbehandler(target.checked ? user.navIdent : undefined)} - > - Signer med mitt navn - + {showUseMyNameCheckbox ? ( + setOverriddenSaksbehandler(target.checked ? user.navIdent : undefined)} + > + Signer med mitt navn + + ) : null} )} @@ -151,7 +154,6 @@ const Checkboxes = styled.div` border-style: dashed; border-radius: var(--a-border-radius-medium); border-width: ${ptToEm(2)}; - width: min-content; white-space: nowrap; display: flex; gap: ${pxToEm(8)}; @@ -161,6 +163,8 @@ const Checkboxes = styled.div` margin-right: auto; margin-top: ${pxToEm(16)}; margin-bottom: ${pxToEm(8)}; + flex-wrap: wrap; + justify-content: center; `; const StyledSignatures = styled.div` diff --git a/frontend/src/plate/templates/helpers.ts b/frontend/src/plate/templates/helpers.ts index ba2aca07e..c2e337526 100644 --- a/frontend/src/plate/templates/helpers.ts +++ b/frontend/src/plate/templates/helpers.ts @@ -140,10 +140,10 @@ export const createSimpleBulletList = (...textItems: string[]): BulletListElemen children: textItems.map(createSimpleListItem), }); -export const createSignature = (): SignatureElement => ({ +export const createSignature = (includeMedunderskriver = true): SignatureElement => ({ type: ELEMENT_SIGNATURE, useShortName: false, - includeMedunderskriver: true, + includeMedunderskriver, useSuffix: true, overriddenSaksbehandler: undefined, children: [{ text: '' }], diff --git a/frontend/src/plate/templates/simple-templates.ts b/frontend/src/plate/templates/simple-templates.ts index 69f55ecfd..620793d9a 100644 --- a/frontend/src/plate/templates/simple-templates.ts +++ b/frontend/src/plate/templates/simple-templates.ts @@ -4,6 +4,7 @@ import { TextAlign } from '@app/plate/types'; import { DistribusjonsType } from '@app/types/documents/documents'; import type { IMutableSmartEditorTemplate } from '@app/types/smart-editor/smart-editor'; import { TemplateIdEnum } from '@app/types/smart-editor/template-enums'; +import type { Immutable } from '@app/types/types'; import { BaseParagraphPlugin } from '@udecode/plate-core'; import { LabelContentSource } from '../types'; import { @@ -18,12 +19,22 @@ import { createSimpleParagraph, } from './helpers'; -export const GENERELT_BREV_TEMPLATE = deepFreeze({ - templateId: TemplateIdEnum.GENERELT_BREV, - tittel: 'Generelt brev', - richText: [createCurrentDate(), createHeader(), createSimpleParagraph(), createSignature(), createFooter()], - dokumentTypeId: DistribusjonsType.BREV, -}); +const getGenereltBrevTemplate = (includeMedunderskriver: boolean): Immutable => + deepFreeze({ + templateId: TemplateIdEnum.GENERELT_BREV, + tittel: 'Generelt brev', + richText: [ + createCurrentDate(), + createHeader(), + createSimpleParagraph(), + createSignature(includeMedunderskriver), + createFooter(), + ], + dokumentTypeId: DistribusjonsType.BREV, + }); + +export const GENERELT_BREV_TEMPLATE = getGenereltBrevTemplate(true); +export const GENERELT_BREV_WITHOUT_MU_TEMPLATE = getGenereltBrevTemplate(false); export const NOTAT_TEMPLATE = deepFreeze({ templateId: TemplateIdEnum.NOTAT,