Skip to content

Commit fa8fe33

Browse files
committed
fix: #371 Add_confirmation_before_deleting_data
1 parent e6c6ec4 commit fa8fe33

File tree

15 files changed

+283
-62
lines changed

15 files changed

+283
-62
lines changed

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import {ReportsComponent} from './modules/reports/pages/reports.component';
6666
import {InputDateComponent} from './modules/shared/components/input-date/input-date.component';
6767
import {TimeRangeFormComponent} from './modules/reports/components/time-range-form/time-range-form.component';
6868
import {TimeEntriesTableComponent} from './modules/reports/components/time-entries-table/time-entries-table.component';
69+
import { DialogComponent } from './modules/shared/components/dialog/dialog.component';
6970

7071
const maskConfig: Partial<IConfig> = {
7172
validation: false,
@@ -112,6 +113,7 @@ const maskConfig: Partial<IConfig> = {
112113
InputDateComponent,
113114
TimeRangeFormComponent,
114115
TimeEntriesTableComponent,
116+
DialogComponent,
115117
],
116118
imports: [
117119
NgxMaskModule.forRoot(maskConfig),

src/app/modules/activities-management/components/activity-list/activity-list.component.html

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,33 @@
1010
<tr class="d-flex" *ngFor="let activity of activities">
1111
<td class="col-sm-9">{{ activity.name }}</td>
1212
<td class="col-sm-3 text-center">
13-
<button type="button" class="btn btn-sm btn-primary" (click)="updateActivity(activity.id)"><i
14-
class="fa fa-pencil fa-xs"></i></button>
15-
<button type="button" class="btn btn-sm btn-danger ml-2" (click)="deleteActivity(activity.id)"><i
16-
class="fas fa-trash-alt fa-xs"></i></button>
13+
<button type="button" class="btn btn-sm btn-primary" (click)="updateActivity(activity.id)">
14+
<i class="fa fa-pencil fa-xs"></i>
15+
</button>
16+
<button
17+
type="button"
18+
class="btn btn-sm btn-danger ml-2"
19+
data-toggle="modal"
20+
data-target="#deleteModal"
21+
(click)="openModal(activity)"
22+
>
23+
<i class="fas fa-trash-alt fa-xs"></i>
24+
</button>
1725
</td>
1826
</tr>
1927
</tbody>
2028
</table>
2129
</div>
30+
31+
<app-dialog
32+
*ngIf="showModal"
33+
class="modal fade"
34+
id="deleteModal"
35+
tabindex="-1"
36+
role="dialog"
37+
aria-hidden="true"
38+
[title]="'Delete Activity'"
39+
[list]="activityToDelete"
40+
(removeList)="deleteActivity($event)"
41+
>
42+
</app-dialog>

src/app/modules/activities-management/components/activity-list/activity-list.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { Activity } from '../../../shared/models';
1414
})
1515
export class ActivityListComponent implements OnInit {
1616
activities: Activity[] = [];
17+
showModal = false;
18+
activityToDelete: Activity;
1719

1820
constructor(private store: Store<ActivityState>) {}
1921

@@ -28,9 +30,15 @@ export class ActivityListComponent implements OnInit {
2830

2931
deleteActivity(activityId: string) {
3032
this.store.dispatch(new DeleteActivity(activityId));
33+
this.showModal = true;
3134
}
3235

3336
updateActivity(activityId: string) {
3437
this.store.dispatch(new SetActivityToEdit(activityId));
3538
}
39+
40+
openModal(item: Activity) {
41+
this.activityToDelete = item;
42+
this.showModal = true;
43+
}
3644
}
Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,46 @@
1-
<table *ngIf="customers" class="table table-sm table-bordered table-striped mb-0" datatable [dtTrigger]="dtTrigger" [dtOptions]="dtOptions">
1+
<table
2+
*ngIf="customers"
3+
class="table table-sm table-bordered table-striped mb-0"
4+
datatable
5+
[dtTrigger]="dtTrigger"
6+
[dtOptions]="dtOptions"
7+
>
28
<thead class="thead-blue">
39
<tr class="d-flex">
410
<th class="col-9">Name</th>
511
<th class="col-3 text-center">Options</th>
612
</tr>
713
</thead>
814
<tbody>
9-
<tr
10-
class="d-flex"
11-
*ngFor="let customer of customers"
12-
>
15+
<tr class="d-flex" *ngFor="let customer of customers">
1316
<td class="col-sm-9">{{ customer.name }}</td>
1417
<td class="col-sm-3 text-center">
1518
<button (click)="editCustomer(customer.id)" type="button" class="btn btn-sm btn-primary">
1619
<i class="fa fa-pencil fa-xs"></i>
1720
</button>
18-
<button (click)="deleteCustomer(customer.id)" type="button" class="btn btn-sm btn-danger ml-2">
21+
<button
22+
data-toggle="modal"
23+
data-target="#deleteModal"
24+
(click)="openModal(customer)"
25+
type="button"
26+
class="btn btn-sm btn-danger ml-2"
27+
>
1928
<i class="fa fa-trash-alt fa-xs"></i>
2029
</button>
2130
</td>
2231
</tr>
2332
</tbody>
2433
</table>
34+
35+
<app-dialog
36+
*ngIf="showModal"
37+
class="modal fade"
38+
id="deleteModal"
39+
tabindex="-1"
40+
role="dialog"
41+
aria-hidden="true"
42+
[title]="'Delete Customer'"
43+
[list]="customerToDelete"
44+
(removeList)="deleteCustomer($event)"
45+
>
46+
</app-dialog>

src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
2929
dtElement: DataTableDirective;
3030
loadCustomersSubscription: Subscription;
3131
changeCustomerSubscription: Subscription;
32+
showModal = false;
33+
customerToDelete: Customer;
3234

3335
constructor(private store: Store<Customer>, private actionsSubject$: ActionsSubject) { }
3436

@@ -79,6 +81,7 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
7981

8082
deleteCustomer(customerId: string) {
8183
this.store.dispatch(new DeleteCustomer(customerId));
84+
this.showModal = false;
8285
}
8386

8487
private rerenderDataTable(): void {
@@ -91,4 +94,9 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
9194
this.dtTrigger.next();
9295
}
9396
}
97+
98+
openModal(item: Customer) {
99+
this.customerToDelete = item;
100+
this.showModal = true;
101+
}
94102
}

