diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 30cd0a596..89313ee17 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -28,11 +28,11 @@ import { ActivitiesManagementComponent } from './modules/activities-management/p import { ActivityListComponent } from './modules/activities-management/components/activity-list/activity-list.component'; import { CreateActivityComponent } from './modules/activities-management/components/create-activity/create-activity.component'; import { FilterProjectPipe } from './modules/shared/pipes/filter-project/filter-project.pipe'; -import { SearchProjectComponent } from './modules/shared/components/search-project/search-project.component'; +import { SearchComponent } from './modules/shared/components/search/search.component'; import { HomeComponent } from './modules/home/home.component'; import { LoginComponent } from './modules/login/login.component'; import { ActivityEffects } from './modules/activities-management/store/activity-management.effects'; -import { ProjectEffects } from './modules/project-management/store/project.effects'; +import { ProjectEffects } from './modules/customer-management/components/projects/components/store/project.effects'; import { TechnologyEffects } from './modules/shared/store/technology.effects'; import { ProjectTypeEffects } from './modules/customer-management/components/projects-type/store/project-type.effects'; import { reducers, metaReducers } from './reducers'; @@ -77,7 +77,7 @@ import { InjectTokenInterceptor } from './modules/shared/interceptors/inject.tok HomeComponent, LoginComponent, FilterProjectPipe, - SearchProjectComponent, + SearchComponent, CustomerComponent, CustomerListComponent, ManagementCustomerProjectsComponent, diff --git a/src/app/modules/activities-management/services/activity.service.spec.ts b/src/app/modules/activities-management/services/activity.service.spec.ts index 8906c83de..bddd39355 100644 --- a/src/app/modules/activities-management/services/activity.service.spec.ts +++ b/src/app/modules/activities-management/services/activity.service.spec.ts @@ -60,9 +60,9 @@ describe('Activity Service', () => { service.deleteActivity(activities[0].id).subscribe((activitiesInResponse) => { expect(activitiesInResponse.filter((activity) => activity.id !== activities[0].id)).toEqual([activities[1]]); }); - const getActivitiesRequest = httpMock.expectOne(url); - expect(getActivitiesRequest.request.method).toBe('DELETE'); - getActivitiesRequest.flush(activities); + const deleteActivitiesRequest = httpMock.expectOne(url); + expect(deleteActivitiesRequest.request.method).toBe('DELETE'); + deleteActivitiesRequest.flush(activities); }); it('update activity using PUT from baseUrl', () => { diff --git a/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.html b/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.html index ddb09b322..511e12599 100644 --- a/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.html +++ b/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.html @@ -49,7 +49,10 @@ >
- +
+ + +
diff --git a/src/app/modules/customer-management/components/projects-type/store/project-type.selectors.ts b/src/app/modules/customer-management/components/projects-type/store/project-type.selectors.ts index 389f5d2d2..8d838bec3 100644 --- a/src/app/modules/customer-management/components/projects-type/store/project-type.selectors.ts +++ b/src/app/modules/customer-management/components/projects-type/store/project-type.selectors.ts @@ -12,10 +12,14 @@ export const projectTypeIdToEdit = createSelector(getProjectTypeState, (state: P return state.projectTypeIdToEdit; }); -export const getProjectTypeById = createSelector(allProjectTypes, projectTypeIdToEdit, (projectType, projectTypeId) => { - if (projectType && projectTypeId) { - return projectType.find((activity) => { - return activity.id === projectTypeId; - }); +export const getProjectTypeById = createSelector( + allProjectTypes, + projectTypeIdToEdit, + (projectTypes, projectTypeId) => { + if (projectTypes && projectTypeId) { + return projectTypes.find((projectType) => { + return projectType.id === projectTypeId; + }); + } } -}); +); diff --git a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.html b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.html index 57df0f0ce..8c47f5e87 100644 --- a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.html +++ b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.html @@ -1,28 +1,36 @@ -
-
-
- - - - - -
-
-
-
-
-
- +
+
+ +
+ Project name is required.
- -
+ +
+ +
+ + + +
diff --git a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts index 4db7c5c75..5bcfc541c 100644 --- a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts +++ b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts @@ -1,14 +1,43 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - +import { MockStore, provideMockStore } from '@ngrx/store/testing'; +import { FormBuilder } from '@angular/forms'; +import { Subscription } from 'rxjs'; import { CreateProjectComponent } from './create-project.component'; +import { ProjectState } from '../store/project.reducer'; +import { Project } from 'src/app/modules/shared/models'; +import { getProjectToEdit } from '../store/project.selectors'; +import { UpdateProject, CreateProject, ResetProjectToEdit } from '../store/project.actions'; describe('InputProjectComponent', () => { let component: CreateProjectComponent; let fixture: ComponentFixture; + let store: MockStore; + let getProjectToEditMock; + + const state = { + projectList: [{ id: '', name: '', project_type_id: '' }], + isLoading: false, + message: '', + projectToEdit: undefined, + }; + + const project: Project = { + id: '1', + name: 'Test', + description: 'xxx', + project_type_id: '123', + }; + + const projectForm = { + name: 'Test', + description: 'xxx', + project_type_id: '123', + }; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [CreateProjectComponent], + providers: [FormBuilder, provideMockStore({ initialState: state })], }).compileComponents(); })); @@ -16,9 +45,107 @@ describe('InputProjectComponent', () => { fixture = TestBed.createComponent(CreateProjectComponent); component = fixture.componentInstance; fixture.detectChanges(); + + store = TestBed.inject(MockStore); + store.setState(state); + + component.projectToEditSubscription = new Subscription(); + component.projectTypesSubscription = new Subscription(); + }); + + afterEach(() => { + fixture.destroy(); }); it('component should be created', () => { expect(component).toBeTruthy(); }); + + it('should destroy the subscriptions', () => { + component.projectToEditSubscription = new Subscription(); + component.projectTypesSubscription = new Subscription(); + const subscription = spyOn(component.projectToEditSubscription, 'unsubscribe'); + const projectTypeSubscription = spyOn(component.projectTypesSubscription, 'unsubscribe'); + + component.ngOnDestroy(); + + expect(subscription).toHaveBeenCalledTimes(1); + expect(projectTypeSubscription).toHaveBeenCalledTimes(1); + }); + + it('should reset form #onSubmit and dispatch UpdateProject action', () => { + const currentState = { + data: [project], + isLoading: false, + message: '', + projectToEdit: project, + }; + + getProjectToEditMock = store.overrideSelector(getProjectToEdit, currentState.projectToEdit); + component.projectToEdit = getProjectToEditMock; + + const projectUpdated = { + id: component.projectToEdit.id, + name: 'Test', + description: 'xxx', + project_type_id: '123', + }; + + component.projectToEditSubscription = new Subscription(); + component.projectTypesSubscription = new Subscription(); + spyOn(component.projectForm, 'reset'); + spyOn(store, 'dispatch'); + const subscription = spyOn(component.projectToEditSubscription, 'unsubscribe'); + const projectTypeSubscription = spyOn(component.projectTypesSubscription, 'unsubscribe'); + + component.onSubmit(projectForm); + component.ngOnDestroy(); + + expect(subscription).toHaveBeenCalledTimes(1); + expect(projectTypeSubscription).toHaveBeenCalledTimes(1); + + expect(component.projectForm.reset).toHaveBeenCalled(); + expect(store.dispatch).toHaveBeenCalledTimes(1); + expect(store.dispatch).toHaveBeenCalledWith(new UpdateProject(projectUpdated)); + }); + + it('should reset form onSubmit and dispatch CreateProject action', () => { + component.projectToEdit = undefined; + + spyOn(component.projectForm, 'reset'); + spyOn(store, 'dispatch'); + + component.onSubmit(project); + + expect(component.projectForm.reset).toHaveBeenCalled(); + expect(store.dispatch).toHaveBeenCalledTimes(1); + expect(store.dispatch).toHaveBeenCalledWith(new CreateProject(project)); + }); + + it('should set data in projectForm', () => { + component.projectToEditSubscription = new Subscription(); + component.projectTypesSubscription = new Subscription(); + component.projectToEdit = project; + + const subscription = spyOn(component.projectToEditSubscription, 'unsubscribe'); + const projectTypeSubscription = spyOn(component.projectTypesSubscription, 'unsubscribe'); + spyOn(component.projectForm, 'setValue'); + + component.setDataToUpdate(project); + component.ngOnDestroy(); + + expect(subscription).toHaveBeenCalledTimes(1); + expect(projectTypeSubscription).toHaveBeenCalledTimes(1); + expect(component.projectForm.setValue).toHaveBeenCalledTimes(1); + expect(component.projectForm.setValue).toHaveBeenCalledWith(projectForm); + }); + + it('should dispatch a ResetActivityToEdit action', () => { + spyOn(store, 'dispatch'); + + component.cancelButton(); + + expect(store.dispatch).toHaveBeenCalledTimes(1); + expect(store.dispatch).toHaveBeenCalledWith(new ResetProjectToEdit()); + }); }); diff --git a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.ts b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.ts index a487c4204..be8f0f0dc 100644 --- a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.ts +++ b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.ts @@ -1,10 +1,89 @@ -import { Component } from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { FormBuilder, Validators } from '@angular/forms'; +import { Store, select } from '@ngrx/store'; + +import { ProjectState } from '../store/project.reducer'; +import * as actions from '../store/project.actions'; +import { getProjectToEdit } from '../store/project.selectors'; +import { Project, ProjectType } from 'src/app/modules/shared/models'; +import { allProjectTypes, ProjectTypeState } from '../../../projects-type/store'; +import { Subscription } from 'rxjs'; @Component({ selector: 'app-create-project', templateUrl: './create-project.component.html', styleUrls: ['./create-project.component.scss'], }) -export class CreateProjectComponent { - constructor() {} +export class CreateProjectComponent implements OnInit, OnDestroy { + projectForm; + projectToEdit: Project; + projectsTypes: ProjectType[] = []; + + projectTypesSubscription: Subscription; + projectToEditSubscription: Subscription; + constructor( + private formBuilder: FormBuilder, + private store: Store, + private projectTypeStore: Store + ) { + this.projectForm = this.formBuilder.group({ + name: ['', Validators.required], + description: [''], + project_type_id: [''], + }); + } + + ngOnInit() { + const projectToEditSubscription = this.store.pipe(select(getProjectToEdit)); + projectToEditSubscription.subscribe((project) => { + this.projectToEdit = project; + this.setDataToUpdate(this.projectToEdit); + }); + + const projectTypesSubscription = this.projectTypeStore.pipe(select(allProjectTypes)); + projectTypesSubscription.subscribe((projectsType) => { + this.projectsTypes = projectsType; + }); + } + + ngOnDestroy() { + this.projectToEditSubscription.unsubscribe(); + this.projectTypesSubscription.unsubscribe(); + } + + onSubmit(formData) { + this.projectForm.reset(); + if (this.projectToEdit) { + const projectData = { id: this.projectToEdit.id, ...formData }; + this.store.dispatch(new actions.UpdateProject(projectData)); + } else { + this.store.dispatch(new actions.CreateProject(formData)); + } + } + + get name() { + return this.projectForm.get('name'); + } + + get description() { + return this.projectForm.get('description'); + } + + get project_type_id() { + return this.projectForm.get('project_type_id'); + } + + setDataToUpdate(projectData: Project) { + if (projectData) { + this.projectForm.setValue({ + name: projectData.name, + description: projectData.description, + project_type_id: projectData.project_type_id, + }); + } + } + + cancelButton() { + this.store.dispatch(new actions.ResetProjectToEdit()); + } } diff --git a/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.html b/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.html index 36a702d45..ed10b4e63 100644 --- a/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.html +++ b/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.html @@ -1,3 +1,9 @@ +
+
+
+ +
+
@@ -8,12 +14,20 @@ diff --git a/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.spec.ts b/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.spec.ts index 78bad5ba3..88970513b 100644 --- a/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.spec.ts +++ b/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.spec.ts @@ -1,16 +1,33 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ProjectListComponent } from './project-list.component'; +import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { NgxPaginationModule } from 'ngx-pagination'; +import { Subscription } from 'rxjs'; +import { ProjectListComponent } from './project-list.component'; +import { ProjectState } from '../store/project.reducer'; +import { allProjects } from '../store/project.selectors'; +import { SetProjectToEdit, DeleteProject } from '../store/project.actions'; +import { FilterProjectPipe } from '../../../../../shared/pipes'; -describe('ProjectTableListComponent', () => { +describe('ProjectListComponent', () => { let component: ProjectListComponent; let fixture: ComponentFixture; + let store: MockStore; + let allProjectsSelectorMock; + + const state = { + projectList: [{ id: 'id', name: 'name', project_type_id: '' }], + isLoading: false, + message: '', + projectToEdit: undefined, + }; + + const project = { id: '123', name: 'aaa', description: 'xxx', project_type_id: '1234' }; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [NgxPaginationModule], - declarations: [ProjectListComponent], + declarations: [ProjectListComponent, FilterProjectPipe], + providers: [provideMockStore({ initialState: state })], }).compileComponents(); })); @@ -18,9 +35,60 @@ describe('ProjectTableListComponent', () => { fixture = TestBed.createComponent(ProjectListComponent); component = fixture.componentInstance; fixture.detectChanges(); + + store = TestBed.inject(MockStore); + store.setState(state); + allProjectsSelectorMock = store.overrideSelector(allProjects, state.projectToEdit); + component.projectsSubscription = new Subscription(); + }); + + afterEach(() => { + fixture.destroy(); }); it('component should be created', () => { expect(component).toBeTruthy(); }); + + it('onInit, LoadProjects action is dispatched', () => { + spyOn(store, 'dispatch'); + + component.ngOnInit(); + + expect(store.dispatch).toHaveBeenCalled(); + }); + + it('should destroy the subscriptions', () => { + component.projectsSubscription = new Subscription(); + const subscription = spyOn(component.projectsSubscription, 'unsubscribe'); + + component.ngOnDestroy(); + + expect(subscription).toHaveBeenCalledTimes(1); + }); + + it('updateProject, should dispatch SetProjectToEdit action', () => { + component.projectsSubscription = new Subscription(); + const subscription = spyOn(component.projectsSubscription, 'unsubscribe'); + spyOn(store, 'dispatch'); + component.updateProject(project); + component.ngOnDestroy(); + + expect(subscription).toHaveBeenCalledTimes(1); + expect(store.dispatch).toHaveBeenCalledTimes(1); + expect(store.dispatch).toHaveBeenCalledWith(new SetProjectToEdit(project)); + }); + + it('deleteProject, should dispatch DeleteProject action', () => { + component.projectsSubscription = new Subscription(); + const subscription = spyOn(component.projectsSubscription, 'unsubscribe'); + + spyOn(store, 'dispatch'); + component.deleteProject(project.id); + component.ngOnDestroy(); + + expect(subscription).toHaveBeenCalledTimes(1); + expect(store.dispatch).toHaveBeenCalledTimes(1); + expect(store.dispatch).toHaveBeenCalledWith(new DeleteProject(project.id)); + }); }); diff --git a/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.ts b/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.ts index 27a7fe347..9eab41537 100644 --- a/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.ts +++ b/src/app/modules/customer-management/components/projects/components/project-list/project-list.component.ts @@ -1,25 +1,46 @@ -import { Component } from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { Store, select } from '@ngrx/store'; +import { Subscription } from 'rxjs'; import { ITEMS_PER_PAGE } from 'src/environments/environment'; +import { Project } from 'src/app/modules/shared/models'; +import { ProjectState } from '../store/project.reducer'; +import { allProjects } from '../store/project.selectors'; +import * as actions from '../store/project.actions'; @Component({ selector: 'app-project-list', templateUrl: './project-list.component.html', styleUrls: ['./project-list.component.scss'], }) -export class ProjectListComponent { +export class ProjectListComponent implements OnInit, OnDestroy { initPage3 = 1; itemsPerPage = ITEMS_PER_PAGE; + isLoading = false; + projects: Project[] = []; + filterProjects = ''; - projects = [ - { - id: '1', - name: 'Mobile app', - }, - { - id: '2', - name: 'Legacy code', - }, - ]; + projectsSubscription: Subscription; - constructor() {} + constructor(private store: Store) {} + + ngOnInit(): void { + this.store.dispatch(new actions.LoadProjects()); + const projectsSubscription = this.store.pipe(select(allProjects)); + projectsSubscription.subscribe((response) => { + this.isLoading = response.isLoading; + this.projects = response.projectList; + }); + } + + ngOnDestroy() { + this.projectsSubscription.unsubscribe(); + } + + updateProject(project) { + this.store.dispatch(new actions.SetProjectToEdit(project)); + } + + deleteProject(projectId: string) { + this.store.dispatch(new actions.DeleteProject(projectId)); + } } diff --git a/src/app/modules/project-management/services/project.service.spec.ts b/src/app/modules/customer-management/components/projects/components/services/project.service.spec.ts similarity index 77% rename from src/app/modules/project-management/services/project.service.spec.ts rename to src/app/modules/customer-management/components/projects/components/services/project.service.spec.ts index 8e3dcc0bc..7e72f5d74 100644 --- a/src/app/modules/project-management/services/project.service.spec.ts +++ b/src/app/modules/customer-management/components/projects/components/services/project.service.spec.ts @@ -1,6 +1,6 @@ import { TestBed, inject } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { Project } from '../../shared/models'; +import { Project } from '../../../../../shared/models'; import { ProjectService } from './project.service'; describe('ProjectService', () => { @@ -12,16 +12,19 @@ describe('ProjectService', () => { id: '1', name: 'app 1', description: 'It is a good app', + project_type_id: '123', }, { id: '2', name: 'app 2', description: 'It is a good app', + project_type_id: '123', }, { id: '3', name: 'app 3', description: 'It is a good app', + project_type_id: '123', }, ]; @@ -57,7 +60,7 @@ describe('ProjectService', () => { }); it('create project using POST from url', () => { - const project: Project[] = [{ id: '1', name: 'ccc', description: 'xxx' }]; + const project: Project[] = [{ id: '1', name: 'ccc', description: 'xxx', project_type_id: '123' }]; service.url = 'projects'; service.createProject(project).subscribe((response) => { expect(response.length).toBe(1); @@ -68,7 +71,7 @@ describe('ProjectService', () => { }); it('update project using PUT from url', () => { - const project: Project = { id: '1', name: 'new name', description: 'description' }; + const project: Project = { id: '1', name: 'new name', description: 'description', project_type_id: '123' }; service.url = 'projects'; service.updateProject(project).subscribe((response) => { expect(response.name).toBe('new name'); @@ -77,4 +80,14 @@ describe('ProjectService', () => { expect(updateProjectRequest.request.method).toBe('PUT'); updateProjectRequest.flush(project); }); + + it('delete project using DELETE from baseUrl', () => { + const url = `${service.url}/1`; + service.deleteProject(projectsList[0].id).subscribe((projectsInResponse) => { + expect(projectsInResponse.filter((project) => project.id !== projectsList[0].id).length).toEqual(2); + }); + const deleteActivitiesRequest = httpMock.expectOne(url); + expect(deleteActivitiesRequest.request.method).toBe('DELETE'); + deleteActivitiesRequest.flush(projectsList); + }); }); diff --git a/src/app/modules/project-management/services/project.service.ts b/src/app/modules/customer-management/components/projects/components/services/project.service.ts similarity index 62% rename from src/app/modules/project-management/services/project.service.ts rename to src/app/modules/customer-management/components/projects/components/services/project.service.ts index d30d8e771..b3ac3df18 100644 --- a/src/app/modules/project-management/services/project.service.ts +++ b/src/app/modules/customer-management/components/projects/components/services/project.service.ts @@ -1,8 +1,9 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { environment } from './../../../../environments/environment'; -import { Project } from '../../shared/models'; +import { environment } from '../../../../../../../environments/environment'; +import { Project } from '../../../../../shared/models'; +import { AzureAdB2CService } from '../../../../../login/services/azure.ad.b2c.service'; @Injectable({ providedIn: 'root', @@ -11,7 +12,7 @@ export class ProjectService { projects: Project[] = []; url = `${environment.timeTrackerApiUrl}/projects`; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, private azureAdB2CService: AzureAdB2CService) {} getProjects(): Observable { return this.http.get(this.url); @@ -21,7 +22,6 @@ export class ProjectService { return this.http.post(this.url, { ...projectData, customer_id: 'b6e6a2f1-ce5c-49b3-8649-d154b4f3c305', - tenant_id: 'b95385bd-d0f4-4823-b874-af9421c14c8e', }); } @@ -29,4 +29,8 @@ export class ProjectService { const { id } = projectData; return this.http.put(`${this.url}/${id}`, projectData); } + + deleteProject(projectId: string): Observable { + return this.http.delete(`${this.url}/${projectId}`); + } } diff --git a/src/app/modules/project-management/store/project.actions.spec.ts b/src/app/modules/customer-management/components/projects/components/store/project.actions.spec.ts similarity index 60% rename from src/app/modules/project-management/store/project.actions.spec.ts rename to src/app/modules/customer-management/components/projects/components/store/project.actions.spec.ts index 6600a194a..1042d5627 100644 --- a/src/app/modules/project-management/store/project.actions.spec.ts +++ b/src/app/modules/customer-management/components/projects/components/store/project.actions.spec.ts @@ -16,6 +16,7 @@ describe('Actions for Projects', () => { id: '1', name: 'Training', description: 'It is good for learning', + project_type_id: '123', }); expect(createProjectSuccess.type).toEqual(actions.ProjectActionTypes.CREATE_PROJECT_SUCCESS); }); @@ -30,6 +31,7 @@ describe('Actions for Projects', () => { id: '1', name: 'Training', description: 'It is good for learning', + project_type_id: '123', }); expect(updateProjectSuccess.type).toEqual(actions.ProjectActionTypes.UPDATE_PROJECT_SUCCESS); }); @@ -38,4 +40,29 @@ describe('Actions for Projects', () => { const updateProjectFail = new actions.UpdateProjectFail('error'); expect(updateProjectFail.type).toEqual(actions.ProjectActionTypes.UPDATE_PROJECT_FAIL); }); + + it('SetProjectToEdit type is ProjectActionTypes.SET_PROJECT_TO_EDIT', () => { + const setProjectToEdit = new actions.SetProjectToEdit({ + id: '1', + name: 'Training', + description: 'It is good for learning', + project_type_id: '123', + }); + expect(setProjectToEdit.type).toEqual(actions.ProjectActionTypes.SET_PROJECT_TO_EDIT); + }); + + it('ResetProjectToEdit type is ActivityManagementActionTypes.RESET_PROJECT_TO_EDIT', () => { + const resetProjectToEdit = new actions.ResetProjectToEdit(); + expect(resetProjectToEdit.type).toEqual(actions.ProjectActionTypes.RESET_PROJECT_TO_EDIT); + }); + + it('DeleteProjectSuccess type is ProjectActionTypes.DELETE_PROJECT_SUCCESS', () => { + const deleteProjectSuccess = new actions.DeleteProjectSuccess('1'); + expect(deleteProjectSuccess.type).toEqual(actions.ProjectActionTypes.DELETE_PROJECT_SUCCESS); + }); + + it('DeleteProjectFail type is ProjectActionTypes.DELETE_PROJECT_FAIL', () => { + const deleteProjectFail = new actions.DeleteProjectFail('error'); + expect(deleteProjectFail.type).toEqual(actions.ProjectActionTypes.DELETE_PROJECT_FAIL); + }); }); diff --git a/src/app/modules/project-management/store/project.actions.ts b/src/app/modules/customer-management/components/projects/components/store/project.actions.ts similarity index 63% rename from src/app/modules/project-management/store/project.actions.ts rename to src/app/modules/customer-management/components/projects/components/store/project.actions.ts index 97fbcf671..53f3c272f 100644 --- a/src/app/modules/project-management/store/project.actions.ts +++ b/src/app/modules/customer-management/components/projects/components/store/project.actions.ts @@ -1,5 +1,5 @@ import { Action } from '@ngrx/store'; -import { Project } from '../../shared/models'; +import { Project } from '../../../../../shared/models'; export enum ProjectActionTypes { LOAD_PROJECTS = '[Projects] LOAD_PROJECTS', @@ -11,6 +11,11 @@ export enum ProjectActionTypes { UPDATE_PROJECT = '[Projects] UPDATE_PROJECT', UPDATE_PROJECT_SUCCESS = '[Projects] UPDATE_PROJECT_SUCCESS', UPDATE_PROJECT_FAIL = '[Projects] UPDATE_PROJECT_FAIL', + SET_PROJECT_TO_EDIT = '[Projects] SET_PROJECT_TO_EDIT', + RESET_PROJECT_TO_EDIT = '[Projects] RESET_PROJECT_TO_EDIT', + DELETE_PROJECT = '[Projects] DELETE_PROJECT', + DELETE_PROJECT_SUCCESS = '[Projects] DELETE_PROJECT_SUCESS', + DELETE_PROJECT_FAIL = '[Projects] DELETE_PROJECT_FAIL', } export class LoadProjects implements Action { @@ -64,6 +69,34 @@ export class UpdateProjectFail implements Action { constructor(public error: string) {} } +export class SetProjectToEdit implements Action { + public readonly type = ProjectActionTypes.SET_PROJECT_TO_EDIT; + + constructor(public payload: Project) {} +} + +export class ResetProjectToEdit implements Action { + public readonly type = ProjectActionTypes.RESET_PROJECT_TO_EDIT; +} + +export class DeleteProject implements Action { + public readonly type = ProjectActionTypes.DELETE_PROJECT; + + constructor(public projectId: string) {} +} + +export class DeleteProjectSuccess implements Action { + public readonly type = ProjectActionTypes.DELETE_PROJECT_SUCCESS; + + constructor(public projectId: string) {} +} + +export class DeleteProjectFail implements Action { + public readonly type = ProjectActionTypes.DELETE_PROJECT_FAIL; + + constructor(public error: string) {} +} + export type ProjectActions = | LoadProjects | LoadProjectsSuccess @@ -73,4 +106,9 @@ export type ProjectActions = | CreateProjectFail | UpdateProject | UpdateProjectSuccess - | UpdateProjectFail; + | UpdateProjectFail + | SetProjectToEdit + | ResetProjectToEdit + | DeleteProject + | DeleteProjectSuccess + | DeleteProjectFail; diff --git a/src/app/modules/project-management/store/project.effects.ts b/src/app/modules/customer-management/components/projects/components/store/project.effects.ts similarity index 79% rename from src/app/modules/project-management/store/project.effects.ts rename to src/app/modules/customer-management/components/projects/components/store/project.effects.ts index 269651203..c4c85f782 100644 --- a/src/app/modules/project-management/store/project.effects.ts +++ b/src/app/modules/customer-management/components/projects/components/store/project.effects.ts @@ -1,8 +1,8 @@ import { Injectable } from '@angular/core'; -import { ofType, Actions, Effect } from '@ngrx/effects'; -import { Action } from '@ngrx/store'; import { of, Observable } from 'rxjs'; import { catchError, map, mergeMap } from 'rxjs/operators'; +import { Action } from '@ngrx/store'; +import { ofType, Actions, Effect } from '@ngrx/effects'; import { ProjectService } from '../services/project.service'; import * as actions from './project.actions'; @@ -50,4 +50,18 @@ export class ProjectEffects { ) ) ); + + @Effect() + deleteProject$: Observable = this.actions$.pipe( + ofType(actions.ProjectActionTypes.DELETE_PROJECT), + map((action: actions.DeleteProject) => action.projectId), + mergeMap((projectId) => + this.projectService.deleteProject(projectId).pipe( + map(() => { + return new actions.DeleteProjectSuccess(projectId); + }), + catchError((error) => of(new actions.DeleteProjectFail(error))) + ) + ) + ); } diff --git a/src/app/modules/project-management/store/project.reducer.spec.ts b/src/app/modules/customer-management/components/projects/components/store/project.reducer.spec.ts similarity index 52% rename from src/app/modules/project-management/store/project.reducer.spec.ts rename to src/app/modules/customer-management/components/projects/components/store/project.reducer.spec.ts index d6b3193ca..eb5bdcd16 100644 --- a/src/app/modules/project-management/store/project.reducer.spec.ts +++ b/src/app/modules/customer-management/components/projects/components/store/project.reducer.spec.ts @@ -1,9 +1,10 @@ -import { Project } from './../../shared/models'; +import { Project } from '../../../../../shared/models'; import * as actions from './project.actions'; import { projectReducer, ProjectState } from './project.reducer'; describe('projectReducer', () => { - const initialState: ProjectState = { projectList: [], isLoading: false }; + const initialState: ProjectState = { projectList: [], isLoading: false, message: '', projectToEdit: undefined }; + const project: Project = { id: '1', name: 'aaa', description: 'bbb', project_type_id: '123' }; it('on LoadProjects, isLoading is true', () => { const action = new actions.LoadProjects(); @@ -12,7 +13,7 @@ describe('projectReducer', () => { }); it('on LoadProjectsSuccess, projectsFound are saved in the store', () => { - const projectsFound: Project[] = [{ id: '', name: '', description: '' }]; + const projectsFound: Project[] = [{ id: '', name: '', description: '', project_type_id: '123' }]; const action = new actions.LoadProjectsSuccess(projectsFound); const state = projectReducer(initialState, action); expect(state.projectList).toEqual(projectsFound); @@ -25,7 +26,6 @@ describe('projectReducer', () => { }); it('on CreateProject, isLoading is true', () => { - const project: Project = { id: '1', name: 'Training', description: 'It is good for learning' }; const action = new actions.CreateProject(project); const state = projectReducer(initialState, action); @@ -33,7 +33,6 @@ describe('projectReducer', () => { }); it('on CreateProjectSuccess, project is saved in the store', () => { - const project: Project = { id: '1', name: 'Training', description: 'It is good for learning' }; const action = new actions.CreateProjectSuccess(project); const state = projectReducer(initialState, action); @@ -50,7 +49,6 @@ describe('projectReducer', () => { }); it('on UpdateProject, isLoading is true', () => { - const project: Project = { id: '1', name: 'Training', description: 'It is good for learning' }; const action = new actions.UpdateProject(project); const state = projectReducer(initialState, action); @@ -58,8 +56,12 @@ describe('projectReducer', () => { }); it('on UpdateProjectSuccess, project is saved in the store', () => { - const project: Project = { id: '1', name: 'Training', description: 'It is good for learning' }; - const currentState: ProjectState = { projectList: [project], isLoading: false }; + const currentState: ProjectState = { + projectList: [project], + isLoading: false, + message: '', + projectToEdit: project, + }; const action = new actions.UpdateProjectSuccess(project); const state = projectReducer(currentState, action); @@ -74,4 +76,56 @@ describe('projectReducer', () => { expect(state.projectList).toEqual([]); expect(state.isLoading).toEqual(false); }); + + it('on SetProjectToEdit, should save the project to edit', () => { + const action = new actions.SetProjectToEdit(project); + + const state = projectReducer(initialState, action); + + expect(state.projectToEdit).toEqual(project); + expect(state.message).toEqual('Set projectToEdit property'); + }); + + it('on ResetProjectToEdit, should clean the projectToEdit variable', () => { + const action = new actions.ResetProjectToEdit(); + + const state = projectReducer(initialState, action); + + expect(state.projectToEdit).toEqual(undefined); + expect(state.message).toEqual('Reset projectToEdit property'); + }); + + it('on DeleteProject, isLoading is true', () => { + const projectIdToDelete = '1'; + const action = new actions.DeleteProject(projectIdToDelete); + + const state = projectReducer(initialState, action); + expect(state.isLoading).toEqual(true); + expect(state.message).toEqual('Loading delete project'); + }); + + it('on DeleteProjectSuccess, message equal to Project removed successfully!', () => { + const currentState: ProjectState = { + projectList: [project], + isLoading: false, + message: '', + projectToEdit: undefined, + }; + const projectIdToDelete = '1'; + const action = new actions.DeleteProjectSuccess(projectIdToDelete); + + const state = projectReducer(currentState, action); + expect(state.projectList).toEqual([]); + expect(state.message).toEqual('Project removed successfully!'); + }); + + it('on DeleteProjectFail, message equal to Something went wrong deleting the project!', () => { + const projectToEdit = '1'; + const action = new actions.DeleteProjectFail(projectToEdit); + + const state = projectReducer(initialState, action); + expect(state.projectList).toEqual([]); + expect(state.isLoading).toEqual(false); + expect(state.message).toEqual('Something went wrong deleting the project!'); + }); }); diff --git a/src/app/modules/project-management/store/project.reducer.ts b/src/app/modules/customer-management/components/projects/components/store/project.reducer.ts similarity index 50% rename from src/app/modules/project-management/store/project.reducer.ts rename to src/app/modules/customer-management/components/projects/components/store/project.reducer.ts index 357078966..16a7c4414 100644 --- a/src/app/modules/project-management/store/project.reducer.ts +++ b/src/app/modules/customer-management/components/projects/components/store/project.reducer.ts @@ -1,14 +1,18 @@ import { ProjectActions, ProjectActionTypes } from './project.actions'; -import { Project } from '../../shared/models'; +import { Project } from '../../../../../shared/models'; export interface ProjectState { projectList: Project[]; isLoading: boolean; + message: string; + projectToEdit: Project; } export const initialState = { projectList: [], isLoading: false, + message: '', + projectToEdit: undefined, }; export const projectReducer = (state: ProjectState = initialState, action: ProjectActions) => { @@ -18,6 +22,7 @@ export const projectReducer = (state: ProjectState = initialState, action: Proje return { ...state, isLoading: true, + message: 'Loading projects!', }; } case ProjectActionTypes.LOAD_PROJECTS_SUCCESS: @@ -25,12 +30,15 @@ export const projectReducer = (state: ProjectState = initialState, action: Proje ...state, projectList: action.payload, isLoading: false, + message: 'Data fetch successfully!', }; case ProjectActionTypes.LOAD_PROJECTS_FAIL: { return { projectList: [], isLoading: false, + message: 'Something went wrong fetching projects!', + projectToEdit: undefined, }; } @@ -38,6 +46,7 @@ export const projectReducer = (state: ProjectState = initialState, action: Proje return { ...state, isLoading: true, + message: 'Loading create projects!', }; } @@ -46,6 +55,7 @@ export const projectReducer = (state: ProjectState = initialState, action: Proje ...state, projectList: [...state.projectList, action.payload], isLoading: false, + message: 'Data created successfully!', }; } @@ -53,6 +63,8 @@ export const projectReducer = (state: ProjectState = initialState, action: Proje return { projectList: [], isLoading: false, + message: 'Something went wrong creating projects!', + projectToEdit: undefined, }; } @@ -60,6 +72,7 @@ export const projectReducer = (state: ProjectState = initialState, action: Proje return { ...state, isLoading: true, + message: 'Loading update project', }; } @@ -71,6 +84,8 @@ export const projectReducer = (state: ProjectState = initialState, action: Proje ...state, projectList: projects, isLoading: false, + message: 'Data updated successfully!', + projectToEdit: undefined, }; } @@ -78,8 +93,54 @@ export const projectReducer = (state: ProjectState = initialState, action: Proje return { projectList: [], isLoading: false, + message: 'Something went wrong updating projects!', + projectToEdit: undefined, }; } + + case ProjectActionTypes.SET_PROJECT_TO_EDIT: { + return { + ...state, + projectToEdit: action.payload, + message: 'Set projectToEdit property', + }; + } + + case ProjectActionTypes.RESET_PROJECT_TO_EDIT: { + return { + ...state, + projectToEdit: undefined, + message: 'Reset projectToEdit property', + }; + } + + case ProjectActionTypes.DELETE_PROJECT: { + return { + ...state, + isLoading: true, + message: 'Loading delete project', + }; + } + + case ProjectActionTypes.DELETE_PROJECT_SUCCESS: { + const newProjects = state.projectList.filter((project) => project.id !== action.projectId); + return { + ...state, + projectList: newProjects, + isLoading: false, + message: 'Project removed successfully!', + }; + } + + case ProjectActionTypes.DELETE_PROJECT_FAIL: { + return { + projectList: [], + isLoading: false, + message: 'Something went wrong deleting the project!', + projectToEdit: undefined, + }; + } + default: return state; } diff --git a/src/app/modules/project-management/store/project.selectors.ts b/src/app/modules/customer-management/components/projects/components/store/project.selectors.ts similarity index 70% rename from src/app/modules/project-management/store/project.selectors.ts rename to src/app/modules/customer-management/components/projects/components/store/project.selectors.ts index bc57589cd..52b77634b 100644 --- a/src/app/modules/project-management/store/project.selectors.ts +++ b/src/app/modules/customer-management/components/projects/components/store/project.selectors.ts @@ -7,3 +7,7 @@ const getProjectState = createFeatureSelector('projects'); export const allProjects = createSelector(getProjectState, (state: ProjectState) => { return state; }); + +export const getProjectToEdit = createSelector(getProjectState, (state: ProjectState) => { + return state.projectToEdit; +}); diff --git a/src/app/modules/customer-management/pages/customer.component.html b/src/app/modules/customer-management/pages/customer.component.html index 949c99563..050635714 100644 --- a/src/app/modules/customer-management/pages/customer.component.html +++ b/src/app/modules/customer-management/pages/customer.component.html @@ -5,7 +5,7 @@

Customers

- +
diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts b/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts index 56fe584f6..ac9be0c31 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts @@ -6,8 +6,8 @@ import { TechnologyState } from '../../store/technology.reducers'; import { allTechnologies } from '../../store/technology.selectors'; import { DetailsFieldsComponent } from './details-fields.component'; import * as actions from '../../store/technology.actions'; -import { ProjectState } from '../../../project-management/store/project.reducer'; -import { allProjects } from '../../../project-management/store/project.selectors'; +import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer'; +import { allProjects } from '../../../customer-management/components/projects/components/store/project.selectors'; describe('DetailsFieldsComponent', () => { type Merged = TechnologyState & ProjectState; @@ -20,8 +20,10 @@ describe('DetailsFieldsComponent', () => { const state = { projects: { - projectList: [{ id: 'id', name: 'name', description: 'description' }], + projectList: [{ id: 'id', name: 'name', description: 'description', project_type_id: '123' }], isLoading: false, + message: '', + projectToEdit: undefined, }, technologies: { technologyList: { items: [{ name: 'java' }] }, diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.ts b/src/app/modules/shared/components/details-fields/details-fields.component.ts index b432563b9..840f73d24 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.ts @@ -16,11 +16,11 @@ import * as actions from '../../store/technology.actions'; import { allTechnologies } from '../../store/technology.selectors'; import { Technology, Project, Activity } from '../../models'; -import { ProjectState } from '../../../project-management/store/project.reducer'; +import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer'; import { TechnologyState } from '../../store/technology.reducers'; import { LoadActivities, ActivityState, allActivities } from '../../../activities-management/store'; -import { allProjects } from '../../../project-management/store/project.selectors'; -import * as projectActions from '../../../project-management/store/project.actions'; +import { allProjects } from '../../../customer-management/components/projects/components/store/project.selectors'; +import * as projectActions from '../../../customer-management/components/projects/components/store/project.actions'; type Merged = TechnologyState & ProjectState & ActivityState; diff --git a/src/app/modules/shared/components/modal/modal.component.spec.ts b/src/app/modules/shared/components/modal/modal.component.spec.ts index f74b800c8..99a10a6a8 100644 --- a/src/app/modules/shared/components/modal/modal.component.spec.ts +++ b/src/app/modules/shared/components/modal/modal.component.spec.ts @@ -27,7 +27,7 @@ describe('ModalComponent', () => { id: '1', name: 'app 4', description: 'It is a good app', - status: 'inactive', + project_type_id: '123', completed: true, project: 'ErnstYoung', startDate: '2020-02-05T15:36:15.887Z', diff --git a/src/app/modules/shared/components/search-project/search-project.component.scss b/src/app/modules/shared/components/search-project/search-project.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/app/modules/shared/components/search-project/search-project.component.spec.ts b/src/app/modules/shared/components/search-project/search-project.component.spec.ts deleted file mode 100644 index 72133452f..000000000 --- a/src/app/modules/shared/components/search-project/search-project.component.spec.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { SearchProjectComponent } from './search-project.component'; - -describe('SearchProjectComponent', () => { - let component: SearchProjectComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [SearchProjectComponent], - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(SearchProjectComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - it('should emit changeFilterProject event #changeFilterValue', () => { - component.filterProject = 'angular'; - spyOn(component.changeFilterProject, 'emit'); - component.changeFilterValue(); - expect(component.changeFilterProject.emit).toHaveBeenCalled(); - }); -}); diff --git a/src/app/modules/shared/components/search-project/search-project.component.ts b/src/app/modules/shared/components/search-project/search-project.component.ts deleted file mode 100644 index 921bed28b..000000000 --- a/src/app/modules/shared/components/search-project/search-project.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component, OnInit, Output, EventEmitter } from '@angular/core'; - -@Component({ - selector: 'app-search-project', - templateUrl: './search-project.component.html', - styleUrls: ['./search-project.component.scss'] -}) -export class SearchProjectComponent implements OnInit { - - filterProject: string; - @Output() changeFilterProject = new EventEmitter(); - - constructor() { } - - ngOnInit(): void { - } - - changeFilterValue() { - this.changeFilterProject.emit(this.filterProject); - } - -} diff --git a/src/app/modules/shared/components/search-project/search-project.component.html b/src/app/modules/shared/components/search/search.component.html similarity index 81% rename from src/app/modules/shared/components/search-project/search-project.component.html rename to src/app/modules/shared/components/search/search.component.html index f755cd754..3c68af43e 100644 --- a/src/app/modules/shared/components/search-project/search-project.component.html +++ b/src/app/modules/shared/components/search/search.component.html @@ -4,8 +4,8 @@ type="text" class="form-control" placeholder=" Search..." - name="filterProject" - [(ngModel)]="filterProject" + name="filterValue" + [(ngModel)]="filterValue" style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, FontAwesome;" /> diff --git a/src/app/modules/project-management/models/.gitkeep b/src/app/modules/shared/components/search/search.component.scss similarity index 100% rename from src/app/modules/project-management/models/.gitkeep rename to src/app/modules/shared/components/search/search.component.scss diff --git a/src/app/modules/shared/components/search/search.component.spec.ts b/src/app/modules/shared/components/search/search.component.spec.ts new file mode 100644 index 000000000..6e93ca539 --- /dev/null +++ b/src/app/modules/shared/components/search/search.component.spec.ts @@ -0,0 +1,31 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SearchComponent } from './search.component'; + +describe('SearchComponent', () => { + let component: SearchComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [SearchComponent], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(SearchComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should emit changedFilterValue event #changeFilterValue', () => { + component.filterValue = 'angular'; + spyOn(component.changedFilterValue, 'emit'); + component.changeFilterValue(); + expect(component.changedFilterValue.emit).toHaveBeenCalled(); + }); +}); diff --git a/src/app/modules/shared/components/search/search.component.ts b/src/app/modules/shared/components/search/search.component.ts new file mode 100644 index 000000000..9a76ff189 --- /dev/null +++ b/src/app/modules/shared/components/search/search.component.ts @@ -0,0 +1,19 @@ +import { Component, OnInit, Output, EventEmitter } from '@angular/core'; + +@Component({ + selector: 'app-search', + templateUrl: './search.component.html', + styleUrls: ['./search.component.scss'], +}) +export class SearchComponent implements OnInit { + filterValue: string; + @Output() changedFilterValue = new EventEmitter(); + + constructor() {} + + ngOnInit(): void {} + + changeFilterValue() { + this.changedFilterValue.emit(this.filterValue); + } +} diff --git a/src/app/modules/shared/models/project.model.ts b/src/app/modules/shared/models/project.model.ts index 57486d20f..afa1eac15 100644 --- a/src/app/modules/shared/models/project.model.ts +++ b/src/app/modules/shared/models/project.model.ts @@ -1,7 +1,7 @@ export interface Project { id: string; customer_id?: string; - tenant_id?: string; name: string; - description: string; + description?: string; + project_type_id: string; } diff --git a/src/app/modules/shared/pipes/filter-project/filter-project.pipe.spec.ts b/src/app/modules/shared/pipes/filter-project/filter-project.pipe.spec.ts index d00d98669..cb86135f9 100644 --- a/src/app/modules/shared/pipes/filter-project/filter-project.pipe.spec.ts +++ b/src/app/modules/shared/pipes/filter-project/filter-project.pipe.spec.ts @@ -7,16 +7,19 @@ describe('FilterProjectPipe', () => { id: '1', name: 'App 1', description: 'It is a good app', + project_type_id: '123', }, { id: '2', name: 'app 2', description: 'It is a good app', + project_type_id: '124', }, { id: '3', name: 'App 3', description: 'It is a good app', + project_type_id: '125', }, ]; diff --git a/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts b/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts index a9093e64a..1ce64a711 100644 --- a/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts +++ b/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts @@ -3,8 +3,8 @@ import { provideMockStore, MockStore } from '@ngrx/store/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ProjectListHoverComponent } from './project-list-hover.component'; -import { ProjectState } from '../../../project-management/store/project.reducer'; -import { allProjects } from '../../../project-management/store/project.selectors'; +import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer'; +import { allProjects } from '../../../customer-management/components/projects/components/store/project.selectors'; import { FilterProjectPipe } from '../../../shared/pipes'; import { NewEntry } from '../../../shared/models'; import * as action from '../../store/entry.actions'; @@ -16,8 +16,10 @@ describe('ProjectListHoverComponent', () => { let mockProjectsSelector; const state = { - projectList: [{ id: 'id', name: 'name', description: 'description' }], + projectList: [{ id: 'id', name: 'name', description: 'description', project_type_id: '123' }], isLoading: false, + message: '', + projectToEdit: undefined, }; beforeEach(async(() => { diff --git a/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.ts b/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.ts index 2ccfda345..ced1dd7a9 100644 --- a/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.ts +++ b/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.ts @@ -1,9 +1,9 @@ import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { Store, select } from '@ngrx/store'; import { Project } from 'src/app/modules/shared/models'; -import { allProjects } from '../../../project-management/store/project.selectors'; -import { ProjectState } from '../../../project-management/store/project.reducer'; -import * as actions from '../../../project-management/store/project.actions'; +import { allProjects } from '../../../customer-management/components/projects/components/store/project.selectors'; +import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer'; +import * as actions from '../../../customer-management/components/projects/components/store/project.actions'; import * as entryActions from '../../store/entry.actions'; @Component({ diff --git a/src/app/modules/time-clock/pages/time-clock.component.spec.ts b/src/app/modules/time-clock/pages/time-clock.component.spec.ts index 87fb266b1..562e512a3 100644 --- a/src/app/modules/time-clock/pages/time-clock.component.spec.ts +++ b/src/app/modules/time-clock/pages/time-clock.component.spec.ts @@ -5,9 +5,9 @@ import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; import { TimeClockComponent } from './time-clock.component'; -import { ProjectState } from '../../project-management/store/project.reducer'; +import { ProjectState } from '../../customer-management/components/projects/components/store/project.reducer'; import { ProjectListHoverComponent } from '../components'; -import { ProjectService } from '../../project-management/services/project.service'; +import { ProjectService } from '../../customer-management/components/projects/components/services/project.service'; import { FilterProjectPipe } from '../../shared/pipes'; describe('TimeClockComponent', () => { diff --git a/src/app/modules/time-entries/pages/time-entries.component.spec.ts b/src/app/modules/time-entries/pages/time-entries.component.spec.ts index e5e9e8363..55459b4c2 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.spec.ts +++ b/src/app/modules/time-entries/pages/time-entries.component.spec.ts @@ -12,8 +12,8 @@ import { GroupByDatePipe } from '../../shared/pipes'; import { TechnologyState } from '../../shared/store/technology.reducers'; import { allTechnologies } from '../../shared/store/technology.selectors'; import { TimeEntriesComponent } from './time-entries.component'; -import { ProjectState } from '../../project-management/store/project.reducer'; -import { allProjects } from '../../project-management/store/project.selectors'; +import { ProjectState } from '../../customer-management/components/projects/components/store/project.reducer'; +import { allProjects } from '../../customer-management/components/projects/components/store/project.selectors'; describe('TimeEntriesComponent', () => { type Merged = TechnologyState & ProjectState; @@ -25,8 +25,10 @@ describe('TimeEntriesComponent', () => { const state = { projects: { - projectList: [{ id: 'id', name: 'name', description: 'description' }], + projectList: [{ id: 'id', name: 'name', description: 'description', project_type_id: '123' }], isLoading: false, + message: '', + projectToEdit: undefined, }, activities: { data: [{ id: 'id', name: 'name', description: 'description' }], diff --git a/src/app/reducers/index.ts b/src/app/reducers/index.ts index 06baa53b2..183dce699 100644 --- a/src/app/reducers/index.ts +++ b/src/app/reducers/index.ts @@ -1,5 +1,5 @@ import { ActionReducerMap, MetaReducer } from '@ngrx/store'; -import { projectReducer } from '../modules/project-management/store/project.reducer'; +import { projectReducer } from '../modules/customer-management/components/projects/components/store/project.reducer'; import { activityManagementReducer } from '../modules/activities-management/store/activity-management.reducers'; import { technologyReducer } from '../modules/shared/store/technology.reducers'; import { customerManagementReducer } from '../modules/customer-management/store/customer-management.reducers';
{{ project.name }} - - + +