Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
217fbb8
feat: TT-208 add new column in activity-list
thegreatyamori Apr 19, 2021
6c1c06f
feat: TT-208 add switch status button in column
thegreatyamori Apr 19, 2021
dc10fcf
feat: TT-208 remove delete button & assign openmodal to switch
thegreatyamori Apr 20, 2021
fb37b3b
feat: TT-208 connect switch btn with ngrx flux
thegreatyamori Apr 20, 2021
f0275f8
feat: TT-208 update ngrx delete flux
thegreatyamori Apr 20, 2021
e8ee50f
feat: TT-208 show active activities in entry & details fields
thegreatyamori Apr 21, 2021
a62c980
feat: TT-208 change ui-switch to button
thegreatyamori Apr 22, 2021
5c19c86
fix: TT-208 display the required activities when clicking on time en…
thegreatyamori Apr 26, 2021
a76051c
Merge branch 'master' into TT-208-don't-allow-deleting-activities
thegreatyamori Apr 26, 2021
aa698ee
feat: TT-208 add new column in activity-list
thegreatyamori Apr 26, 2021
5ca9a8f
feat: TT-208 add switch status button in column
thegreatyamori Apr 26, 2021
17d5acd
feat: TT-208 remove delete button & assign openmodal to switch
thegreatyamori Apr 26, 2021
90742ad
feat: TT-208 connect switch btn with ngrx flux
thegreatyamori Apr 26, 2021
4977dff
feat: TT-208 update ngrx delete flux
thegreatyamori Apr 26, 2021
1d0107d
feat: TT-208 show active activities in entry & details fields
thegreatyamori Apr 21, 2021
5808250
feat: TT-208 change ui-switch to button
thegreatyamori Apr 22, 2021
286033c
fix: TT-208 display the required activities when clicking on time en…
thegreatyamori Apr 26, 2021
3a5e107
feat: TT-208 rebase on latest master commit
thegreatyamori Apr 26, 2021
1c9ee96
fix: TT-208 merging conflicts
thegreatyamori Apr 26, 2021
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: TT-208 display the required activities when clicking on time ent…
…ry with inactive activity
  • Loading branch information
thegreatyamori committed Apr 26, 2021
commit 5c19c86af87eef27373c1ce2240a97d4f3db5cda
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
formControlName="activity_id"
>
<option value="" selected="selected"></option>
<option *ngFor="let activity of activities" value="{{ activity.id }}">{{ activity.name }}</option>
<option *ngFor="let activity of activities$ | async" value="{{ activity.id }}">{{ activity.name }}</option>
</select>
</div>
<div
Expand Down Expand Up @@ -133,7 +133,7 @@
id="end_hour"
class="timepicker-input"
[class.timepicker-input--disabled]="!(project_id.value && project_name.value)"
></ngx-timepicker-field>
></ngx-timepicker-field>
</div>
</div>

Expand All @@ -142,26 +142,18 @@
(technologyRemoved)="onTechnologiesUpdated($event)"
[selectedTechnologies]="selectedTechnologies"
#technologies
>
>
</app-technologies>

