Skip to content

Commit 8c9f5cc

Browse files
authored
[ANG-1074] fix(my-projects): added new filter for projects (#666)
* fix(my-projects): added new filter for projects * fix(my-projects): updated styles
1 parent 648fc2a commit 8c9f5cc

File tree

13 files changed

+223
-243
lines changed

13 files changed

+223
-243
lines changed

src/app/features/home/pages/dashboard/dashboard.component.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@
2525
{{ 'home.loggedIn.dashboard.quickSearch.osf' | translate }}
2626
</p>
2727

28+
<osf-search-input
29+
[placeholder]="'home.loggedIn.dashboard.quickSearch.searchPlaceholder' | translate"
30+
[control]="searchControl"
31+
/>
32+
2833
<osf-my-projects-table
34+
class="block mt-4"
2935
[items]="filteredProjects()"
3036
[tableParams]="tableParams()"
31-
[searchControl]="searchControl"
3237
[sortColumn]="sortColumn()"
3338
[sortOrder]="sortOrder()"
3439
[isLoading]="areProjectsLoading()"
35-
[searchPlaceholder]="'home.loggedIn.dashboard.quickSearch.searchPlaceholder' | translate"
3640
(pageChange)="onPageChange($event)"
3741
(sort)="onSort($event)"
3842
(itemClick)="navigateToProject($event)"

src/app/features/home/pages/dashboard/dashboard.component.spec.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
import { Store } from '@ngxs/store';
22

3-
import { MockComponents } from 'ng-mocks';
3+
import { MockComponents, MockProviders } from 'ng-mocks';
44

55
import { signal, WritableSignal } from '@angular/core';
66
import { ComponentFixture, TestBed } from '@angular/core/testing';
77
import { By } from '@angular/platform-browser';
88

9-
import { LoadingSpinnerComponent, MyProjectsTableComponent, SubHeaderComponent } from '@shared/components';
9+
import { CustomConfirmationService, CustomDialogService, ProjectRedirectDialogService } from '@osf/shared/services';
10+
import {
11+
LoadingSpinnerComponent,
12+
MyProjectsTableComponent,
13+
SearchInputComponent,
14+
SubHeaderComponent,
15+
} from '@shared/components';
1016
import { MyResourcesSelectors } from '@shared/stores';
1117

1218
import { DashboardComponent } from './dashboard.component';
1319

1420
import { getProjectsMockForComponent } from '@testing/data/dashboard/dasboard.data';
1521
import { OSFTestingStoreModule } from '@testing/osf.testing.module';
1622

17-
describe.skip('DashboardComponent', () => {
23+
describe('DashboardComponent', () => {
1824
let component: DashboardComponent;
1925
let fixture: ComponentFixture<DashboardComponent>;
2026

@@ -31,7 +37,7 @@ describe.skip('DashboardComponent', () => {
3137
imports: [
3238
DashboardComponent,
3339
OSFTestingStoreModule,
34-
...MockComponents(SubHeaderComponent, MyProjectsTableComponent, LoadingSpinnerComponent),
40+
...MockComponents(SubHeaderComponent, MyProjectsTableComponent, LoadingSpinnerComponent, SearchInputComponent),
3541
],
3642
providers: [
3743
{
@@ -46,14 +52,15 @@ describe.skip('DashboardComponent', () => {
4652
dispatch: jest.fn(),
4753
},
4854
},
55+
MockProviders(CustomDialogService, CustomConfirmationService, ProjectRedirectDialogService),
4956
],
5057
}).compileComponents();
5158

5259
fixture = TestBed.createComponent(DashboardComponent);
5360
component = fixture.componentInstance;
5461
});
5562

56-
it('should show loading s pinner when projects are loading', () => {
63+
it('should show loading spinner when projects are loading', () => {
5764
areProjectsLoadingSignal.set(true);
5865
fixture.detectChanges();
5966

src/app/features/home/pages/dashboard/dashboard.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
IconComponent,
2020
LoadingSpinnerComponent,
2121
MyProjectsTableComponent,
22+
SearchInputComponent,
2223
SubHeaderComponent,
2324
} from '@osf/shared/components';
2425
import { DEFAULT_TABLE_PARAMS } from '@osf/shared/constants';
@@ -34,6 +35,7 @@ import { ClearMyResources, GetMyProjects, MyResourcesSelectors } from '@osf/shar
3435
Button,
3536
SubHeaderComponent,
3637
MyProjectsTableComponent,
38+
SearchInputComponent,
3739
IconComponent,
3840
TranslatePipe,
3941
LoadingSpinnerComponent,
@@ -68,8 +70,6 @@ export class DashboardComponent implements OnInit {
6870

6971
readonly existsProjects = computed(() => this.projects().length || !!this.searchControl.value?.length);
7072

71-
emailAddress = '';
72-
7373
constructor() {
7474
this.setupSearchSubscription();
7575
this.setupTotalRecordsEffect();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { ResourceSearchMode } from '@osf/shared/enums';
2+
import { TabOption } from '@osf/shared/models';
3+
4+
export const PROJECT_FILTER_OPTIONS: TabOption[] = [
5+
{
6+
value: ResourceSearchMode.User,
7+
label: 'myProjects.tabOptions.all',
8+
},
9+
{
10+
value: ResourceSearchMode.Root,
11+
label: 'myProjects.tabOptions.root',
12+
},
13+
{
14+
value: ResourceSearchMode.Component,
15+
label: 'myProjects.tabOptions.component',
16+
},
17+
];

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,25 @@
2828
}
2929

3030
<p-tabpanel [value]="tabOption.Projects" class="flex flex-column gap-4 flex-1">
31+
<div class="flex flex-column gap-4 md:flex-row md:align-items-center">
32+
<osf-search-input
33+
class="flex-1"
34+
[placeholder]="'myProjects.table.searchPlaceholder' | translate"
35+
[control]="searchControl"
36+
/>
37+
38+
<osf-select
39+
class="flex-1"
40+
[options]="projectFilterOption"
41+
[(selectedValue)]="selectedProjectFilterOption"
42+
[fullWidth]="true"
43+
(changeValue)="onProjectFilterChange()"
44+
></osf-select>
45+
</div>
46+
3147
<osf-my-projects-table
3248
[items]="projects()"
3349
[tableParams]="tableParams()"
34-
[searchControl]="searchControl"
3550
[sortColumn]="sortColumn()"
3651
[sortOrder]="sortOrder()"
3752
[isLoading]="isLoading()"
@@ -42,10 +57,14 @@
4257
</p-tabpanel>
4358

4459
<p-tabpanel [value]="tabOption.Registrations" class="flex flex-column gap-4 flex-1">
60+
<osf-search-input
61+
[placeholder]="'myProjects.table.searchPlaceholder' | translate"
62+
[control]="searchControl"
63+
/>
64+
4565
<osf-my-projects-table
4666
[items]="registrations()"
4767
[tableParams]="tableParams()"
48-
[searchControl]="searchControl"
4968
[sortColumn]="sortColumn()"
5069
[sortOrder]="sortOrder()"
5170
[isLoading]="isLoading()"
@@ -56,10 +75,14 @@
5675
</p-tabpanel>
5776

5877
<p-tabpanel [value]="tabOption.Preprints" class="flex flex-column gap-4 flex-1">
78+
<osf-search-input
79+
[placeholder]="'myProjects.table.searchPlaceholder' | translate"
80+
[control]="searchControl"
81+
/>
82+
5983
<osf-my-projects-table
6084
[items]="preprints()"
6185
[tableParams]="tableParams()"
62-
[searchControl]="searchControl"
6386
[sortColumn]="sortColumn()"
6487
[sortOrder]="sortOrder()"
6588
[isLoading]="isLoading()"
@@ -70,10 +93,14 @@
7093
</p-tabpanel>
7194

7295
<p-tabpanel [value]="tabOption.Bookmarks" class="flex flex-column gap-4 flex-1">
96+
<osf-search-input
97+
[placeholder]="'myProjects.table.searchPlaceholder' | translate"
98+
[control]="searchControl"
99+
/>
100+
73101
<osf-my-projects-table
74102
[items]="bookmarks()"
75103
[tableParams]="tableParams()"
76-
[searchControl]="searchControl"
77104
[sortColumn]="sortColumn()"
78105
[sortOrder]="sortOrder()"
79106
[isLoading]="isLoading()"

0 commit comments

Comments
 (0)