Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(resource view): dsp app the resource viewer does not reload properly after deselecting a resource from the comparison viewer(Dev-1123) #793

Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
31f6cea
open image in new tab
Vijeinath Aug 5, 2022
d83b97b
comment
Vijeinath Aug 8, 2022
b17d6d0
move replace file function
Vijeinath Aug 8, 2022
04f3924
download still image
Vijeinath Aug 8, 2022
2a1c53a
doc
Vijeinath Aug 8, 2022
121502c
feat(resource.component): introduce forceResourceReload
domsteinbach Aug 9, 2022
1d5bee4
feat(resource.component): introduce forceReload
domsteinbach Aug 9, 2022
6fdeb24
feat(resource.component): pass forceResourceReload
domsteinbach Aug 9, 2022
3b01a18
refactor(resourceIds): change to map (faster, shorter, less side effe…
domsteinbach Aug 9, 2022
65861ec
feat(reload resource): add force reload
domsteinbach Aug 9, 2022
4216e0a
feat(reload resource): pass force reload
domsteinbach Aug 9, 2022
ebf2e1f
feat(reload resource): pass force reload to comparison-component
domsteinbach Aug 9, 2022
fa849fc
Merge branch 'main' into wip/dev-1123-dsp-app-the-resource-viewer-doe…
domsteinbach Aug 9, 2022
d55694f
refactor(force reload): remove forceReload Input and simply compare t…
domsteinbach Aug 10, 2022
02d4b4d
refactor(force reload): remove forceReload Input
domsteinbach Aug 10, 2022
1945e11
refactor(force reload): remove forceResourceReload
domsteinbach Aug 10, 2022
1385bb2
refactor(force reload): remove forceResourceReload
domsteinbach Aug 10, 2022
8ea8195
refactor(forceReload): remove forceReload
domsteinbach Aug 10, 2022
75ca711
Merge branch 'main' into wip/dev-1123-dsp-app-the-resource-viewer-doe…
domsteinbach Aug 10, 2022
9a74166
chore: restore from main
domsteinbach Aug 10, 2022
ec172f7
Merge branch 'main' into wip/dev-1123-dsp-app-the-resource-viewer-doe…
domsteinbach Aug 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/app/workspace/comparison/comparison.component.ts
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/workspace/resource/resource.component.html
Expand Up @@ -13,7 +13,7 @@
[resourceIri]="incomingResource ? incomingResource.res.id : resource.res.id"
[project]="resource.res.attachedToProject"
[currentTab]="selectedTabLabel"
[parentResource]="resource.res"
[parentResource]="incomingResource ? incomingResource.res : resource.res"
[activateRegion]="selectedRegion"
(loaded)="representationLoaded($event)"
(goToPage)="compoundNavigation($event)"
Expand Down
9 changes: 6 additions & 3 deletions src/app/workspace/resource/resource.component.ts
Expand Up @@ -57,6 +57,8 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy {

@Input() splitSizeChanged: SplitSize;

oldResourceIri: string; // for change detection

projectCode: string;

resourceUuid: string;
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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;
}

Expand All @@ -185,6 +187,7 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy {
if (this.resourceIri) {
this.getResource(this.resourceIri);
}
this.oldResourceIri = this.resourceIri;
}

ngOnDestroy() {
Expand Down
15 changes: 10 additions & 5 deletions src/app/workspace/results/results.component.html
@@ -1,23 +1,28 @@
<!-- In case if results present -->
<div class="content" *ngIf="searchParams">

<as-split direction="horizontal" (dragEnd)="splitSizeChanged = $event">
<as-split direction="horizontal" (dragEnd)="splitSize = $event">
<as-split-area [size]="40">
<app-list-view [search]="searchParams" [displayViewSwitch]="false" [withMultipleSelection]="true"
(selectedResources)="openSelectedResources($event)">
(selectedResources)="onSelectionChange($event)">
</app-list-view>
</as-split-area>
<as-split-area [size]="60" *ngIf="selectedResources?.count > 0" cdkScrollable>
<div [ngSwitch]="viewMode">
<!-- single resource view -->
<app-resource *ngSwitchCase="'single'" [resourceIri]="selectedResources.resInfo[0].id" [splitSizeChanged]="splitSizeChanged"></app-resource>
<app-resource *ngSwitchCase="'single'"
[resourceIri]="resourceIri"
[splitSizeChanged]="splitSize">
</app-resource>

<!-- intermediate view -->
<app-intermediate *ngSwitchCase="'intermediate'" [resources]="selectedResources" (action)="viewMode=$event"></app-intermediate>

<!-- multiple resources view / comparison viewer -->
<app-comparison *ngSwitchCase="'compare'" [noOfResources]="selectedResources.count"
[resources]="selectedResources.resInfo" [splitSizeChanged]="splitSizeChanged">
<app-comparison *ngSwitchCase="'compare'"
[noOfResources]="selectedResources.count"
[resources]="selectedResources.resInfo"
[splitSizeChanged]="splitSize">
</app-comparison>
</div>
</as-split-area>
Expand Down
8 changes: 4 additions & 4 deletions src/app/workspace/results/results.component.ts
Expand Up @@ -33,7 +33,7 @@ export class ResultsComponent {

loading = true;

splitSizeChanged: SplitSize;
splitSize: SplitSize;

constructor(
private _route: ActivatedRoute,
Expand Down Expand Up @@ -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');
}
}

}

}