Skip to content

Commit

Permalink
Select name used for formal name
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Oct 14, 2023
1 parent 47272c7 commit a308ce8
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 11 deletions.
9 changes: 5 additions & 4 deletions myconext-gui/src/components/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
document.body.classList.add("modal-open");
})
onDestroy(()=> {
onDestroy(() => {
document.body.classList.remove("modal-open");
})
Expand Down Expand Up @@ -94,9 +94,10 @@
</div>

<div class="options">
<Button className="cancel" onClick={cancel}
label={I18n.t("modal.cancel")}/>

{#if cancel}
<Button className="cancel" onClick={cancel}
label={I18n.t("modal.cancel")}/>
{/if}
<Button onClick={submit}
warning={warning}
href={href}
Expand Down
25 changes: 25 additions & 0 deletions myconext-gui/src/components/ValidatedData.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script>
import I18n from "i18n-js";
export let institution = {};
</script>
<style lang="scss">
div.validated-data {
margin: 20px 0 10px 20px;
}
</style>
<div class="validated-data">
<table>
<thead/>
<tbody>
<tr>
<td class="attribute">{I18n.t("profile.givenName")}:</td>
<td>{institution.givenName}</td>
</tr>
<tr>
<td>{I18n.t("profile.familyName")}:</td>
<td>{institution.familyName}</td>
</tr>
</tbody>
</table>
</div>
5 changes: 4 additions & 1 deletion myconext-gui/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ I18n.translations.en = {
preferInstitution: "Prefer institution",
preferredInstitutionConfirmation: "Do you want to use the information received from {{name}} to be the default information to share with services?",
preferred: "{{name}] is now your preferred source of information",
expired: "Expired"
expired: "Expired",
newInstitution: "Your identity has been verified",
newInstitutionInfo: "We have replaced the following information with the verified data from your institution:",
ok: "Continue"
},
eppnAlreadyLinked: {
header: "Connection not added!",
Expand Down
5 changes: 4 additions & 1 deletion myconext-gui/src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ I18n.translations.nl = {
preferInstitution: "Voorkeursinstelling",
preferredInstitutionConfirmation: "Wil je de informatie die we van {{name}} ontvangen, gebruiken als standaardinformatie om met diensten te delen?",
preferred: "{{name}] is nu de bron van je persoonsinformatie",
expired: "Verlopen"
expired: "Verlopen",
newInstitution: "Je identiteit is geverifïeerd",
newInstitutionInfo: "We hebben de volgende informatie overschreven met de geverifïeerde gegevens:",
ok: "Ga door"
},
eppnAlreadyLinked: {
header: "Koppeling niet gemaakt!",
Expand Down
23 changes: 20 additions & 3 deletions myconext-gui/src/routes/PersonalInfo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import {isEmpty} from "../utils/utils";
import InstitutionRole from "../components/InstitutionRole.svelte";
import {institutionName} from "../utils/services";
import ValidatedData from "../components/ValidatedData.svelte";
let eduIDLinked = false;
Expand All @@ -32,8 +33,10 @@
let showModal = false;
let showDeleteInstitutionModal = false;
let showNewInstitutionModal = false;
let showPreferredInstitutionModal = false;
let selectedInstitution;
let newInstitution = {};
const preferInstitution = (showConfirmation, linkedAccount) => {
preferredInstitution = linkedAccount;
Expand Down Expand Up @@ -161,12 +164,17 @@
onMount(() => {
refresh();
if (($user.linkedAccounts || []).length > 1) {
if (($user.linkedAccounts || []).length > 0) {
const urlSearchParams = new URLSearchParams(window.location.search);
const schacHomeOrganization = urlSearchParams.get("institution");
const institution = $user.linkedAccounts.find(ins => ins.schacHomeOrganization === schacHomeOrganization);
if (institution && !isEmpty(institution.givenName) && !isEmpty(institution.familyName)) {
preferInstitution(true, institution);
newInstitution = institution;
if (($user.linkedAccounts || []).length === 1) {
showNewInstitutionModal = true;
} else {
preferInstitution(true, institution);
}
}
}
});
Expand Down Expand Up @@ -348,7 +356,7 @@
{/if}
</div>
<EditField label={I18n.t("profile.chosenName")}
firstValue={$user.chosenName || $user.givenName}
firstValue={$user.chosenName}
editableByUser={true}
saveLabel={I18n.t("edit.save")}
editMode={chosenNameEditMode}
Expand Down Expand Up @@ -442,6 +450,15 @@
cancel={() => showPreferredInstitutionModal = false}
question={I18n.t("profile.preferredInstitutionConfirmation", {name: institutionName(preferredInstitution)})}
title={I18n.t("profile.preferInstitution")}>
<ValidatedData institution={newInstitution}/>
</Modal>
{/if}

{#if showNewInstitutionModal}
<Modal submit={() => showNewInstitutionModal = false}
question={I18n.t("profile.newInstitutionInfo")}
confirmTitle={I18n.t("profile.ok")}
title={I18n.t("profile.newInstitution")}>
<ValidatedData institution={newInstitution}/>
</Modal>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class UserResponse implements Serializable {

private final String id;
private final String email;
private final String callName;
private final String chosenName;
private final String givenName;
private final String familyName;
private final boolean usePassword;
Expand All @@ -43,7 +43,7 @@ public UserResponse(User user,
IdPMetaDataResolver idPMetaDataResolver) {
this.id = user.getId();
this.email = user.getEmail();
this.callName = user.getChosenName();
this.chosenName = user.getChosenName();
this.givenName = user.getGivenName();
this.familyName = user.getFamilyName();
this.schacHomeOrganization = user.getSchacHomeOrganization();
Expand Down

0 comments on commit a308ce8

Please sign in to comment.