Skip to content

Commit 70eedbe

Browse files
authored
Merge pull request #29 from GaziYucel/stable-3_4_0
Update ror api to version 2 for ojs 3.4
2 parents daa2fce + 18850b7 commit 70eedbe

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

templates/contributor.tpl

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,30 @@
8686
}
8787
},
8888
apiLookup() {
89-
fetch('https://api.ror.org/v1/organizations?affiliation=' + this.searchPhrase + '*')
89+
fetch('https://api.ror.org/v2/organizations?query=' + this.searchPhrase)
9090
.then(response => response.json())
9191
.then(data => {
9292
this.organizations = [];
9393
let items = data.items;
9494
items.forEach((item) => {
95-
let labels = { /* */};
96-
for (let i = 0; i < item.organization.labels.length; i++) {
97-
labels[item.organization.labels[i].iso639]
98-
= item.organization.labels[i].label
99-
}
95+
let names = { /* */};
96+
const noLangCode = 'no_lang_code';
97+
const displayLocale =
98+
item.names?.find((i) => i.types.includes('ror_display'))?.lang !== null
99+
? item.names?.find((i) => i.types.includes('ror_display'))?.lang
100+
: noLangCode;
101+
102+
item.names?.forEach((name) => {
103+
if (name.types.includes('label') || name.types.includes('ror_display')) {
104+
const locale = name.lang !== null ? name.lang : noLangCode;
105+
names[locale] = name.value;
106+
}
107+
});
108+
100109
let row = {
101-
id: item.organization.id,
102-
name: item.organization.name,
103-
labels: labels
110+
id: item.id,
111+
name: names[displayLocale],
112+
labels: names
104113
};
105114

106115
this.organizations.push(row);

0 commit comments

Comments
 (0)