Skip to content

Commit 94dcc24

Browse files
authored
Merge pull request #738 from OpenKnowledgeMaps/dev
Dev
2 parents b9a4066 + 585db25 commit 94dcc24

3 files changed

Lines changed: 30 additions & 13 deletions

File tree

vis/js/dataprocessing/managers/DataManager.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,18 @@ class DataManager {
147147
this.config.convert_author_names
148148
);
149149

150-
// old variable with all authors_string
150+
// old variable with all authors_string
151151
// paper.authors_string = paper.authors_list.join(", ");
152152

153-
if (paper.authors_list.length > 15) {
154-
const firstAuthors = paper.authors_list.slice(0, 14).join(", ");
153+
if (paper.authors_list.length > 20) {
154+
const firstAuthors = paper.authors_list.slice(0, 19).join(", ");
155155
const lastAuthor = paper.authors_list[paper.authors_list.length - 1];
156-
// get first 14 authors and add "..." and last author for the visual part the map
157-
paper.authors_string = `${firstAuthors}, ... ${lastAuthor}`;
158-
// in the case of more than 15 authors left an array of 16 authors for further processing in the visual part with "..." between the authors
159-
paper.authors_list = paper.authors_list.slice(0, 15).concat(lastAuthor);
156+
// get first 19 authors and add "..." and last author for the visual part the map
157+
paper.authors_string = `${firstAuthors}, ... ${lastAuthor}`;
158+
// in the case of more than 19 authors left an array of 20 authors for further processing in the visual part with "..." between the authors
159+
paper.authors_list = paper.authors_list.slice(0, 20).concat(lastAuthor);
160+
} else {
161+
paper.authors_string = paper.authors_list.join(", ");
160162
}
161163
}
162164

vis/js/templates/Paper.jsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class Paper extends React.Component {
100100
const { maxSize, enlargeFactor } = this.props;
101101
const { onClick, onMouseOver, onMouseOut } = this.props;
102102

103-
const { title, authors_string: authors, year, area } = data;
103+
const {title, authors_string: authors, authors_list: authors_list, year, area} = data;
104104
const { num_readers: readers, published_in: publisher } = data;
105105
const { x, y, width: baseWidth, height: baseHeight } = this.state;
106106
const { path: basePath, dogEar: baseDogEar } = this.state;
@@ -168,6 +168,19 @@ class Paper extends React.Component {
168168
eventHandlers.onMouseOut = handleMouseOut;
169169
}
170170

171+
172+
// function returns a string of authors with conditionals if the list is too long, it's cut off and an ellipsis is added
173+
// if less than maxLength authors, the full list is returned
174+
function cutAuthors(authorsList, maxLength) {
175+
if (authorsList.length > maxLength) {
176+
const firstAuthors = authorsList.slice(0, maxLength - 1).join(', ');
177+
const lastAuthor = authorsList[authorsList.length - 1];
178+
return `${firstAuthors}, ... ${lastAuthor}`;
179+
} else {
180+
return authors
181+
}
182+
}
183+
171184
return (
172185
// html template starts here
173186
<g className={gClass} {...eventHandlers}>
@@ -222,7 +235,8 @@ class Paper extends React.Component {
222235
<p id="details" className={sizeModifierClass}>
223236
<Hyphenate>
224237
<Highlight hyphenated queryHighlight>
225-
{authors}
238+
{/*{authors}*/}
239+
{cutAuthors(authors_list, 15)}
226240
</Highlight>
227241
</Hyphenate>
228242
</p>
@@ -478,7 +492,7 @@ export const isNonTextDocument = (paper) => {
478492
}
479493

480494
const knownTypes = paper.resulttype.filter((t) => t.toLowerCase() !== UNKNOWN_TYPE);
481-
495+
482496
// the only type is unknown
483497
if (knownTypes.length === 0) {
484498
return true;

vis/js/templates/listentry/Details.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ const getAuthorsString = (authorsList, maxLength) => {
5353

5454
const ellipsis = "...";
5555
const join = ", ";
56+
const maxLengthAuthors = 15;
5657
let finalString = authorsListCopy.shift();
57-
if (authorsList.length > 15) {
58-
const first19Authors = authorsList.slice(0, 14).join(", ");
58+
if (authorsList.length > maxLengthAuthors) {
59+
const firstAuthors = authorsList.slice(0, maxLengthAuthors - 1).join(join);
5960
const lastAuthor = authorsList[authorsList.length - 1];
60-
finalString = `${first19Authors}, ... ${lastAuthor}`;
61+
finalString = `${firstAuthors}, ... ${lastAuthor}`;
6162
return finalString;
6263
}
6364
while (authorsListCopy.length > 0) {

0 commit comments

Comments
 (0)