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

Tests and comments on shared => DONE

parent ff26de58
No related branches found
No related tags found
2 merge requests!29Develop,!26Resolve "Add tests for shared module"
...@@ -11,7 +11,15 @@ import { Pipe, PipeTransform } from '@angular/core'; ...@@ -11,7 +11,15 @@ import { Pipe, PipeTransform } from '@angular/core';
import { Survey } from 'src/app/metamodel/models'; import { Survey } from 'src/app/metamodel/models';
@Pipe({name: 'surveyByName'}) /**
* @class
* @classdesc Returns survey corresponding to the given name.
*
* @example
* // returns survey object that matching with the 'mySurvey' name among the survey list
* {{ surveyList | surveyByName:'mySurvey' }}
*/
@Pipe({ name: 'surveyByName' })
export class SurveyByNamePipe implements PipeTransform { export class SurveyByNamePipe implements PipeTransform {
transform(surveyList: Survey[], surveyName: string): Survey { transform(surveyList: Survey[], surveyName: string): Survey {
return surveyList.find(survey => survey.name === surveyName); return surveyList.find(survey => survey.name === surveyName);
......
...@@ -26,6 +26,10 @@ import { NgxJsonViewerModule } from 'ngx-json-viewer'; ...@@ -26,6 +26,10 @@ import { NgxJsonViewerModule } from 'ngx-json-viewer';
import { sharedComponents } from './components'; import { sharedComponents } from './components';
import { sharedPipes } from './pipes'; import { sharedPipes } from './pipes';
/**
* @class
* @classdesc Shared module.
*/
@NgModule({ @NgModule({
declarations: [ declarations: [
sharedComponents, sharedComponents,
...@@ -64,4 +68,4 @@ import { sharedPipes } from './pipes'; ...@@ -64,4 +68,4 @@ import { sharedPipes } from './pipes';
sharedPipes sharedPipes
] ]
}) })
export class SharedModule { } export class SharedModule { }
\ No newline at end of file
...@@ -13,14 +13,3 @@ export const getHost = (apiUrl: string): string => { ...@@ -13,14 +13,3 @@ export const getHost = (apiUrl: string): string => {
} }
return apiUrl; return apiUrl;
} }
/**
* Sorts objects by the display property.
*
* @param {number} a - The first object to sort.
* @param {number} b - The second object to sort.
*
* @example
* [objects].sortByDisplay()
*/
export const sortByDisplay = (a, b) => a.display - b.display;
import { Attribute, Dataset, DatasetFamily, Instance, OutputCategory, Survey } from './app/metamodel/models'; import {
Attribute,
Dataset,
DatasetFamily,
Instance,
OutputCategory,
OutputFamily, SelectOption,
Survey
} from './app/metamodel/models';
export const SURVEY_LIST: Survey[] = [ export const SURVEY_LIST: Survey[] = [
{ {
...@@ -21,6 +29,75 @@ export const SURVEY_LIST: Survey[] = [ ...@@ -21,6 +29,75 @@ export const SURVEY_LIST: Survey[] = [
} }
]; ];
export const INSTANCE_LIST: Instance[] = [
{
name: 'myOtherInstance',
label: 'My Other Instance',
data_path: 'data/path',
config: {
design: {
design_color: 'green',
design_background_color: 'darker green',
design_logo: 'path/to/logo',
design_favicon: 'path/to/favicon'
},
home: {
home_component: 'HomeComponent',
home_config: {
home_component_text: 'Description',
home_component_logo: 'path/to/logo'
}
},
search: {
search_by_criteria_allowed: false,
search_by_criteria_label: 'Search',
search_multiple_allowed: false,
search_multiple_label: 'Search multiple',
search_multiple_all_datasets_selected: false
},
documentation: {
documentation_allowed: false,
documentation_label: 'Documentation'
}
},
nb_dataset_families: 2,
nb_datasets: 1
},
{
name: 'myInstance',
label: 'My Instance',
data_path: 'data/path',
config: {
design: {
design_color: 'green',
design_background_color: 'darker green',
design_logo: 'path/to/logo',
design_favicon: 'path/to/favicon'
},
home: {
home_component: 'HomeComponent',
home_config: {
home_component_text: 'Description',
home_component_logo: 'path/to/logo'
}
},
search: {
search_by_criteria_allowed: false,
search_by_criteria_label: 'Search',
search_multiple_allowed: false,
search_multiple_label: 'Search multiple',
search_multiple_all_datasets_selected: false
},
documentation: {
documentation_allowed: false,
documentation_label: 'Documentation'
}
},
nb_dataset_families: 1,
nb_datasets: 2
}
];
export const INSTANCE: Instance = { export const INSTANCE: Instance = {
name: 'myInstance', name: 'myInstance',
label: 'My Instance', label: 'My Instance',
...@@ -240,6 +317,7 @@ export const ATTRIBUTE_LIST: Attribute[] = [ ...@@ -240,6 +317,7 @@ export const ATTRIBUTE_LIST: Attribute[] = [
operator: '=', operator: '=',
type: 'integer', type: 'integer',
display_detail: 2, display_detail: 2,
id_criteria_family: 1,
options: [ options: [
{ label: 'Three', value: 'three', display: 3 }, { label: 'Three', value: 'three', display: 3 },
{ label: 'One', value: 'one', display: 1 }, { label: 'One', value: 'one', display: 1 },
...@@ -332,6 +410,16 @@ export const CATEGORY_LIST: OutputCategory[] = [ ...@@ -332,6 +410,16 @@ export const CATEGORY_LIST: OutputCategory[] = [
} }
]; ];
export const OUTPUT_FAMILY_LIST: OutputFamily[] = [
{ id: 2, label: 'Output family Two', display: 2, opened: true },
{ id: 1, label: 'Output family One', display: 1, opened: false }
];
export const SELECT_OPTION_LIST: SelectOption[] = [
{ id: 2, label: 'select_option_label_two', value: 'select_option_label_two', display: 2, select_name: 'name_two' },
{ id: 1, label: 'select_option_label_one', value: 'select_option_label_one', display: 1, select_name: 'name_one' }
];
export const OBJECT_DETAIL: any = { export const OBJECT_DETAIL: any = {
label_four: 'spec1d', label_four: 'spec1d',
label_five: 5 label_five: 5
......
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