From 71fdeb009148536de8722ca6de1782d6468a1403 Mon Sep 17 00:00:00 2001 From: Marcin Procyk Date: Tue, 6 Sep 2022 16:26:34 +0200 Subject: [PATCH 1/4] fix proprties sorting --- .../workspace/resource/resource.component.ts | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/app/workspace/resource/resource.component.ts b/src/app/workspace/resource/resource.component.ts index 0420b6a87b..7452accaf5 100644 --- a/src/app/workspace/resource/resource.component.ts +++ b/src/app/workspace/resource/resource.component.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/member-ordering */ +import { A } from '@angular/cdk/keycodes'; import { Component, Inject, Input, OnChanges, OnDestroy, OnInit, SimpleChange, ViewChild } from '@angular/core'; import { MatTabChangeEvent } from '@angular/material/tabs'; import { Title } from '@angular/platform-browser'; @@ -30,6 +31,7 @@ import { SystemPropertyDefinition } from '@dasch-swiss/dsp-js'; import { Subscription } from 'rxjs'; +import { delay } from 'rxjs/operators'; import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; import { ErrorHandlerService } from 'src/app/main/services/error-handler.service'; import { NotificationService } from 'src/app/main/services/notification.service'; @@ -319,8 +321,11 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy { this.requestIncomingResources(this.resource); } - // gather resource property information - res.resProps = this.initProps(response); + setTimeout(() => { + // gather resource property information + res.resProps = this.initProps(response); + }, 2000); + // gather system property information res.systemProps = this.resource.res.entityInfo.getPropertyDefinitionsByType(SystemPropertyDefinition); @@ -415,9 +420,17 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy { ); // sort properties by guiOrder - props = props - .filter(prop => prop.propDef.objectType !== Constants.GeomValue) - .sort((a, b) => (a.guiDef.guiOrder > b.guiDef.guiOrder) ? 1 : -1); + props = + props + .filter(prop => prop.propDef.objectType !== Constants.GeomValue) + .sort((a, b) => (a.guiDef.guiOrder > b.guiDef.guiOrder) ? 1 : -1) + // to get equal results on all browser engines which implements sorting in different way + // properties list has to be sorted again, pushing all "has..." properties to the bottom + .sort((a, b) => { + if (a.propDef.label.startsWith('has')) { + return 1; + } + }); return props; } From 4fe5e6daa357c3501853d40925a58fc4d91fbc7b Mon Sep 17 00:00:00 2001 From: Marcin Procyk Date: Wed, 7 Sep 2022 10:54:44 +0200 Subject: [PATCH 2/4] review fixes --- src/app/workspace/resource/resource.component.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/app/workspace/resource/resource.component.ts b/src/app/workspace/resource/resource.component.ts index 7452accaf5..ff330cb0c4 100644 --- a/src/app/workspace/resource/resource.component.ts +++ b/src/app/workspace/resource/resource.component.ts @@ -1,5 +1,4 @@ /* eslint-disable @typescript-eslint/member-ordering */ -import { A } from '@angular/cdk/keycodes'; import { Component, Inject, Input, OnChanges, OnDestroy, OnInit, SimpleChange, ViewChild } from '@angular/core'; import { MatTabChangeEvent } from '@angular/material/tabs'; import { Title } from '@angular/platform-browser'; @@ -31,7 +30,6 @@ import { SystemPropertyDefinition } from '@dasch-swiss/dsp-js'; import { Subscription } from 'rxjs'; -import { delay } from 'rxjs/operators'; import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; import { ErrorHandlerService } from 'src/app/main/services/error-handler.service'; import { NotificationService } from 'src/app/main/services/notification.service'; @@ -321,11 +319,8 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy { this.requestIncomingResources(this.resource); } - setTimeout(() => { - // gather resource property information - res.resProps = this.initProps(response); - }, 2000); - + // gather resource property information + res.resProps = this.initProps(response); // gather system property information res.systemProps = this.resource.res.entityInfo.getPropertyDefinitionsByType(SystemPropertyDefinition); From 0f64efffb527b370db177f9bea1cfbebac83ab4b Mon Sep 17 00:00:00 2001 From: Marcin Procyk Date: Wed, 7 Sep 2022 10:55:42 +0200 Subject: [PATCH 3/4] remove more unused imports --- src/app/workspace/resource/resource.component.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/app/workspace/resource/resource.component.ts b/src/app/workspace/resource/resource.component.ts index ff330cb0c4..62a987fca1 100644 --- a/src/app/workspace/resource/resource.component.ts +++ b/src/app/workspace/resource/resource.component.ts @@ -24,9 +24,6 @@ import { ReadResourceSequence, ReadStillImageFileValue, ReadTextFileValue, - ResourceClassAndPropertyDefinitions, - ResourceClassDefinition, - ResourceClassDefinitionWithPropertyDefinition, SystemPropertyDefinition } from '@dasch-swiss/dsp-js'; import { Subscription } from 'rxjs'; From 52fb4da673d5bca565b19e7ee0340751f2e169cf Mon Sep 17 00:00:00 2001 From: Marcin Procyk Date: Wed, 7 Sep 2022 12:23:20 +0200 Subject: [PATCH 4/4] change the condition of the second sort --- src/app/workspace/resource/resource.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/workspace/resource/resource.component.ts b/src/app/workspace/resource/resource.component.ts index 62a987fca1..7c7cf49a4e 100644 --- a/src/app/workspace/resource/resource.component.ts +++ b/src/app/workspace/resource/resource.component.ts @@ -419,7 +419,7 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy { // to get equal results on all browser engines which implements sorting in different way // properties list has to be sorted again, pushing all "has..." properties to the bottom .sort((a, b) => { - if (a.propDef.label.startsWith('has')) { + if (a.guiDef.guiOrder === undefined) { return 1; } });