Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5710 add breadcrumbs to tasks lists #7757

Merged
merged 96 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
cdcf4da
remove own place for offline users reports breadcrumbs
elvisdorkenoo Aug 16, 2022
7538e37
fix ponctuation coding style
elvisdorkenoo Aug 17, 2022
eceb40e
minor changes
elvisdorkenoo Aug 19, 2022
ea0fbfc
update messages tab breadcrumbs
elvisdorkenoo Aug 25, 2022
d56e881
update messages tab breadcrumbs
elvisdorkenoo Aug 25, 2022
9523922
add breadcrumbs display update to report and message
elvisdorkenoo Aug 26, 2022
f15dc81
fix unit test
elvisdorkenoo Aug 26, 2022
2660772
fix unit test 2
elvisdorkenoo Aug 26, 2022
2ddc752
fix unit test 2
elvisdorkenoo Aug 26, 2022
de97add
fix unit test 3
elvisdorkenoo Aug 26, 2022
c6152dd
fix unit test 4
elvisdorkenoo Aug 26, 2022
884e3f4
fix unit test 5
elvisdorkenoo Aug 26, 2022
3fe346d
fix unit tests
elvisdorkenoo Aug 26, 2022
0d189c2
fix unit tests functions
elvisdorkenoo Aug 26, 2022
ed07e1c
fix unit tests functions
elvisdorkenoo Aug 26, 2022
cfb46e1
fix unit tests messages component
elvisdorkenoo Aug 26, 2022
7915562
fix coding style
elvisdorkenoo Aug 29, 2022
dac433f
some refactoring following PR code review
elvisdorkenoo Aug 30, 2022
dd23303
add breadcrumbs to tasks tab
elvisdorkenoo Sep 1, 2022
7d65415
add breadcrumbs to tasks tab
elvisdorkenoo Sep 1, 2022
00e507a
breadcrumbs in two lines
elvisdorkenoo Sep 1, 2022
fcfdc5a
add unit tests to messages tab
elvisdorkenoo Sep 2, 2022
cacd0e8
add unit test to messages breadcrumbs
elvisdorkenoo Sep 2, 2022
65a130d
add unit tests to reports and messages breadcrumbs
elvisdorkenoo Sep 3, 2022
81a7bd4
add breadcrumbs to tasks tab
elvisdorkenoo Sep 1, 2022
a953159
add breadcrumbs to tasks tab
elvisdorkenoo Sep 1, 2022
7698d0a
fix tests
elvisdorkenoo Sep 2, 2022
cb066fa
fix broken unit tests
elvisdorkenoo Sep 3, 2022
30faef1
fix unit tests
elvisdorkenoo Sep 3, 2022
81dcd93
minor changes
elvisdorkenoo Sep 3, 2022
ae37aed
minor changes
elvisdorkenoo Sep 3, 2022
8344348
fix task unit test
elvisdorkenoo Sep 3, 2022
ec1c8bc
fix task unit test
elvisdorkenoo Sep 3, 2022
b0e05d9
fix task unit test
elvisdorkenoo Sep 3, 2022
7a31fcb
fix task unit test
elvisdorkenoo Sep 3, 2022
4f66eb3
add unit tests to tasks lineages
elvisdorkenoo Sep 5, 2022
68900b2
add unit tests to tasks lineages
elvisdorkenoo Sep 5, 2022
ca5627c
apply code review recommandations
elvisdorkenoo Sep 5, 2022
4aaed95
apply code review recommandations
elvisdorkenoo Sep 5, 2022
9e083f0
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 5, 2022
ad8a21e
refactoring refresh tasks function
elvisdorkenoo Sep 5, 2022
8998312
apply most of review recommandations for messages and reports
elvisdorkenoo Sep 6, 2022
ec2b459
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 6, 2022
3f53451
apply most of review recommandations for tasks
elvisdorkenoo Sep 7, 2022
4a52c83
apply most of review recommandations for messages and reports
elvisdorkenoo Sep 7, 2022
981e992
apply most of review recommandations for tasks
elvisdorkenoo Sep 7, 2022
6011687
apply most of review recommandations for tasks
elvisdorkenoo Sep 7, 2022
4d0d319
Merge branch 'master' of github.com:medic/cht-core into 5697-update-b…
elvisdorkenoo Sep 7, 2022
b54f13d
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 7, 2022
70137c5
apply most of review recommandations for messages and reports
elvisdorkenoo Sep 7, 2022
172b152
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 7, 2022
eaa98ef
change this.currentLevel to promise
elvisdorkenoo Sep 7, 2022
5741c82
e2e fix
latin-panda Sep 8, 2022
683f668
apply recommandations except report unit tests structure for now
elvisdorkenoo Sep 11, 2022
8be9c28
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 11, 2022
e8f4199
Merge branch '5710-add-breadcrumbs-to-tasks-lists' of github.com:medi…
elvisdorkenoo Sep 11, 2022
4939ebb
minor changes
elvisdorkenoo Sep 11, 2022
f480f7c
fix indentations
elvisdorkenoo Sep 11, 2022
1acc294
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 11, 2022
63add58
apply code review recommandations for tasks
elvisdorkenoo Sep 11, 2022
7169639
Merge branch 'master' of github.com:medic/cht-core into 5697-update-b…
elvisdorkenoo Sep 11, 2022
294ae76
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 11, 2022
af6c515
minor changes
elvisdorkenoo Sep 12, 2022
03915ef
minor changes
elvisdorkenoo Sep 12, 2022
cb1b555
fix unit tests for null values in lineages
elvisdorkenoo Sep 12, 2022
d6a3137
fix unit tests forID missing in taskDocs
elvisdorkenoo Sep 12, 2022
2602efe
trying report unit tests refactoring
elvisdorkenoo Sep 12, 2022
03bd416
Fixing unit test
latin-panda Sep 12, 2022
a38ded8
removing .only() from unit tests
latin-panda Sep 12, 2022
ff93496
remove console.log for report component
elvisdorkenoo Sep 12, 2022
c5bd08a
minor changes
elvisdorkenoo Sep 12, 2022
6d7cb7f
make this.currentLevel a promise for report component
elvisdorkenoo Sep 12, 2022
fbc6bc6
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 12, 2022
5b64c06
make this.currentLevel a promise for task component
elvisdorkenoo Sep 12, 2022
46441e7
remove tick for imports
elvisdorkenoo Sep 12, 2022
52fc587
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 12, 2022
09ef7e5
Merge branch 'master' of github.com:medic/cht-core into 5697-update-b…
elvisdorkenoo Sep 13, 2022
efeb2fc
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 13, 2022
9f97525
apply code review requested changes
elvisdorkenoo Sep 13, 2022
dae884c
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 13, 2022
0098a58
apply code review requested changes
elvisdorkenoo Sep 13, 2022
5d3648e
apply code review requested changes
elvisdorkenoo Sep 13, 2022
5b5fa10
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 13, 2022
bcf9870
apply code review requested changes
elvisdorkenoo Sep 14, 2022
6beae56
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 14, 2022
8a60b20
apply code review requested changes
elvisdorkenoo Sep 14, 2022
919d64f
apply code review requested changes
elvisdorkenoo Sep 15, 2022
247877d
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 15, 2022
6414d8b
apply code review requested changes
elvisdorkenoo Sep 15, 2022
d6eec6c
add e2e tests for reports breadcrumbs
elvisdorkenoo Sep 16, 2022
1476213
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 16, 2022
5430cc3
add e2e tests for reports breadcrumbs
elvisdorkenoo Sep 16, 2022
49fc243
Merge branch '5697-update-breadcrumbs-displayed-levels' of github.com…
elvisdorkenoo Sep 16, 2022
1ecad5d
fix e2e
latin-panda Sep 21, 2022
bdf4065
Merge branch 'master' of github.com:medic/cht-core into 5710-add-brea…
elvisdorkenoo Sep 22, 2022
4992734
Merge branch 'master' of github.com:medic/cht-core into 5710-add-brea…
elvisdorkenoo Sep 22, 2022
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
2 changes: 1 addition & 1 deletion tests/page-objects/tasks/tasks.wdio.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const noSelectedTaskSelector = '.empty-selection';

