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

fix(openchallenges): use default text for empty start/end dates #2217

Merged
merged 6 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
@@ -1,10 +1,11 @@
<main *ngIf="challenge">
<div id="bio">
<h3 class="top-section-title">Overview</h3>
<p>{{ use_default(challenge.description) }}</p>
<p>{{ useNaIfEmpty(challenge.description) }}</p>
<div *ngIf="challenge.description.endsWith('...')">
<a class="read-more" href="{{ challenge.websiteUrl }}"
>Continue reading <mat-icon aria-hidden="true" inline="true">open_in_new</mat-icon></a>
>Continue reading <mat-icon aria-hidden="true" inline="true">open_in_new</mat-icon></a
>
</div>
</div>
<div id="details">
Expand All @@ -13,11 +14,15 @@ <h3 class="section-title">Challenge Details</h3>
<tbody>
<tr>
<td class="text-right">Start Date</td>
<td>{{ challenge.startDate }}</td>
<td [ngClass]="{ 'text-grey': challenge.startDate === null }">
{{ useNaIfEmpty(challenge.startDate) }}
</td>
</tr>
<tr>
<td class="text-right">End Date</td>
<td>{{ challenge.endDate }}</td>
<td [ngClass]="{ 'text-grey': challenge.endDate === null }">
{{ useNaIfEmpty(challenge.endDate) }}
</td>
</tr>
<tr>
<td class="text-right">Status</td>
Expand All @@ -26,7 +31,7 @@ <h3 class="section-title">Challenge Details</h3>
<tr>
<td class="text-right">Platform</td>
<td [ngClass]="{ 'text-grey': challenge.platform.name === '' }">
{{ use_default(challenge.platform.name) }}
{{ useNaIfEmpty(challenge.platform.name) }}
</td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export class ChallengeOverviewComponent {
organizationCards: OrganizationCard[] = MOCK_ORGANIZATION_CARDS;
// mockTopics = ['breast', 'cancer'];

use_default(str: string) {
return str === '' ? 'Not available' : str;
useNaIfEmpty(str: string | null | undefined) {
return str ?? 'Not available';
vpchung marked this conversation as resolved.
Show resolved Hide resolved
}

prettify(camel: string | undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id="bio" class="row">
<div class="col">
<h3>Overview</h3>
<p>{{ use_default(org.description) }}</p>
<p>{{ useNaIfEmpty(org.description) }}</p>
<div *ngIf="org.description.endsWith('...')">
<a class="read-more" href="{{ org.websiteUrl }}"
>Continue reading <mat-icon aria-hidden="true" inline="true">open_in_new</mat-icon></a>
Expand All @@ -15,11 +15,11 @@ <h3 class="section-title">Organization Details</h3>
<tbody>
<tr>
<td class="text-right">Acronym</td>
<td [ngClass]="{ 'text-grey': org.acronym === '' }">{{ use_default(org.acronym) }}</td>
<td [ngClass]="{ 'text-grey': org.acronym === '' }">{{ useNaIfEmpty(org.acronym) }}</td>
</tr>
<tr>
<td class="text-right">Contact Email</td>
<td [ngClass]="{ 'text-grey': org.email === '' }">{{ use_default(org.email) }}</td>
<td [ngClass]="{ 'text-grey': org.email === '' }">{{ useNaIfEmpty(org.email) }}</td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class OrgProfileOverviewComponent {
@Input({ required: true }) organization!: Organization;
organizationCards: OrganizationCard[] = MOCK_ORGANIZATION_CARDS;

use_default(str: string | undefined) {
return str === '' ? 'Not available' : str;
useNaIfEmpty(str: string | undefined) {
return str || 'Not available';
}
}