From afbefb335c701d8cb782121f12bf6555712516cc Mon Sep 17 00:00:00 2001 From: Futa Ikeda Date: Thu, 8 Apr 2021 10:49:22 -0400 Subject: [PATCH 1/2] Load all authors for preprint detail page --- app/controllers/preprints/provider/preprint-detail.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/preprints/provider/preprint-detail.js b/app/controllers/preprints/provider/preprint-detail.js index c03fa6ae..29427526 100644 --- a/app/controllers/preprints/provider/preprint-detail.js +++ b/app/controllers/preprints/provider/preprint-detail.js @@ -4,6 +4,7 @@ import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; import { task, waitForQueue } from 'ember-concurrency'; +import loadAll from 'ember-osf/utils/load-relationship'; import $ from 'jquery'; @@ -38,6 +39,7 @@ export default Controller.extend({ userHasEnteredReview: false, showWarning: false, previousTransition: null, + authors: [], hasTags: bool('preprint.tags.length'), expandedAbstract: navigator.userAgent.includes('Prerender'), @@ -168,14 +170,17 @@ export default Controller.extend({ const response = yield this.get('store').findRecord( 'preprint', preprintId, - { include: ['node', 'license', 'review_actions', 'contributors'] }, + { include: ['node', 'license', 'review_actions'] }, ).catch(() => this.replaceRoute('page-not-found')); + const contributors = this.get('authors'); + loadAll(response, 'contributors', contributors, { + filter: { bibliographic: true }, + }); this.set('preprint', response); if (response.get('dateWithdrawn') !== null) { this.set('isWithdrawn', true); } - this.set('authors', response.get('contributors')); this.set('preprint', response); let withdrawalRequest = yield this.get('preprint.requests'); withdrawalRequest = withdrawalRequest.toArray(); From 7222a629765441368c129b0dffbcff6db944de88 Mon Sep 17 00:00:00 2001 From: Futa Ikeda Date: Thu, 8 Apr 2021 14:16:56 -0400 Subject: [PATCH 2/2] Fix bug where contributor list gets duplicated --- app/controllers/preprints/provider/preprint-detail.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/preprints/provider/preprint-detail.js b/app/controllers/preprints/provider/preprint-detail.js index 29427526..bf67fde9 100644 --- a/app/controllers/preprints/provider/preprint-detail.js +++ b/app/controllers/preprints/provider/preprint-detail.js @@ -39,7 +39,6 @@ export default Controller.extend({ userHasEnteredReview: false, showWarning: false, previousTransition: null, - authors: [], hasTags: bool('preprint.tags.length'), expandedAbstract: navigator.userAgent.includes('Prerender'), @@ -173,10 +172,11 @@ export default Controller.extend({ { include: ['node', 'license', 'review_actions'] }, ).catch(() => this.replaceRoute('page-not-found')); - const contributors = this.get('authors'); + const contributors = []; loadAll(response, 'contributors', contributors, { filter: { bibliographic: true }, }); + this.set('authors', contributors); this.set('preprint', response); if (response.get('dateWithdrawn') !== null) { this.set('isWithdrawn', true);