const tasksList = () => $(taskListSelector);
const getTaskById = (emissionId) => $(`${taskListSelector} li[data-record-id="${emissionId}"`);
const getTasks = () => $$(`${taskListSelector} li`);
const getTasks = () => $$(`${taskListSelector} li.content-row`);

const getTaskInfo = async (taskElement) => {
const contactName = await (await taskElement.$('h4 span')).getText();
Expand Down
1 change: 1 addition & 0 deletions webapp/src/ts/modules/tasks/tasks.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ <h4>
</div>

<div *ngIf="task.priorityLabel" class="warning">{{task.priorityLabel}}</div>
<div *ngIf="task.lineage?.length" class="detail" [innerHTML]="task.lineage | lineage"></div>
</div>
</a>
</li>
Expand Down
124 changes: 86 additions & 38 deletions webapp/src/ts/modules/tasks/tasks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@ import { Selectors } from '@mm-selectors/index';
import { TelemetryService } from '@mm-services/telemetry.service';
import { TourService } from '@mm-services/tour.service';
import { GlobalActions } from '@mm-actions/global';
import { LineageModelGeneratorService } from '@mm-services/lineage-model-generator.service';
import { UserContactService } from '@mm-services/user-contact.service';
import { SessionService } from '@mm-services/session.service';

@Component({
templateUrl: './tasks.component.html',
})
export class TasksComponent implements OnInit, OnDestroy {
constructor(
private store:Store,
private changesService:ChangesService,
private contactTypesService:ContactTypesService,
private rulesEngineService:RulesEngineService,
private telemetryService:TelemetryService,
private tourService:TourService,
private route:ActivatedRoute,
private store: Store,
private changesService: ChangesService,
private contactTypesService: ContactTypesService,
private rulesEngineService: RulesEngineService,
private telemetryService: TelemetryService,
private tourService: TourService,
private route: ActivatedRoute,
private lineageModelGeneratorService: LineageModelGeneratorService,
private userContactService: UserContactService,
private sessionService: SessionService,
) {
this.tasksActions = new TasksActions(store);
this.globalActions = new GlobalActions(store);
Expand All @@ -41,6 +47,7 @@ export class TasksComponent implements OnInit, OnDestroy {
hasTasks;
loading;
tasksDisabled;
currentLevel;

private tasksLoaded;
private debouncedReload;
Expand Down Expand Up @@ -97,6 +104,9 @@ export class TasksComponent implements OnInit, OnDestroy {
this.hasTasks = false;
this.loading = true;
this.debouncedReload = _debounce(this.refreshTasks.bind(this), 1000, { maxWait: 10 * 1000 });

this.currentLevel = this.sessionService.isOnlineOnly() ? Promise.resolve() : this.getCurrentLineageLevel();

this.refreshTasks();

this.tourService.startIfNeeded(this.route.snapshot);
Expand Down Expand Up @@ -128,40 +138,78 @@ export class TasksComponent implements OnInit, OnDestroy {
});
}

private refreshTasks() {
const telemetryData:any = {
start: Date.now(),
};

return this.rulesEngineService
.isEnabled()
.then(isEnabled => {
this.tasksDisabled = !isEnabled;
return isEnabled ? this.rulesEngineService.fetchTaskDocsForAllContacts() : [];
})
.then(taskDocs => {
this.hasTasks = taskDocs.length > 0;
this.loading = false;
this.tasksActions.setTasksList(this.hydrateEmissions(taskDocs));
if (!this.tasksLoaded) {
this.tasksActions.setTasksLoaded(true);
}

telemetryData.end = Date.now();
const telemetryEntryName = !this.tasksLoaded ? `tasks:load`: `tasks:refresh`;
this.telemetryService.record(telemetryEntryName, telemetryData.end - telemetryData.start);
})
.catch(err => {
console.error('Error getting tasks for all contacts', err);

this.error = true;
this.loading = false;
this.hasTasks = false;
this.tasksActions.setTasksList([]);
});
private async refreshTasks() {
try {
const telemetryData: any = {
start: Date.now(),
};

const isEnabled = await this.rulesEngineService.isEnabled();
this.tasksDisabled = !isEnabled;
const taskDocs = isEnabled ? await this.rulesEngineService.fetchTaskDocsForAllContacts() : [];

this.hasTasks = taskDocs.length > 0;
this.loading = false;

const hydratedTasks = await this.hydrateEmissions(taskDocs) || [];
const subjects = await this.getLineagesFromTaskDocs(hydratedTasks);
if (subjects?.size) {
const userLineageLevel = await this.currentLevel;
hydratedTasks.forEach(task => {
task.lineage = this.getTaskLineage(subjects, task, userLineageLevel);
});
}

this.tasksActions.setTasksList(hydratedTasks);

if (!this.tasksLoaded) {
this.tasksActions.setTasksLoaded(true);
}

telemetryData.end = Date.now();
const telemetryEntryName = !this.tasksLoaded ? `tasks:load` : `tasks:refresh`;
this.telemetryService.record(telemetryEntryName, telemetryData.end - telemetryData.start);

} catch (exception) {
console.error('Error getting tasks for all contacts', exception);
this.error = true;
this.loading = false;
this.hasTasks = false;
this.tasksActions.setTasksList([]);
}
}

listTrackBy(index, task) {
return task?._id;
}

private getCurrentLineageLevel() {
return this.userContactService.get().then(user => user?.parent?.name);
}

private getLineagesFromTaskDocs(taskDocs) {
const ids = [...new Set(taskDocs.map(task => task.owner))];
return this.lineageModelGeneratorService
.reportSubjects(ids)
.then(subjects => new Map(subjects.map(subject => [subject._id, subject.lineage])));
}

private getTaskLineage(subjects, task, userLineageLevel) {
const lineage = subjects
.get(task.owner)
?.map(lineage => lineage?.name);
return this.cleanAndRemoveCurrentLineage(lineage, userLineageLevel);
}

private cleanAndRemoveCurrentLineage(lineage, userLineageLevel) {
if (!lineage?.length) {
return;
}
lineage = lineage.filter(level => level);
const item = lineage[lineage.length - 1];
if (item === userLineageLevel) {
lineage.pop();
}
return lineage;
}
}
Loading