Skip to content
Merged
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
Prev Previous commit
Next Next commit
fix: #87 fixed issues and remove search component
  • Loading branch information
daros10 committed Apr 17, 2020
commit 2e9aef9c24225c30d1ac3c4a4fdcf9e1d1cb1f14
2 changes: 0 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { environment } from '../environments/environment';
import { CustomerComponent } from './modules/customer-management/pages/customer.component';
// tslint:disable-next-line: max-line-length
import { CustomerListComponent } from './modules/customer-management/components/customer-info/components/customer-list/customer-list.component';
import { SearchComponent } from './modules/customer-management/components/search/search.component';
// tslint:disable-next-line: max-line-length
import { ManagementCustomerProjectsComponent } from './modules/customer-management/components/management-customer-projects/management-customer-projects.component';
import { CreateCustomerComponent } from './modules/customer-management/components/customer-info/components/create-customer/create-customer';
Expand Down Expand Up @@ -78,7 +77,6 @@ import { CustomerEffects } from './modules/customer-management/store/customer-ma
SearchProjectComponent,
CustomerComponent,
CustomerListComponent,
SearchComponent,
ManagementCustomerProjectsComponent,
CreateCustomerComponent,
CreateProjectComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="form-group">
<div
*ngIf="showAlert && messageToShow !== ''"
[ngClass]="{'bg-secondary': messageToShow == 'Customer create successfully!', 'bg-primary': messageToShow != 'Customer create successfully!'}"
[ngClass]="{'bg-secondary': messageToShow == 'Customer created successfully!', 'bg-primary': messageToShow != 'Customer created successfully!'}"
class="alert alert-dismissible fade fade-in show text-white"
role="alert"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormBuilder } from '@angular/forms';
import { MockStore, provideMockStore } from '@ngrx/store/testing';

import { CreateCustomerComponent } from './create-customer';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { CustomerState, CreateCustomer } from 'src/app/modules/customer-management/store';
import { FormBuilder } from '@angular/forms';
import { Customer } from 'src/app/modules/shared/models/customer.model';
import * as models from 'src/app/modules/shared/models/index';

