Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix: TT-26 notify
  • Loading branch information
scastillo-jp committed Mar 15, 2021
commit 2ca690f1778a3f86b6b285670b5dfe5bee2827da
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import {NgxMaterialTimepickerModule} from 'ngx-material-timepicker';
// tslint:disable-next-line: max-line-length
import { TechnologyReportTableComponent } from './modules/technology-report/components/technology-report-table/technology-report-table.component';
import { TechnologyReportComponent } from './modules/technology-report/pages/technology-report.component';
import { ModalDialogModule } from 'ngx-modal-dialog';

const maskConfig: Partial<IConfig> = {
validation: false,
Expand Down Expand Up @@ -144,6 +145,7 @@ const maskConfig: Partial<IConfig> = {
AutocompleteLibModule,
NgxMaterialTimepickerModule,
UiSwitchModule,
ModalDialogModule.forRoot(),
StoreModule.forRoot(reducers, {
metaReducers,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
formControlName="name"
placeholder="Customer name"
[class.is-invalid]="customerForm.invalid && customerForm.touched"
(input)="onSearchChange($event.target.value)"
required
/>
<span
Expand All @@ -23,6 +24,7 @@
rows="3"
formControlName="description"
placeholder="Customer description"
(input)="onSearchChange($event.target.value)"
></textarea>
</div>
<button type="submit" class="btn btn-primary" [disabled]="!customerForm.valid">Save</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { LoadCustomerProjects, CleanCustomerProjects } from '../../../projects/c
export class CreateCustomerComponent implements OnInit, OnDestroy {
customerForm: FormGroup;
@Input() areTabsActive: boolean;
@Input() haveChanges: boolean;
@Output() ishaveChanges = new EventEmitter<boolean>();
@Output() changeValueAreTabsActives = new EventEmitter<boolean>();
@Output() closeCustomerComponent = new EventEmitter<boolean>();
customerToEdit: Customer;
Expand Down Expand Up @@ -68,6 +70,7 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
this.store.dispatch(new LoadProjectTypes(customerData.id));
this.store.dispatch(new LoadCustomerProjects(customerData.id));
this.changeValueAreTabsActives.emit(true);
this.ishaveChanges.emit(this.haveChanges = false);
this.customerForm.setValue({
name: customerData.name,
description: customerData.description,
Expand All @@ -94,4 +97,14 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
this.store.dispatch(new ResetCustomerToEdit());
this.closeCustomerComponent.emit(false);
}

onSearchChange(searchValue: string): void {
if (searchValue) {
this.haveChanges = true;
this.ishaveChanges.emit(this.haveChanges);
} else {
this.haveChanges = false;
this.ishaveChanges.emit(this.haveChanges);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,28 @@
<td class="col-3 text-break">{{ customer.name }}</td>
<td class="col-4 text-center">
<button
data-toggle="modal"
(click)="editCustomer(customer.id)"
type="button"
data-target="#editModal"
class="btn btn-sm btn-primary"
>
<i class="fa fa-pencil fa-xs"></i>
<i class="fa fa-pencil fa-xs">{{haveChanges}}</i>
</button>

<app-dialog
*ngIf="showModal"
class="modal fade"
id="editModal"
tabindex="-1"
role="dialog"
aria-hidden="true"
[title]="'Edit Customer'"
[body]="message"
(closeModalEvent)="testMessage(customer.id)"
>
</app-dialog>

<button
data-toggle="modal"
data-target="#deleteModal"
Expand All @@ -52,4 +68,4 @@
[body]="message"
(closeModalEvent)="deleteCustomer()"
>
</app-dialog>
</app-dialog>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ResetProjectTypeToEdit } from '../../../projects-type/store';
})
export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
@Input() showCustomerForm: boolean;
@Input() haveChanges: boolean;
@Output() changeValueShowCustomerForm = new EventEmitter<boolean>();
@Input()
customers: Customer[] = [];
Expand Down Expand Up @@ -77,10 +78,25 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
}

editCustomer(customerId: string) {
if (this.haveChanges === true) {
this.message = `Do you have changes in a client, do you want to discard them?`;
this.showModal = true;
} else {
this.showCustomerForm = true;
this.showModal = false;
this.changeValueShowCustomerForm.emit(this.showCustomerForm);
this.resetProjectFieldsToEdit();
this.store.dispatch(new SetCustomerToEdit(customerId));
}
}

testMessage(customerId: string) {
this.showCustomerForm = true;
this.showModal = false;
this.haveChanges = null;
this.changeValueShowCustomerForm.emit(this.showCustomerForm);
this.store.dispatch(new SetCustomerToEdit(customerId));
this.resetProjectFieldsToEdit();
this.store.dispatch(new SetCustomerToEdit(customerId));
}

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ <h4 class="navbar-brand nav-title">{{customerName}}</h4>
<app-create-customer
[areTabsActive]="areTabsActive"
(changeValueAreTabsActives)="activeTabs($event)"
(ishaveChanges)="getChangesInputs($event)"
(closeCustomerComponent)="closeCustomer($event)"
></app-create-customer>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { Component, Output, EventEmitter, OnInit } from '@angular/core';
})
export class ManagementCustomerProjectsComponent implements OnInit {
@Output() closeCustemerForm = new EventEmitter<boolean>();
@Output() sendChanges = new EventEmitter<boolean>();
areTabsActive: boolean;
haveChanges: boolean;
activeTab: string;
customerName: string;

Expand Down Expand Up @@ -42,4 +44,11 @@ export class ManagementCustomerProjectsComponent implements OnInit {
this.activeTab = activeTab;
}

getChangesInputs($haveChanges: boolean) {
setTimeout(() => {
this.haveChanges = $haveChanges;
this.sendChanges.emit($haveChanges);
console.log('manager-custome-project detect changes : ', this.haveChanges);
}, 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
</div>
<app-customer-list
[showCustomerForm]="showCustomerForm"
[haveChanges]="haveChanges"
(changeValueShowCustomerForm)="showCustomerForm = $event"
></app-customer-list>
<div class="row" *ngIf="showCustomerForm">
<div class="col">
<app-management-customer-projects (closeCustemerForm)="closeCustomerForm($event)"></app-management-customer-projects>
<app-management-customer-projects (sendChanges)="getChangesInputs($event)" (closeCustemerForm)="closeCustomerForm($event)"></app-management-customer-projects>
</div>
</div>
</div>
10 changes: 9 additions & 1 deletion src/app/modules/customer-management/pages/customer.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Store } from '@ngrx/store';
import { Customer } from 'src/app/modules/shared/models';
import { SetCustomerToEdit } from 'src/app/modules/customer-management/store';
import { Component } from '@angular/core';
import { Component, Output, EventEmitter } from '@angular/core';

@Component({
selector: 'app-customer',
Expand All @@ -10,6 +10,8 @@ import { Component } from '@angular/core';
})
export class CustomerComponent {
showCustomerForm = false;
haveChanges = false;

activityName: string;

constructor(private store: Store<Customer>) { }
Expand All @@ -21,4 +23,10 @@ export class CustomerComponent {
closeCustomerForm(event) {
this.showCustomerForm = event;
}

getChangesInputs(event) {
this.haveChanges = event;
console.log('customer.component sending changes', this.haveChanges);
}

}
3 changes: 2 additions & 1 deletion src/app/modules/time-entries/pages/time-entries.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,5 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
this.message = `Are you sure you want to delete ${item.activity_name}?`;
this.showModal = true;
}
}

}