<div class="form-group text-left">
<label for="NotesTextarea">Description:</label>
<textarea
maxlength="1500"
formControlName="description"
class="form-control"
id="NotesTextarea"
rows="3"
>
<textarea maxlength="1500" formControlName="description" class="form-control" id="NotesTextarea" rows="3">
</textarea>
</div>
</fieldset>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save</button>
<button #closeModal type="button" class="btn btn-secondary" data-dismiss="modal">
Close
</button>
<button #closeModal type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ describe('DetailsFieldsComponent', () => {
isLoading: false,
},
activities: {
data: [{ id: 'fc5fab41-a21e-4155-9d05-511b956ebd05', tenant_id: 'ioet', deleted: null, name: 'abc', status: 'active' }],
data: [{ id: 'fc5fab41-a21e-4155-9d05-511b956ebd05', tenant_id: 'ioet', deleted: null, name: 'abc', status: 'active' },
{ id: 'fc5fab41-a21e-4155-9d05-511b956ebd07', tenant_id: 'ioet_1', deleted: null, name: 'def', status: 'active' },
{ id: 'fc5fab41-a21e-4155-9d05-511b956ebd08', tenant_id: 'ioet_2', deleted: null, name: 'ghi', status: 'inactive' },
{ id: 'fc5fab41-a21e-4155-9d05-511b956ebd09', tenant_id: 'ioet_3', deleted: null, name: 'jkl', status: 'active' }],
isLoading: false,
message: 'Data fetch successfully!',
activityIdToEdit: '',
Expand Down Expand Up @@ -193,6 +196,7 @@ describe('DetailsFieldsComponent', () => {
component.ngOnChanges();
expect(component.shouldRestartEntry).toBeFalse();
expect(component.entryForm.value).toEqual(initialData);
expect(component.activities$).toBe(undefined);
});

it('should emit ngOnChange with new data', () => {
Expand All @@ -215,6 +219,24 @@ describe('DetailsFieldsComponent', () => {
expect(component.entryForm.value).toEqual(formValue);
});

const activitiesParams = [
{ select_activity_id: 'fc5fab41-a21e-4155-9d05-511b956ebd07', expected_size_activities: 3, title: 'active' },
{ select_activity_id: 'fc5fab41-a21e-4155-9d05-511b956ebd08', expected_size_activities: 4, title: 'inactive' }
];
activitiesParams.map(param => {
it(`should emit ngOnChange to set ${param.expected_size_activities} activities for select (${param.title} time entry clicked)`, () => {
component.entryToEdit = { ...entryToEdit, activity_id: param.select_activity_id };
spyOn(component.entryForm, 'patchValue');
component.ngOnChanges();

component.activities$.subscribe(items => {
console.log(items);

expect(items.length).toBe(param.expected_size_activities);
});
});
});

it('should call createError ', () => {
const childComponent = jasmine.createSpyObj('ChildComponent', ['closeModal']);
component.closeModal = childComponent;
Expand Down Expand Up @@ -512,6 +534,17 @@ describe('DetailsFieldsComponent', () => {
expect(endDateInput.id).toEqual('end_date');
expect(endDateInput.max).toEqual(expectedDate);
});

it('should find an activity with given id & status: inactive', () => {

const expectedActivity = { id: 'fc5fab41-a21e-4155-9d05-511b956ebd08', tenant_id: 'ioet_2', deleted: null, name: 'ghi', status: 'inactive' };

component.entryToEdit = { ...entryToEdit, activity_id: 'fc5fab41-a21e-4155-9d05-511b956ebd08' };
spyOn(component.entryForm, 'patchValue');

const foundActivity = component.findInactiveActivity(state.activities.data);
expect(foundActivity).toEqual(expectedActivity);
});
/*
TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
and now these couple of tests are failing. A solution to this error might be generate a Test Wrapper Component. More details here:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActionsSubject, select, Store } from '@ngrx/store';
import * as moment from 'moment';
import { ToastrService } from 'ngx-toastr';
import { filter } from 'rxjs/operators';
import { filter, map, mergeMap } from 'rxjs/operators';
import { getCreateError, getUpdateError } from 'src/app/modules/time-clock/store/entry.selectors';
import { ActivityState, allActiveActivities, LoadActivities } from '../../../activities-management/store';
import { ActivityState, allActiveActivities, allActivities, LoadActivities } from '../../../activities-management/store';
import * as projectActions from '../../../customer-management/components/projects/components/store/project.actions';
import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer';
import { getProjects } from '../../../customer-management/components/projects/components/store/project.selectors';
Expand All @@ -20,6 +20,7 @@ import { ProjectSelectedEvent } from './project-selected-event';
import { get } from 'lodash';
import { DATE_FORMAT } from 'src/environments/environment';
import { TechnologiesComponent } from '../technologies/technologies.component';
import { Observable } from 'rxjs';

type Merged = TechnologyState & ProjectState & ActivityState & EntryState;
@Component({
Expand All @@ -39,7 +40,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
selectedTechnologies: string[] = [];
isLoading = false;
listProjects: Project[] = [];
activities: Activity[] = [];
activities$: Observable<Activity[]>;
goingToWorkOnThis = false;
shouldRestartEntry = false;

Expand Down Expand Up @@ -78,10 +79,6 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
});

this.store.dispatch(new LoadActivities());
const activities$ = this.store.pipe(select(allActiveActivities));
activities$.subscribe((response) => {
this.activities = response;
});

const updateError$ = this.store.pipe(select(getUpdateError));
updateError$.subscribe((updateError) => {
Expand Down Expand Up @@ -133,6 +130,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
ngOnChanges(): void {
this.goingToWorkOnThis = this.entryToEdit ? this.entryToEdit.running : false;
this.shouldRestartEntry = false;

if (this.entryToEdit) {
this.selectedTechnologies = this.entryToEdit.technologies;
const projectFound = this.listProjects.find((project) => project.id === this.entryToEdit.project_id);
Expand All @@ -148,6 +146,17 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
uri: this.entryToEdit.uri,
technology: '',
});

this.activities$ = this.store.pipe(
select(allActiveActivities),
mergeMap(activeActivities => this.store.pipe(
select(allActivities),
map(activities => this.findInactiveActivity(activities) !== undefined
? [...activeActivities, this.findInactiveActivity(activities)]
: activeActivities
)
))
);
} else {
this.cleanForm();
}
Expand Down Expand Up @@ -176,6 +185,12 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
this.cleanForm(true);
}

findInactiveActivity(activities) {
return activities.find(activity => activity.status === 'inactive' &&
activity.id === this.entryToEdit.activity_id
);
}

onTechnologiesUpdated($event: string[]) {
this.selectedTechnologies = $event;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
</button>
</div>
</div>
<div style="height: 15px;"></div>
<div style="height: 15px"></div>
<app-month-picker (dateSelected)="dateSelected($event)"></app-month-picker>
<div style="height: 15px;"></div>
<div style="height: 15px"></div>

<table class="table table-sm table-striped mb-0" *ngIf="(timeEntriesDataSource$ | async) as dataSource">
<table class="table table-sm table-striped mb-0" *ngIf="timeEntriesDataSource$ | async as dataSource">
<thead class="thead-blue">
<tr class="d-flex">
<th class="col">Date</th>
Expand Down Expand Up @@ -73,7 +73,7 @@ <h5 class="modal-title">{{ entryId ? 'Edit Entry' : 'New Entry' }}</h5>
[entryToEdit]="entry"
(saveEntry)="saveEntry($event)"
(projectSelected)="projectSelected($event)"
[canMarkEntryAsWIP]='canMarkEntryAsWIP'
[canMarkEntryAsWIP]="canMarkEntryAsWIP"
#detailsFields
>
</app-details-fields>
Expand Down