Skip to content

Commit

Permalink
Fix signature checkbox wrap, don't include MU signature by default fo…
Browse files Browse the repository at this point in the history
…r finished behandlinger
  • Loading branch information
eriksson-daniel committed Jan 13, 2025
1 parent 4b2565b commit caf5c7f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
30 changes: 17 additions & 13 deletions frontend/src/plate/components/signature/signature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const Signature = (props: PlateElementProps<SignatureElement>) => {
const showMedunderskriverCheckbox = hasMedunderskriver && !isRolAnswers;
const showForkortedeNavnCheckbox = hasMedunderskriver || !signature.anonymous;
const showSuffixCheckbox = !(signature.anonymous || isRolAnswers);
const showUseMyNameCheckbox = oppgave.avsluttetAvSaksbehandlerDate === null;

const hideAll = !(showForkortedeNavnCheckbox || showSuffixCheckbox || hasMedunderskriver);

Expand Down Expand Up @@ -92,18 +93,20 @@ export const Signature = (props: PlateElementProps<SignatureElement>) => {
</Checkbox>
) : null}

<Checkbox
disabled={
isReadOnly ||
(user.navIdent === creator && (overriddenWithSelf || element.overriddenSaksbehandler === undefined))
}
checked={
overriddenWithSelf || (user.navIdent === creator && element.overriddenSaksbehandler === undefined)
}
onChange={({ target }) => setOverriddenSaksbehandler(target.checked ? user.navIdent : undefined)}
>
Signer med mitt navn
</Checkbox>
{showUseMyNameCheckbox ? (
<Checkbox
disabled={
isReadOnly ||
(user.navIdent === creator && (overriddenWithSelf || element.overriddenSaksbehandler === undefined))
}
checked={
overriddenWithSelf || (user.navIdent === creator && element.overriddenSaksbehandler === undefined)
}
onChange={({ target }) => setOverriddenSaksbehandler(target.checked ? user.navIdent : undefined)}
>
Signer med mitt navn
</Checkbox>
) : null}
</Checkboxes>
)}

Expand Down Expand Up @@ -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)};
Expand All @@ -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`
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/plate/templates/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '' }],
Expand Down
23 changes: 17 additions & 6 deletions frontend/src/plate/templates/simple-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -18,12 +19,22 @@ import {
createSimpleParagraph,
} from './helpers';

export const GENERELT_BREV_TEMPLATE = deepFreeze<IMutableSmartEditorTemplate>({
templateId: TemplateIdEnum.GENERELT_BREV,
tittel: 'Generelt brev',
richText: [createCurrentDate(), createHeader(), createSimpleParagraph(), createSignature(), createFooter()],
dokumentTypeId: DistribusjonsType.BREV,
});
const getGenereltBrevTemplate = (includeMedunderskriver: boolean): Immutable<IMutableSmartEditorTemplate> =>
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<IMutableSmartEditorTemplate>({
templateId: TemplateIdEnum.NOTAT,
Expand Down

0 comments on commit caf5c7f

Please sign in to comment.