From 28612a11bbbf55a20af001746101e6c19f372e6c Mon Sep 17 00:00:00 2001 From: NishaSharma14 Date: Tue, 30 Jan 2024 13:54:08 +0100 Subject: [PATCH 1/3] fix: fixes #1026 --- resources/js/Mixins/Global.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/js/Mixins/Global.js b/resources/js/Mixins/Global.js index 92ee4e40..c2fb46a3 100644 --- a/resources/js/Mixins/Global.js +++ b/resources/js/Mixins/Global.js @@ -216,7 +216,11 @@ export default { extractQueryParam(query) { if (query.indexOf("http") > -1) { var url = new URL(query); - query = url.pathname.replace("/", ""); + if(query.indexOf("dois") > -1){ + query = url.pathname.replace("/dois/", ""); + } else { + query = url.pathname.replace("/", ""); + } } return query.trim(); }, @@ -324,7 +328,11 @@ export default { extractQueryParam(query) { if (query.indexOf("http") > -1) { var url = new URL(query); - query = url.pathname.replace("/", ""); + if(query.indexOf("dois") > -1){ + query = url.pathname.replace("/dois/", ""); + } else { + query = url.pathname.replace("/", ""); + } } return query.trim(); }, From 350a17cf3f49f894c2ef3f2617e6c53f7a8e14de Mon Sep 17 00:00:00 2001 From: NishaSharma14 Date: Wed, 31 Jan 2024 14:01:17 +0100 Subject: [PATCH 2/3] fix: duplicate citation error --- app/Http/Controllers/CitationController.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/CitationController.php b/app/Http/Controllers/CitationController.php index 974f8963..1bbdc58f 100644 --- a/app/Http/Controllers/CitationController.php +++ b/app/Http/Controllers/CitationController.php @@ -32,16 +32,17 @@ public function save(Request $request, UpdateProject $updater, Project $project) $processedCitations = []; foreach ($citations as $citation) { - $title = $citation['title']; + $doi = $citation['doi']; Validator::make($citation, [ 'title' => ['required', 'string'], + 'doi' => ['required', 'string'], 'authors' => ['required', 'string'], ])->validate(); - if (! is_null($title)) { - $_citation = $project->citations->filter(function ($a) use ($title) { - return $title === $a->title; + if (! is_null($doi)) { + $_citation = $project->citations->filter(function ($a) use ($doi) { + return $doi === $a->doi; })->first(); //dd($_author); if ($_citation) { From ccb15d815fdb56417b970fc2dccdd6d7a59bcbdc Mon Sep 17 00:00:00 2001 From: NishaSharma14 Date: Wed, 31 Jan 2024 14:08:01 +0100 Subject: [PATCH 3/3] test_citation_can_be_added_and_updated --- database/factories/CitationFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/factories/CitationFactory.php b/database/factories/CitationFactory.php index 843704d6..41116e33 100644 --- a/database/factories/CitationFactory.php +++ b/database/factories/CitationFactory.php @@ -29,7 +29,7 @@ public function definition() $author = $author1.', '.$author2; return [ - 'doi' => null, + 'doi' => "10.102X/acs.jnatprod.1c01SS", 'title' => $this->faker->title(), 'authors' => $author, 'citation_text' => $this->faker->text(),