-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: more conversions to use signals (#388)
- Loading branch information
Showing
43 changed files
with
501 additions
and
572 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,9 @@ proxy.conf.json | |
npm-debug.log | ||
yarn-error.log | ||
|
||
# NX | ||
.nx/cache | ||
|
||
# IDEs and editors | ||
.idea/ | ||
.project | ||
|
3 changes: 2 additions & 1 deletion
3
src/app/common/dialog/configurable-dialog/configurable-dialog.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,8 @@ export class DialogService { | |
{ | ||
title, | ||
message, | ||
okText | ||
okText, | ||
hideCancel: true | ||
}, | ||
modalOptions | ||
); | ||
|
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
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 |
---|---|---|
@@ -1,59 +1,60 @@ | ||
import { | ||
DestroyRef, | ||
Directive, | ||
HostBinding, | ||
Input, | ||
OnInit, | ||
SimpleChange, | ||
inject | ||
booleanAttribute, | ||
inject, | ||
input | ||
} from '@angular/core'; | ||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; | ||
|
||
import { NgSelectComponent } from '@ng-select/ng-select'; | ||
|
||
@Directive({ | ||
selector: 'ng-select[multi-select]', | ||
standalone: true | ||
standalone: true, | ||
// eslint-disable-next-line @angular-eslint/no-host-metadata-property | ||
host: { | ||
['class.ng-hide-arrow-wrapper']: 'hideArrow()' | ||
} | ||
}) | ||
export class MultiSelectDirective implements OnInit { | ||
private select = inject(NgSelectComponent); | ||
|
||
private destroyRef = inject(DestroyRef); | ||
readonly #select = inject(NgSelectComponent); | ||
readonly #destroyRef = inject(DestroyRef); | ||
|
||
@Input() | ||
@HostBinding('class.ng-hide-arrow-wrapper') | ||
hideArrow = true; | ||
readonly hideArrow = input(true, { transform: booleanAttribute }); | ||
|
||
ngOnInit() { | ||
this.select.addTag = true; | ||
this.select.hideSelected = true; | ||
this.select.multiple = true; | ||
this.#select.addTag = true; | ||
this.#select.hideSelected = true; | ||
this.#select.multiple = true; | ||
this.updateIsOpen(false); | ||
|
||
// change detection doesn't work properly when setting items programmatically | ||
// tslint:disable-next-line:no-lifecycle-call | ||
this.select.ngOnChanges({ | ||
this.#select.ngOnChanges({ | ||
items: new SimpleChange([], [], true) | ||
}); | ||
|
||
this.select.addEvent.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => { | ||
this.#select.addEvent.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => { | ||
this.updateIsOpen(false); | ||
}); | ||
this.select.searchEvent.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => { | ||
this.#select.searchEvent.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => { | ||
const isOpen = event.term.trim().length > 0; | ||
this.updateIsOpen(isOpen); | ||
}); | ||
// Clear the items on clear event. Fixes bug where cleared items are suggested as options. | ||
this.select.clearEvent.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => { | ||
this.select.itemsList.setItems([]); | ||
this.#select.clearEvent.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => { | ||
this.#select.itemsList.setItems([]); | ||
}); | ||
} | ||
|
||
private updateIsOpen(isOpen: boolean) { | ||
// change detection doesn't work properly when setting input programmatically | ||
// tslint:disable-next-line:no-lifecycle-call | ||
const change = new SimpleChange(this.select.isOpen, isOpen, false); | ||
this.select.isOpen = isOpen; | ||
this.select.ngOnChanges({ isOpen: change }); | ||
const change = new SimpleChange(this.#select.isOpen, isOpen, false); | ||
this.#select.isOpen = isOpen; | ||
this.#select.ngOnChanges({ isOpen: change }); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,47 @@ | ||
import { HttpErrorResponse } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
|
||
import { BehaviorSubject } from 'rxjs'; | ||
import { Injectable, signal } from '@angular/core'; | ||
|
||
import { SystemAlert } from './system-alert.model'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class SystemAlertService { | ||
private id = 0; | ||
private defaultType = 'danger'; | ||
private alerts: SystemAlert[] = []; | ||
alerts$: BehaviorSubject<SystemAlert[]> = new BehaviorSubject(this.alerts); | ||
#id = 0; | ||
#defaultType = 'danger'; | ||
#alerts = signal<SystemAlert[]>([]); | ||
|
||
alerts = this.#alerts.asReadonly(); | ||
|
||
clearAllAlerts() { | ||
this.alerts.length = 0; | ||
this.alerts$.next(this.alerts); | ||
this.#alerts.set([]); | ||
} | ||
|
||
clear(index: number) { | ||
this.alerts.splice(index, 1); | ||
this.alerts$.next(this.alerts); | ||
this.#alerts.update((a) => { | ||
a.splice(index, 1); | ||
return [...a]; | ||
}); | ||
} | ||
|
||
clearAlertById(id: number) { | ||
const index = this.alerts.findIndex((value) => value.id === id); | ||
const index = this.#alerts().findIndex((value) => value.id === id); | ||
this.clear(index); | ||
} | ||
|
||
addAlert(msg: string, type?: string, ttl?: number, subtext?: string) { | ||
const alert = new SystemAlert(this.id++, type || this.defaultType, msg, subtext); | ||
|
||
this.alerts.push(alert); | ||
const alert = new SystemAlert(this.#id++, type || this.#defaultType, msg, subtext); | ||
|
||
// If they passed in a ttl parameter, age off the alert after said timeout | ||
if (ttl && ttl > 0) { | ||
if (ttl ?? 0 > 0) { | ||
setTimeout(() => this.clearAlertById(alert.id), ttl); | ||
} | ||
this.alerts$.next(this.alerts); | ||
this.#alerts.update((alerts) => [...alerts, alert]); | ||
} | ||
|
||
addClientErrorAlert(error: HttpErrorResponse) { | ||
if (error.status >= 400 && error.status < 500) { | ||
this.addAlert(error.error.message); | ||
} | ||
} | ||
|
||
getAlerts(): SystemAlert[] { | ||
return this.alerts; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/app/common/table/actions-menu-column/actions-menu-column.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
10 changes: 5 additions & 5 deletions
10
src/app/common/table/columns/ago-date/ago-date-column.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
Oops, something went wrong.