Skip to content

Commit

Permalink
Merge branch 'master' into update-hoved-sokefelt
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremiahUy authored Nov 10, 2023
2 parents ca66276 + 8b2aa0a commit 6fc6bd8
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 268 deletions.
2 changes: 1 addition & 1 deletion apps/backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<hypersistence-utils-hibernate-60.version>3.6.0</hypersistence-utils-hibernate-60.version>
<simpleclient.version>0.16.0</simpleclient.version>
<logstash-logback-encoder.version>7.4</logstash-logback-encoder.version>
<shedlock.version>5.9.1</shedlock.version>
<shedlock.version>5.10.0</shedlock.version>
<commons-collections4.version>4.4</commons-collections4.version>
<graphql-spring-boot-starter.version>15.0.0</graphql-spring-boot-starter.version>
<graphql.version>21.0</graphql.version>
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/components/DeleteItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const DeleteItem = (props: { fun: () => Promise<any>; redirect: string; b

return (
<>
<Button variant="danger" onClick={() => setOpen(true)} icon={<TrashIcon aria-label="" aria-hidden />} size={props.buttonSize ? props.buttonSize : undefined}>
<Button variant="danger" onClick={() => setOpen(true)} size={props.buttonSize ? props.buttonSize : undefined}>
{props.buttonLabel ? props.buttonLabel : 'Slett'}
</Button>
<Modal open={open} onClose={() => setOpen(false)} header={{ heading: 'Bekreft slett' }}>
Expand Down
17 changes: 7 additions & 10 deletions apps/frontend/src/components/common/TeamName.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { useTeam } from '../../api/TeamApi'
import { teamKatTeamLink } from '../../util/config'
import { Block } from 'baseui/block'
import { theme } from '../../util'
import { Link } from '@navikt/ds-react'
import { Detail, Link } from '@navikt/ds-react'

export const TeamName = (props: { id: string; link?: boolean }) => {
const [name] = useTeam()(props.id)

return props.link ? (
<Link rel="noopener noreferrer" target={'_blank'} href={teamKatTeamLink(props.id)}>
<Link className="text-sm" rel="noopener noreferrer" target={'_blank'} href={teamKatTeamLink(props.id)}>
{name} (åpnes i ny fane)
</Link>
) : (
Expand All @@ -17,11 +15,10 @@ export const TeamName = (props: { id: string; link?: boolean }) => {
}

export const Teams = (props: { teams: string[]; link?: boolean; list?: boolean }) => (
<Block display={props.list ? 'block' : 'flex'} flexWrap>
{props.teams.map((t) => (
<Block key={t} marginRight={props.list ? 'none' : theme.sizing.scale600} marginBottom={props.list ? theme.sizing.scale600 : 'none'}>
<TeamName id={t} link={props.link} />
</Block>
<div className="flex flex-wrap gap-2 items-center">
<Detail className="font-bold">Team:</Detail>
{props.teams.map((t, idx) => (
<TeamName key={`team_${idx}`} id={t} link={props.link} />
))}
</Block>
</div>
)
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const EtterlevelseSecondaryHeader = ({ tab, setTab, setNavigatePath, ette
},
}}
>
Tema for dokumentasjon
Temaoversikt
</LabelSmall>
</Button>
</Block>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { EtterlevelseArkiv, EtterlevelseArkivStatus } from '../../constants'
import { createEtterlevelseArkiv, updateEtterlevelseArkiv } from '../../api/ArkiveringApi'
import React, { useState } from 'react'
import moment from 'moment'
import CustomizedModal from '../common/CustomizedModal'
import { borderRadius } from '../common/Style'
import Button from '../common/Button'
import { BodyLong } from '@navikt/ds-react'
import { BodyLong, Button, Modal } from '@navikt/ds-react'
import { user } from '../../services/User'

type ArkiveringModalProps = {
Expand Down Expand Up @@ -48,22 +45,12 @@ export const ArkiveringModal = ({ arkivModal, setArkivModal, etterlevelseDokumen
}

return (
<CustomizedModal
isOpen={arkivModal}
<Modal
open={arkivModal}
onClose={() => {
setIsArchivingCancelled(false)
setArkivModal(false)
}}
size="default"
overrides={{
Dialog: {
style: {
width: '375px',
boxShadow: '0 2px 4px -1px rgba(0, 0, 0, .2), 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 3px 0 rgba(0, 0, 0, .12)',
...borderRadius('4px'),
},
},
}}
>
<ModalHeader>{etterlevelseArkiv && etterlevelseArkiv.status === EtterlevelseArkivStatus.TIL_ARKIVERING ? 'Arkivering bestilt' : 'Arkivér i Websak'}</ModalHeader>
<ModalBody>
Expand Down Expand Up @@ -111,12 +98,7 @@ export const ArkiveringModal = ({ arkivModal, setArkivModal, etterlevelseDokumen
setIsArchivingCancelled(false)
}
}}
kind={etterlevelseArkiv.status !== EtterlevelseArkivStatus.TIL_ARKIVERING ? 'primary' : 'secondary'}
$style={{
borderWidth: '2px',
marginRight: '16px',
padding: '14px 16px',
}}
variant={etterlevelseArkiv.status !== EtterlevelseArkivStatus.TIL_ARKIVERING ? 'primary' : 'secondary'}
>
{etterlevelseArkiv && etterlevelseArkiv.status === EtterlevelseArkivStatus.TIL_ARKIVERING ? 'Avbryt arkivering i WebSak' : 'Arkivér i WebSak'}
</Button>
Expand All @@ -127,16 +109,13 @@ export const ArkiveringModal = ({ arkivModal, setArkivModal, etterlevelseDokumen
setIsArchivingCancelled(false)
setArkivModal(false)
}}
kind="primary"
$style={{
padding: '14px 16px',
}}
variant="primary"
>
Lukk
</Button>
)}
</Block>
</ModalBody>
</CustomizedModal>
</Modal>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
} from '../../../api/EtterlevelseDokumentasjonApi'
import { Behandling, EtterlevelseDokumentasjonQL, Team, Virkemiddel } from '../../../constants'
import { Code, codelist, ListName } from '../../../services/Codelist'
import Button, { buttonContentStyle } from '../../common/Button'
import CustomizedModal from '../../common/CustomizedModal'
import { Button as BaseUIButton, KIND } from 'baseui/button'
import { FieldArray, FieldArrayRenderProps, FieldProps, Form, Formik } from 'formik'
import { FormControl } from 'baseui/form-control'
Expand All @@ -33,7 +31,8 @@ import { useSearchTeam } from '../../../api/TeamApi'
import { RenderTagList } from '../../common/TagList'
import { useNavigate } from 'react-router-dom'
import { updateBehandlingNameWithNumber } from '../common/utils'
import { Modal } from '@navikt/ds-react'
import { Button, Modal } from '@navikt/ds-react'
import { buttonContentStyle } from '../../common/Button'

type EditEtterlevelseDokumentasjonModalProps = {
etterlevelseDokumentasjon?: EtterlevelseDokumentasjonQL
Expand Down Expand Up @@ -130,12 +129,8 @@ export const EditEtterlevelseDokumentasjonModal = (props: EditEtterlevelseDokume
}

return (
<Block>
<Button
onClick={() => setIsEtterlevelseDokumntasjonerModalOpen(true)}
startEnhancer={props.isEditButton ? <img src={editIcon} alt="edit icon" /> : <img src={plusIcon} alt="plus icon" />}
size="compact"
>
<div>
<Button onClick={() => setIsEtterlevelseDokumntasjonerModalOpen(true)} size="small" variant="secondary" className="whitespace-nowrap">
{props.isEditButton ? 'Rediger etterlevelsesdokumentet' : 'Nytt etterlevelsesdokument'}
</Button>

Expand Down Expand Up @@ -425,11 +420,10 @@ export const EditEtterlevelseDokumentasjonModal = (props: EditEtterlevelseDokume
)}

<Block display="flex" justifyContent="flex-end">
<Button kind="secondary" type="button" onClick={() => setIsEtterlevelseDokumntasjonerModalOpen(false)}>
<Button variant="secondary" onClick={() => setIsEtterlevelseDokumntasjonerModalOpen(false)}>
Avbryt
</Button>
<Button
marginLeft={true}
type="button"
onClick={() => {
submitForm()
Expand All @@ -444,7 +438,7 @@ export const EditEtterlevelseDokumentasjonModal = (props: EditEtterlevelseDokume
</Formik>
</ModalBody>
</Modal>
</Block>
</div>
)
}
export default EditEtterlevelseDokumentasjonModal
121 changes: 64 additions & 57 deletions apps/frontend/src/components/export/ExportEtterlevelseModal.tsx
Original file line number Diff line number Diff line change
@@ -1,76 +1,56 @@
import { faFileWord } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { Block } from 'baseui/block'
import { Button, KIND } from 'baseui/button'
import { SIZE } from 'baseui/input'
import React, { useState } from 'react'
import { env } from '../../util/env'
import CustomizedModal from '../common/CustomizedModal'
import { borderColor, borderRadius, borderStyle, borderWidth, marginZero } from '../common/Style'
import { ModalBody, ModalHeader } from 'baseui/modal'
import { Select, Value } from 'baseui/select'
import { customSelectOverrides } from '../krav/Edit/RegelverkEdit'
import { codelist, ListName } from '../../services/Codelist'
import axios from 'axios'
import { theme } from '../../util'
import { ettlevColors } from '../../util/theme'
import { KIND as NKIND, Notification } from 'baseui/notification'
import { ParagraphMedium } from 'baseui/typography'
import { Loader } from '@navikt/ds-react'
import { Button, Loader, Modal, Select } from '@navikt/ds-react'

type ExportEtterlevelseModalProps = {
etterlevelseDokumentasjonId: String
}

export const ExportEtterlevelseModal = (props: ExportEtterlevelseModalProps) => {
const [isExportModalOpen, setIsExportModalOpen] = useState<boolean>(false)
const [selectedTema, setSelectedTema] = useState<Value>([])
const [isLoading, setIsLoading] = useState<boolean>(false)
const [errorMessage, setErrorMessage] = useState<String>('')
const [valgtTema, setValgtTema] = useState<string>('')

return (
<Block display="flex" alignItems="center" marginRight="12px">
<Button kind={KIND.tertiary} size={SIZE.compact} onClick={() => setIsExportModalOpen(true)}>
<Block marginRight="6px">
<FontAwesomeIcon icon={faFileWord} />
</Block>
<Block>Eksporter</Block>
<div>
<Button variant="tertiary" size="small" onClick={() => setIsExportModalOpen(true)}>
Eksporter til Word
</Button>

<CustomizedModal
isOpen={isExportModalOpen}
<Modal
open={isExportModalOpen}
onClose={() => {
setValgtTema('')
setIsExportModalOpen(false)
}}
size="default"
overrides={{
Dialog: {
style: {
width: '375px',
boxShadow: '0 2px 4px -1px rgba(0, 0, 0, .2), 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 3px 0 rgba(0, 0, 0, .12)',
...borderRadius('4px'),
},
},
}}
header={{ heading: 'Eksporter etterlevelse' }}
>
<ModalHeader>Eksporter etterlevelse</ModalHeader>
<ModalBody>
<Modal.Body>
{isLoading ? (
<Block display="flex" justifyContent="center" width="100%">
<Loader size="large" />
</Block>
) : (
<Block>
<Select
placeholder="Velg et tema for eksportering"
options={codelist.getParsedOptions(ListName.TEMA)}
value={selectedTema}
onChange={({ value }) => {
setErrorMessage('')
setSelectedTema(value)
}}
overrides={customSelectOverrides}
/>
<div className="flex flex-col gap-4">
<Select label="Velg et tema for eksportering" onChange={(ev) => setValgtTema(ev.currentTarget.value)} value={valgtTema}>
<option key="" value="">
Velg tema
</option>
{codelist.getParsedOptions(ListName.TEMA).map((opt) => (
<option key={`option_${opt.id}`} value={opt.id}>
{opt.label}
</option>
))}
</Select>
{errorMessage && (
<Block width="100%" marginTop="16px">
<Notification
Expand All @@ -96,18 +76,23 @@ export const ExportEtterlevelseModal = (props: ExportEtterlevelseModalProps) =>
</Notification>
</Block>
)}
<Block marginTop="16px" display="flex" $style={{ justifyContent: 'flex-end', paddingTop: '16px' }}>
<div className="flex gap-2">
<Button
kind={KIND.primary}
size={SIZE.compact}
variant="tertiary"
onClick={() => {
setValgtTema('')
setIsExportModalOpen(false)
}}
>
Avbryt
</Button>
<Button
variant="secondary"
onClick={() => {
;(async () => {
setIsLoading(true)
setErrorMessage('')
const exportUrl =
selectedTema.length > 0
? `${env.backendBaseUrl}/export/etterlevelsedokumentasjon?etterlevelseDokumentasjonId=${props.etterlevelseDokumentasjonId}&temakode=${selectedTema[0].id}`
: `${env.backendBaseUrl}/export/etterlevelsedokumentasjon?etterlevelseDokumentasjonId=${props.etterlevelseDokumentasjonId}`
const exportUrl = `${env.backendBaseUrl}/export/etterlevelsedokumentasjon?etterlevelseDokumentasjonId=${props.etterlevelseDokumentasjonId}`

axios
.get(exportUrl)
Expand All @@ -122,17 +107,39 @@ export const ExportEtterlevelseModal = (props: ExportEtterlevelseModalProps) =>
})()
}}
>
<Block marginRight="6px">
<FontAwesomeIcon icon={faFileWord} />
</Block>
<Block>{selectedTema.length > 0 ? 'Eksporter med valgt tema' : 'Eksporter alle tema'}</Block>
Eksporter alle tema
</Button>
</Block>
</Block>
<Button
variant="primary"
disabled={valgtTema == ''}
onClick={() => {
;(async () => {
setIsLoading(true)
setErrorMessage('')
const exportUrl = `${env.backendBaseUrl}/export/etterlevelsedokumentasjon?etterlevelseDokumentasjonId=${props.etterlevelseDokumentasjonId}&temakode=${valgtTema}`

axios
.get(exportUrl)
.then(() => {
window.location.href = exportUrl
setIsLoading(false)
setIsExportModalOpen(false)
})
.catch((e) => {
setErrorMessage(e.response.data.message)
setIsLoading(false)
})
})()
}}
>
Eksporter valgt tema
</Button>
</div>
</div>
)}
</ModalBody>
</CustomizedModal>
</Block>
</Modal.Body>
</Modal>
</div>
)
}

Expand Down
Loading

0 comments on commit 6fc6bd8

Please sign in to comment.