-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: multi select for organisations
- Loading branch information
1 parent
f36319f
commit 548e659
Showing
13 changed files
with
156 additions
and
30 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
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
57 changes: 57 additions & 0 deletions
57
frontend/src/app/core/components/select-check-all.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,57 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { FormControl } from '@angular/forms'; | ||
import { | ||
MatCheckboxChange, | ||
MatCheckboxModule, | ||
} from '@angular/material/checkbox'; | ||
|
||
// adapted from https://onthecode.co.uk/blog/select-all-option-mat-select | ||
// needs a style in the global stylesheet. search for .app-select-check-all | ||
@Component({ | ||
selector: 'app-select-check-all', | ||
standalone: true, | ||
imports: [MatCheckboxModule], | ||
template: ` | ||
<mat-checkbox | ||
class="app-select-check-all" | ||
[indeterminate]="isIndeterminate()" | ||
[checked]="isChecked()" | ||
(click)="$event.stopPropagation()" | ||
(change)="toggleSelection($event)"> | ||
{{ text }} | ||
</mat-checkbox> | ||
`, | ||
}) | ||
export class SelectCheckAllComponent { | ||
@Input() | ||
model!: FormControl; | ||
@Input() values: string[] = []; | ||
@Input() text = 'Alle'; | ||
@Output() changeEvent = new EventEmitter<boolean>(); | ||
|
||
isChecked(): boolean { | ||
return ( | ||
this.model.value && | ||
this.values.length && | ||
this.model.value.length === this.values.length | ||
); | ||
} | ||
|
||
isIndeterminate(): boolean { | ||
return ( | ||
this.model.value && | ||
this.values.length && | ||
this.model.value.length && | ||
this.model.value.length < this.values.length | ||
); | ||
} | ||
|
||
toggleSelection(change: MatCheckboxChange): void { | ||
if (change.checked) { | ||
this.model.setValue(this.values); | ||
} else { | ||
this.model.setValue([]); | ||
} | ||
this.changeEvent.emit(change.checked); | ||
} | ||
} |
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
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