Skip to content

Commit 2ca690f

Browse files
committed
fix: TT-26 notify
1 parent 118e0d1 commit 2ca690f

File tree

10 files changed

+75
-7
lines changed

10 files changed

+75
-7
lines changed

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import {NgxMaterialTimepickerModule} from 'ngx-material-timepicker';
7777
// tslint:disable-next-line: max-line-length
7878
import { TechnologyReportTableComponent } from './modules/technology-report/components/technology-report-table/technology-report-table.component';
7979
import { TechnologyReportComponent } from './modules/technology-report/pages/technology-report.component';
80+
import { ModalDialogModule } from 'ngx-modal-dialog';
8081

8182
const maskConfig: Partial<IConfig> = {
8283
validation: false,
@@ -144,6 +145,7 @@ const maskConfig: Partial<IConfig> = {
144145
AutocompleteLibModule,
145146
NgxMaterialTimepickerModule,
146147
UiSwitchModule,
148+
ModalDialogModule.forRoot(),
147149
StoreModule.forRoot(reducers, {
148150
metaReducers,
149151
}),

src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
formControlName="name"
99
placeholder="Customer name"
1010
[class.is-invalid]="customerForm.invalid && customerForm.touched"
11+
(input)="onSearchChange($event.target.value)"
1112
required
1213
/>
1314
<span
@@ -23,6 +24,7 @@
2324
rows="3"
2425
formControlName="description"
2526
placeholder="Customer description"
27+
(input)="onSearchChange($event.target.value)"
2628
></textarea>
2729
</div>
2830
<button type="submit" class="btn btn-primary" [disabled]="!customerForm.valid">Save</button>

src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { LoadCustomerProjects, CleanCustomerProjects } from '../../../projects/c
2323
export class CreateCustomerComponent implements OnInit, OnDestroy {
2424
customerForm: FormGroup;
2525
@Input() areTabsActive: boolean;
26+
@Input() haveChanges: boolean;
27+
@Output() ishaveChanges = new EventEmitter<boolean>();
2628
@Output() changeValueAreTabsActives = new EventEmitter<boolean>();
2729
@Output() closeCustomerComponent = new EventEmitter<boolean>();
2830
customerToEdit: Customer;
@@ -68,6 +70,7 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
6870
this.store.dispatch(new LoadProjectTypes(customerData.id));
6971
this.store.dispatch(new LoadCustomerProjects(customerData.id));
7072
this.changeValueAreTabsActives.emit(true);
73+
this.ishaveChanges.emit(this.haveChanges = false);
7174
this.customerForm.setValue({
7275
name: customerData.name,
7376
description: customerData.description,
@@ -94,4 +97,14 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
9497
this.store.dispatch(new ResetCustomerToEdit());
9598
this.closeCustomerComponent.emit(false);
9699
}
100+
101+
onSearchChange(searchValue: string): void {
102+
if (searchValue) {
103+
this.haveChanges = true;
104+
this.ishaveChanges.emit(this.haveChanges);
105+
} else {
106+
this.haveChanges = false;
107+
this.ishaveChanges.emit(this.haveChanges);
108+
}
109+
}
97110
}

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,28 @@
2020
<td class="col-3 text-break">{{ customer.name }}</td>
2121
<td class="col-4 text-center">
2222
<button
23+
data-toggle="modal"
2324
(click)="editCustomer(customer.id)"
2425
type="button"
26+
data-target="#editModal"
2527
class="btn btn-sm btn-primary"
2628
>
27-
<i class="fa fa-pencil fa-xs"></i>
29+
<i class="fa fa-pencil fa-xs">{{haveChanges}}</i>
2830
</button>
31+
32+
<app-dialog
33+
*ngIf="showModal"
34+
class="modal fade"
35+
id="editModal"
36+
tabindex="-1"
37+
role="dialog"
38+
aria-hidden="true"
39+
[title]="'Edit Customer'"
40+
[body]="message"
41+
(closeModalEvent)="testMessage(customer.id)"
42+
>
43+
</app-dialog>
44+
2945
<button
3046
data-toggle="modal"
3147
data-target="#deleteModal"
@@ -52,4 +68,4 @@
5268
[body]="message"
5369
(closeModalEvent)="deleteCustomer()"
5470
>
55-
</app-dialog>
71+
</app-dialog>

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ResetProjectTypeToEdit } from '../../../projects-type/store';
2020
})
2121
export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
2222
@Input() showCustomerForm: boolean;
23+
@Input() haveChanges: boolean;
2324
@Output() changeValueShowCustomerForm = new EventEmitter<boolean>();
2425
@Input()
2526
customers: Customer[] = [];
@@ -77,10 +78,25 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
7778
}
7879

