Skip to content

Commit

Permalink
Merge pull request #1074 from NFDI4Chem/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NishaSharma14 authored Jan 31, 2024
2 parents 49926db + ccb15d8 commit e125d31
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
9 changes: 5 additions & 4 deletions app/Http/Controllers/CitationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion database/factories/CitationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
12 changes: 10 additions & 2 deletions resources/js/Mixins/Global.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down Expand Up @@ -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();
},
Expand Down

0 comments on commit e125d31

Please sign in to comment.