mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
[SM-650] Updating search and select all to work together properly (#5510)
* Updating search and select all to work together properly * adding comment and moving filtered data below private variables * thomas suggested changes * making service-accounts-list the same as projects and secrest list * changes * Update service-accounts-list.component.ts * removing unnecessary code * setting active filter on set data, adding comment * removing unused field * Update libs/components/src/table/table-data-source.ts Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> --------- Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
This commit is contained in:
@@ -28,6 +28,7 @@ export class ServiceAccountsListComponent implements OnDestroy {
|
||||
|
||||
@Input()
|
||||
set search(search: string) {
|
||||
this.selection.clear();
|
||||
this.dataSource.filter = search;
|
||||
}
|
||||
|
||||
@@ -55,15 +56,20 @@ export class ServiceAccountsListComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
isAllSelected() {
|
||||
const numSelected = this.selection.selected.length;
|
||||
const numRows = this.serviceAccounts.length;
|
||||
return numSelected === numRows;
|
||||
if (this.selection.selected?.length > 0) {
|
||||
const numSelected = this.selection.selected.length;
|
||||
const numRows = this.dataSource.filteredData.length;
|
||||
return numSelected === numRows;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
toggleAll() {
|
||||
this.isAllSelected()
|
||||
? this.selection.clear()
|
||||
: this.selection.select(...this.serviceAccounts.map((s) => s.id));
|
||||
if (this.isAllSelected()) {
|
||||
this.selection.clear();
|
||||
} else {
|
||||
this.selection.select(...this.dataSource.filteredData.map((s) => s.id));
|
||||
}
|
||||
}
|
||||
|
||||
delete(serviceAccount: ServiceAccountView) {
|
||||
|
||||
@@ -26,6 +26,7 @@ export class ProjectsListComponent {
|
||||
|
||||
@Input()
|
||||
set search(search: string) {
|
||||
this.selection.clear();
|
||||
this.dataSource.filter = search;
|
||||
}
|
||||
|
||||
@@ -45,15 +46,20 @@ export class ProjectsListComponent {
|
||||
) {}
|
||||
|
||||
isAllSelected() {
|
||||
const numSelected = this.selection.selected.length;
|
||||
const numRows = this.projects.length;
|
||||
return numSelected === numRows;
|
||||
if (this.selection.selected?.length > 0) {
|
||||
const numSelected = this.selection.selected.length;
|
||||
const numRows = this.dataSource.filteredData.length;
|
||||
return numSelected === numRows;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
toggleAll() {
|
||||
this.isAllSelected()
|
||||
? this.selection.clear()
|
||||
: this.selection.select(...this.projects.map((s) => s.id));
|
||||
if (this.isAllSelected()) {
|
||||
this.selection.clear();
|
||||
} else {
|
||||
this.selection.select(...this.dataSource.filteredData.map((s) => s.id));
|
||||
}
|
||||
}
|
||||
|
||||
deleteProject(projectId: string) {
|
||||
|
||||
@@ -29,6 +29,7 @@ export class SecretsListComponent implements OnDestroy {
|
||||
|
||||
@Input()
|
||||
set search(search: string) {
|
||||
this.selection.clear();
|
||||
this.dataSource.filter = search;
|
||||
}
|
||||
|
||||
@@ -61,15 +62,20 @@ export class SecretsListComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
isAllSelected() {
|
||||
const numSelected = this.selection.selected.length;
|
||||
const numRows = this.secrets.length;
|
||||
return numSelected === numRows;
|
||||
if (this.selection.selected?.length > 0) {
|
||||
const numSelected = this.selection.selected.length;
|
||||
const numRows = this.dataSource.filteredData.length;
|
||||
return numSelected === numRows;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
toggleAll() {
|
||||
this.isAllSelected()
|
||||
? this.selection.clear()
|
||||
: this.selection.select(...this.secrets.map((s) => s.id));
|
||||
if (this.isAllSelected()) {
|
||||
this.selection.clear();
|
||||
} else {
|
||||
this.selection.select(...this.dataSource.filteredData.map((s) => s.id));
|
||||
}
|
||||
}
|
||||
|
||||
bulkDeleteSecrets() {
|
||||
|
||||
Reference in New Issue
Block a user