use record list to find orphan task records when toggling

This commit is contained in:
Jake McDermott 2018-06-25 01:36:16 -04:00
parent ccd8a48617
commit 71f2388ec8
No known key found for this signature in database
GPG Key ID: 3B02CAD476EECB35
2 changed files with 12 additions and 8 deletions

View File

@ -1,4 +1,7 @@
/* eslint camelcase: 0 */
const EVENT_START_TASK = 'playbook_on_task_start';
const EVENT_START_PLAY = 'playbook_on_play_start';
let $compile;
let $q;
let $scope;
@ -142,8 +145,15 @@ function toggleMenuExpand () {
if (scroll.isPaused()) return;
const recordList = Object.keys(render.record).map(key => render.record[key]);
const playRecords = recordList.filter(({ name }) => name === EVENT_START_PLAY);
const playIds = playRecords.map(({ uuid }) => uuid);
const toggled = recordList
// get any task record that does not have a parent play record
const orphanTaskRecords = recordList
.filter(({ name }) => name === EVENT_START_TASK)
.filter(({ parents }) => !parents.some(uuid => playIds.indexOf(uuid) >= 0));
const toggled = playRecords.concat(orphanTaskRecords)
.map(({ uuid }) => getToggleElements(uuid))
.filter(({ icon }) => icon.length > 0)
.map(({ icon, lines }) => setExpanded(icon, lines, !vm.isMenuExpanded));

View File

@ -119,6 +119,7 @@ function JobRenderService ($q, $sce, $window) {
const info = {
id: event.id,
line: ln + 1,
name: event.event,
uuid: event.uuid,
level: event.event_level,
start: event.start_line,
@ -210,13 +211,6 @@ function JobRenderService ($q, $sce, $window) {
if (current.parents) {
classList = current.parents.reduce((list, uuid) => `${list} child-of-${uuid}`, '');
}
// if a row has children, and has parent,
// we grab all its children and append parent to its children
if (id !== '' && current.parents) {
const children = $(`.child-of-${current.uuid}`);
const parentId = current.parents[0];
children.addClass(`child-of-${parentId}`);
}
}
if (!tdEvent) {