Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Clear All" functionality for persons #44

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@
caption="Add person"
(click)="onAdd(content)">
</button>

<app-person-sort-buttons/>

@if ((personsCount$ | async)! > 0) {
<button app-delete-button
caption="Clear all persons"
confirmationMessage="Are you sure you want to clear all persons?"
(deleteConfirmed)="onDeleteAll()">
</button>
}
</div>

<div class="d-flex gap-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {PersonSortButtonsComponent} from '../../../shared/components/person-sort
import {PersonSlotFilterComponent} from '../../../shared/components/person-slot-filter/person-slot-filter.component';
import {SearchFieldComponent} from '../../../shared/components/search-field/search-field.component';
import {map} from 'rxjs';
import {DeleteButtonComponent} from '../../../shared/components/delete-button/delete-button.component';


@Component({
Expand All @@ -29,7 +30,8 @@ import {map} from 'rxjs';
AddButtonComponent,
PersonSortButtonsComponent,
PersonSlotFilterComponent,
SearchFieldComponent
SearchFieldComponent,
DeleteButtonComponent
],
templateUrl: './person-list.component.html',
styleUrl: './person-list.component.scss'
Expand Down Expand Up @@ -79,6 +81,11 @@ export class PersonListComponent {
}


protected onDeleteAll() {
this.personService.removeAllPersons();
}


private openOffcanvas(content: TemplateRef<any>, title: string) {
this.offcanvasTitle = title;

Expand Down
5 changes: 5 additions & 0 deletions src/app/persons/services/person.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ export class PersonService {
}


public removeAllPersons() {
this.persons.forEach(p => this.removePerson(p));
}


public addAvailablePerson(person: Person) {
this.availablePersons = this.availablePersons.concat(person);
this.sortAvailablePersons(this.nameSortOrder(), this.slotSortOrder());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
(click)="onAdd(content)">
</button>

<button app-delete-button caption="Clear all prior knowledge"
confirmationMessage="Are you sure you want to clear all prior knowledge?"
(deleteConfirmed)="onDeleteAll()">
</button>
@if ((knowledgeList$ | async)!.length > 0) {
<button app-delete-button caption="Clear all prior knowledge"
confirmationMessage="Are you sure you want to clear all prior knowledge?"
(deleteConfirmed)="onDeleteAll()">
</button>
}
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Component, inject, TemplateRef} from '@angular/core';
import {PriorKnowledgeService} from '../../services/prior-knowledge.service';
import {AsyncPipe} from '@angular/common';
import {PriorKnowledgeViewComponent} from '../prior-knowledge-view/prior-knowledge-view.component';
import {createPriorKnowledge, PriorKnowledge} from '../../models/prior-knowledge.model';
import {NgbOffcanvas, NgbOffcanvasOptions} from '@ng-bootstrap/ng-bootstrap';
Expand All @@ -9,18 +8,19 @@ import {DataNotAvailableInfoComponent} from "../../../shared/components/data-not
import {DataNotAvailableViewComponent} from '../../../shared/components/data-not-available-view/data-not-available-view.component';
import {AddButtonComponent} from "../../../shared/components/add-button/add-button.component";
import {DeleteButtonComponent} from "../../../shared/components/delete-button/delete-button.component";
import {AsyncPipe} from '@angular/common';


@Component({
selector: 'app-prior-knowledge-list',
imports: [
AsyncPipe,
PriorKnowledgeViewComponent,
PriorKnowledgeEditComponent,
DataNotAvailableInfoComponent,
DataNotAvailableViewComponent,
AddButtonComponent,
DeleteButtonComponent
DeleteButtonComponent,
AsyncPipe
],
templateUrl: './prior-knowledge-list.component.html',
styleUrl: './prior-knowledge-list.component.scss'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
</button>
}

<button app-delete-button
caption="Clear all time slots"
confirmationMessage="Are you sure you want to clear all time slots?"
(deleteConfirmed)="onDeleteAll()">
</button>
@if ((timeSlotCount$ | async)! > 0) {
<button app-delete-button
caption="Clear all time slots"
confirmationMessage="Are you sure you want to clear all time slots?"
(deleteConfirmed)="onDeleteAll()">
</button>
}
</div>
</div>
</div>
Expand Down