Skip to content

Commit

Permalink
Merge pull request #1913 from CSCfi/CSCTTV-5312v3
Browse files Browse the repository at this point in the history
hide caption, if jufo class data is missing
  • Loading branch information
konolak authored Jan 9, 2025
2 parents 88da393 + fb65c81 commit ec9359f
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,17 @@ export class SinglePublicationComponent
}

filterData() {
// Helper function to check if the field exists and has data
// Helper function to check if the field exists and has valid data
const checkEmpty = (item: { field: string }) => {
return UtilityService.stringHasContent(
this.responseData.publications[0][item.field]
);
};
// Helper function to check if the field has some data
const checkIfValueExists = (item: { field: string }) => {
return this.responseData.publications[0][item.field]?.length > 0;
};

// Filter all the fields to only include properties with defined data
this.infoFields = this.infoFields.filter((item) => checkEmpty(item));
// this.authorFields = this.authorFields.filter(item => checkEmpty(item));
Expand All @@ -645,8 +650,8 @@ export class SinglePublicationComponent
);
this.typeFields = this.typeFields.filter((item) => checkEmpty(item));

// Jufo code 0 must be shown, so exception added
this.mediumFields = this.mediumFields.filter((item) => item.field !== 'jufoClassCode' ? checkEmpty(item) : true);
// Jufo code 0 must be shown, so exception added. Check empty function cannot be used, since in interprets 0 as empty.
this.mediumFields = this.mediumFields.filter((item) => item.field !== 'jufoClassCode' ? checkEmpty(item) : checkIfValueExists(item));
this.linksFields = this.linksFields.filter((item) => checkEmpty(item));
this.otherFields = this.otherFields.filter((item) => checkEmpty(item));
this.open_accessFields = this.open_accessFields.filter((item) =>
Expand Down

0 comments on commit ec9359f

Please sign in to comment.