Skip to content

Commit

Permalink
feat: more bulk actions - delete/archive/anonymize multiple records f…
Browse files Browse the repository at this point in the history
…rom list (#2154)

closes #2092
  • Loading branch information
christophscheuing authored Feb 16, 2024
1 parent 189cd1c commit c642edf
Show file tree
Hide file tree
Showing 7 changed files with 385 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
</p>

<p i18n>
This record is archived and will be be hidden from lists and select
options by default.
This record is archived and will be hidden from lists and select options
by default.
</p>
</mat-card-content>

<mat-card-actions *ngIf="!entity.anonymized">
<button
mat-stroked-button
color="accent"
(click)="entityRemoveService.undoArchive(entity)"
(click)="entityActionsService.undoArchive(entity)"
>
Reactivate
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ import { EntityActionsService } from "../../entity/entity-actions/entity-actions
export class EntityArchivedInfoComponent {
@Input() entity: Entity;

constructor(public entityRemoveService: EntityActionsService) {}
constructor(public entityActionsService: EntityActionsService) {}
}
33 changes: 33 additions & 0 deletions src/app/core/entity-list/entity-list/entity-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,39 @@ <h2>{{ title }}</h2>
<div>Actions on selected records:</div>

<div class="flex-row gap-small bulk-action-button">
<button
mat-raised-button
(click)="archiveRecords()"
[disabled]="selectedRows.length === 0"
matTooltip="Select rows to archive"
i18n-matTooltip
color="accent"
i18n="bulk action button"
>
Archive
</button>
<button
mat-raised-button
(click)="anonymizeRecords()"
[disabled]="selectedRows.length === 0"
matTooltip="Select rows to anonymize"
i18n-matTooltip
color="accent"
i18n="bulk action button"
>
Anonymize
</button>
<button
mat-raised-button
(click)="deleteRecords()"
[disabled]="selectedRows.length === 0"
matTooltip="Select rows to delete"
i18n-matTooltip
color="accent"
i18n="bulk action button"
>
Delete
</button>
<button
mat-raised-button
(click)="duplicateRecords()"
Expand Down
17 changes: 17 additions & 0 deletions src/app/core/entity-list/entity-list/entity-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { MatTooltipModule } from "@angular/material/tooltip";
import { Sort } from "@angular/material/sort";
import { ExportColumnConfig } from "../../export/data-transformation-service/export-column-config";
import { RouteTarget } from "../../../route-target";
import { EntityActionsService } from "app/core/entity/entity-actions/entity-actions.service";
import { EntitiesTableComponent } from "../../common-components/entities-table/entities-table.component";
import { applyUpdate } from "../../entity/model/entity-update";
import { Subscription } from "rxjs";
Expand Down Expand Up @@ -160,6 +161,7 @@ export class EntityListComponent<T extends Entity>
private entities: EntityRegistry,
private dialog: MatDialog,
private duplicateRecord: DuplicateRecordService,
private entityActionsService: EntityActionsService,
) {
this.screenWidthObserver
.platform()
Expand Down Expand Up @@ -294,6 +296,21 @@ export class EntityListComponent<T extends Entity>
this.selectedRows = undefined;
}

async deleteRecords() {
await this.entityActionsService.delete(this.selectedRows);
this.selectedRows = undefined;
}

async archiveRecords() {
await this.entityActionsService.archive(this.selectedRows);
this.selectedRows = undefined;
}

async anonymizeRecords() {
await this.entityActionsService.anonymize(this.selectedRows);
this.selectedRows = undefined;
}

onRowClick(row: T) {
this.elementClick.emit(row);
}
Expand Down
Loading

0 comments on commit c642edf

Please sign in to comment.