-
Notifications
You must be signed in to change notification settings - Fork 12
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
fix(openchallenges): create pipe to map enum values of challenge properties to labels #2612
Conversation
I realize the challenge card has incentive information. To avoid calling the function hundreds of times to get incentive label for each challenge card, I will change to create a separate mapping file for label-value. |
When I was trying to update the incentive in the challenge card component, all pages displayed blank with an error indicating that loading the footer failed. Here is the error message. statistics-viewer.component.ts:13 Uncaught TypeError: Cannot read properties of undefined (reading 'FooterComponent')
at Module.FooterComponent (statistics-viewer.component.ts:13:72)
at 72716 (challenge-search.component.ts:83:5)
at __webpack_require__ (bootstrap:19:1)
at 17844 (challenge-search.component.ts:87:34)
at __webpack_require__ (bootstrap:19:1)
at 15392 (variables.ts:9:2)
at __webpack_require__ (bootstrap:19:1)
at 71604 (mock-avatars.ts:14:2)
at __webpack_require__ (bootstrap:19:1)
at 65488 (statistics-viewer.component.ts:13:72) I noticed this issue when I shared the mapping file in the |
libs/openchallenges/challenge/src/lib/challenge-overview/challenge-overview.component.html
Outdated
Show resolved
Hide resolved
Potential circular dependency, if creating a new mapping file stored in
|
libs/openchallenges/util/src/lib/pipe/challenge-property-label.pipe.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix works as expected, thanks! I like how developer-friendly using Angular pipes to convert constant to human-readable text is.
There are two improvements I can see for the future:
- use the constant from the API client as keys in a dictionary and set the localization strings as the values. This approach has the benefit of defining the content of the dictionary once and they have one "implementation" for each languages.
- extract the localization code from the util library and place it into a "localization" library.
Quality Gate passed for 'openchallenges-app'Issues Measures |
Changelog
util
lib to convert the enum value of a challenge property into a label name based on the mapping filelocated in thestored locally.challenge-search
component