Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/navikt/etterlevelse into …
Browse files Browse the repository at this point in the history
…ds-maillog
  • Loading branch information
PaulMartinKokseter committed Oct 25, 2023
2 parents 7443d86 + 211bdaf commit 8c4f434
Show file tree
Hide file tree
Showing 25 changed files with 405 additions and 555 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ public EtterlevelseArkivResponse toResponse() {
}

public InstanceId convertToInstanceId() {
return new InstanceId(id.toString(), behandlingId + "-" + webSakNummer);
return new InstanceId(id.toString(), behandlingId + "-" + webSakNummer, "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class InstanceId {

private String id;
private String name;
private String number;

@JsonIgnore
public UUID getIdAsUUID() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ public EtterlevelseResponse toResponse() {
}

public InstanceId convertToInstanceId() {
return new InstanceId(id.toString(), behandlingId + "-" + kravId());
return new InstanceId(id.toString(), behandlingId + "-" + kravId(), "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ public EtterlevelseDokumentasjonResponse toResponse() {
}

public InstanceId convertToInstanceId() {
return new InstanceId(id.toString(), title);
return new InstanceId(id.toString(), title, "E" + etterlevelseNummer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@ public KravResponse toResponse() {
}

public InstanceId convertToInstanceId() {
return new InstanceId(id.toString(), navn);
return new InstanceId(id.toString(), navn, "K" + kravNummer + "." + kravVersjon);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public KravPrioriteringResponse toResponse() {
}

public InstanceId convertToInstanceId() {
return new InstanceId(id.toString(), kravId());
return new InstanceId(id.toString(), kravId(), "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public VirkemiddelResponse toResponse() {
}

public InstanceId convertToInstanceId() {
return new InstanceId(id.toString(), navn);
return new InstanceId(id.toString(), navn, "");
}

}
20 changes: 9 additions & 11 deletions apps/frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ export const LoginButton = () => {
// updates window.location on navigation
const location = useLocation()
return (
<Link underline={false} href={loginUrl(location, location.pathname)}>
<InternalHeader.Button as={Link} className="text-white" underline={false} >
<strong>Logg inn</strong>
</InternalHeader.Button>
</Link>
<InternalHeader.Button as={Link} href={loginUrl(location, location.pathname)} className="text-white" underline={false} >
Logg inn
</InternalHeader.Button>
)
}

Expand All @@ -54,7 +52,7 @@ const LoggedInHeader = () => {

const kravPages = user.isKraveier()
? [{ label: 'Forvalte og opprette krav', href: '/kravliste' },
//{ label: 'Forvalte og opprette virkemiddel', href: '/virkemiddelliste' }
//{ label: 'Forvalte og opprette virkemiddel', href: '/virkemiddelliste' }
]
: []
const adminPages = user.isAdmin()
Expand Down Expand Up @@ -186,14 +184,14 @@ const Header = (props: { noSearchBar?: boolean; noLoginButton?: boolean }) => {
<div className="w-full">
<div role="banner" className="w-full flex justify-center">
<SkipToContent />
<div className="w-full">
<InternalHeader >
<InternalHeader className="w-full justify-center items-center">
<div className="w-full flex max-w-7xl">
<InternalHeader.Title href="/">
Etterlevelse
</InternalHeader.Title>
<Spacer />
{!props.noSearchBar && (
<div className="flex w-full max-w-xl justify-center items-center" role="search">
<div className="flex w-full max-w-xl " role="search">
<MainSearch />
</div>
)}
Expand All @@ -204,8 +202,8 @@ const Header = (props: { noSearchBar?: boolean; noLoginButton?: boolean }) => {
{user.isLoggedIn() && <LoggedInHeader />}
</div>
)}
</InternalHeader>
</div>
</div>
</InternalHeader>
</div>
{systemVarsel && systemVarsel.meldingStatus === MeldingStatus.ACTIVE && (
<div
Expand Down
176 changes: 93 additions & 83 deletions apps/frontend/src/components/admin/CodeList/CodeListStyledTable.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import * as React from 'react'
import { useEffect, useState } from 'react'
import { Block } from 'baseui/block'
import { KIND, SIZE as ButtonSize } from 'baseui/button'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faEdit, faGhost, faTrash } from '@fortawesome/free-solid-svg-icons'
import UpdateCodeListModal from './ModalUpdateCodeList'
import DeleteCodeListModal from './ModalDeleteCodeList'
import { Usage } from './CodeListUsage'
import { AuditButton } from '../audit/AuditButton'
import { Code, CodeListFormValues, CodeUsage } from '../../../services/Codelist'
import { Code, CodeListFormValues, CodeUsage, LovCodeRelevans } from '../../../services/Codelist'
import { deleteCodelist, getCodelistUsage, updateCodelist } from '../../../api/CodelistApi'
import { Cell, Row, Table } from '../../common/Table'
import Button from '../../common/Button'
import { theme } from '../../../util'
import { BodyLong, Button, SortState, Table, Tooltip } from '@navikt/ds-react'
import { handleSort } from '../../../util/handleTableSort'
import { DocPencilIcon, GlassesIcon, TrashIcon } from '@navikt/aksel-icons'

type TableCodelistProps = {
tableData: Code[]
Expand All @@ -27,9 +23,11 @@ const CodeListTable = ({ tableData, refresh }: TableCodelistProps) => {
const [errorOnResponse, setErrorOnResponse] = React.useState(null)
const [usage, setUsage] = useState<CodeUsage>()

const [sort, setSort] = useState<SortState>()

useEffect(() => {
if (showUsage && selectedCode) {
;(async () => {
; (async () => {
setUsage(undefined)
const usage = await getCodelistUsage(selectedCode.list, selectedCode.code)
setUsage(usage)
Expand Down Expand Up @@ -60,81 +58,93 @@ const CodeListTable = ({ tableData, refresh }: TableCodelistProps) => {
}
}

let sortedData = tableData

const comparator = (a: Code, b: Code, orderBy: string) => {
switch (orderBy) {
case 'code':
return a.code.localeCompare(b.code)
case 'navn':
return (a.shortName || '').localeCompare(b.shortName || '')
default:
return 0
}
}

sortedData = sortedData.sort((a, b) => {
if (sort) {
return sort.direction === 'ascending'
? comparator(b, a, sort.orderBy)
: comparator(a, b, sort.orderBy)
}
return 1
})

return (
<>
<Table
emptyText="koder"
data={tableData}
config={{
useDefaultStringCompare: true,
initialSortColumn: 'code',
}}
headers={[
{ title: 'code', column: 'code', small: true },
{ title: 'Navn', column: 'shortName', small: true },
{ title: 'Beskrivelse', column: 'description', $style: { width: '55%' } },
{ title: '', small: true },
]}
render={(table) =>
table.data.map((row, index) => (
<Row key={index}>
<Cell small $style={{ wordBreak: 'break-word' }}>
{row.code}
</Cell>
<Cell small>{row.shortName}</Cell>
<Cell $style={{ width: '55%' }}>
<Block display="flex" flexDirection="column" width="100%">
<Block>{row.description}</Block>
<Block $style={{ wordBreak: 'break-word' }} color={theme.colors.negative300}>
{row.data && JSON.stringify(row.data, null, 1)}
</Block>
</Block>
</Cell>
<Cell small>
<Block display="flex" justifyContent="flex-end" width="100%">
<Button
tooltip={'Bruk'}
size={ButtonSize.compact}
kind={row === selectedCode && showUsage ? KIND.primary : KIND.tertiary}
onClick={() => {
setSelectedCode(row)
setShowUsage(true)
}}
label={'Vis bruk'}
>
<FontAwesomeIcon icon={faGhost} />
</Button>
<AuditButton id={`${row.list}-${row.code}`} kind={KIND.tertiary} />
<Button
tooltip={'Rediger'}
size={ButtonSize.compact}
kind={KIND.tertiary}
onClick={() => {
setSelectedCode(row)
setShowEditModal(true)
}}
label={'Rediger'}
>
<FontAwesomeIcon icon={faEdit} />
</Button>
<Button
tooltip={'Slett'}
size={ButtonSize.compact}
kind={KIND.tertiary}
onClick={() => {
setSelectedCode(row)
setShowDeleteModal(true)
}}
label={'Slett'}
>
<FontAwesomeIcon icon={faTrash} />
</Button>
</Block>
</Cell>
</Row>
))
}
/>
<Table size="large" zebraStripes sort={sort} onSortChange={(sortKey) => handleSort(sort, setSort, sortKey)}>
<Table.Header>
<Table.Row>
<Table.ColumnHeader sortKey="code" className="w-[15%]" sortable>Code</Table.ColumnHeader>
<Table.ColumnHeader sortKey="navn" className="w-[25%]" sortable>Navn</Table.ColumnHeader>
<Table.ColumnHeader className="w-1/2 break-all" >Beskrivelse</Table.ColumnHeader>
<Table.ColumnHeader ></Table.ColumnHeader>
</Table.Row>
</Table.Header>
<Table.Body>
{sortedData.map((code: Code, i) => {
return (
<Table.Row key={i + '_' + code.shortName}>
<Table.DataCell className="w-[15%] break-all" scope="row">{code.code}</Table.DataCell>
<Table.DataCell >{code.shortName}</Table.DataCell>
<Table.DataCell className="w-1/2 break-all">
<div>
<BodyLong>{code.description}</BodyLong>
<div className="break-words text-icon-warning">
{code.data && JSON.stringify(code.data, null, 1)}
</div>
</div>
</Table.DataCell>
<Table.DataCell>
<div className="flex justify-end w-full">
<Tooltip content="Vis bruk">
<Button
variant={code === selectedCode && showUsage ? 'primary' : 'tertiary'}
onClick={() => {
setSelectedCode(code)
setShowUsage(true)
}}
icon={<GlassesIcon title="Vis bruk" />}
/>
</Tooltip>
<AuditButton id={`${code.list}-${code.code}`} variant="tertiary" />
<Tooltip content="Rediger">
<Button
variant="tertiary"
onClick={() => {
setSelectedCode(code)
setShowEditModal(true)
}}
icon={<DocPencilIcon title="Rediger" />}
/>
</Tooltip>
<Tooltip content="Slett">
<Button
variant="tertiary"
onClick={() => {
setSelectedCode(code)
setShowDeleteModal(true)
}}
icon={<TrashIcon title="Slett" />}
/>
</Tooltip>
</div>
</Table.DataCell>
</Table.Row>
)
})}
</Table.Body>
</Table>

{showEditModal && selectedCode && (
<UpdateCodeListModal
Expand All @@ -144,7 +154,7 @@ const CodeListTable = ({ tableData, refresh }: TableCodelistProps) => {
code: selectedCode.code ?? '',
shortName: selectedCode.shortName ?? '',
description: selectedCode.description ?? '',
data: selectedCode.data || {},
data: selectedCode.data ? selectedCode.data.relevantFor ? selectedCode.data : { ...selectedCode.data, relevantFor: LovCodeRelevans.KRAV_OG_VIRKEMIDDEL } : { relevantFor: LovCodeRelevans.KRAV_OG_VIRKEMIDDEL },
}}
isOpen={showEditModal}
onClose={() => {
Expand Down
Loading

0 comments on commit 8c4f434

Please sign in to comment.