-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
641 additions
and
246 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
42 changes: 42 additions & 0 deletions
42
.../activities/activity-feed/feed-filters/org-filter-select/org-filter-select.component.html
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<nz-select | ||
nzPlaceHolder="Select Organization" | ||
nzMode="multiple" | ||
nzAllowClear | ||
[(ngModel)]="cvcOrganizationId" | ||
(nzOnSearch)="onSearch$.next($event)" | ||
[nzCustomTemplate]="organizationLabel" | ||
[nzNotFoundContent]="notFound" | ||
[nzOptionHeightPx]="28"> | ||
<nz-option | ||
*ngFor="let organization of filteredOrganizations()" | ||
nzCustomContent | ||
[nzLabel]="organization.name" | ||
[nzValue]="organization.id"> | ||
<ng-container | ||
*ngTemplateOutlet=" | ||
organizationLabel; | ||
context: { | ||
$implicit: { | ||
nzLabel: organization.name, | ||
nzValue: organization.id, | ||
}, | ||
} | ||
"> | ||
</ng-container> | ||
</nz-option> | ||
</nz-select> | ||
|
||
<ng-template | ||
#organizationLabel | ||
let-selected> | ||
<span | ||
nz-icon | ||
[nzType]="'civic-organization'" | ||
nzTheme="twotone" | ||
[nzTwotoneColor]="'Organization' | entityColor"></span> | ||
{{ selected.nzLabel }} | ||
</ng-template> | ||
|
||
<ng-template #notFound> | ||
<span>No organizationsfound matching "{{ onSearch() }}"</span> | ||
</ng-template> |
Empty file.
70 changes: 70 additions & 0 deletions
70
...ts/activities/activity-feed/feed-filters/org-filter-select/org-filter-select.component.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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { Component, input, model, Signal } from '@angular/core' | ||
import { ActivityFeedFilterOptions } from '../../activity-feed.types' | ||
import { CvcPipesModule } from '@app/core/pipes/pipes.module' | ||
import { CommonModule } from '@angular/common' | ||
import { NzSelectModule } from 'ng-zorro-antd/select' | ||
import { NzIconModule } from 'ng-zorro-antd/icon' | ||
import { FormsModule } from '@angular/forms' | ||
import { | ||
BrowseOrganization, | ||
Organization, | ||
OrgFilterSearchGQL, | ||
OrgFilterSearchQuery, | ||
OrgFilterSearchQueryVariables, | ||
} from '@app/generated/civic.apollo' | ||
import { from, map, Subject, switchMap } from 'rxjs' | ||
import { QueryRef } from 'apollo-angular' | ||
import { tag } from 'rxjs-spy/operators' | ||
import { toSignal } from '@angular/core/rxjs-interop' | ||
|
||
@Component({ | ||
selector: 'cvc-org-filter-select', | ||
standalone: true, | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
NzIconModule, | ||
NzSelectModule, | ||
CvcPipesModule, | ||
], | ||
templateUrl: './org-filter-select.component.html', | ||
styleUrl: './org-filter-select.component.less', | ||
}) | ||
export class CvcOrgFilterSelect { | ||
cvcParticipatingOrganizations = | ||
input.required<ActivityFeedFilterOptions['participatingOrganizations']>() | ||
cvcOrganizationId = model.required<number[]>() | ||
|
||
onSearch$: Subject<string> | ||
onSearch: Signal<string> | ||
queryRef!: QueryRef<OrgFilterSearchQuery, OrgFilterSearchQueryVariables> | ||
filteredOrganizations: Signal<BrowseOrganization[]> | ||
|
||
constructor(private gql: OrgFilterSearchGQL) { | ||
this.onSearch$ = new Subject<string>() | ||
const filteredOrganizations$ = this.onSearch$.pipe( | ||
tag(`filteredOrganizations$`), | ||
switchMap((nameStr) => { | ||
const query = { name: nameStr, first: 25 } | ||
if (this.queryRef) { | ||
const refetch = this.queryRef.refetch({ name: nameStr }) | ||
return from(refetch) | ||
} else { | ||
this.queryRef = this.gql.watch({ name: nameStr }) | ||
return this.queryRef.valueChanges | ||
} | ||
}), | ||
map( | ||
(result) => | ||
result.data?.organizations.edges.map( | ||
(e) => e.node! as BrowseOrganization | ||
) ?? [] | ||
), | ||
tag(`${this.constructor.name} filteredOrganizations$ after`) | ||
) | ||
this.filteredOrganizations = toSignal(filteredOrganizations$, { | ||
initialValue: [], | ||
}) | ||
this.onSearch = toSignal(this.onSearch$, { initialValue: '' }) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...nents/activities/activity-feed/feed-filters/org-filter-select/org-filter-select.query.gql
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
query OrgFilterSearch($name: String) { | ||
organizations(name: $name) { | ||
pageInfo { | ||
endCursor | ||
hasNextPage | ||
hasPreviousPage | ||
startCursor | ||
} | ||
edges { | ||
node { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ctivities/activity-feed/feed-filters/user-filter-select/user-filter-select.component.html
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<nz-select | ||
nzPlaceHolder="Select User" | ||
nzMode="multiple" | ||
nzAllowClear | ||
[(ngModel)]="cvcUserId" | ||
(nzOnSearch)="onSearch$.next($event)" | ||
[nzCustomTemplate]="userLabel" | ||
[nzNotFoundContent]="notFound" | ||
[nzOptionOverflowSize]="12" | ||
[nzOptionHeightPx]="28"> | ||
<nz-option | ||
*ngFor="let user of filteredUsers()" | ||
nzCustomContent | ||
[nzLabel]="user.displayName" | ||
[nzValue]="user.id"> | ||
<ng-container | ||
*ngTemplateOutlet=" | ||
userLabel; | ||
context: { | ||
$implicit: { | ||
nzLabel: user.displayName ?? user.name ?? user.username, | ||
nzValue: user.id, | ||
}, | ||
} | ||
"> | ||
</ng-container> | ||
</nz-option> | ||
</nz-select> | ||
|
||
<ng-template | ||
#userLabel | ||
let-selected> | ||
<span | ||
nz-icon | ||
[nzType]="'civic-curator'" | ||
nzTheme="twotone" | ||
[nzTwotoneColor]="'Curator' | entityColor"></span> | ||
{{ selected.nzLabel }} | ||
</ng-template> | ||
|
||
<ng-template #notFound> | ||
<span>No users found matching "{{ onSearch() }}"</span> | ||
</ng-template> |
Empty file.
Oops, something went wrong.