Skip to content

Commit

Permalink
editor: fix date in MEF persons suggestions
Browse files Browse the repository at this point in the history
Fixes wrong dates displayed in the persons suggestions of the form
editor. The function which computes the dates for authors is replaced by
`authorized_access_point_representing_a_person`.

Closes rero/rero-ils#1038.

Co-Authored-by: Peter Weber <[email protected]>
  • Loading branch information
rerowep committed Jun 15, 2020
1 parent a76fc4c commit 59a4702
Showing 1 changed file with 1 addition and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,50 +134,10 @@ export class RemoteAutocompleteInputTypeComponent extends FieldType implements O
*/
getNameSource(sourceData) {
if (sourceData) {
const data = sourceData;
let name = data.preferred_name_for_person;
if (data.date_of_birth || data.date_of_death) {
name += ', ';
if (data.date_of_birth) {
name += this.extractDate(data.date_of_birth);
}
name += ' - ';
if (data.date_of_death) {
name += this.extractDate(data.date_of_death);
}
}
return name;
return sourceData.authorized_access_point_representing_a_person;
}
}

getName(metadata) {
for (const source of ['idref', 'gnd', 'bnf', 'rero']) {
if (metadata[source]) {
const data = metadata[source];
let name = source.toUpperCase( );
name += ': ' + data.preferred_name_for_person;
if (data.date_of_birth || data.date_of_death) {
name += ', ';
if (data.date_of_birth) {
name += this.extractDate(data.date_of_birth);
}
name += ' - ';
if (data.date_of_death) {
name += this.extractDate(data.date_of_death);
}
}
return name;
}
}
}

extractDate(date) {
const mDate = moment(date, ['YYYY', 'YYYY-MM', 'YYYY-MM-DD']);
if (mDate.isValid()) {
return mDate.format('YYYY');
}
return date;
}

changeTypeaheadLoading(e: boolean): void {
this.typeaheadLoading = e;
Expand Down

0 comments on commit 59a4702

Please sign in to comment.