src/app/modules/customer-management/components/projects-type/components/project-type-list/project-type-list.component.html

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,33 @@
1010
<tr class="d-flex" *ngFor="let projectType of projectTypes">
1111
<td class="col-sm-9">{{ projectType.name }}</td>
1212
<td class="col-sm-3 text-center">
13-
<button type="button" class="btn btn-sm btn-primary" (click)="updateProjectType(projectType.id)"><i
14-
class="fa fa-pencil fa-xs"></i></button>
15-
<button type="button" class="btn btn-sm btn-danger ml-2" (click)="deleteProjectType(projectType.id)"><i
16-
class="fas fa-trash-alt fa-xs"></i></button>
13+
<button type="button" class="btn btn-sm btn-primary" (click)="updateProjectType(projectType.id)">
14+
<i class="fa fa-pencil fa-xs"></i>
15+
</button>
16+
<button
17+
type="button"
18+
data-toggle="modal"
19+
data-target="#deleteModal"
20+
class="btn btn-sm btn-danger ml-2"
21+
(click)="openModal(projectType)"
22+
>
23+
<i class="fas fa-trash-alt fa-xs"></i>
24+
</button>
1725
</td>
1826
</tr>
1927
</tbody>
2028
</table>
2129
</div>
30+
31+
<app-dialog
32+
*ngIf="showModal"
33+
class="modal fade"
34+
id="deleteModal"
35+
tabindex="-1"
36+
role="dialog"
37+
aria-hidden="true"
38+
[title]="'Delete Activity'"
39+
[list]="projectTypeToDelete"
40+
(removeList)="deleteProjectType($event)"
41+
>
42+
</app-dialog>

