Skip to content

Commit

Permalink
fix(signature-collection): Fix collection and signature active state (#…
Browse files Browse the repository at this point in the history
…16206)

* Fix collection and signature active state

* fix collection isActive

---------

Co-authored-by: albinagu <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 30, 2024
1 parent 4db48bd commit ce108c5
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 10 deletions.
58 changes: 57 additions & 1 deletion libs/clients/signature-collection/src/clientConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,60 @@
"/Admin/Medmaelalisti/{ID}/ToggleList": {
"patch": {
"tags": ["Admin"],
"summary": "Toggle fyrir úrvinnslu lokið virkni í stjórnborði",
"parameters": [
{
"name": "ID",
"in": "path",
"description": "",
"required": true,
"schema": { "type": "integer", "format": "int32" }
},
{
"name": "shouldToggle",
"in": "query",
"description": "Optional. Sjálfkrafa true en hægt að setja false ef á að halda úrvinnslu áfram",
"schema": { "type": "boolean", "default": true }
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MedmaelalistiBaseDTO"
}
}
}
},
"204": { "description": "No Content" },
"400": {
"description": "Bad Request",
"content": {
"application/json": { "schema": { "type": "string" } }
}
}
}
}
},
"/Admin/Medmaelalisti/{ID}/LockList": {
"patch": {
"tags": ["Admin"],
"summary": "Lokar meðmælalista sem skilað hefur verið inn",
"parameters": [
{
"name": "ID",
"in": "path",
"description": "ID meðmælalista sem á að loka",
"required": true,
"schema": { "type": "integer", "format": "int32" }
},
{
"name": "shouldLock",
"in": "query",
"description": "Optional. Sjálfkrafa true en hægt að setja false ef á að opna aftur á lokaðan lista",
"schema": { "type": "boolean", "default": true }
}
],
"responses": {
Expand Down Expand Up @@ -1197,6 +1245,11 @@
"in": "path",
"required": true,
"schema": { "type": "integer", "format": "int32" }
},
{
"name": "shouldToggle",
"in": "query",
"schema": { "type": "boolean", "default": true }
}
],
"responses": {
Expand Down Expand Up @@ -2075,6 +2128,7 @@
"dagsetningLokar": { "type": "string", "format": "date-time" },
"lokadHandvirkt": { "type": "boolean" },
"listaLokad": { "type": "boolean" },
"urvinnslaLokid": { "type": "boolean" },
"svaedi": { "$ref": "#/components/schemas/SvaediDTO" }
},
"additionalProperties": false
Expand All @@ -2091,6 +2145,7 @@
"dagsetningLokar": { "type": "string", "format": "date-time" },
"lokadHandvirkt": { "type": "boolean" },
"listaLokad": { "type": "boolean" },
"urvinnslaLokid": { "type": "boolean" },
"svaedi": { "$ref": "#/components/schemas/SvaediDTO" },
"fjoldiMedmaela": { "type": "integer", "format": "int32" },
"frambod": { "$ref": "#/components/schemas/FrambodBaseDTO" },
Expand Down Expand Up @@ -2273,7 +2328,8 @@
"medmaeliTegundNr": { "type": "integer", "format": "int32" },
"bladsidaNr": { "type": "integer", "format": "int32" },
"dagsetning": { "type": "string", "format": "date-time" },
"valid": { "type": "boolean" }
"valid": { "type": "boolean" },
"locked": { "type": "boolean" }
},
"additionalProperties": false
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ describe('MyService', () => {
listId: '123',
signee: { name: '', nationalId: '', address: '' },
valid: false,
locked: false,
},
],
requirementsMet: true,
Expand Down Expand Up @@ -151,6 +152,7 @@ describe('MyService', () => {
},
dagsetningLokar: new Date('01.01.2199'),
listaLokad: false,
urvinnslaLokid: false,
frambodNafn: 'Jónsframboð',
listiNafn: 'Jónslisti',
},
Expand All @@ -171,6 +173,7 @@ describe('MyService', () => {
},
dagsetningLokar: new Date('01.01.1900'),
listaLokad: true,
urvinnslaLokid: true,
frambodNafn: 'Jónsframboð',
listiNafn: 'Jónslisti',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,18 +375,17 @@ export class SignatureCollectionClientService {
)
const isExtended = list.endTime > endTime
const signedThisPeriod = signature.isInitialType === !isExtended
const canUnsignDigital = isPresidential ? signature.isDigital : true
const canUnsignInvalid = isPresidential ? signature.valid : true
return {
signedDate: signature.created,
isDigital: signature.isDigital,
pageNumber: signature.pageNumber,
isValid: signature.valid,
canUnsign:
canUnsignDigital &&
canUnsignInvalid &&
list.active &&
signedThisPeriod,
canUnsign: isPresidential
? signature.isDigital &&
signature.valid &&
list.active &&
signedThisPeriod
: !signature.locked,
...list,
} as SignedList
}),
Expand Down
4 changes: 2 additions & 2 deletions libs/clients/signature-collection/src/lib/types/list.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ export const mapList = (
const area = mapArea(areas)
const numberOfSignatures = list.fjoldiMedmaela ?? 0

const isActive = endTime > new Date()
const isActive = !list.listaLokad
const isExtended = endTime > collection.sofnunEnd
const reviewed = list.lokadHandvirkt ?? false
const reviewed = list.urvinnslaLokid ?? false

return {
id: list.id?.toString() ?? '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface Signature {
pageNumber?: number
valid: boolean
isInitialType: boolean
locked: boolean
}
const digitalTypes = [1, 3]
const initialTypes = [1, 2]
Expand All @@ -40,5 +41,6 @@ export const mapSignature = (signature: MedmaeliDTO): Signature => {
pageNumber:
!isDigital && signature.bladsidaNr ? signature.bladsidaNr : undefined,
valid: signature.valid ?? true,
locked: signature.locked ?? false,
}
}

0 comments on commit ce108c5

Please sign in to comment.