From 567ee7a27b6c6d7175aef33e40697acae04621b8 Mon Sep 17 00:00:00 2001 From: dschreij Date: Fri, 5 Feb 2021 08:59:40 +0100 Subject: [PATCH] #51. Partial fix to prevent crashing in studies list --- .../Studies/CurrentStudies/CurrentStudies.vue | 10 +------ .../Studies/StudiesList/StudiesList.vue | 27 ++++++++++--------- .../pages/dashboard/studies/_id/index.vue | 9 +++---- resources/pages/dashboard/studies/index.vue | 6 +++++ 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/resources/components/Studies/CurrentStudies/CurrentStudies.vue b/resources/components/Studies/CurrentStudies/CurrentStudies.vue index f9d4321..377e63c 100644 --- a/resources/components/Studies/CurrentStudies/CurrentStudies.vue +++ b/resources/components/Studies/CurrentStudies/CurrentStudies.vue @@ -60,15 +60,7 @@ export default { async loadStudies () { this.loading = true try { - const response = await this.Study.fetch() - // Attach studies to local representation of logged in user. - this.User.insertOrUpdate({ - where: this.$auth.user.id, - data: { - id: this.$auth.user.id, - studies: response.entities.studies - } - }) + await this.Study.fetch() } catch (e) { processErrors(e, this.notify) } finally { diff --git a/resources/components/Studies/StudiesList/StudiesList.vue b/resources/components/Studies/StudiesList/StudiesList.vue index a812dc6..121081d 100644 --- a/resources/components/Studies/StudiesList/StudiesList.vue +++ b/resources/components/Studies/StudiesList/StudiesList.vue @@ -36,16 +36,20 @@ - - - - {{ $t('studies.list.shared_by') }} {{ studyOwners[item.id].name }} - - + + + + + {{ $t('studies.list.shared_by') }} {{ + studyOwners[item.id] && studyOwners[item.id].name + }} + + + @@ -73,7 +77,6 @@ export default { computed: { studyOwners () { return this.studies.reduce((result, study) => { - console.log(study.id, study.users) result[study.id] = study?.users.find(user => user.pivot.is_owner) return result }, {}) @@ -81,7 +84,7 @@ export default { }, methods: { userIsOwner (studyID) { - console.log(this.studyOwners) + if (!this.studyOwners[studyID]) { return true } return this.$auth.user.id === this.studyOwners[studyID].id } } diff --git a/resources/pages/dashboard/studies/_id/index.vue b/resources/pages/dashboard/studies/_id/index.vue index f4971f3..d326491 100644 --- a/resources/pages/dashboard/studies/_id/index.vue +++ b/resources/pages/dashboard/studies/_id/index.vue @@ -117,7 +117,7 @@ const defaultPagination = { } export default { - name: 'Study', + name: 'StudyPage', components: { StudyActions, StudyTitle: () => import('@/components/Studies/page/StudyTitle'), @@ -244,10 +244,9 @@ export default { async fetchStudy (studyID, options) { try { await this.Study.fetchById(studyID, { - /* Below breaks the studies list, if studies are shared */ - // persistOptions: { - // create: ['users'] - // }, + persistOptions: { + create: ['users'] + }, ...options }) } catch (e) { diff --git a/resources/pages/dashboard/studies/index.vue b/resources/pages/dashboard/studies/index.vue index f5d9f49..f336b31 100644 --- a/resources/pages/dashboard/studies/index.vue +++ b/resources/pages/dashboard/studies/index.vue @@ -9,3 +9,9 @@ + +