Commit 21db22ec authored by François Agneray's avatar François Agneray
Browse files

Fixed bug: Display info (family, attribute...)

parent 1a4f4062
......@@ -3,9 +3,9 @@ export interface Dataset {
table_ref: string;
label: string;
description: string;
illustration: string;
display: number;
count: number;
vo: boolean;
project_name: string;
id_dataset_family: number;
}
<div *ngFor="let attribute of getAttributeByFamily(criteriaFamily.id)">
<div *ngFor="let attribute of getAttributeListSortedByDisplay()">
<div [ngSwitch]="attribute.search_type">
<div *ngSwitchCase="'field'">
<app-field class="criteria" [id]="attribute.id" [operator]="attribute.operator"
......
......@@ -10,20 +10,18 @@ import { Family, Attribute, Option } from '../../../metamodel/model';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class CriteriaByFamilyComponent {
@Input() criteriaFamily: Family;
@Input() datasetAttributeList: Attribute[];
@Input() attributeList: Attribute[];
@Input() criteriaList: Criterion[];
@Output() addCriterion: EventEmitter<Criterion> = new EventEmitter();
@Output() deleteCriterion: EventEmitter<number> = new EventEmitter();
getAttributeByFamily(idFamily: number): Attribute[] {
return this.datasetAttributeList
.filter(attribute => attribute.id_criteria_family === idFamily)
getAttributeListSortedByDisplay(): Attribute[] {
return this.attributeList
.sort((a, b) => a.criteria_display - b.criteria_display);
}
getOptions(idAttribute: number): Option[] {
return this.datasetAttributeList.find(attribute => attribute.id === idAttribute).options;
return this.attributeList.find(attribute => attribute.id === idAttribute).options;
}
getCriterion(id: number): Criterion {
......
......@@ -3,8 +3,7 @@
<p class="border-bottom bg-light text-primary py-4 pl-4">{{ criteriaFamilyList[0].label }}</p>
<div class="px-3">
<app-criteria-by-family
[criteriaFamily]="criteriaFamilyList[0]"
[datasetAttributeList]="datasetAttributeList"
[attributeList]="getAttributeByFamily(criteriaFamilyList[0].id)"
[criteriaList]="criteriaList"
(addCriterion)="add($event)"
(deleteCriterion)="delCriterion($event)">
......@@ -14,7 +13,7 @@
</div>
<accordion *ngIf="criteriaFamilyList.length > 1">
<ng-container *ngFor="let family of criteriaFamilyList">
<ng-container *ngFor="let family of getCriteriaFamilyListSortedByDisplay()">
<accordion-group #ag *ngIf="getAttributeByFamily(family.id).length > 0" [panelClass]="'custom-accordion'" [isOpen]="true"
class="my-2">
<button class="btn btn-link btn-block clearfix" accordion-heading>
......@@ -26,8 +25,7 @@
</div>
</button>
<app-criteria-by-family
[criteriaFamily]="family"
[datasetAttributeList]="datasetAttributeList"
[attributeList]="getAttributeByFamily(family.id)"
[criteriaList]="criteriaList"
(addCriterion)="add($event)"
(deleteCriterion)="delCriterion($event)">
......
......@@ -21,6 +21,11 @@ export class CriteriaTabsComponent {
.filter(attribute => attribute.id_criteria_family === idFamily);
}
getCriteriaFamilyListSortedByDisplay() {
return this.criteriaFamilyList
.sort((a, b) => a.display - b.display);
}
add(criterion: Criterion): void {
this.addCriterion.emit(criterion);
}
......
......@@ -2,10 +2,10 @@
<div class="border rounded my-2">
<p class="border-bottom bg-light text-primary py-4 pl-4">List of datasets</p>
<ul class="p-0">
<li *ngFor="let datasetName of datasetFamilyList[0].datasets; last as isLast"
<li *ngFor="let dataset of getDatasetListByFamily(datasetFamilyList[0].id); last as isLast"
class="list-unstyled px-3 pt-3 pb-0">
{{ i }}
<app-dataset-card [dataset]="getDataset(datasetName)" [project]="getProject(datasetName)"
<app-dataset-card [dataset]="dataset" [project]="getProject(dataset)"
[datasetSelected]="datasetSelected" (select)="select.emit($event)">
</app-dataset-card>
<hr *ngIf="!isLast">
......@@ -15,16 +15,16 @@
</div>
<tabset *ngIf="datasetFamilyList.length > 1" [justified]="true">
<tab *ngFor="let family of datasetFamilyList" heading="{{family.label}} ({{family.datasets.length}})">
<div *ngIf="family.datasets.length < 1" class="row align-items-center family-empty">
<tab *ngFor="let family of getDatasetFamilyListSortedByDisplay()" heading="{{family.label}} ({{getDatasetListByFamily(family.id).length}})">
<div *ngIf="getDatasetListByFamily(family.id).length < 1" class="row align-items-center family-empty">
<div class="col">
<p class="text-center">This family dataset is empty for now</p>
</div>
</div>
<ul *ngIf="family.datasets.length > 0" class="p-0">
<li *ngFor="let datasetName of family.datasets" class="list-unstyled p-1 mx-auto dataset-card">
<app-dataset-card [dataset]="getDataset(datasetName)" [project]="getProject(datasetName)"
<ul *ngIf="getDatasetListByFamily(family.id).length > 0" class="p-0">
<li *ngFor="let dataset of getDatasetListByFamily(family.id)" class="list-unstyled p-1 mx-auto dataset-card">
<app-dataset-card [dataset]="dataset" [project]="getProject(dataset)"
[datasetSelected]="datasetSelected" (select)="select.emit($event)">
</app-dataset-card>
</li>
......
......@@ -15,11 +15,18 @@ export class DatasetTabsComponent {
@Input() datasetSelected: string;
@Output() select: EventEmitter<string> = new EventEmitter();
getDataset(datasetName: string) {
return this.datasetList.find(dataset => dataset.name === datasetName);
getDatasetListByFamily(idFamily: number): Dataset[] {
return this.datasetList
.filter(d => d.id_dataset_family === idFamily)
.sort((a, b) => a.display - b.display);
}
getProject(datasetName: string) {
return this.projectList.find(project => project.name === this.getDataset(datasetName).project_name);
getDatasetFamilyListSortedByDisplay() {
return this.datasetFamilyList
.sort((a, b) => a.display - b.display);
}
getProject(dataset: Dataset): Project {
return this.projectList.find(project => project.name === dataset.project_name);
}
}
......@@ -6,7 +6,7 @@
<span *ngIf="isAllSelected">Unselect All</span>
</button>
<hr class="my-1">
<button *ngFor="let attribute of attributeList" class="btn btn-block text-left py-0 m-0"
<button *ngFor="let attribute of getAttributeListSortedByDisplay()" class="btn btn-block text-left py-0 m-0"
(click)="toggleSelection(attribute.id)">
<div *ngIf="isSelected(attribute.id); then selected else unselected"></div>
{{ attribute.form_label }}
......
......@@ -15,6 +15,11 @@ export class OutputByCategoryComponent {
@Input() isAllSelected: boolean;
@Output() change: EventEmitter<number[]> = new EventEmitter();
getAttributeListSortedByDisplay() {
return this.attributeList
.sort((a, b) => a.output_display - b.output_display);
}
isSelected(id: number) {
return this.outputList.filter(i => i === id).length > 0;
}
......
<div class="row">
<div *ngFor="let category of getCategoryByFamily(outputFamily.id)" class="col-12 col-md-6 my-3 text-center">
<div *ngFor="let category of getCategoryByFamilySortedByDisplay(outputFamily.id)" class="col-12 col-md-6 my-3 text-center">
<app-output-by-category
[categoryLabel]="category.label"
[attributeList]="getAttributeByCategory(category.id)"
......
......@@ -16,7 +16,7 @@ export class OutputByFamilyComponent {
@Output() changed: EventEmitter<number[]> = new EventEmitter();
isAllSelected = false;
getCategoryByFamily(idFamily: number): Category[] {
getCategoryByFamilySortedByDisplay(idFamily: number): Category[] {
return this.categoryList
.filter(category => category.id_output_family === idFamily)
.sort((a, b) => a.display - b.display);
......@@ -24,8 +24,7 @@ export class OutputByFamilyComponent {
getAttributeByCategory(idCategory: number): Attribute[] {
return this.datasetAttributeList
.filter(attribute => attribute.id_output_category === idCategory)
.sort((a, b) => a.output_display - b.output_display);
.filter(attribute => attribute.id_output_category === idCategory);
}
getIsAllSelected(idCategory: number): boolean {
......
......@@ -10,7 +10,7 @@
</div>
<accordion *ngIf="outputFamilyList.length > 1">
<accordion-group #ag *ngFor="let family of outputFamilyList" [panelClass]="'custom-accordion-output'" class="my-2"
<accordion-group #ag *ngFor="let family of getOutputFamilyListSortedByDisplay()" [panelClass]="'custom-accordion-output'" class="my-2"
[isOpen]="true">
<button class="btn btn-link btn-block clearfix" accordion-heading>
<div class="pull-left float-left">
......
......@@ -15,6 +15,11 @@ export class OutputTabsComponent {
@Input() outputList: number[];
@Output() changed: EventEmitter<number[]> = new EventEmitter();
getOutputFamilyListSortedByDisplay(): Family[] {
return this.outputFamilyList
.sort((a, b) => a.display - b.display);
}
change(clonedOutpuList: number[]): void {
this.changed.emit(clonedOutpuList);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment