Skip to content

Commit

Permalink
Fixes crash when DOI for wrong object type used. #2429
Browse files Browse the repository at this point in the history
  • Loading branch information
knirirr committed Nov 21, 2024
1 parent 9d798d3 commit 1c1389c
Showing 1 changed file with 43 additions and 35 deletions.
78 changes: 43 additions & 35 deletions src/components/Editor/EditPublications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -523,51 +523,59 @@ export default {
} else {
let dataPublication;
if (Array.isArray(data)) {
console.log("Array!");
dataPublication = data[0];
} else {
console.log("Object!");
dataPublication = data;
}
if (
dataPublication.metadata.upload_type === "publication" ||
(dataPublication.metadata.resource_type &&
dataPublication.metadata.resource_type.type &&
dataPublication.metadata.resource_type.type === "publication")
) {
this.newPublication = {
journal: null,
doi: null,
title: null,
url: null,
year: null,
authors: null,
};
if (dataPublication.metadata.journal_title) {
this.newPublication.journal =
dataPublication.metadata.journal_title;
} else {
if (dataPublication.metadata.meeting) {
if (dataPublication.metadata !== undefined) {
if (dataPublication.metadata.upload_type === "publication" ||
(dataPublication.metadata.resource_type &&
dataPublication.metadata.resource_type.type &&
dataPublication.metadata.resource_type.type === "publication")
) {
this.newPublication = {
journal: null,
doi: null,
title: null,
url: null,
year: null,
authors: null,
};
if (dataPublication.metadata.journal_title) {
this.newPublication.journal =
dataPublication.metadata.meeting.title;
dataPublication.metadata.journal_title;
} else {
if (dataPublication.metadata.meeting) {
this.newPublication.journal =
dataPublication.metadata.meeting.title;
}
}
this.newPublication.doi = dataPublication.doi;
this.newPublication.title = dataPublication.metadata.title;
this.newPublication.url = dataPublication.links.doi;
this.newPublication.year = Number(
dataPublication.metadata.publication_date.split("-")[0]
);
let authors = [];
dataPublication.metadata.creators.forEach(function (a) {
authors.push(a.name + "; ");
});
this.newPublication.authors = authors.join("");
this.newPublication.isCitation = false;
this.openEditor = true;
}
this.newPublication.doi = dataPublication.doi;
this.newPublication.title = dataPublication.metadata.title;
this.newPublication.url = dataPublication.links.doi;
this.newPublication.year = Number(
dataPublication.metadata.publication_date.split("-")[0]
);
let authors = [];
dataPublication.metadata.creators.forEach(function (a) {
authors.push(a.name + "; ");
});
this.newPublication.authors = authors.join("");
this.newPublication.isCitation = false;
this.openEditor = true;
} else {
else {
this.errors.doi = true;
}
}
else {
this.errors.doi = true;
}
}
} else {
}
else {
/* istanbul ignore next */
this.newPublication.journal =
data["container-title-short"] || data["container-title"];
Expand Down

0 comments on commit 1c1389c

Please sign in to comment.