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

Merge branch '139-search-multiple-select-aor-unselect-all-datasets-by-default' into 'develop'

Resolve "[Search Multiple] Select or unselect all datasets by default"

Closes #139

See merge request !152
parents c87cbf5d d758c543
Pipeline #3228 passed with stages
in 8 minutes and 41 seconds
......@@ -6,14 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [3.5.0] - 2020-xx
### Added
- #136 => Add detail view for spectra type object and default object
### Fixed
### Changed
- #139 => Datasets selected in search multiple is a configurable option in anis-admin
- #138 => Sort attributes and put scrollbar if table too long in Documentation module
- #133 => Change typo if only one dataset
## [3.4.0] - 2020-10
### Added
- #132 => Add reset cone search button in search multiple
......
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NavComponent } from './nav.component';
import { INSTANCE } from '../../../settings/test-data/instance';
describe('[Core] Component: NavComponent', () => {
let component: NavComponent;
......@@ -52,18 +53,7 @@ describe('[Core] Component: NavComponent', () => {
});
it('should display search, search multiple and documentation links if instance config allows it', () => {
component.instance = {
name: 'toto',
label: 'Toto',
client_url: '',
nb_dataset_families: 1,
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
documentation: true
}
};
component.instance = INSTANCE;
fixture.detectChanges();
const template = fixture.nativeElement;
expect(template.querySelector('#search_link')).toBeTruthy();
......@@ -80,7 +70,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: false,
search_multiple: false,
search_multiple: {
allowed: false,
all_datasets_selected: false
},
documentation: false
} };
fixture.detectChanges();
......@@ -99,7 +92,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: true,
search_multiple: false,
search_multiple: {
allowed: false,
all_datasets_selected: false
},
documentation: false
}
};
......@@ -112,7 +108,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: false,
search_multiple: false,
search_multiple: {
allowed: false,
all_datasets_selected: false
},
documentation: false
} };
expect(component.isSearchAllowed()).toBeFalsy();
......@@ -127,7 +126,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
search_multiple: {
allowed: true,
all_datasets_selected: false
},
documentation: false
}
};
......@@ -140,7 +142,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: true,
search_multiple: false,
search_multiple: {
allowed: false,
all_datasets_selected: false
},
documentation: false
}
};
......@@ -156,7 +161,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
search_multiple: {
allowed: true,
all_datasets_selected: false
},
documentation: true
}
};
......@@ -169,7 +177,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
search_multiple: {
allowed: true,
all_datasets_selected: false
},
documentation: false
}
};
......
......@@ -26,7 +26,7 @@ export class NavComponent {
isSearchMultipleAllowed(): boolean {
if (this.instance && this.instance.config.search_multiple) {
return this.instance.config.search_multiple;
return this.instance.config.search_multiple.allowed;
}
return false;
}
......
import * as instanceActions from './instance.action';
import { Instance } from '../model';
import { INSTANCE } from '../../../settings/test-data/instance';
describe('[Metamodel] Instance action', () => {
it('should create LoadInstanceMetaAction', () => {
......@@ -8,21 +8,9 @@ describe('[Metamodel] Instance action', () => {
});
it('should create LoadDatasetSearchMetaSuccessAction', () => {
const payload: Instance = {
name: 'toto',
label: 'Toto',
client_url: '',
nb_dataset_families: 1,
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
documentation: true
}
};
const action = new instanceActions.LoadInstanceMetaSuccessAction(payload);
const action = new instanceActions.LoadInstanceMetaSuccessAction(INSTANCE);
expect(action.type).toEqual(instanceActions.LOAD_INSTANCE_META_SUCCESS);
expect(action.payload).toEqual(payload);
expect(action.payload).toEqual(INSTANCE);
});
it('should create LoadDatasetSearchMetaFailAction', () => {
......
......@@ -6,7 +6,10 @@ export interface Instance {
nb_datasets: number;
config: {
search: boolean;
search_multiple: boolean;
search_multiple: {
allowed: boolean;
all_datasets_selected: boolean;
};
documentation: boolean;
};
}
import * as fromInstance from './instance.reducer';
import * as instanceActions from '../action/instance.action';
import { Instance } from '../model';
import { INSTANCE } from '../../../settings/test-data/instance';
describe('[Metamodel] Instance reducer', () => {
it('should return init state', () => {
......@@ -12,18 +13,7 @@ describe('[Metamodel] Instance reducer', () => {
});
it('should set instance', () => {
const instance: Instance = {
name: 'toto',
label: 'Toto',
client_url: '',
nb_dataset_families: 1,
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
documentation: true
}
};
const instance: Instance = INSTANCE;
const { initialState } = fromInstance;
const action = new instanceActions.LoadInstanceMetaSuccessAction(instance);
const state = fromInstance.reducer(initialState, action);
......
......@@ -62,22 +62,23 @@ export class SearchMultipleEffects {
})
);
// @Effect()
// loadDatasetSearchMetaSuccessAction$ = this.actions$.pipe(
// ofType(datasetActions.LOAD_DATASET_SEARCH_META_SUCCESS),
// withLatestFrom(this.store$),
// switchMap(([action, state]) => {
// if (state.searchMultiple.selectedDatasets.length === 0) {
// const loadDatasetSearchMetaSuccessAction = action as datasetActions.LoadDatasetSearchMetaSuccessAction;
// const datasetWithConeSearchList: Dataset[] = loadDatasetSearchMetaSuccessAction.payload[1]
// .filter(d => d.config.cone_search && d.config.cone_search.enabled === true);
// const selectedDatasets: string[] = datasetWithConeSearchList.map(d => d.name);
// return of(new searchMultipleActions.InitSelectedDatasetsAction(selectedDatasets));
// } else {
// return of({ type: '[No Action] ' + searchMultipleActions.INIT_SELECTED_DATASETS });
// }
// })
// );
@Effect()
loadDatasetSearchMetaSuccessAction$ = this.actions$.pipe(
ofType(datasetActions.LOAD_DATASET_SEARCH_META_SUCCESS),
withLatestFrom(this.store$),
switchMap(([action, state]) => {
const allDatasetsSelected = state.metamodel.instance.instance.config.search_multiple.all_datasets_selected;
if (allDatasetsSelected && state.searchMultiple.selectedDatasets.length === 0) {
const loadDatasetSearchMetaSuccessAction = action as datasetActions.LoadDatasetSearchMetaSuccessAction;
const datasetWithConeSearchList: Dataset[] = loadDatasetSearchMetaSuccessAction.payload[1]
.filter(d => d.config.cone_search && d.config.cone_search.enabled === true);
const selectedDatasets: string[] = datasetWithConeSearchList.map(d => d.name);
return of(new searchMultipleActions.InitSelectedDatasetsAction(selectedDatasets));
} else {
return of({ type: '[No Action]' + searchMultipleActions.INIT_SELECTED_DATASETS });
}
})
);
@Effect()
retrieveDatasetsCountAction$ = this.actions$.pipe(
......
import { Instance } from '../../app/metamodel/model';
export const INSTANCE: Instance = {
name: 'instance',
label: 'Instance',
client_url: 'http://localhost.com',
nb_dataset_families: 2,
nb_datasets: 3,
config: {
search: true,
search_multiple: {
allowed: true,
all_datasets_selected: true,
},
documentation: true
}
};
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