Skip to content

Commit 49ad574

Browse files
committed
fix: TT-29 Modal-implemented
1 parent 9db07be commit 49ad574

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<td class="col-5 text-break">{{ customer.id }}</td>
1515
<td class="col-3 text-break">{{ customer.name }}</td>
1616
<td class="col-4 text-center">
17-
<button (click)="editCustomer(customer.id)" type="button" class="btn btn-sm btn-primary">
17+
<button data-toggle="modal" data-target="#editModal" (click)="openEditModal(customer)" type="button" class="btn btn-sm btn-primary">
1818
<i class="fa fa-pencil fa-xs"></i>
1919
</button>
2020
<button data-toggle="modal" data-target="#deleteModal" (click)="openModal(customer)" type="button"
@@ -30,3 +30,6 @@
3030
<app-dialog *ngIf="showModal" class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-hidden="true"
3131
[title]="'Delete Customer'" [body]="message" (closeModalEvent)="deleteCustomer()">
3232
</app-dialog>
33+
<app-dialog *ngIf="showModal" class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-hidden="true"
34+
[title]="'Edit Customer'" [body]="message" (closeModalEvent)="editCustomer()">
35+
</app-dialog>

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import {
1313
} from './../../../../store/customer-management.actions';
1414
import { ResetProjectToEdit } from '../../../projects/components/store/project.actions';
1515
import { ResetProjectTypeToEdit } from '../../../projects-type/store';
16-
//import { EntryState } from 'src/app/modules/time-clock/store/entry.reducer';
17-
//import { ConsoleReporter } from 'jasmine';
16+
import { EntryState } from 'src/app/modules/time-clock/store/entry.reducer';
1817
@Component({
1918
selector: 'app-customer-list',
2019
templateUrl: './customer-list.component.html',
@@ -33,6 +32,7 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
3332
changeCustomerSubscription: Subscription;
3433
showModal = false;
3534
idToDelete: string;
35+
idToEdit: string;
3636
message: string;
3737
isLoading$: Observable<boolean>;
3838

@@ -78,10 +78,10 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
7878
this.dtTrigger.unsubscribe();
7979
}
8080

81-
editCustomer(customerId: string) {
81+
editCustomer() {
8282
this.showCustomerForm = true;
8383
this.changeValueShowCustomerForm.emit(this.showCustomerForm);
84-
this.store.dispatch(new SetCustomerToEdit(customerId));
84+
this.store.dispatch(new SetCustomerToEdit(this.idToEdit));
8585
this.resetProjectFieldsToEdit();
8686
}
8787

@@ -111,13 +111,14 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
111111
this.message = `Are you sure you want to delete ${item.name}?`;
112112
this.showModal = true;
113113
}
114-
/*openEditModal(customerId: string) {
115-
if(){
116-
editCustomer(customer.id)
117-
}else{
118-
this.idToDelete = item.id;
114+
openEditModal(item: Customer) {
115+
if (this.showCustomerForm === true) {
116+
this.idToEdit = item.id;
119117
this.message = `The changes will lose. Are you sure you change to customer ${item.name}?`;
120118
this.showModal = true;
119+
} else {
120+
this.idToEdit = item.id;
121+
this.editCustomer();
121122
}
122-
}*/
123+
}
123124
}

0 commit comments

Comments
 (0)