Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide caption, if jufo class data is missing #1913

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading