From f690a37e35abc13792de1bd4121c29f332ef756d Mon Sep 17 00:00:00 2001 From: domsteinbach <36757218+domsteinbach@users.noreply.github.com> Date: Thu, 11 Aug 2022 14:29:45 +0200 Subject: [PATCH] fix(resource view): dsp app the resource viewer does not reload properly after deselecting a resource from the comparison viewer(Dev-1123) (#793) * open image in new tab * feat(resource.component): introduce forceResourceReload * feat(resource.component): introduce forceReload * feat(resource.component): pass forceResourceReload * refactor(resourceIds): change to map (faster, shorter, less side effects) * feat(reload resource): add force reload * feat(reload resource): pass force reload * feat(reload resource): pass force reload to comparison-component * refactor(force reload): remove forceReload Input and simply compare the state of the iri * refactor(force reload): remove forceReload Input * refactor(force reload): remove forceResourceReload * refactor(force reload): remove forceResourceReload * refactor(forceReload): remove forceReload * chore: restore from main --- .../workspace/comparison/comparison.component.ts | 5 +---- src/app/workspace/resource/resource.component.ts | 9 ++++++--- src/app/workspace/results/results.component.html | 15 ++++++++++----- src/app/workspace/results/results.component.ts | 8 ++++---- 4 files changed, 21 insertions(+), 16 deletions(-) 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 @@