-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,225 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/pages/acceptInvitation/AcceptInvitationCreateUserAccount.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<template> | ||
<div> | ||
<div class="userInvitation__reviewPanel__item"> | ||
<h4 class="userInvitation__reviewPanel__item__header">Email Address</h4> | ||
<div class="userInvitation__reviewPanel__item__value"> | ||
{{ store.email }} | ||
</div> | ||
</div> | ||
</div> | ||
<br /> | ||
<field-text | ||
:label="t('user.username')" | ||
:value="fields.username" | ||
name="username" | ||
size="large" | ||
:all-errors="sectionErrors" | ||
@change="updateField" | ||
/> | ||
<br /> | ||
<field-text | ||
:label="t('user.password')" | ||
:value="fields.password" | ||
name="password" | ||
input-type="password" | ||
size="large" | ||
:all-errors="sectionErrors" | ||
@change="updateField" | ||
/> | ||
<div> | ||
<field-show-ensuring-link | ||
primary-locale="en" | ||
name="privacyStatement" | ||
:value="fields.privacyStatement" | ||
:all-errors="sectionErrors" | ||
:options="options" | ||
@change="updateField" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import {defineProps, ref, computed} from 'vue'; | ||
import {useTranslation} from '@/composables/useTranslation'; | ||
import FieldText from '@/components/Form/fields/FieldText.vue'; | ||
import FieldShowEnsuringLink from '@/components/Form/fields/FieldShowEnsuringLink.vue'; | ||
import {useAcceptInvitationPageStore} from './AcceptInvitationPageStore'; | ||
const props = defineProps({ | ||
validateFields: {type: Array, required: true}, | ||
}); | ||
const {t} = useTranslation(); | ||
const fields = ref({username: '', password: '', privacyStatement: false}); | ||
const options = ref([ | ||
{ | ||
value: true, | ||
label: | ||
'Yes, I agree to have my data collected and stored according to the <button>Privacy Statement</button>.', | ||
}, | ||
]); | ||
const store = useAcceptInvitationPageStore(); | ||
function updateField(fieldName, b, fieldValue) { | ||
fields.value[fieldName] = fieldValue; | ||
store.updateAcceptInvitationPayload(fieldName, fieldValue); | ||
} | ||
const sectionErrors = computed(() => { | ||
return props.validateFields.reduce((obj, key) => { | ||
if (store.errors[key]) { | ||
obj[key] = store.errors[key]; | ||
} | ||
return obj; | ||
}, {}); | ||
}); | ||
</script> | ||
<style lang="less"> | ||
.userInvitation__reviewPanel__item { | ||
&:last-child { | ||
border-bottom: none; | ||
} | ||
} | ||
.userInvitation__reviewPanel__item__header { | ||
margin: 0; | ||
font-size: 0.875rem; | ||
line-height: 1.5rem; | ||
} | ||
.userInvitation__reviewPanel__item__value { | ||
margin-bottom: 1rem; | ||
font-size: 0.875rem; | ||
line-height: 1.5rem; | ||
} | ||
div fieldset { | ||
border: none !important; | ||
} | ||
</style> |
74 changes: 74 additions & 0 deletions
74
src/pages/acceptInvitation/AcceptInvitationCreateUserForms.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<template> | ||
<div> | ||
<div class="userInvitation__reviewPanel__item"> | ||
<h4 class="userInvitation__reviewPanel__item__header">Email Address</h4> | ||
<div class="userInvitation__reviewPanel__item__value"> | ||
{{ store.email }} | ||
</div> | ||
</div> | ||
</div> | ||
<div> | ||
<div class="userInvitation__reviewPanel__item"> | ||
<h4 class="userInvitation__reviewPanel__item__header">ORCID iD</h4> | ||
<div class="userInvitation__reviewPanel__item__value"> | ||
{{ | ||
store.acceptinvitationPayload.orcid | ||
? store.acceptinvitationPayload.orcid | ||
: t('invitation.orcid.acceptInvitation.message') | ||
}} | ||
<icon | ||
v-if="store.acceptinvitationPayload.orcid" | ||
icon="orcid" | ||
:inline="true" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
<pkp-form | ||
v-bind="userForm" | ||
class="userInvitation__stepForm" | ||
@set="updateUserDetailsForm" | ||
></pkp-form> | ||
</template> | ||
|
||
<script setup> | ||
import {defineProps, computed} from 'vue'; | ||
import PkpForm from '@/components/Form/Form.vue'; | ||
import {useForm} from '@/composables/useForm'; | ||
import {useAcceptInvitationPageStore} from './AcceptInvitationPageStore'; | ||
const props = defineProps({ | ||
form: {type: Object, required: true}, | ||
validateFields: {type: Array, required: true}, | ||
}); | ||
const store = useAcceptInvitationPageStore(); | ||
function updateUserDetailsForm(a, {fields}, c, d) { | ||
if (fields) { | ||
fields.forEach((field) => { | ||
if (store.acceptinvitationPayload[field.name] !== field.value) { | ||
store.updateAcceptInvitationPayload(field.name, field.value); | ||
} | ||
}); | ||
} | ||
} | ||
const { | ||
form: userForm, | ||
connectWithPayload, | ||
connectWithErrors, | ||
} = useForm(props.form); | ||
connectWithPayload(store.acceptinvitationPayload); | ||
const sectionErrors = computed(() => { | ||
return props.validateFields.reduce((obj, key) => { | ||
if (store.errors[key]) { | ||
obj[key] = store.errors[key]; | ||
} | ||
return obj; | ||
}, {}); | ||
}); | ||
connectWithErrors(sectionErrors); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<template> | ||
<h1 ref="wrapper" class="app__pageHeading"> | ||
{{ pageTitle }} | ||
</h1> | ||
<p> | ||
{{ pageTitleDescription }} | ||
</p> | ||
</template> | ||
|
||
<script setup> | ||
import {defineProps} from 'vue'; | ||
defineProps({ | ||
pageTitle: {type: String, required: true}, | ||
pageTitleDescription: {type: String, required: true}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {Primary, Controls, Stories, Meta, ArgTypes} from '@storybook/blocks'; | ||
|
||
import * as AcceptInvitationPage from './AcceptInvitationPage.stories.js'; | ||
|
||
<Meta of={AcceptInvitationPage} /> | ||
|
||
# User Invitation page | ||
|
||
<ArgTypes /> |
70 changes: 70 additions & 0 deletions
70
src/pages/acceptInvitation/AcceptInvitationPage.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import AcceptInvitationPage from './AcceptInvitationPage.vue'; | ||
import {http, HttpResponse} from 'msw'; | ||
import PageInitConfigMock from './mocks/pageInitConfig'; | ||
import invitationMock from './mocks/invitationMock'; | ||
|
||
export default { | ||
title: 'Pages/AcceptInvitation', | ||
component: AcceptInvitationPage, | ||
}; | ||
|
||
export const Init = { | ||
render: (args) => ({ | ||
components: {AcceptInvitationPage}, | ||
setup() { | ||
return {args}; | ||
}, | ||
template: '<AcceptInvitationPage v-bind="args" />', | ||
}), | ||
parameters: { | ||
msw: { | ||
handlers: [ | ||
http.get( | ||
'https://mock/index.php/publicknowledge/api/v1/invitations/65/key/8aqc3W', | ||
async (r) => { | ||
return HttpResponse.json(invitationMock, {status: 200}); | ||
}, | ||
), | ||
http.post( | ||
'https://mock/index.php/publicknowledge/api/v1/invitations/65/key/8aqc3W/refine', | ||
async ({request}) => { | ||
const postBody = await request.json(); | ||
let errors = {}; | ||
|
||
if (!Object.keys(postBody).includes('username')) { | ||
errors['username'] = ['This field is required']; | ||
} | ||
if (!Object.keys(postBody).includes('password')) { | ||
errors['password'] = ['This field is required']; | ||
} | ||
if (!Object.keys(postBody).includes('affiliation')) { | ||
errors['affiliation'] = ['This field is required']; | ||
} | ||
if (!Object.keys(postBody).includes('country')) { | ||
errors['country'] = ['This field is required']; | ||
} | ||
Object.keys(postBody).forEach((element) => { | ||
if (element !== 'orcid') { | ||
if (postBody[element] === '') { | ||
errors[element] = ['This field is required']; | ||
} | ||
} | ||
}); | ||
|
||
if (Object.keys(errors).length > 0) { | ||
return HttpResponse.json(errors, {status: 422}); | ||
} | ||
return HttpResponse.json(postBody, {status: 200}); | ||
}, | ||
), | ||
http.post( | ||
'https://mock/index.php/publicknowledge/api/v1/invitations/65/key/8aqc3W/finalize', | ||
async (r) => { | ||
return HttpResponse.json(invitationMock, {status: 201}); | ||
}, | ||
), | ||
], | ||
}, | ||
}, | ||
args: PageInitConfigMock, | ||
}; |
Oops, something went wrong.