describe('CreateCustomerComponent', () => {
let component: CreateCustomerComponent;
Expand All @@ -17,7 +17,7 @@ describe('CreateCustomerComponent', () => {
message: '',
};

const customerData: Customer = {
const customerData: models.Customer = {
name: 'aa',
description: 'bb',
tenant_id: 'cc',
Expand Down Expand Up @@ -72,8 +72,8 @@ describe('CreateCustomerComponent', () => {
expect(component.customerForm.reset).toHaveBeenCalled();
});

it('should be enable tabs and show message Customer create successfully! ', () => {
component.isActiveItemTabs = false;
it('should be enable tabs and show message Customer created successfully! ', () => {
component.areTabsActive = false;
component.messageToShow = '';

spyOn(store, 'dispatch');
Expand All @@ -82,14 +82,14 @@ describe('CreateCustomerComponent', () => {

component.onSubmit(customerData);

component.setStatusOnScreen('Customer create successfully!');
component.setStatusOnScreen('Customer created successfully!');

expect(component.messageToShow).toEqual('Customer create successfully!');
expect(component.isActiveItemTabs).toBeTrue();
expect(component.messageToShow).toEqual('Customer created successfully!');
expect(component.areTabsActive).toBeTrue();
});

it('should be disabled tabs and show message Something went wrong creating customer! ', () => {
component.isActiveItemTabs = false;
it('should be disabled tabs and show message An error occurred, try again later. ', () => {
component.areTabsActive = false;
component.messageToShow = '';

spyOn(store, 'dispatch');
Expand All @@ -98,9 +98,9 @@ describe('CreateCustomerComponent', () => {

component.onSubmit(customerData);

component.setStatusOnScreen('Something went wrong creating customer!');
component.setStatusOnScreen('An error occurred, try again later.');

expect(component.messageToShow).toEqual('Something went wrong creating customer!');
expect(component.isActiveItemTabs).toBeFalse();
expect(component.messageToShow).toEqual('An error occurred, try again later.');
expect(component.areTabsActive).toBeFalse();
});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, Input, Output, EventEmitter, OnDestroy, OnInit } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { CustomerState, CreateCustomer } from 'src/app/modules/customer-management/store';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sort imports by module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

import { Store, select } from '@ngrx/store';

import { Subscription } from 'rxjs';
import { CustomerState, CreateCustomer } from 'src/app/modules/customer-management/store';
import { getStatusMessage } from 'src/app/modules/customer-management/store/customer-management.selectors';

@Component({
Expand All @@ -12,8 +13,8 @@ import { getStatusMessage } from 'src/app/modules/customer-management/store/cust
})
export class CreateCustomerComponent implements OnInit, OnDestroy {
customerForm: FormGroup;
@Input() isActiveItemTabs: boolean;
@Output() changeValueIsActiveItemTabs = new EventEmitter<boolean>();
@Input() areTabsActive: boolean;
@Output() changeValueAreTabsActives = new EventEmitter<boolean>();
showAlert = false;
messageToShow = '';
saveSubscription: Subscription;
Expand All @@ -29,12 +30,11 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
const messages$ = this.store.pipe(select(getStatusMessage));
this.saveSubscription = messages$.subscribe((valueMessage) => {
this.setStatusOnScreen(valueMessage);
console.log(valueMessage);
});
}

ngOnDestroy() {
this.isActiveItemTabs = false;
this.areTabsActive = false;
this.saveSubscription.unsubscribe();
}

Expand All @@ -44,14 +44,14 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
}

setStatusOnScreen(message: string) {
if (message === 'Customer create successfully!') {
if (message === 'Customer created successfully!') {
this.messageToShow = message;
this.isActiveItemTabs = true;
this.changeValueIsActiveItemTabs.emit(this.isActiveItemTabs);
} else if (message === 'Something went wrong creating customer!') {
this.areTabsActive = true;
this.changeValueAreTabsActives.emit(this.areTabsActive);
} else if (message === 'An error occurred, try again later.') {
this.messageToShow = message;
this.isActiveItemTabs = false;
this.changeValueIsActiveItemTabs.emit(this.isActiveItemTabs);
this.areTabsActive = false;
this.changeValueAreTabsActives.emit(this.areTabsActive);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
>
</li>
<li class="nav-item">
<!--nav-active-->
<a
class="nav-link text-black font-weight-bold"
[ngClass]="{ 'nav-active': isActiveNavsItemTabs, disabled: !isActiveNavsItemTabs }"
[ngClass]="{ 'nav-active': areTabsActive, disabled: !areTabsActive }"
id="projects-type-tab"
data-toggle="tab"
href="#projectsType"
Expand All @@ -27,7 +26,7 @@
<li class="nav-item">
<a
class="nav-link text-black font-weight-bold"
[ngClass]="{ 'nav-active': isActiveNavsItemTabs, disabled: !isActiveNavsItemTabs }"
[ngClass]="{ 'nav-active': areTabsActive, disabled: !areTabsActive }"
id="projects-tab"
data-toggle="tab"
href="#projects"
Expand All @@ -45,8 +44,8 @@
aria-labelledby="customer-information-tab"
>
<app-create-customer
[isActiveItemTabs]="isActiveNavsItemTabs"
(changeValueIsActiveItemTabs)="isActiveNavsItemTabs = $event"
[areTabsActive]="areTabsActive"
(changeValueAreTabsActives)="areTabsActive = $event"
></app-create-customer>
</div>
<div class="tab-pane fade mt-3" id="projects" role="tabpanel" aria-labelledby="projects-tab">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Component } from '@angular/core';
styleUrls: ['./management-customer-projects.component.scss'],
})
export class ManagementCustomerProjectsComponent {
isActiveNavsItemTabs = false;
areTabsActive = false;

constructor() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
<hr />
<div class="row text-right">
<hr />
<app-search></app-search>
<div class="col-5 text-right">
<app-search-project></app-search-project>
</div>
</div>
<app-project-list></app-project-list>
</div>

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ <h4>Customers</h4>
<div class="col">
<button (click)="activateCustomerForm()" type="button" class="btn btn-primary">Add new customer</button>
</div>
<app-search></app-search>
<div class="col-5 text-right">
<app-search-project></app-search-project>
</div>
</div>
<app-customer-list></app-customer-list>
<div class="row" *ngIf="showCustomerForm">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed, inject } from '@angular/core/testing';

import { CustomerService } from './customer.service';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { Customer } from '../../shared/models/customer.model';

describe('CustomerService', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpHeaders } from '@angular/common/http';

import { environment } from './../../../../environments/environment';
import { Observable } from 'rxjs';

@Injectable({
providedIn: 'root',
})
export class CustomerService {
baseUrl = `${environment.timeTrackerApiUrl}/customers`;
baseUrl = `https://private-8c3d21-ts32.apiary-mock.com/customers`;

constructor(private http: HttpClient) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ describe('customerManagementReducer', () => {
expect(state.isLoading).toEqual(false);
});

it('on CreateCustomerFail, message equal to Something went wrong creating customer! ', () => {
it('on CreateCustomerFail, message equal to An error occurred, try again later. ', () => {
const action = new actions.CreateCustomerFail('error');
const state = customerManagementReducer(initialState, action);

expect(state.message).toEqual('Something went wrong creating customer!');
expect(state.message).toEqual('An error occurred, try again later.');
expect(state.isLoading).toEqual(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function customerManagementReducer(
...state,
data: [action.payload],
isLoading: false,
message: 'Customer create successfully!',
message: 'Customer created successfully!',
};
}

Expand All @@ -39,7 +39,7 @@ export function customerManagementReducer(
...state,
data: [],
isLoading: false,
message: 'Something went wrong creating customer!',
message: 'An error occurred, try again later.',
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<div class="form-group">
<input (keyup)="changeFilterValue()" type="text" class="form-control" placeholder="&#xF002; Search projects..." name="filterProject" [(ngModel)]="filterProject" style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, FontAwesome">
</div>
<input
(keyup)="changeFilterValue()"
type="text"
class="form-control"
placeholder="&#xF002; Search..."
name="filterProject"
[(ngModel)]="filterProject"
style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, FontAwesome;"
/>
</div>
1 change: 1 addition & 0 deletions src/app/modules/shared/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './activity.model';
export * from './entry.model';
export * from './project.model';
export * from './technology.model';
export * from './customer.model';