-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add descriptive name to avoid conflicts
- Loading branch information
Showing
8 changed files
with
148 additions
and
99 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
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
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
63 changes: 52 additions & 11 deletions
63
libs/openchallenges/util/src/lib/pipe/challenge-property-label.pipe.ts
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 |
---|---|---|
@@ -1,35 +1,76 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { | ||
ChallengeCategory, | ||
ChallengeIncentive, | ||
ChallengeSort, | ||
ChallengeStatus, | ||
ChallengeSubmissionType, | ||
} from '@sagebionetworks/openchallenges/api-client-angular'; | ||
import { | ||
challengeIncentivesLabels, | ||
challengeSubmissionTypesLabels, | ||
} from './challenge-property-labels'; | ||
ChallengeCategoriesOptions, | ||
ChallengeIncentivesOptions, | ||
ChallengeSortOptions, | ||
ChallengeStatusOptions, | ||
ChallengeSubmissionTypesOptions, | ||
} from './challenge-property-options'; | ||
|
||
@Pipe({ | ||
name: 'incentiveLabel', | ||
name: 'challengeCategoryLabel', | ||
standalone: true, | ||
}) | ||
export class IncentiveLabelPipe implements PipeTransform { | ||
export class ChallengeCategoryLabelPipe implements PipeTransform { | ||
transform(category: ChallengeCategory): string | undefined { | ||
const option = ChallengeCategoriesOptions.find( | ||
(item) => item.value === category | ||
); | ||
return option ? option.label : undefined; | ||
} | ||
} | ||
|
||
@Pipe({ | ||
name: 'challengeIncentiveLabel', | ||
standalone: true, | ||
}) | ||
export class ChallengeIncentiveLabelPipe implements PipeTransform { | ||
transform(incentive: ChallengeIncentive): string | undefined { | ||
const filterItem = challengeIncentivesLabels.find( | ||
const option = ChallengeIncentivesOptions.find( | ||
(item) => item.value === incentive | ||
); | ||
return filterItem ? filterItem.label : undefined; | ||
return option ? option.label : undefined; | ||
} | ||
} | ||
|
||
@Pipe({ | ||
name: 'challengeSortLabel', | ||
standalone: true, | ||
}) | ||
export class ChallengeSortLabelPipe implements PipeTransform { | ||
transform(sort: ChallengeSort): string | undefined { | ||
const option = ChallengeSortOptions.find((item) => item.value === sort); | ||
return option ? option.label : undefined; | ||
} | ||
} | ||
|
||
@Pipe({ | ||
name: 'challengeStatusLabel', | ||
standalone: true, | ||
}) | ||
export class ChallengeStatusLabelPipe implements PipeTransform { | ||
transform(status: ChallengeStatus): string | undefined { | ||
const option = ChallengeStatusOptions.find((item) => item.value === status); | ||
return option ? option.label : undefined; | ||
} | ||
} | ||
|
||
@Pipe({ | ||
name: 'submissionTypeLabel', | ||
name: 'challengeSubmissionTypeLabel', | ||
standalone: true, | ||
}) | ||
export class SubmissionTypeLabelPipe implements PipeTransform { | ||
export class ChallengeSubmissionTypeLabelPipe implements PipeTransform { | ||
transform(submissionType: ChallengeSubmissionType): string | undefined { | ||
const filterItem = challengeSubmissionTypesLabels.find( | ||
const option = ChallengeSubmissionTypesOptions.find( | ||
(item) => item.value === submissionType | ||
); | ||
return filterItem ? filterItem.label : undefined; | ||
return option ? option.label : undefined; | ||
} | ||
} |
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