Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
fix(query): breadcrumb text formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbornsen authored and sudsen committed Oct 23, 2018
1 parent c34d78c commit 3d49dcb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h4>Please wait, we are loading your data.</h4>
>&nbsp;
<span class="pointer breadcrumbs"
(click)="navigateToQuery(breadcrumb)">
Query - {{ i }}
{{ breadcrumbsText(i, breadcrumb) }}
</span>
</ng-container>&nbsp;>&nbsp;<span class="current-query">{{ currentQuery }}</span>
</div>
Expand Down
11 changes: 10 additions & 1 deletion src/app/components_ngrx/planner-query/planner-query.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class PlannerQueryComponent implements OnInit, OnDestroy, AfterViewChecke
if (query.hasOwnProperty('q')) {
this.searchQuery = query.q;
this.disableInput = false;
this.currentQuery = 'Query';
this.currentQuery = this.breadcrumbsText('', query);
const filters = this.filterService.queryToJson(query.q);
this.store.dispatch(new WorkItemActions.Get({
pageSize: 200,
Expand Down Expand Up @@ -193,6 +193,15 @@ export class PlannerQueryComponent implements OnInit, OnDestroy, AfterViewChecke
});
}

breadcrumbsText(index, query) {
const parentNumber = this.filterService.isOnlyChildQuery(query.q);
if (parentNumber !== null) {
return `Query ${index === '' ? '' : '-'} ${index} (Child of #${parentNumber})`;
} else {
return `Query ${index === '' ? '' : '-'} ${index}`;
}
}

ngAfterViewChecked() {
if (document.getElementsByClassName('navbar-pf').length > 0) {
this.hdrHeight = (document.getElementsByClassName('navbar-pf')[0] as HTMLElement).offsetHeight;
Expand Down
19 changes: 19 additions & 0 deletions src/app/services/filter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,23 @@ export class FilterService {
});
return query;
}

/**
* This function takes only a query string
* and returns the parent number if it's only a child Query
* @param query
* @returns string
*/
isOnlyChildQuery(query: string): string | null {
try {
const jsonQuery = this.queryToJson(query);
if (jsonQuery[this.or_notation] &&
jsonQuery[this.or_notation].length === 1 &&
jsonQuery[this.or_notation][0]['parent.number'] &&
jsonQuery[this.or_notation][0]['parent.number'][this.equal_notation]) {
return jsonQuery[this.or_notation][0]['parent.number'][this.equal_notation];
}
} catch {}
return null;
}
}

0 comments on commit 3d49dcb

Please sign in to comment.