-
Notifications
You must be signed in to change notification settings - Fork 22
feat/219 add institutions list page #129
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0e24fb2
feat(institutions): add institutions list page
volodyayakubovskyy 562be9c
Merge branch 'main' into feat/219-institutions
volodyayakubovskyy f422ead
feat(institutions): added fixes by suggestions
volodyayakubovskyy 90ad942
feat(institutions): added fixes by suggestions
volodyayakubovskyy 824d5e1
Merge branch 'main' into feat/219-institutions
volodyayakubovskyy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <section class="flex-column flex flex-1"> | ||
| <osf-sub-header | ||
| class="pt-6" | ||
| [description]="'institutions.description' | translate" | ||
| [title]="'institutions.title' | translate" | ||
| [icon]="'institutions'" | ||
| /> | ||
|
|
||
| @if (institutionsLoading()) { | ||
| <div class="flex-1 mt-4 md:mt-8 lg:pt-5"> | ||
| <osf-loading-spinner /> | ||
| </div> | ||
| } @else { | ||
| <div class="flex-column flex flex-1 w-full bg-white p-5"> | ||
| <osf-search-input [control]="searchControl" [placeholder]="'institutions.searchInstitutions' | translate" /> | ||
|
|
||
| <div class="py-5 flex flex-column gap-3"> | ||
| @for (institution of institutions(); track $index) { | ||
| <div class="border-1 border-round-xl grey-border-color px-5 py-4 flex align-items-center gap-4"> | ||
| <img [ngSrc]="institution.assets.logo" [alt]="institution.name" width="60" height="60" /> | ||
|
|
||
| <h3 class="text-lg">{{ institution.name }}</h3> | ||
| </div> | ||
| } | ||
| </div> | ||
|
|
||
| <osf-custom-paginator | ||
| [first]="first()" | ||
| [totalCount]="totalInstitutionsCount()" | ||
| (pageChanged)="onPageChange($event)" | ||
| ></osf-custom-paginator> | ||
| </div> | ||
| } | ||
| </section> |
Empty file.
22 changes: 22 additions & 0 deletions
22
src/app/features/institutions/institutions.component.spec.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
|
||
| import { InstitutionsComponent } from './institutions.component'; | ||
|
|
||
| describe('InstitutionsComponent', () => { | ||
| let component: InstitutionsComponent; | ||
| let fixture: ComponentFixture<InstitutionsComponent>; | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [InstitutionsComponent], | ||
| }).compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(InstitutionsComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should create', () => { | ||
| expect(component).toBeTruthy(); | ||
| }); | ||
| }); |
123 changes: 123 additions & 0 deletions
123
src/app/features/institutions/institutions.component.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| import { createDispatchMap, select } from '@ngxs/store'; | ||
|
|
||
| import { TranslatePipe } from '@ngx-translate/core'; | ||
|
|
||
| import { PaginatorState } from 'primeng/paginator'; | ||
|
|
||
| import { debounceTime, distinctUntilChanged } from 'rxjs'; | ||
|
|
||
| import { NgOptimizedImage } from '@angular/common'; | ||
| import { ChangeDetectionStrategy, Component, DestroyRef, effect, inject, signal, untracked } from '@angular/core'; | ||
| import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop'; | ||
| import { FormControl } from '@angular/forms'; | ||
| import { ActivatedRoute, Router } from '@angular/router'; | ||
|
|
||
| import { parseQueryFilterParams } from '@core/helpers'; | ||
| import { | ||
| CustomPaginatorComponent, | ||
| LoadingSpinnerComponent, | ||
| SearchInputComponent, | ||
| SubHeaderComponent, | ||
| } from '@shared/components'; | ||
| import { TABLE_PARAMS } from '@shared/constants'; | ||
| import { QueryParams } from '@shared/models'; | ||
| import { FetchInstitutions, InstitutionsSelectors } from '@shared/stores'; | ||
|
|
||
| @Component({ | ||
| selector: 'osf-institutions', | ||
| imports: [ | ||
| SubHeaderComponent, | ||
| TranslatePipe, | ||
| SearchInputComponent, | ||
| NgOptimizedImage, | ||
| CustomPaginatorComponent, | ||
| LoadingSpinnerComponent, | ||
| ], | ||
| templateUrl: './institutions.component.html', | ||
| styleUrl: './institutions.component.scss', | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| }) | ||
| export class InstitutionsComponent { | ||
| private readonly route = inject(ActivatedRoute); | ||
| private readonly router = inject(Router); | ||
| private readonly destroyRef = inject(DestroyRef); | ||
|
|
||
| private readonly actions = createDispatchMap({ getInstitutions: FetchInstitutions }); | ||
|
|
||
| searchControl = new FormControl(''); | ||
|
|
||
| queryParams = toSignal(this.route.queryParams); | ||
| currentPage = signal(1); | ||
| currentPageSize = signal(TABLE_PARAMS.rows); | ||
| first = signal(0); | ||
|
|
||
| institutions = select(InstitutionsSelectors.getInstitutions); | ||
| totalInstitutionsCount = select(InstitutionsSelectors.getInstitutionsTotalCount); | ||
| institutionsLoading = select(InstitutionsSelectors.isInstitutionsLoading); | ||
|
|
||
| constructor() { | ||
| this.setupQueryParamsEffect(); | ||
| this.setupSearchSubscription(); | ||
| } | ||
|
|
||
| onPageChange(event: PaginatorState): void { | ||
| this.currentPage.set(event.page ? this.currentPage() + 1 : 1); | ||
| this.first.set(event.first ?? 0); | ||
| this.updateQueryParams({ | ||
| page: this.currentPage(), | ||
| size: event.rows, | ||
| }); | ||
| } | ||
|
|
||
| private setupQueryParamsEffect(): void { | ||
| effect(() => { | ||
| const rawQueryParams = this.queryParams(); | ||
| if (!rawQueryParams) return; | ||
|
|
||
| const parsedQueryParams = parseQueryFilterParams(rawQueryParams); | ||
|
|
||
| this.updateComponentState(parsedQueryParams); | ||
|
|
||
| this.actions.getInstitutions(parsedQueryParams.page, parsedQueryParams.size, parsedQueryParams.search); | ||
| }); | ||
| } | ||
|
|
||
| private updateQueryParams(updates: Partial<QueryParams>): void { | ||
| const queryParams: Record<string, string | undefined> = {}; | ||
|
|
||
| if ('page' in updates) { | ||
| queryParams['page'] = updates.page!.toString(); | ||
| } | ||
| if ('size' in updates) { | ||
| queryParams['size'] = updates.size!.toString(); | ||
| } | ||
| if ('search' in updates) { | ||
| queryParams['search'] = updates.search || undefined; | ||
| } | ||
|
|
||
| this.router.navigate([], { | ||
| relativeTo: this.route, | ||
| queryParams, | ||
| queryParamsHandling: 'merge', | ||
| }); | ||
| } | ||
|
|
||
| private setupSearchSubscription(): void { | ||
| this.searchControl.valueChanges | ||
| .pipe(debounceTime(300), distinctUntilChanged(), takeUntilDestroyed(this.destroyRef)) | ||
| .subscribe((searchControl) => { | ||
| this.updateQueryParams({ | ||
| search: searchControl ?? '', | ||
| page: 1, | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| private updateComponentState(params: QueryParams): void { | ||
| untracked(() => { | ||
| this.currentPage.set(params.page); | ||
| this.currentPageSize.set(params.size); | ||
| this.searchControl.setValue(params.search); | ||
| }); | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { Routes } from '@angular/router'; | ||
|
|
||
| import { InstitutionsComponent } from '@osf/features/institutions/institutions.component'; | ||
|
|
||
| export const routes: Routes = [ | ||
| { | ||
| path: '', | ||
| component: InstitutionsComponent, | ||
| }, | ||
| ]; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
src/app/features/institutions/services/institutions.service.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
src/app/features/institutions/store/institutions.selectors.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,3 +1,2 @@ | ||
| export * from './meeting-submissions-table.constants'; | ||
| export * from './meetings-fields.constants'; | ||
| export * from './meetings-table.constants'; |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.