Skip to content

Commit 02b51c4

Browse files
authored
Add published_by and modified_by to child document table and display them in UI (#7611)
1 parent 954b526 commit 02b51c4

File tree

25 files changed

+238
-96
lines changed

25 files changed

+238
-96
lines changed

frontend/src/e2e-test/dev-api/fixtures.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,10 +1794,12 @@ export class Fixture {
17941794
createdBy: systemInternalUser.id,
17951795
status: 'DRAFT',
17961796
modifiedAt: HelsinkiDateTime.now(),
1797-
contentModifiedAt: HelsinkiDateTime.now(),
1798-
contentModifiedBy: null,
1797+
modifiedBy: systemInternalUser.id,
1798+
contentLockedAt: HelsinkiDateTime.now(),
1799+
contentLockedBy: null,
17991800
documentKey: null,
18001801
publishedAt: null,
1802+
publishedBy: null,
18011803
content: {
18021804
answers: [
18031805
{
@@ -1834,7 +1836,6 @@ export class Fixture {
18341836
publishedAt
18351837
})
18361838
},
1837-
18381839
withPublishedContent(publishedContent: DocumentContent | null) {
18391840
return Fixture.childDocument({
18401841
...value,

frontend/src/e2e-test/generated/api-types.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,19 @@ export interface DevChildDocument {
436436
answeredBy: EvakaUserId | null
437437
childId: PersonId
438438
content: DocumentContent
439-
contentModifiedAt: HelsinkiDateTime
440-
contentModifiedBy: EmployeeId | null
439+
contentLockedAt: HelsinkiDateTime
440+
contentLockedBy: EmployeeId | null
441441
created: HelsinkiDateTime | null
442442
createdBy: EvakaUserId
443443
decision: DevChildDocumentDecision | null
444444
decisionMaker: EmployeeId | null
445445
documentKey: string | null
446446
id: ChildDocumentId
447447
modifiedAt: HelsinkiDateTime
448+
modifiedBy: EvakaUserId
448449
processId: CaseProcessId | null
449450
publishedAt: HelsinkiDateTime | null
451+
publishedBy: EvakaUserId | null
450452
publishedContent: DocumentContent | null
451453
status: DocumentStatus
452454
templateId: DocumentTemplateId
@@ -1429,7 +1431,7 @@ export function deserializeJsonDevChildDocument(json: JsonOf<DevChildDocument>):
14291431
...json,
14301432
answeredAt: (json.answeredAt != null) ? HelsinkiDateTime.parseIso(json.answeredAt) : null,
14311433
content: deserializeJsonDocumentContent(json.content),
1432-
contentModifiedAt: HelsinkiDateTime.parseIso(json.contentModifiedAt),
1434+
contentLockedAt: HelsinkiDateTime.parseIso(json.contentLockedAt),
14331435
created: (json.created != null) ? HelsinkiDateTime.parseIso(json.created) : null,
14341436
decision: (json.decision != null) ? deserializeJsonDevChildDocumentDecision(json.decision) : null,
14351437
modifiedAt: HelsinkiDateTime.parseIso(json.modifiedAt),

frontend/src/e2e-test/specs/0_citizen/citizen-child-documents.spec.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ beforeEach(async () => {
8585
documentIdVasu = (
8686
await Fixture.childDocument({
8787
childId: child.id,
88-
templateId: templateIdVasu
88+
templateId: templateIdVasu,
89+
publishedBy: evakaUserId(decisionMaker.id)
8990
})
9091
.withPublishedAt(mockedNow)
9192
.withPublishedContent({
@@ -111,7 +112,8 @@ beforeEach(async () => {
111112
documentIdHojks = (
112113
await Fixture.childDocument({
113114
childId: child.id,
114-
templateId: templateIdHojks
115+
templateId: templateIdHojks,
116+
publishedBy: evakaUserId(decisionMaker.id)
115117
})
116118
.withPublishedAt(mockedNow)
117119
.withPublishedContent({
@@ -137,7 +139,8 @@ beforeEach(async () => {
137139
documentIdPed = (
138140
await Fixture.childDocument({
139141
templateId: templateIdPed,
140-
childId: child.id
142+
childId: child.id,
143+
publishedBy: evakaUserId(decisionMaker.id)
141144
})
142145
.withModifiedAt(mockedNow)
143146
.withPublishedAt(mockedNow)
@@ -167,7 +170,8 @@ beforeEach(async () => {
167170
templateId: templateIdDecision,
168171
childId: child.id,
169172
status: 'COMPLETED',
170-
decisionMaker: decisionMaker.id
173+
decisionMaker: decisionMaker.id,
174+
publishedBy: evakaUserId(decisionMaker.id)
171175
})
172176
.withModifiedAt(mockedNow)
173177
.withPublishedAt(mockedNow)
@@ -282,6 +286,7 @@ describe('Citizen child documents listing page', () => {
282286
status: 'COMPLETED',
283287
content: documentContent,
284288
publishedAt: mockedNow,
289+
publishedBy: evakaUserId(unitSupervisor.id),
285290
publishedContent: documentContent,
286291
answeredAt: mockedNow,
287292
answeredBy: evakaUserId(unitSupervisor.id)
@@ -339,6 +344,7 @@ describe('Citizen child documents editor page', () => {
339344
status: 'CITIZEN_DRAFT',
340345
content: documentContent,
341346
publishedAt: mockedNow,
347+
publishedBy: evakaUserId(decisionMaker.id),
342348
publishedContent: documentContent
343349
}).save()
344350

@@ -416,6 +422,7 @@ describe('Citizen child documents editor page', () => {
416422
status: 'CITIZEN_DRAFT',
417423
content: documentContent,
418424
publishedAt: mockedNow,
425+
publishedBy: evakaUserId(decisionMaker.id),
419426
publishedContent: documentContent
420427
}).save()
421428

frontend/src/e2e-test/specs/5_employee/child-documents.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ describe('Employee - Child documents', () => {
653653
status: 'COMPLETED',
654654
content,
655655
publishedAt,
656+
publishedBy: evakaUserId(unitSupervisor.id),
656657
publishedContent: content,
657658
answeredAt,
658659
answeredBy: evakaUserId(guardian.id)
@@ -936,6 +937,7 @@ describe('Employee - Child documents', () => {
936937
answers: []
937938
},
938939
publishedAt: now,
940+
publishedBy: evakaUserId(director.id),
939941
publishedContent: {
940942
answers: []
941943
},
@@ -960,6 +962,7 @@ describe('Employee - Child documents', () => {
960962
answers: []
961963
},
962964
publishedAt: now,
965+
publishedBy: evakaUserId(director.id),
963966
publishedContent: {
964967
answers: []
965968
},
@@ -1065,6 +1068,7 @@ describe('Employee - Child documents', () => {
10651068
answers: []
10661069
},
10671070
publishedAt: now,
1071+
publishedBy: evakaUserId(director.id),
10681072
publishedContent: {
10691073
answers: []
10701074
},

frontend/src/employee-frontend/components/child-documents/ChildDocumentEditView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const ConcurrentEditWarning = React.memo(function ConcurrentEditWarning({
124124

125125
const errorText = currentLock
126126
? i18n.childInformation.childDocuments.editor.lockedErrorDetailed(
127-
currentLock.modifiedByName,
127+
currentLock.lockedByName,
128128
currentLock.opensAt.toLocalTime().format()
129129
)
130130
: i18n.childInformation.childDocuments.editor.lockedError

frontend/src/employee-frontend/components/child-information/ChildDocuments.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
} from 'lib-common/query'
3131
import type { UUID } from 'lib-common/types'
3232
import DisableableLink from 'lib-components/atoms/DisableableLink'
33+
import Tooltip from 'lib-components/atoms/Tooltip'
3334
import { AddButtonRow } from 'lib-components/atoms/buttons/AddButton'
3435
import { IconOnlyButton } from 'lib-components/atoms/buttons/IconOnlyButton'
3536
import { SelectF } from 'lib-components/atoms/dropdowns/Select'
@@ -112,9 +113,27 @@ const InternalChildDocuments = React.memo(function InternalChildDocuments({
112113
<span>{document.templateName}</span>
113114
</DisableableLink>
114115
</WiderTd>
115-
<Td>{document.modifiedAt.format()}</Td>
116+
<Td>
117+
<Tooltip
118+
tooltip={i18n.childInformation.childDocuments.table.modifiedBy(
119+
document.modifiedBy
120+
)}
121+
>
122+
{document.modifiedAt.format()}
123+
</Tooltip>
124+
</Td>
116125
<Td data-qa="document-published-at">
117-
{document.publishedAt?.format() ?? '-'}
126+
{document.publishedAt && document.publishedBy ? (
127+
<Tooltip
128+
tooltip={i18n.childInformation.childDocuments.table.publishedBy(
129+
document.publishedBy
130+
)}
131+
>
132+
{document.publishedAt.format()}
133+
</Tooltip>
134+
) : (
135+
'-'
136+
)}
118137
</Td>
119138
<StatusTd data-qa="document-status">
120139
<ChildDocumentStateChip

frontend/src/lib-common/generated/api-types/document.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ export interface ChildDocumentSummary {
237237
decisionMaker: EvakaUser | null
238238
id: ChildDocumentId
239239
modifiedAt: HelsinkiDateTime
240+
modifiedBy: string
240241
publishedAt: HelsinkiDateTime | null
242+
publishedBy: string | null
241243
status: DocumentStatus
242244
templateId: DocumentTemplateId
243245
templateName: string
@@ -401,8 +403,8 @@ export interface DocumentTemplateSummary {
401403
* Generated from fi.espoo.evaka.document.childdocument.DocumentWriteLock
402404
*/
403405
export interface DocumentWriteLock {
404-
modifiedBy: EvakaUserId
405-
modifiedByName: string
406+
lockedBy: EvakaUserId
407+
lockedByName: string
406408
opensAt: HelsinkiDateTime
407409
}
408410

frontend/src/lib-customizations/defaults/employee/i18n/fi.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,9 +882,11 @@ export const fi = {
882882
status: 'Tila',
883883
open: 'Avaa asiakirja',
884884
modified: 'Muokattu',
885+
modifiedBy: (name: string) => `Muokkaaja ${name}.`,
885886
unit: 'Yksikkö',
886887
valid: 'Voimassa',
887888
published: 'Julkaistu',
889+
publishedBy: (name: string) => `Julkaisija ${name}.`,
888890
sent: 'Lähetetty',
889891
notSent: 'Ei lähetetty',
890892
answered: 'Vastattu',

service/src/integrationTest/kotlin/fi/espoo/evaka/caseprocess/MigrationTest.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -827,9 +827,11 @@ class MigrationTest : FullApplicationTest(resetDbBeforeEach = true) {
827827
content = DocumentContent(emptyList()),
828828
publishedContent = null,
829829
modifiedAt = created,
830-
contentModifiedAt = created,
831-
contentModifiedBy = employee.id,
830+
modifiedBy = employee.evakaUserId,
831+
contentLockedAt = created,
832+
contentLockedBy = employee.id,
832833
publishedAt = null,
834+
publishedBy = null,
833835
)
834836

835837
db.transaction { tx ->
@@ -886,9 +888,11 @@ class MigrationTest : FullApplicationTest(resetDbBeforeEach = true) {
886888
content = DocumentContent(emptyList()),
887889
publishedContent = DocumentContent(emptyList()),
888890
modifiedAt = modified,
889-
contentModifiedAt = modified,
890-
contentModifiedBy = employee.id,
891+
modifiedBy = employee.evakaUserId,
892+
contentLockedAt = modified,
893+
contentLockedBy = employee.id,
891894
publishedAt = modified,
895+
publishedBy = employee.evakaUserId,
892896
documentKey = "foobar123",
893897
)
894898

service/src/integrationTest/kotlin/fi/espoo/evaka/document/archival/ArchiveChildDocumentServiceIntegrationTest.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ class ArchiveChildDocumentServiceIntegrationTest : FullApplicationTest(resetDbBe
190190
)
191191

192192
val emptyContent = DocumentContent(emptyList())
193+
val employee = DevEmployee()
194+
tx.insert(employee)
193195
val childDocument =
194196
DevChildDocument(
195197
id = documentId,
@@ -199,9 +201,11 @@ class ArchiveChildDocumentServiceIntegrationTest : FullApplicationTest(resetDbBe
199201
content = emptyContent,
200202
publishedContent = emptyContent,
201203
modifiedAt = now,
202-
contentModifiedAt = now,
203-
contentModifiedBy = null,
204+
modifiedBy = employee.evakaUserId,
205+
contentLockedAt = now,
206+
contentLockedBy = null,
204207
publishedAt = now,
208+
publishedBy = employee.evakaUserId,
205209
answeredAt = null,
206210
answeredBy = null,
207211
processId = process.id,

0 commit comments

Comments
 (0)