7980
editCustomer(customerId: string) {
81+
if (this.haveChanges === true) {
82+
this.message = `Do you have changes in a client, do you want to discard them?`;
83+
this.showModal = true;
84+
} else {
85+
this.showCustomerForm = true;
86+
this.showModal = false;
87+
this.changeValueShowCustomerForm.emit(this.showCustomerForm);
88+
this.resetProjectFieldsToEdit();
89+
this.store.dispatch(new SetCustomerToEdit(customerId));
90+
}
91+
}
92+
93+
testMessage(customerId: string) {
8094
this.showCustomerForm = true;
95+
this.showModal = false;
96+
this.haveChanges = null;
8197
this.changeValueShowCustomerForm.emit(this.showCustomerForm);
82-
this.store.dispatch(new SetCustomerToEdit(customerId));
8398
this.resetProjectFieldsToEdit();
99+
this.store.dispatch(new SetCustomerToEdit(customerId));
84100
}
85101

86102
private resetProjectFieldsToEdit() {
@@ -109,5 +125,4 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
109125
this.message = `Are you sure you want to delete ${item.name}?`;
110126
this.showModal = true;
111127
}
112-
113128
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ <h4 class="navbar-brand nav-title">{{customerName}}</h4>
5555
<app-create-customer
5656
[areTabsActive]="areTabsActive"
5757
(changeValueAreTabsActives)="activeTabs($event)"
58+
(ishaveChanges)="getChangesInputs($event)"
5859
(closeCustomerComponent)="closeCustomer($event)"
5960
></app-create-customer>
6061
</div>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import { Component, Output, EventEmitter, OnInit } from '@angular/core';
1010
})
1111
export class ManagementCustomerProjectsComponent implements OnInit {
1212
@Output() closeCustemerForm = new EventEmitter<boolean>();
13+
@Output() sendChanges = new EventEmitter<boolean>();
1314
areTabsActive: boolean;
15+
haveChanges: boolean;
1416
activeTab: string;
1517
customerName: string;
1618

@@ -42,4 +44,11 @@ export class ManagementCustomerProjectsComponent implements OnInit {
4244
this.activeTab = activeTab;
4345
}
4446

47+
getChangesInputs($haveChanges: boolean) {
48+
setTimeout(() => {
49+
this.haveChanges = $haveChanges;
50+
this.sendChanges.emit($haveChanges);
51+
console.log('manager-custome-project detect changes : ', this.haveChanges);
52+
}, 1);
53+
}
4554
}

src/app/modules/customer-management/pages/customer.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
</div>
77
<app-customer-list
88
[showCustomerForm]="showCustomerForm"
9+
[haveChanges]="haveChanges"
910
(changeValueShowCustomerForm)="showCustomerForm = $event"
1011
></app-customer-list>
1112
<div class="row" *ngIf="showCustomerForm">
1213
<div class="col">
13-
<app-management-customer-projects (closeCustemerForm)="closeCustomerForm($event)"></app-management-customer-projects>
14+
<app-management-customer-projects (sendChanges)="getChangesInputs($event)" (closeCustemerForm)="closeCustomerForm($event)"></app-management-customer-projects>
1415
</div>
1516
</div>
1617
</div>

src/app/modules/customer-management/pages/customer.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Store } from '@ngrx/store';
22
import { Customer } from 'src/app/modules/shared/models';
33
import { SetCustomerToEdit } from 'src/app/modules/customer-management/store';
4-
import { Component } from '@angular/core';
4+
import { Component, Output, EventEmitter } from '@angular/core';
55

66
@Component({
77
selector: 'app-customer',
@@ -10,6 +10,8 @@ import { Component } from '@angular/core';
1010
})
1111
export class CustomerComponent {
1212
showCustomerForm = false;
13+
haveChanges = false;
14+
1315
activityName: string;
1416

1517
constructor(private store: Store<Customer>) { }
@@ -21,4 +23,10 @@ export class CustomerComponent {
2123
closeCustomerForm(event) {
2224
this.showCustomerForm = event;
2325
}
26+
27+
getChangesInputs(event) {
28+
this.haveChanges = event;
29+
console.log('customer.component sending changes', this.haveChanges);
30+
}
31+
2432
}

src/app/modules/time-entries/pages/time-entries.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,5 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
165165
this.message = `Are you sure you want to delete ${item.activity_name}?`;
166166
this.showModal = true;
167167
}
168-
}
168+
169+
}

0 commit comments

Comments
 (0)