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

Merge branch '93-auto-select-dataset' into 'develop'

Resolve "Auto select dataset"

Closes #93

See merge request !103
parents 9044e893 84f6cffa
No related branches found
No related tags found
2 merge requests!113Develop,!103Resolve "Auto select dataset"
Pipeline #2594 passed
...@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [3.3.0] - 2020-05 ## [3.3.0] - 2020-05
### Added ### Added
- #90 => Dynamic documentation to explain how to export results via server urls - #90 => Dynamic documentation to explain how to export results via server urls
- #88 => Search by cone search
- #93 => Auto select dataset if only one present
### Fixed ### Fixed
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<ul class="p-0"> <ul class="p-0">
<li *ngFor="let dataset of getDatasetListByFamily(datasetFamilyList[0].id); last as isLast" <li *ngFor="let dataset of getDatasetListByFamily(datasetFamilyList[0].id); last as isLast"
class="list-unstyled px-3 pt-3 pb-0"> class="list-unstyled px-3 pt-3 pb-0">
<!-- {{ i }} -->
<app-dataset-card [dataset]="dataset" [project]="getProject(dataset)" <app-dataset-card [dataset]="dataset" [project]="getProject(dataset)"
[datasetSelected]="datasetSelected" (select)="select.emit($event)"> [datasetSelected]="datasetSelected" (select)="select.emit($event)">
</app-dataset-card> </app-dataset-card>
...@@ -30,7 +29,7 @@ ...@@ -30,7 +29,7 @@
</span> </span>
</div> </div>
</button> </button>
<div *ngFor="let dataset of getDatasetListByFamily(family.id); last as isLast"> <div *ngFor="let dataset of getDatasetListByFamily(family.id); last as isLast">
<app-dataset-card <app-dataset-card
[dataset]="dataset" [dataset]="dataset"
[project]="getProject(dataset)" [project]="getProject(dataset)"
......
...@@ -21,11 +21,11 @@ describe('[Search][Dataset] Component: DatasetTabsComponent', () => { ...@@ -21,11 +21,11 @@ describe('[Search][Dataset] Component: DatasetTabsComponent', () => {
}) })
class TestHostComponent { class TestHostComponent {
@ViewChild(DatasetTabsComponent, { static: false }) @ViewChild(DatasetTabsComponent, { static: false })
public testedComponent: DatasetTabsComponent; testedComponent: DatasetTabsComponent;
private projectList: Project[] = PROJECT_LIST; projectList: Project[] = PROJECT_LIST;
private datasetList: Dataset[] = DATASET_LIST; datasetList: Dataset[] = DATASET_LIST;
private datasetFamilyList: Family[] = DATASET_FAMILY_LIST; datasetFamilyList: Family[] = DATASET_FAMILY_LIST;
private datasetSelected = 'cat_1'; datasetSelected = 'cat_1';
} }
@Component({ selector: 'app-dataset-card', template: '' }) @Component({ selector: 'app-dataset-card', template: '' })
...@@ -69,5 +69,11 @@ describe('[Search][Dataset] Component: DatasetTabsComponent', () => { ...@@ -69,5 +69,11 @@ describe('[Search][Dataset] Component: DatasetTabsComponent', () => {
const project = testedComponent.getProject(DATASET); const project = testedComponent.getProject(DATASET);
expect(project.name).toBe('project_1'); expect(project.name).toBe('project_1');
}); });
it('should select dataset if only one dataset in instance', () => {
testedComponent.select.subscribe((event: string) => expect(event).toBe('cat_1'));
testHostComponent.datasetList = [DATASET]
testHostFixture.detectChanges();
});
}); });
...@@ -10,13 +10,21 @@ import { Project, Dataset, Family } from '../../../metamodel/model'; ...@@ -10,13 +10,21 @@ import { Project, Dataset, Family } from '../../../metamodel/model';
}) })
export class DatasetTabsComponent { export class DatasetTabsComponent {
@Input() projectList: Project[]; @Input() projectList: Project[];
@Input() datasetList: Dataset[]; @Input()
set datasetList(datasetList: Dataset[]) {
this.datasets = datasetList;
if (datasetList.length === 1) {
this.select.emit(datasetList[0].name);
}
}
@Input() datasetFamilyList: Family[]; @Input() datasetFamilyList: Family[];
@Input() datasetSelected: string; @Input() datasetSelected: string;
@Output() select: EventEmitter<string> = new EventEmitter(); @Output() select: EventEmitter<string> = new EventEmitter();
datasets: Dataset[];
getDatasetListByFamily(idFamily: number): Dataset[] { getDatasetListByFamily(idFamily: number): Dataset[] {
return this.datasetList return this.datasets
.filter(d => d.id_dataset_family === idFamily) .filter(d => d.id_dataset_family === idFamily)
.sort((a, b) => a.display - b.display); .sort((a, b) => a.display - b.display);
} }
......
...@@ -70,7 +70,9 @@ export class DatasetComponent implements OnInit { ...@@ -70,7 +70,9 @@ export class DatasetComponent implements OnInit {
} }
selectDataset(datasetName: string): void { selectDataset(datasetName: string): void {
this.store.dispatch(new searchActions.NewSearchAction(datasetName)); // Create a micro tasks that is processed after the current synchronous code
// This micro task prevent the expression has changed after it was checked
Promise.resolve(null).then(() => this.store.dispatch(new searchActions.NewSearchAction(datasetName)));
this.store.dispatch(new attributeActions.LoadAttributeSearchMetaAction(datasetName)); this.store.dispatch(new attributeActions.LoadAttributeSearchMetaAction(datasetName));
this.store.dispatch(new criteriaActions.LoadCriteriaSearchMetaAction(datasetName)); this.store.dispatch(new criteriaActions.LoadCriteriaSearchMetaAction(datasetName));
this.store.dispatch(new outputActions.LoadOutputSearchMetaAction(datasetName)); this.store.dispatch(new outputActions.LoadOutputSearchMetaAction(datasetName));
......
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