Commit dbb36812 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Attribute Lists sorted by id => DONE

parent 518d4232
......@@ -50,10 +50,13 @@ describe('[Documentation] Component: DocumentationComponent', () => {
expect(component.getHost()).toEqual(environment.apiUrl);
});
it('#getAttributeList() should return attributes for selected dataset', () => {
it('#getAttributeList() should return attributes for selected dataset, sorted by id', () => {
const attributeLists: Dictionary<AttributesByDataset> = {
'toto': { datasetName: 'toto', isLoading: false, isLoaded: true, attributeList: ATTRIBUTE_LIST }
};
expect(component.getAttributeList('toto', attributeLists)).toEqual(ATTRIBUTE_LIST);
const attributeList = component.getAttributeList('toto', attributeLists);
expect(attributeList.length).toEqual(2);
expect(attributeList[0].id).toEqual(1);
expect(attributeList[1].id).toEqual(2);
});
});
......@@ -44,6 +44,6 @@ export class DocumentationComponent implements OnInit {
}
getAttributeList(dname: string, attributesLists: Dictionary<AttributesByDataset>): Attribute[] {
return attributesLists[dname].attributeList;
return [...attributesLists[dname].attributeList].sort((a, b) => a.id - b.id);
}
}
import { Attribute, Option } from '../../app/metamodel/model';
export const ATTRIBUTE_LIST: Attribute[] = [
{
id: 2,
name: 'name_two',
table_name: 'table_2',
label: 'label_two',
form_label: 'form_label_two',
description: 'description_two',
output_display: 1,
criteria_display: 1,
search_flag: 'SPECTRUM_1D',
search_type: 'field',
operator: '=',
type: '',
min: null,
max: null,
placeholder_min: '',
placeholder_max: '',
renderer: '',
renderer_config: null,
display_detail: 1,
selected: true,
order_by: true,
order_display: 1,
detail: true,
renderer_detail: 'spectra_graph',
options: null,
vo_utype: '',
vo_ucd: '',
vo_unit: '',
vo_description: '',
vo_datatype: '',
vo_size: 1,
id_criteria_family: 2,
id_output_category: 2
},
{
id: 1,
name: 'name_one',
......@@ -39,40 +74,5 @@ export const ATTRIBUTE_LIST: Attribute[] = [
vo_size: 1,
id_criteria_family: 1,
id_output_category: 1
},
{
id: 2,
name: 'name_two',
table_name: 'table_2',
label: 'label_two',
form_label: 'form_label_two',
description: 'description_two',
output_display: 1,
criteria_display: 1,
search_flag: 'SPECTRUM_1D',
search_type: 'field',
operator: '=',
type: '',
min: null,
max: null,
placeholder_min: '',
placeholder_max: '',
renderer: '',
renderer_config: null,
display_detail: 1,
selected: true,
order_by: true,
order_display: 1,
detail: true,
renderer_detail: 'spectra_graph',
options: null,
vo_utype: '',
vo_ucd: '',
vo_unit: '',
vo_description: '',
vo_datatype: '',
vo_size: 1,
id_criteria_family: 2,
id_output_category: 2
}
];
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