diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.html b/src/app/modules/shared/components/details-fields/details-fields.component.html index cf42da49d..149eb30d4 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.html +++ b/src/app/modules/shared/components/details-fields/details-fields.component.html @@ -1,5 +1,5 @@
-
+
Project
@@ -126,10 +126,10 @@
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 0411f32ac..e0c850a2c 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 @@ -62,7 +62,6 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { start_hour: '00:00', end_hour: '00:00', uri: '', - technology: '', }); } @@ -70,8 +69,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { const technologies$ = this.store.pipe(select(allTechnologies)); technologies$.subscribe((response) => { this.isLoading = response.isLoading; - const filteredItems = response.technologyList.items.filter(item => !this.selectedTechnology.includes(item.name)); - this.technology = { items: filteredItems }; + this.technology = response.technologyList; }); this.store.dispatch(new projectActions.LoadProjects()); @@ -90,17 +88,10 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { ngOnChanges(): void { if (this.entryToEdit) { this.selectedTechnology = this.entryToEdit.technologies; -<<<<<<< HEAD this.project = this.listProjects.find((p) => p.id === this.entryToEdit.project_id); const activity = this.activities.find((a) => a.id === this.entryToEdit.activity_id); this.projectName = this.project.name; this.entryForm.setValue({ -======= - const project = this.listProjects.find((p) => p.id === this.entryToEdit.project_id); - const activity = this.activities.find((a) => a.id === this.entryToEdit.activity_id); - this.entryForm.setValue({ - project: project ? project.name : '', ->>>>>>> fix: #172 Create-time-entries-manually activity: activity ? activity.name : '', description: this.entryToEdit.description, start_date: this.entryToEdit.start_date ? formatDate(this.entryToEdit.start_date, 'yyyy-MM-dd', 'en') : '', @@ -108,18 +99,12 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { end_date: this.entryToEdit.end_date ? formatDate(this.entryToEdit.end_date, 'yyyy-MM-dd', 'en') : '', end_hour: this.entryToEdit.end_date ? formatDate(this.entryToEdit.end_date, 'HH:mm', 'en') : '00:00', uri: this.entryToEdit.uri, - technology: '', }); } else { this.selectedTechnology = []; -<<<<<<< HEAD this.project = ''; this.projectName = ''; this.entryForm.setValue({ -======= - this.entryForm.setValue({ - project: '', ->>>>>>> fix: #172 Create-time-entries-manually activity: '', description: '', start_date: formatDate(new Date(), 'yyyy-MM-dd', 'en'), @@ -127,7 +112,6 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { end_date: formatDate(new Date(), 'yyyy-MM-dd', 'en'), end_hour: '00:00', uri: '', - technology: '', }); } } @@ -140,28 +124,23 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { } setTechnology(name: string) { - this.selectedTechnology = [...this.selectedTechnology, name]; - this.showlist = false; - this.entryForm.get('technology').reset(); + const index = this.selectedTechnology.indexOf(name); + if (index > -1) { + this.removeTag(index); + } else if (this.selectedTechnology.length < 10) { + this.selectedTechnology = [...this.selectedTechnology, name]; + } } removeTag(index) { this.selectedTechnology.splice(index, 1); - this.selectedTechnology = [...this.selectedTechnology, name]; - this.showlist = false; - this.entryForm.get('technology').reset(); } onSubmit() { const activity = this.activities.find((a) => a.name === this.entryForm.value.activity); -<<<<<<< HEAD this.project = this.projectName.id ? this.projectName : this.project; const entry = { project_id: this.project.id, -======= - const entry = { - project_id: this.entryForm.value.project.id, ->>>>>>> fix: #172 Create-time-entries-manually activity_id: activity ? activity.id : null, technologies: this.selectedTechnology, description: this.entryForm.value.description, @@ -170,6 +149,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { uri: this.entryForm.value.uri, }; this.saveEntry.emit(entry); + this.ngOnChanges(); this.closeModal.nativeElement.click(); } } 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 e67ac8fe8..8d33de27f 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 @@ -11,8 +11,6 @@ import { ProjectListHoverComponent } from '../components'; import { FilterProjectPipe } from '../../shared/pipes'; import { AzureAdB2CService } from '../../login/services/azure.ad.b2c.service'; -import { ActionsSubject } from '@ngrx/store'; - describe('TimeClockComponent', () => { let component: TimeClockComponent; let fixture: ComponentFixture; diff --git a/src/app/modules/time-clock/store/entry.actions.spec.ts b/src/app/modules/time-clock/store/entry.actions.spec.ts index cc10bec91..c5b6ce429 100644 --- a/src/app/modules/time-clock/store/entry.actions.spec.ts +++ b/src/app/modules/time-clock/store/entry.actions.spec.ts @@ -46,8 +46,11 @@ describe('Actions for Entries', () => { it('UpdateActiveEntrySuccess type is EntryActionTypes.UDPATE_ACTIVE_ENTRY_SUCCESS', () => { const updateActiveEntrySuccess = new actions.UpdateActiveEntrySuccess({ - project_id: '1', - description: 'It is good for learning', + id: '1', + start_date: new Date(), + end_date: new Date(), + activity: '', + technologies: ['abc', 'abc'], }); expect(updateActiveEntrySuccess.type).toEqual(actions.EntryActionTypes.UPDATE_ACTIVE_ENTRY_SUCCESS); }); diff --git a/src/app/modules/time-clock/store/entry.actions.ts b/src/app/modules/time-clock/store/entry.actions.ts index 63fa9c2fc..d6f745595 100644 --- a/src/app/modules/time-clock/store/entry.actions.ts +++ b/src/app/modules/time-clock/store/entry.actions.ts @@ -97,7 +97,7 @@ export class UpdateActiveEntry implements Action { export class UpdateActiveEntrySuccess implements Action { public readonly type = EntryActionTypes.UPDATE_ACTIVE_ENTRY_SUCCESS; - constructor(public payload: NewEntry) {} + constructor(public payload: Entry) {} } export class UpdateActiveEntryFail implements Action { diff --git a/src/app/modules/time-clock/store/entry.reducer.spec.ts b/src/app/modules/time-clock/store/entry.reducer.spec.ts index 93b200aa7..9cc018f5d 100644 --- a/src/app/modules/time-clock/store/entry.reducer.spec.ts +++ b/src/app/modules/time-clock/store/entry.reducer.spec.ts @@ -11,6 +11,14 @@ describe('entryReducer', () => { technologies: ['angular', 'typescript'], }; + const newEntry: Entry = { + id: '1', + start_date: new Date(), + end_date: new Date(), + activity: '', + technologies: ['abc', 'abc'], + }; + it('on Default, ', () => { const action = new actions.DefaultEntry(); const state = entryReducer(initialState, action); @@ -124,7 +132,7 @@ describe('entryReducer', () => { isLoading: false, message: '', }; - const action = new actions.UpdateActiveEntrySuccess(entry); + const action = new actions.UpdateActiveEntrySuccess(newEntry); const state = entryReducer(currentState, action); expect(state.isLoading).toEqual(false); diff --git a/src/app/modules/time-clock/store/entry.reducer.ts b/src/app/modules/time-clock/store/entry.reducer.ts index 99fbbb9e6..dc6f185da 100644 --- a/src/app/modules/time-clock/store/entry.reducer.ts +++ b/src/app/modules/time-clock/store/entry.reducer.ts @@ -72,7 +72,7 @@ export const entryReducer = (state: EntryState = initialState, action: EntryActi return { ...state, active: action.payload, - entryList: [...state.entryList, action.payload], + entryList: [action.payload, ...state.entryList], isLoading: false, message: 'You clocked-in successfully', }; @@ -120,11 +120,12 @@ export const entryReducer = (state: EntryState = initialState, action: EntryActi } case EntryActionTypes.UPDATE_ACTIVE_ENTRY_SUCCESS: { - const activeEntry = { ...state.active, ...action.payload }; - + const entryList = [...state.entryList]; + const index = entryList.findIndex((entry) => entry.id === action.payload.id); + entryList[index] = action.payload; return { ...state, - active: activeEntry, + entryList, isLoading: false, }; } diff --git a/src/app/modules/time-entries/pages/time-entries.component.html b/src/app/modules/time-entries/pages/time-entries.component.html index 1dceebfc1..4f1a3720a 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.html +++ b/src/app/modules/time-entries/pages/time-entries.component.html @@ -8,11 +8,10 @@ data-target="#editRecordsByDate" class="btn btn-primary" > - Add new entry + New Entry
-<<<<<<< HEAD
@@ -29,14 +28,6 @@ aria-multiselectable="true" >
- -
- {{ item.date }} + {{ item.start_date | date: 'dd/MM/yyyy' }}
- - -
- - - - - - - - - - - - - - - - -
ProjectDuration
{{ item.project_id }}{{ item.time }} - - -
- - + (click)="openModal(item)" + > + + +
+
+
+
+ + + + +