src/app/modules/customer-management/components/projects-type/components/project-type-list/project-type-list.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export class ProjectTypeListComponent implements OnInit {
1616

1717
initPage2 = 1;
1818
itemsPerPage = ITEMS_PER_PAGE;
19+
showModal = false;
20+
projectTypeToDelete: ProjectType;
1921

2022
constructor(private store: Store<ProjectTypeState>) {}
2123

@@ -28,9 +30,15 @@ export class ProjectTypeListComponent implements OnInit {
2830

2931
deleteProjectType(projectTypeId: string) {
3032
this.store.dispatch(new DeleteProjectType(projectTypeId));
33+
this.showModal = false;
3134
}
3235

3336
updateProjectType(projectTypeId: string) {
3437
this.store.dispatch(new SetProjectTypeToEdit(projectTypeId));
3538
}
39+
40+
openModal(item: ProjectType) {
41+
this.projectTypeToDelete = item;
42+
this.showModal = true;
43+
}
3644
}

src/app/modules/customer-management/components/projects/components/project-list/project-list.component.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,30 @@
1313
<button type="button" class="btn btn-sm btn-primary" (click)="updateProject(project)">
1414
<i class="fa fa-pencil fa-xs"></i>
1515
</button>
16-
<button type="button" class="btn btn-sm btn-danger ml-2" (click)="deleteProject(project.id)">
16+
<button
17+
type="button"
18+
data-toggle="modal"
19+
data-target="#deleteModal"
20+
class="btn btn-sm btn-danger ml-2"
21+
(click)="openModal(project)"
22+
>
1723
<i class="fa fa-trash-alt fa-xs"></i>
1824
</button>
1925
</td>
2026
</tr>
2127
</tbody>
2228
</table>
2329
</div>
30+
31+
<app-dialog
32+
*ngIf="showModal"
33+
class="modal fade"
34+
id="deleteModal"
35+
tabindex="-1"
36+
role="dialog"
37+
aria-hidden="true"
38+
[title]="'Delete Activity'"
39+
[list]="projectToDelete"
40+
(removeList)="deleteProject($event)"
41+
>
42+
</app-dialog>

src/app/modules/customer-management/components/projects/components/project-list/project-list.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export class ProjectListComponent implements OnInit, OnDestroy {
1818
isLoading = false;
1919
projects: Project[] = [];
2020
filterProjects = '';
21+
showModal = false;
22+
projectToDelete: Project;
2123

2224
projectsSubscription: Subscription;
2325

@@ -41,5 +43,11 @@ export class ProjectListComponent implements OnInit, OnDestroy {
4143

4244
deleteProject(projectId: string) {
4345
this.store.dispatch(new actions.DeleteProject(projectId));
46+
this.showModal = false;
47+
}
48+
49+
openModal(item: Project) {
50+
this.projectToDelete = item;
51+
this.showModal = true;
4452
}
4553
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div class="modal-dialog" role="document">
2+
<div class="modal-content" *ngIf="list">
3+
<div class="modal-header">
4+
<h5 class="modal-title" >{{ title }}</h5>
5+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
6+
<span aria-hidden="true">&times;</span>
7+
</button>
8+
</div>
9+
<div class="modal-body">
10+
Are you sure you want to delete <b>{{ list.project_name || list.name }}</b>
11+
</div>
12+
<div class="modal-footer">
13+
<button #cancelDeleteModal type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
14+
<button (click)="removeListById(list.id)" type="button" class="btn btn-danger">Delete</button>
15+
</div>
16+
</div>
17+
</div>

0 commit comments

Comments
 (0)