forked from eclipse-basyx/basyx-aas-web-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves toDisplay functions to ReferableUtils
- Loading branch information
Showing
3 changed files
with
23 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Function to extract the english display name from a referable | ||
export function nameToDisplay(referable: any, defaultNameToDisplay = '') { | ||
if (referable && referable?.displayName) { | ||
const displayNameEn = referable.displayName.find((displayName: any) => { | ||
return displayName.language === 'en' && displayName.text !== ''; | ||
}); | ||
if (displayNameEn && displayNameEn.text) return displayNameEn.text; | ||
} | ||
return !defaultNameToDisplay && referable?.idShort ? referable.idShort : defaultNameToDisplay; | ||
} | ||
|
||
// Function to extract the english description from a referable | ||
export function descriptionToDisplay(referable: any) { | ||
if (referable && referable?.description) { | ||
const descriptionEn = referable.description.find( | ||
(description: any) => description && description.language === 'en' && description.text !== '' | ||
); | ||
if (descriptionEn && descriptionEn.text) return descriptionEn.text; | ||
} | ||
return ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters