diff --git a/src/app/workspace/comparison/comparison.component.ts b/src/app/workspace/comparison/comparison.component.ts index 37a595ce89..b4da608e7f 100644 --- a/src/app/workspace/comparison/comparison.component.ts +++ b/src/app/workspace/comparison/comparison.component.ts @@ -37,10 +37,7 @@ export class ComparisonComponent implements OnChanges { ngOnChanges(): void { if (this.resources && this.resources.length) { - this.resourceIds = []; - this.resources.forEach(res => { - this.resourceIds.push(res.id); - }); + this.resourceIds = this.resources.map(res => res.id); } if (!this.noOfResources) { diff --git a/src/app/workspace/resource/resource.component.ts b/src/app/workspace/resource/resource.component.ts index 884e1684fd..ed41cb47f5 100644 --- a/src/app/workspace/resource/resource.component.ts +++ b/src/app/workspace/resource/resource.component.ts @@ -57,6 +57,8 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy { @Input() splitSizeChanged: SplitSize; + oldResourceIri: string; // for change detection + projectCode: string; resourceUuid: string; @@ -127,6 +129,7 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy { this.valueUuid = params['value']; if (this.projectCode && this.resourceUuid) { this.resourceIri = this._resourceService.getResourceIri(this.projectCode, this.resourceUuid); + this.oldResourceIri = this.resourceIri; } this.getResource(this.resourceIri); }); @@ -164,12 +167,11 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy { } ngOnInit() { - } ngOnChanges(changes: { [propName: string]: SimpleChange }) { - // do not reload the whole resource when the split size has changed - if (this.splitSizeChanged) { + // do not reload the whole resource when the iri did not change + if (this.oldResourceIri === this.resourceIri) { return; } @@ -185,6 +187,7 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy { if (this.resourceIri) { this.getResource(this.resourceIri); } + this.oldResourceIri = this.resourceIri; } ngOnDestroy() { diff --git a/src/app/workspace/results/results.component.html b/src/app/workspace/results/results.component.html index 56a96638c9..6521f5436f 100644 --- a/src/app/workspace/results/results.component.html +++ b/src/app/workspace/results/results.component.html @@ -1,23 +1,28 @@
- + + (selectedResources)="onSelectionChange($event)">
- + + - +
diff --git a/src/app/workspace/results/results.component.ts b/src/app/workspace/results/results.component.ts index fccfc0bbc6..19a40e302b 100644 --- a/src/app/workspace/results/results.component.ts +++ b/src/app/workspace/results/results.component.ts @@ -33,7 +33,7 @@ export class ResultsComponent { loading = true; - splitSizeChanged: SplitSize; + splitSize: SplitSize; constructor( private _route: ActivatedRoute, @@ -61,18 +61,18 @@ export class ResultsComponent { this._titleService.setTitle('Search results for ' + this.searchParams.mode + ' search'); } - openSelectedResources(res: FilteredResources) { - + onSelectionChange(res: FilteredResources) { this.selectedResources = res; + this.resourceIri = this.selectedResources.resInfo[0].id; if (!res || res.count <= 1) { this.viewMode = 'single'; + } else { if (this.viewMode !== 'compare') { this.viewMode = ((res && res.count > 0) ? 'intermediate' : 'single'); } } - } }