Skip to content

Commit

Permalink
Merge pull request #646 from Opetushallitus/feature/OPHKIOS-15
Browse files Browse the repository at this point in the history
OTR(Frontend & Backend): OPHKIOS-15 Add assurance given field to interpreter
  • Loading branch information
lket authored Mar 7, 2024
2 parents 2ef6480 + aa15814 commit 3f42c0b
Show file tree
Hide file tree
Showing 19 changed files with 88 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public record ClerkInterpreterDTO(
String country,
String extraInformation,
@NonNull List<String> regions,
@NonNull ClerkInterpreterQualificationsDTO qualifications
@NonNull ClerkInterpreterQualificationsDTO qualifications,
@NonNull Boolean isAssuranceGiven
)
implements ClerkInterpreterDTOCommonFields {}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ public interface ClerkInterpreterDTOCommonFields {
String extraInformation();

List<String> regions();

Boolean isAssuranceGiven();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public record ClerkInterpreterCreateDTO(
@Size(max = 255) String country,
@Size(max = 4096) String extraInformation,
@NonNull @NotNull List<String> regions,
@NonNull @NotEmpty @Valid List<ClerkQualificationCreateDTO> qualifications
@NonNull @NotEmpty @Valid List<ClerkQualificationCreateDTO> qualifications,
@NonNull @NotNull Boolean isAssuranceGiven
)
implements ClerkInterpreterDTOCommonFields {
public ClerkInterpreterCreateDTO {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public record ClerkInterpreterUpdateDTO(
@Size(max = 255) String town,
@Size(max = 255) String country,
@Size(max = 4096) String extraInformation,
@NonNull @NotNull List<String> regions
@NonNull @NotNull List<String> regions,
@NonNull @NotNull Boolean isAssuranceGiven
)
implements ClerkInterpreterDTOCommonFields {
public ClerkInterpreterUpdateDTO {
Expand Down
3 changes: 3 additions & 0 deletions backend/otr/src/main/java/fi/oph/otr/model/Interpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ public class Interpreter extends BaseEntity {

@OneToMany(mappedBy = "interpreter")
private List<Region> regions = new ArrayList<>();

@Column(name = "is_assurance_given", nullable = false)
private boolean isAssuranceGiven;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public interface QualificationRepository extends BaseRepository<Qualification> {
" WHERE q.beginDate <= CURRENT_DATE" +
" AND CURRENT_DATE <= q.endDate" +
" AND q.permissionToPublish = true" +
" AND i.isAssuranceGiven = true" +
" AND q.deletedAt IS NULL" +
" AND i.deletedAt IS NULL" +
" GROUP BY i.id, q.fromLang, q.toLang"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ private Optional<ClerkInterpreterDTO> createClerkInterpreterDTO(
.extraInformation(interpreter.getExtraInformation())
.regions(regions)
.qualifications(interpreterQualificationsDTO)
.isAssuranceGiven(interpreter.isAssuranceGiven())
.build()
);
}
Expand Down Expand Up @@ -308,6 +309,7 @@ private void copyFromInterpreterDTO(final Interpreter interpreter, final ClerkIn
interpreter.setOtherContactInformation(dto.otherContactInfo());
interpreter.setPermissionToPublishOtherContactInfo(dto.permissionToPublishOtherContactInfo());
interpreter.setExtraInformation(dto.extraInformation());
interpreter.setAssuranceGiven(dto.isAssuranceGiven());

final List<Region> regions = dto
.regions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,5 +526,12 @@
<where>name = 'OTHER'</where>
</delete>
</changeSet>
<changeSet id="2024-02-26-add-is-assurance-given" author="lket">
<addColumn tableName="interpreter">
<column name="is_assurance_given" type="BOOL" defaultValueBoolean="true">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>

</databaseChangeLog>
1 change: 1 addition & 0 deletions backend/otr/src/test/java/fi/oph/otr/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static MeetingDate meetingDate(final LocalDate date) {
public static Interpreter interpreter() {
final Interpreter interpreter = new Interpreter();
interpreter.setOnrId(UUID.randomUUID().toString());
interpreter.setAssuranceGiven(true);
interpreter.setPermissionToPublishEmail(true);
interpreter.setPermissionToPublishPhone(true);
interpreter.setPermissionToPublishOtherContactInfo(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ public void testCreateInterpreter() {
.permissionToPublishPhone(true)
.otherContactInfo("other")
.permissionToPublishOtherContactInfo(false)
.isAssuranceGiven(true)
.street("Tulkintie 44")
.postalCode("00100")
.town("Helsinki")
Expand Down Expand Up @@ -459,6 +460,7 @@ public void testCreateInterpreterWithExistingStudent() {
.permissionToPublishEmail(false)
.permissionToPublishPhone(true)
.permissionToPublishOtherContactInfo(false)
.isAssuranceGiven(true)
.regions(List.of("01"))
.qualifications(
List.of(
Expand Down Expand Up @@ -526,6 +528,7 @@ public void testCreateInterpreterFailsForUnknownRegion() {
.permissionToPublishEmail(false)
.permissionToPublishPhone(true)
.permissionToPublishOtherContactInfo(false)
.isAssuranceGiven(true)
.regions(List.of("01", "This region does not exist"))
.qualifications(
List.of(
Expand Down Expand Up @@ -569,6 +572,7 @@ public void testCreateInterpreterFailsForOnrIdAndIndividualisedMismatch() {
.permissionToPublishEmail(false)
.permissionToPublishPhone(true)
.permissionToPublishOtherContactInfo(false)
.isAssuranceGiven(true)
.regions(List.of("01"))
.qualifications(
List.of(
Expand Down Expand Up @@ -674,6 +678,7 @@ public void testUpdateInterpreter() {
.permissionToPublishPhone(false)
.otherContactInfo("[email protected]")
.permissionToPublishOtherContactInfo(true)
.isAssuranceGiven(true)
.extraInformation("extra")
.regions(List.of("01"))
.build();
Expand Down Expand Up @@ -742,6 +747,7 @@ public void testUpdateInterpreterWithDuplicateRegions() {
.permissionToPublishPhone(false)
.otherContactInfo("[email protected]")
.permissionToPublishOtherContactInfo(true)
.isAssuranceGiven(true)
.extraInformation("extra")
.regions(List.of("01", "01", "02"))
.build();
Expand Down Expand Up @@ -803,6 +809,7 @@ public void testUpdateInterpreterFailsForUnknownRegion() {
.permissionToPublishPhone(false)
.otherContactInfo("[email protected]")
.permissionToPublishOtherContactInfo(true)
.isAssuranceGiven(true)
.extraInformation("extra")
.regions(List.of("This region code does not exist"))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ public void setup() {
.identityNumber("3")
.email("[email protected]")
.phoneNumber("+3583456789")
.build(),
"7",
PersonalData
.builder()
.lastName("Ilmarinen")
.firstName("Seppo")
.nickName("Seppo")
.identityNumber("7")
.email("[email protected]")
.phoneNumber("+358121234")
.build()
)
);
Expand All @@ -109,6 +119,7 @@ public void testOnlyPublishingPermittedAreReturned() {
final Interpreter interpreter4 = createInterpreter("4");
final Interpreter interpreter5 = createInterpreterDeleted();
final Interpreter interpreter6 = createInterpreter("6");
final Interpreter interpreter7 = createInterpreter("7");

final MeetingDate meetingDate = Factory.meetingDate();
entityManager.persist(meetingDate);
Expand All @@ -118,6 +129,9 @@ public void testOnlyPublishingPermittedAreReturned() {
interpreter1.setOtherContactInformation("oikeustulkki.company@invalid");
interpreter2.setPermissionToPublishPhone(false);

// Should be missing from public listing
interpreter7.setAssuranceGiven(false);

createRegion(interpreter2, "01");
createRegion(interpreter2, "02");
createRegion(interpreter3, "03");
Expand Down Expand Up @@ -149,6 +163,15 @@ public void testOnlyPublishingPermittedAreReturned() {
nextWeek,
true
);
final Qualification qualification71 = createQualification(
interpreter7,
meetingDate,
"FI",
"EN",
today,
tomorrow,
true
);

// Hidden, duplicate of qualification 21
createQualification(interpreter2, meetingDate, "FI", "SE", yesterday, nextWeek, true);
Expand Down
4 changes: 4 additions & 0 deletions frontend/packages/otr/public/i18n/en-GB/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"description": "You will lose the changes you have made.",
"title": "Do you want to exit the modification view?"
},
"caveats": {
"isNotAssuranceGiven": "The registrations are not visible in the public list!"
},
"fields": {
"country": "Country",
"email": "Email",
Expand All @@ -75,6 +78,7 @@
"address": "Address",
"contactInformation": "Contact details",
"extraInformation": "Additional information",
"isAssuranceGiven": "Declaration given",
"personalInformation": "Personal data",
"regions": "Operating area"
},
Expand Down
4 changes: 4 additions & 0 deletions frontend/packages/otr/public/i18n/fi-FI/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"description": "Menetät tekemäsi muutokset.",
"title": "Haluatko poistua muokkausnäkymästä?"
},
"caveats": {
"isNotAssuranceGiven": "Rekisteröinnit eivät ole näkyvissä julkisessa listauksessa!"
},
"fields": {
"country": "Maa",
"email": "Sähköpostiosoite",
Expand All @@ -75,6 +78,7 @@
"address": "Osoite",
"contactInformation": "Yhteystiedot",
"extraInformation": "Lisätiedot",
"isAssuranceGiven": "Vakuutus annettu",
"personalInformation": "Henkilötiedot",
"regions": "Toiminta-alue"
},
Expand Down
4 changes: 4 additions & 0 deletions frontend/packages/otr/public/i18n/sv-SE/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"description": "Du kommer att förlora dina ändringar.",
"title": "Vill du lämna redigeringsvyn?"
},
"caveats": {
"isNotAssuranceGiven": "Registreringarna syns inte i den offentliga listan!"
},
"fields": {
"country": "Land",
"email": "E-postadress",
Expand All @@ -75,6 +78,7 @@
"address": "Adress",
"contactInformation": "Kontaktuppgifter",
"extraInformation": "Ytterligare information",
"isAssuranceGiven": "Försäkran har getts",
"personalInformation": "Personuppgifter",
"regions": "Verksamhetsområde"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import RadioGroup from '@mui/material/RadioGroup';
import TextField from '@mui/material/TextField';
import { ChangeEvent, useMemo, useState } from 'react';
import {
CustomSwitch,
CustomTextField,
CustomTextFieldProps,
H2,
Expand Down Expand Up @@ -429,6 +430,22 @@ export const ClerkInterpreterDetailsFields = ({
onChange={onFieldChange('regions')}
disabled={isViewMode}
/>
<div className="rows gapped-xs">
<H3>{t('header.isAssuranceGiven')}</H3>
<CustomSwitch
dataTestId="clerk-interpreter__basic-information__assurance-switch"
disabled={isViewMode}
onChange={onFieldChange('isAssuranceGiven')}
value={interpreterBasicInformation?.isAssuranceGiven}
leftLabel={translateCommon('no')}
rightLabel={translateCommon('yes')}
errorLabel={
!interpreterBasicInformation?.isAssuranceGiven && (
<InfoText>{t('caveats.isNotAssuranceGiven')}</InfoText>
)
}
/>
</div>
</>
);
};
1 change: 1 addition & 0 deletions frontend/packages/otr/src/interfaces/clerkInterpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ClerkInterpreterTextFields {

export interface ClerkInterpreterBasicInformation
extends ClerkInterpreterTextFields {
isAssuranceGiven: boolean;
permissionToPublishEmail: boolean;
permissionToPublishPhone: boolean;
permissionToPublishOtherContactInfo: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const initialState: ClerkNewInterpreterState = {
town: '',
country: '',
extraInformation: '',
isAssuranceGiven: false,
permissionToPublishEmail: false,
permissionToPublishPhone: false,
permissionToPublishOtherContactInfo: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const clerkInterpreter = {
firstName: 'Anneli Anna',
nickName: 'Anneli',
email: '[email protected]',
isAssuranceGiven: true,
permissionToPublishEmail: true,
phoneNumber: '+358401000011',
permissionToPublishPhone: true,
Expand Down
4 changes: 4 additions & 0 deletions frontend/packages/otr/src/utils/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class SerializationUtils {
static serializeClerkNewInterpreter(interpreter: ClerkNewInterpreter) {
const {
onrId,
isAssuranceGiven,
isIndividualised,
hasIndividualisedAddress,
permissionToPublishEmail,
Expand All @@ -58,6 +59,7 @@ export class SerializationUtils {
return {
...textFields,
onrId,
isAssuranceGiven,
isIndividualised,
hasIndividualisedAddress,
permissionToPublishEmail,
Expand All @@ -74,6 +76,7 @@ export class SerializationUtils {
const {
id,
version,
isAssuranceGiven,
isIndividualised,
hasIndividualisedAddress,
permissionToPublishEmail,
Expand All @@ -90,6 +93,7 @@ export class SerializationUtils {
...textFields,
id,
version,
isAssuranceGiven,
isIndividualised,
hasIndividualisedAddress,
permissionToPublishEmail,
Expand Down

0 comments on commit 3f42c0b

Please sign in to comment.