Skip to content

Commit

Permalink
feat(signature-collection): New endpoint to update signature page num…
Browse files Browse the repository at this point in the history
…ber (#16163)

* New endpoint to update signature page number

* Fix tests after client update

---------

Co-authored-by: albinagu <[email protected]>
Co-authored-by: kksteini <[email protected]>
  • Loading branch information
3 people authored Sep 26, 2024
1 parent 4cb5e52 commit 60a4187
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IsNumber } from 'class-validator'
import { Field, InputType } from '@nestjs/graphql'
import { SignatureCollectionSignatureIdInput } from './signatureId.input'

@InputType()
export class SignatureCollectionSignatureUpdateInput extends SignatureCollectionSignatureIdInput {
@Field()
@IsNumber()
pageNumber!: number
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { SignatureCollectionCandidateIdInput } from './dto/candidateId.input'
import { SignatureCollectionCanSignFromPaperInput } from './dto/canSignFromPaper.input'
import { ReasonKey } from '@island.is/clients/signature-collection'
import { CanSignInfo } from './models/canSignInfo.model'
import { SignatureCollectionSignatureUpdateInput } from './dto/signatureUpdate.input'

@UseGuards(IdsUserGuard, ScopesGuard)
@Scopes(AdminPortalScope.signatureCollectionProcess)
Expand Down Expand Up @@ -241,4 +242,16 @@ export class SignatureCollectionAdminResolver {
): Promise<SignatureCollectionSignature[]> {
return this.signatureCollectionService.compareLists(input, user)
}

@Mutation(() => SignatureCollectionSuccess)
@Audit()
async signatureCollectionAdminUpdatePaperSignaturePageNumber(
@CurrentUser() user: User,
@Args('input') input: SignatureCollectionSignatureUpdateInput,
): Promise<SignatureCollectionSuccess> {
return this.signatureCollectionService.updateSignaturePageNumber(
user,
input,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { SignatureCollectionListBulkUploadInput } from './dto/bulkUpload.input'
import { SignatureCollectionSlug } from './models/slug.model'
import { SignatureCollectionListStatus } from './models/status.model'
import { SignatureCollectionIdInput } from './dto/collectionId.input'
import { SignatureCollectionSignatureUpdateInput } from './dto/signatureUpdate.input'

@Injectable()
export class SignatureCollectionAdminService {
Expand Down Expand Up @@ -176,4 +177,15 @@ export class SignatureCollectionAdminService {
user,
)
}

async updateSignaturePageNumber(
user: User,
input: SignatureCollectionSignatureUpdateInput,
): Promise<SignatureCollectionSuccess> {
return await this.signatureCollectionClientService.updateSignaturePageNumber(
user,
input.signatureId,
input.pageNumber,
)
}
}
79 changes: 78 additions & 1 deletion libs/clients/signature-collection/src/clientConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,44 @@
}
}
},
"/Admin/Medmaeli/{ID}/UpdateBls": {
"patch": {
"tags": ["Admin"],
"summary": "Uppfærir blaðsíðunúmer skriflegs meðmælis",
"description": "Aðeins m0gulegt fyrir skrifleg meðmæli",
"parameters": [
{
"name": "ID",
"in": "path",
"description": "ID meðmælis sem á að uppfæra",
"required": true,
"schema": { "type": "integer", "format": "int32" }
},
{
"name": "blsNr",
"in": "query",
"description": "Nýtt blaðsíðutal",
"schema": { "type": "integer", "format": "int32" }
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/MedmaeliBaseDTO" }
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": { "schema": { "type": "string" } }
}
}
}
}
},
"/Admin/Medmaelalisti/{ID}": {
"delete": {
"tags": ["Admin"],
Expand Down Expand Up @@ -1722,6 +1760,44 @@
}
}
},
"/Medmaeli/{ID}/UpdateBls": {
"patch": {
"tags": ["Medmaeli"],
"summary": "Uppfærir blaðsíðunúmer skriflegs meðmælis",
"description": "Aðeins m0gulegt fyrir skrifleg meðmæli",
"parameters": [
{
"name": "ID",
"in": "path",
"description": "ID meðmælis sem á að uppfæra",
"required": true,
"schema": { "type": "integer", "format": "int32" }
},
{
"name": "blsNr",
"in": "query",
"description": "Nýtt blaðsíðutal",
"schema": { "type": "integer", "format": "int32" }
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/MedmaeliBaseDTO" }
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": { "schema": { "type": "string" } }
}
}
}
}
},
"/Tegund/Kosning": {
"get": {
"tags": ["Tegund"],
Expand Down Expand Up @@ -2202,11 +2278,12 @@
"additionalProperties": false
},
"SvaediDTO": {
"required": ["nafn", "svaediTegundLysing"],
"required": ["nafn", "nr", "svaediTegundLysing"],
"type": "object",
"properties": {
"id": { "type": "integer", "format": "int32" },
"nafn": { "type": "string" },
"nr": { "type": "string" },
"svaediTegund": { "type": "integer", "format": "int32" },
"svaediTegundLysing": { "type": "string" },
"fjoldi": { "type": "integer", "format": "int32" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,23 @@ export class SignatureCollectionAdminClientService {
return { success: false, reasons: [ReasonKey.DeniedByService] }
}
}

async updateSignaturePageNumber(
auth: Auth,
signatureId: string,
pageNumber: number,
): Promise<Success> {
try {
const res = await this.getApiWithAuth(
this.signatureApi,
auth,
).medmaeliIDUpdateBlsPatch({
iD: parseInt(signatureId),
blsNr: pageNumber,
})
return { success: res.bladsidaNr === pageNumber }
} catch {
return { success: false }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const sofnun: MedmaelasofnunExtendedDTO[] = [
id: 123,
sofnunStart: new Date('01.01.1900'),
sofnunEnd: new Date('01.01.2199'),
svaedi: [{ id: 123, nafn: 'Svæði', svaediTegundLysing: 'Lýsing' }],
svaedi: [{ id: 123, nafn: 'Svæði', svaediTegundLysing: 'Lýsing', nr: '1' }],
frambodList: [{ id: 123, kennitala: '0101010119', nafn: 'Jónsframboð' }],
kosning: {
id: 123,
Expand All @@ -40,7 +40,7 @@ const sofnun: MedmaelasofnunExtendedDTO[] = [
},
]
const sofnunUser: EinstaklingurKosningInfoDTO = {
svaedi: { id: 123, nafn: 'Svæði', svaediTegundLysing: 'Lýsing' },
svaedi: { id: 123, nafn: 'Svæði', svaediTegundLysing: 'Lýsing', nr: '1' },
kennitala: '0101302399',
maFrambod: true,
maFrambodInfo: { aldur: true, rikisfang: true, kennitala: '0101302399' },
Expand Down Expand Up @@ -143,7 +143,12 @@ describe('MyService', () => {
kosningTegund: 'Forsetakosning',
},
frambod: { id: 123, kennitala: '0101016789', nafn: 'Jónsframboð' },
svaedi: { id: 123, nafn: 'Svæði', svaediTegundLysing: 'Lýsing' },
svaedi: {
id: 123,
nafn: 'Svæði',
svaediTegundLysing: 'Lýsing',
nr: '1',
},
dagsetningLokar: new Date('01.01.2199'),
listaLokad: false,
frambodNafn: 'Jónsframboð',
Expand All @@ -158,7 +163,12 @@ describe('MyService', () => {
kosningTegund: 'Forsetakosning',
},
frambod: { id: 321, kennitala: '0202026789', nafn: 'Jónsframboð' },
svaedi: { id: 321, nafn: 'Svæði', svaediTegundLysing: 'Lýsing' },
svaedi: {
id: 321,
nafn: 'Svæði',
svaediTegundLysing: 'Lýsing',
nr: '1',
},
dagsetningLokar: new Date('01.01.1900'),
listaLokad: true,
frambodNafn: 'Jónsframboð',
Expand Down Expand Up @@ -243,7 +253,12 @@ describe('MyService', () => {
sofnunEnd: new Date('01.01.2199'),
},
frambod: { id: 123, kennitala: '0101016789', nafn: 'Jónsframboð' },
svaedi: { id: 123, nafn: 'Svæði', svaediTegundLysing: 'Lýsing' },
svaedi: {
id: 123,
nafn: 'Svæði',
svaediTegundLysing: 'Lýsing',
nr: '1',
},
dagsetningLokar: new Date('01.01.2199'),
listaLokad: false,
frambodNafn: 'Jónsframboð',
Expand Down

0 comments on commit 60a4187

Please sign in to comment.