From e060cce97e6931c69c625273863042ed5e1626a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Mon, 23 May 2022 14:20:19 +0200 Subject: [PATCH] chore(classes): sort resource classes by label (DEV-952) (#748) * chore(search): sort res classes by label * chore(resource): sort res classes by label * chore(ontology): sort res classes by label * style(resource-form): resolve style issue with submit button * test(search): resolve imports * test(search): resolve tests --- .../property-form/property-form.component.ts | 20 ++++++++++------- .../resource-instance-form.component.html | 2 +- .../resource-instance-form.component.scss | 9 +++++++- .../resource-instance-form.component.ts | 7 +++++- ...e-and-property-selection.component.spec.ts | 22 +++++++++++-------- ...source-and-property-selection.component.ts | 13 ++++++++--- ...ch-select-resource-class.component.spec.ts | 11 +++++++++- 7 files changed, 60 insertions(+), 24 deletions(-) diff --git a/src/app/project/ontology/property-form/property-form.component.ts b/src/app/project/ontology/property-form/property-form.component.ts index a068dd6dd8..d43d145b52 100644 --- a/src/app/project/ontology/property-form/property-form.component.ts +++ b/src/app/project/ontology/property-form/property-form.component.ts @@ -24,6 +24,7 @@ import { CacheService } from 'src/app/main/cache/cache.service'; import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; import { existingNamesValidator } from 'src/app/main/directive/existing-name/existing-name.directive'; import { ErrorHandlerService } from 'src/app/main/services/error-handler.service'; +import { SortingService } from 'src/app/main/services/sorting.service'; import { CustomRegex } from 'src/app/workspace/resource/values/custom-regex'; import { AutocompleteItem } from 'src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/operator'; import { DefaultProperties, DefaultProperty, PropertyCategory, PropertyInfoObject } from '../default-data/default-properties'; @@ -135,7 +136,8 @@ export class PropertyFormComponent implements OnInit { private _cache: CacheService, private _errorHandler: ErrorHandlerService, private _fb: FormBuilder, - private _os: OntologyService + private _os: OntologyService, + private _sortingService: SortingService ) { } ngOnInit() { @@ -179,14 +181,16 @@ export class PropertyFormComponent implements OnInit { // reset list of ontology classes this.ontologyClasses = []; response.forEach(onto => { - const ontoClasses: ClassToSelect = { - ontologyId: onto.id, - ontologyLabel: onto.label, - classes: onto.getAllClassDefinitions() - }; - this.ontologyClasses.push(ontoClasses); + const classDef = this._sortingService.keySortByAlphabetical(onto.getAllClassDefinitions(), 'label'); + if (classDef.length) { + const ontoClasses: ClassToSelect = { + ontologyId: onto.id, + ontologyLabel: onto.label, + classes: classDef + }; + this.ontologyClasses.push(ontoClasses); + } }); - } ); diff --git a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html index 005ebc614e..6c1a9a8f39 100644 --- a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html +++ b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html @@ -79,7 +79,7 @@ -
+