Skip to content
Snippets Groups Projects
Commit 720b8248 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Merge branch '113-bug-summary-output-list' into 'develop'

Resolve "Bug summary output list"

Closes #113

See merge request !123
parents 2af1039f 5a58a605
No related branches found
No related tags found
2 merge requests!147Develop,!123Resolve "Bug summary output list"
Pipeline #2829 passed
......@@ -56,7 +56,7 @@
<!-- Accordion categories -->
<accordion [isAnimated]="true">
<accordion-group *ngFor="let category of getCategoryByFamilySortedByDisplay(family.id)" #ag panelClass="customClass" [isOpen]="accordionCategoryIsOpen" class="pl-4">
<accordion-group *ngFor="let category of getCategoryByFamilySortedByDisplay(family.id)" #ag panelClass="customClass" [isOpen]="currentStep === 'output' || outputList.length < 10" class="pl-4">
<button class="btn btn-link btn-block clearfix pb-1" accordion-heading>
<div class="pull-left float-left">
{{ category.label }}
......@@ -71,11 +71,14 @@
</button>
<!-- Output list -->
<ul class="mb-0 pl-4 list-unstyled">
<li *ngFor="let output of getOutputByCategory(category.id)" class="pb-1">
<ul *ngIf="getSelectedOutputByCategory(category.id).length > 0; else noOutputs" class="mb-0 pl-4 list-unstyled">
<li *ngFor="let output of getSelectedOutputByCategory(category.id)" class="pb-1">
{{ output.form_label }}
</li>
</ul>
<ng-template #noOutputs>
<p class="mb-1 pl-4">No selected output</p>
</ng-template>
</accordion-group>
</accordion>
</accordion-group>
......
......@@ -41,12 +41,6 @@ describe('[Search] Component: SummaryComponent', () => {
component.criteriaList = [];
expect(component.noCriteria()).toBeFalsy();
});
it('#getOutputByCategory() should return attributes belonging to the given category', () => {
component.datasetAttributeList = ATTRIBUTE_LIST;
expect(component.getOutputByCategory(1).length).toEqual(1);
expect(component.getOutputByCategory(1)[0].id).toEqual(1);
});
it('#getAttribute() should return the attribute with the given id', () => {
component.datasetAttributeList = ATTRIBUTE_LIST;
......@@ -65,5 +59,13 @@ describe('[Search] Component: SummaryComponent', () => {
expect(sortedCategoryList[0].id).toBe(2);
expect(sortedCategoryList[1].id).toBe(1);
});
it('#getSelectedOutputByCategory() should return selected attributes belonging to the given category', () => {
component.datasetAttributeList = ATTRIBUTE_LIST;
component.outputList = [1];
expect(component.getSelectedOutputByCategory(1).length).toEqual(1);
component.outputList = [];
expect(component.getSelectedOutputByCategory(1).length).toEqual(0);
});
});
......@@ -26,7 +26,6 @@ export class SummaryComponent {
@Input() queryParams: SearchQueryParams;
accordionFamilyIsOpen = true;
accordionCategoryIsOpen = false;
getDataset(): Dataset {
return this.datasetList.find(dataset => dataset.name === this.datasetName);
......@@ -39,10 +38,6 @@ export class SummaryComponent {
return true;
}
getOutputByCategory(idCategory: number): Attribute[] {
return this.datasetAttributeList.filter(attribute => attribute.id_output_category === idCategory);
}
getAttribute(id: number): Attribute {
return this.datasetAttributeList.find(attribute => attribute.id === id);
}
......@@ -56,4 +51,9 @@ export class SummaryComponent {
.filter(category => category.id_output_family === idFamily)
.sort((a, b) => a.display - b.display);
}
getSelectedOutputByCategory(idCategory: number): Attribute[] {
const outputListByCategory = this.datasetAttributeList.filter(attribute => attribute.id_output_category === idCategory);
return outputListByCategory.filter(attribute => this.outputList.includes(attribute.id));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment