Skip to content

Commit

Permalink
Merge pull request #1103 from NFDI4Chem/issue-#646
Browse files Browse the repository at this point in the history
fix: enable addition of multiple authors at once.
  • Loading branch information
CS76 authored Mar 13, 2024
2 parents 95b7fdd + 9d59a8e commit e63039e
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions resources/js/Shared/ManageAuthor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ export default {
error: "",
showManageRoleDialog: false,
drag: false,
formattedAuthors: [],
// todo : dynamically load this from the config
contributorType: [
{
Expand Down Expand Up @@ -881,6 +882,7 @@ export default {
this.form.contributor_type = this.contributorType[0];
this.isEdit = false;
this.error = "";
this.formattedAuthors = [];
},
/*Edit author*/
edit(author) {
Expand Down Expand Up @@ -911,7 +913,6 @@ export default {
this.loading = true;
this.error = "";
this.query = this.extractQueryParam(this.query);
this.fetchedAuthors = [];
let isDOI = new RegExp(/\b(10[.][0-9]{4,}(?:[.][0-9]+)*)\b/g).test(
this.query
);
Expand Down Expand Up @@ -954,7 +955,6 @@ export default {
},
/*Make REST Call to Crossref API */
fetchDataFromCrossref(query) {
this.fetchedAuthors = [];
axios
.get(this.$page.props.CROSSREF_API + this.query)
.then((res) => {
Expand All @@ -974,7 +974,6 @@ export default {
},
/*Make REST call to Datacite API */
fetchDataFromDatacite(query) {
this.fetchedAuthors = [];
axios
.get(this.$page.props.DATACITE_API + this.query)
.then((res) => {
Expand All @@ -1001,7 +1000,6 @@ export default {
},
/*Format authors response*/
formatAuthorResponse(authors, apiType) {
var formattedAuthors = [];
if (authors && authors.length > 0) {
switch (apiType) {
case "europemc":
Expand All @@ -1022,7 +1020,7 @@ export default {
? author.authorAffiliationDetailsList
.authorAffiliation[0].affiliation
: "";
formattedAuthors.push(a);
this.formattedAuthors.push(a);
});
break;
case "crossref":
Expand All @@ -1034,7 +1032,7 @@ export default {
a.affiliation = author.affiliation[0]
? author.affiliation[0].name
: "";
formattedAuthors.push(a);
this.formattedAuthors.push(a);
});
break;
case "datacite":
Expand All @@ -1055,13 +1053,20 @@ export default {
a.affiliation = author.affiliation
? author.affiliation[0]
: "";
formattedAuthors.push(a);
this.formattedAuthors.push(a);
});
break;
}
}
const keys = ["firstName", "lastName", "orcidId"];
this.formattedAuthors = this.formattedAuthors.filter(
(value, index, self) =>
self.findIndex((v) =>
keys.every((k) => v[k] === value[k])
) === index
);
this.loading = false;
return formattedAuthors;
return this.formattedAuthors;
},
/*Format the response*/
formatAuthors(authors) {
Expand Down Expand Up @@ -1149,6 +1154,7 @@ export default {
},
/*Make request to save API*/
executeQuery() {
console.log("execute query method called..");
this.authorsForm.authors = this.authors;
const keys = ["given_name", "family_name"];
this.authorsForm.authors = this.authorsForm.authors.filter(
Expand All @@ -1165,7 +1171,10 @@ export default {
this.form.contributor_type = {};
this.form.contributor_type = this.contributorType[0];
this.displayAddAuthorForms = false;
this.formattedAuthors = [];
this.fetchedAuthors = [];
this.isEdit = false;
this.query = "";
},
onError: (err) => console.error(err),
});
Expand Down

0 comments on commit e63039e

Please sign in to comment.