Skip to content

Commit 6cbe917

Browse files
committed
fix(my-projects-table): fixed comments
1 parent a6a2c29 commit 6cbe917

4 files changed

Lines changed: 12 additions & 14 deletions

File tree

‎src/app/features/my-projects/my-projects.component.html‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
[sortColumn]="sortColumn()"
6464
[sortOrder]="sortOrder()"
6565
[isLoading]="isLoading()"
66-
[showDownloadColumn]="true"
6766
[downloadCellTemplate]="projectDownloadCell"
6867
[emptyMessageKey]="projectsEmptyMessageKey()"
6968
(pageChange)="onPageChange($event)"

‎src/app/shared/components/my-projects-table/my-projects-table.component.html‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
<p-sortIcon field="dateModified" />
3232
</th>
3333

34-
@if (showDownloadColumn()) {
35-
<th aria-hidden="true"></th>
34+
@if (downloadCellTemplate()) {
35+
<th [attr.aria-label]="'common.buttons.download' | translate"></th>
3636
}
3737
</tr>
3838
</ng-template>
@@ -53,9 +53,9 @@
5353

5454
<td>{{ item.dateModified | date: 'MMM d, y, h:mm a' }}</td>
5555

56-
@if (showDownloadColumn()) {
56+
@if (downloadCellTemplate(); as downloadTemplate) {
5757
<td class="text-center">
58-
<ng-container *ngTemplateOutlet="downloadCellTemplate(); context: { $implicit: item }" />
58+
<ng-container *ngTemplateOutlet="downloadTemplate; context: { $implicit: item }" />
5959
</td>
6060
}
6161
</tr>

‎src/app/shared/components/my-projects-table/my-projects-table.component.spec.ts‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { MockComponents } from 'ng-mocks';
33
import { SortEvent } from 'primeng/api';
44
import { TablePageEvent } from 'primeng/table';
55

6+
import { TemplateRef } from '@angular/core';
67
import { ComponentFixture, TestBed } from '@angular/core/testing';
78

89
import { SortOrder } from '@osf/shared/enums/sort-order.enum';
@@ -87,17 +88,14 @@ describe('MyProjectsTableComponent', () => {
8788
expect(component.sortOrder()).toBe(SortOrder.Desc);
8889
});
8990

90-
it('should default isLoading and showDownloadColumn to false', () => {
91+
it('should default isLoading to false', () => {
9192
expect(component.isLoading()).toBe(false);
92-
expect(component.showDownloadColumn()).toBe(false);
9393
});
9494

95-
it('should accept isLoading and showDownloadColumn inputs', () => {
95+
it('should accept isLoading input', () => {
9696
fixture.componentRef.setInput('isLoading', true);
97-
fixture.componentRef.setInput('showDownloadColumn', true);
9897

9998
expect(component.isLoading()).toBe(true);
100-
expect(component.showDownloadColumn()).toBe(true);
10199
});
102100

103101
it('should default emptyMessageKey to common.search.noResultsFound', () => {
@@ -118,8 +116,8 @@ describe('MyProjectsTableComponent', () => {
118116
expect(component.columnCount()).toBe(3);
119117
});
120118

121-
it('should return columnCount of 4 when download column is shown', () => {
122-
fixture.componentRef.setInput('showDownloadColumn', true);
119+
it('should return columnCount of 4 when downloadCellTemplate is provided', () => {
120+
fixture.componentRef.setInput('downloadCellTemplate', {} as TemplateRef<{ $implicit: MyResourcesItem }>);
123121

124122
expect(component.columnCount()).toBe(4);
125123
});

‎src/app/shared/components/my-projects-table/my-projects-table.component.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ import { IconComponent } from '../icon/icon.component';
3030
changeDetection: ChangeDetectionStrategy.OnPush,
3131
})
3232
export class MyProjectsTableComponent {
33+
private readonly BASE_COLUMN_COUNT = 3;
34+
3335
readonly items = input<MyResourcesItem[]>([]);
3436
readonly tableParams = input.required<TableParameters>();
3537
readonly sortColumn = input<string | undefined>(undefined);
3638
readonly sortOrder = input<SortOrder>(SortOrder.Asc);
3739
readonly isLoading = input<boolean>(false);
38-
readonly showDownloadColumn = input<boolean>(false);
3940
readonly emptyMessageKey = input<string>('common.search.noResultsFound');
4041
readonly downloadCellTemplate = input<TemplateRef<{ $implicit: MyResourcesItem }>>();
4142

@@ -45,7 +46,7 @@ export class MyProjectsTableComponent {
4546

4647
readonly skeletonData = Array.from({ length: 10 }, () => ({}) as MyResourcesItem);
4748

48-
readonly columnCount = computed(() => (this.showDownloadColumn() ? 4 : 3));
49+
readonly columnCount = computed(() => this.BASE_COLUMN_COUNT + Number(!!this.downloadCellTemplate()));
4950

5051
onPageChange(event: TablePageEvent): void {
5152
this.pageChange.emit(event);

0 commit comments

Comments
 (0)