Browse Source

Update joining a study

master
Joshua Rubingh 5 months ago
parent
commit
3655ed0619
  1. 22
      components/contributors/list.vue
  2. 3
      locales/en.js
  3. 2
      locales/nl.js
  4. 128
      pages/researchStudies/_studyId/contributors/join.vue

22
components/contributors/list.vue

@ -42,7 +42,11 @@ @@ -42,7 +42,11 @@
{{ item.researcher.faculty.name }}
</span>
<span v-else>
{{ $t('page.researchStudies.studyId.contributors.table.no_faculty') }}
{{
$t(
'page.researchStudies.studyId.contributors.index.table.no_faculty'
)
}}
</span>
</template>
@ -52,7 +56,9 @@ @@ -52,7 +56,9 @@
</span>
<span v-else>
{{
$t('page.researchStudies.studyId.contributors.table.no_university')
$t(
'page.researchStudies.studyId.contributors.index.table.no_university'
)
}}
</span>
</template>
@ -65,6 +71,10 @@ @@ -65,6 +71,10 @@
{{ item.active }}
</template>
<template #item.invitePending="{ item }">
{{ item.invite_pending }}
</template>
<template #item.actions="{ item }">
<contributors-delete-button
v-if="isAdmin"
@ -152,6 +162,14 @@ export default { @@ -152,6 +162,14 @@ export default {
),
value: 'active',
},
{
text: $t(
'page.researchStudies.studyId.contributors.index.table.heading.invite_pending'
),
value: 'invite_pending',
},
{
text: '',
value: 'actions',

3
locales/en.js

@ -51,6 +51,7 @@ export default { @@ -51,6 +51,7 @@ export default {
role: 'Role',
owner: 'Owner',
active: 'Active',
invite_pending: 'Invite pending',
},
no_faculty: 'Unknown faculty',
no_university: 'Unknown university',
@ -61,6 +62,8 @@ export default { @@ -61,6 +62,8 @@ export default {
},
join: {
title: 'Join this research study',
failed: 'We could not validate this invitation. Please contact the study owner/admin.',
waiting_message: 'Please wait while we check your invitation.'
},
contributorId: {
detail: {

2
locales/nl.js

@ -61,6 +61,8 @@ export default { @@ -61,6 +61,8 @@ export default {
},
join: {
title: 'Doe mee aan dit onderzoek',
failed: 'We kunnen deze uitnodging niet valideren. Neem contact op met de studie eigenaar/beheerder.',
waiting_message: 'Even geduld a.u.b. terwijl we uw uitnodiging controleren.'
},
contributorId: {
detail: {

128
pages/researchStudies/_studyId/contributors/join.vue

@ -7,9 +7,31 @@ @@ -7,9 +7,31 @@
{{ studyData.name }}
</ui-rug-card-title>
<v-card-text class="flex-row mb-6">
<pre>{{ studyData }}</pre>
<v-btn elevation="2" @click="check_invitation"></v-btn>
<v-card-text class="flex-row mb-6 white text-center">
<br />
<h1>
{{
$t(
'page.researchStudies.studyId.contributors.join.waiting_message'
)
}}
</h1>
<br />
<v-progress-circular
v-if="joinState == -1"
indeterminate
size="48"
color="primary"
></v-progress-circular>
<v-alert v-if="joinState == 0" type="error">
{{ errorMessage }}
</v-alert>
<v-alert v-if="joinState == 1" type="success">
{{ $t('page.researchStudies.studyId.contributors.join.success') }}
</v-alert>
</v-card-text>
</v-col>
</v-row>
@ -17,14 +39,8 @@ @@ -17,14 +39,8 @@
</template>
<script>
/*
import { mapActions } from 'vuex'
import Form from '@/lib/form'
*/
export default {
async asyncData({ store, route }) {
// const data = {
const studyId = route.params.studyId
const jwtToken = route.query.key
@ -34,81 +50,53 @@ export default { @@ -34,81 +50,53 @@ export default {
studyId,
jwtToken,
studyData: store.getters['studies/getActiveStudy'],
// store.getters['studies/getJoinInvitationMessage'],
}
},
data() {
const $t = this.$t.bind(this)
return {
/*
message: {
Bla: 'test',
},
*/
/*
formData: {
first_name: undefined,
last_name: undefined,
email: undefined,
role: null,
studyId: this.$route.params.studyId,
},
form: new Form({
form: 'formData',
vm: this,
action: this['studies/inviteContributor'],
schema: {
type: 'object',
properties: {
first_name: {
type: 'string',
minLength: 2,
maxLength: 100,
},
last_name: {
type: 'string',
minLength: 2,
maxLength: 100,
},
email: {
type: 'string',
format: 'email',
},
role: {
type: 'string',
},
},
required: ['first_name', 'last_name', 'email', 'role'],
},
onResponse() {
const studyId = this.vm.$route.params.studyId
this.vm.$router.push(
this.vm.localePath(`/researchStudies/${studyId}/contributors`)
)
},
}),
*/
joinState: -1,
errorMessage: $t('page.researchStudies.studyId.contributors.join.failed'),
}
},
head() {
const $t = this.$t.bind(this)
return {
title: $t('page.researchStudies.studyId.contributors.join.title'),
}
},
mounted() {
this.check_invitation(this.$store)
},
methods: {
// ...mapActions(['studies/inviteContributor']),
async check_invitation({ store }) {
console.log(this)
// Dit kan een 404 veroorzaken, maar dat zou dan als melding terug moeten komen, en niet een 404 pagina tonen.....
await this.$store.dispatch('studies/joinContributor', {
studyId: this.studyId,
key: this.jwtToken,
check_invitation() {
return new Promise((resolve, reject) => {
this.$store
.dispatch('studies/joinContributor', {
studyId: this.studyId,
key: this.jwtToken,
})
.then(
(response) => {
// TODO: Should we force a reload after success??
// const joinSuccess = this.$store.getters['studies/getJoinInvitationMessage']
this.joinState = 1
},
(error) => {
if (error.response.status !== 404) {
// Here we get the error(s) back from the API server in an array
this.errorMessage = error.response.data
.map((message) => {
return message.message
})
.join('<br />')
}
this.joinState = 0
}
)
})
const joinSuccess = store.getters['studies/getJoinInvitationMessage']
console.log(joinSuccess)
},
},
}

Loading…
Cancel
Save