diff --git a/src/app/workspace/resource/properties/properties.component.html b/src/app/workspace/resource/properties/properties.component.html index d4ef61e983..6ce887d0ba 100644 --- a/src/app/workspace/resource/properties/properties.component.html +++ b/src/app/workspace/resource/properties/properties.component.html @@ -137,7 +137,11 @@

- diff --git a/src/app/workspace/search/advanced-search/advanced-search.component.ts b/src/app/workspace/search/advanced-search/advanced-search.component.ts index cd4ea943bf..f8a0c303e6 100644 --- a/src/app/workspace/search/advanced-search/advanced-search.component.ts +++ b/src/app/workspace/search/advanced-search/advanced-search.component.ts @@ -10,7 +10,7 @@ import { ViewChild } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; -import { ApiResponseError, Constants, KnoraApiConnection, OntologiesMetadata } from '@dasch-swiss/dsp-js'; +import { ApiResponseError, Constants, KnoraApiConnection, OntologiesMetadata, OntologyMetadata } from '@dasch-swiss/dsp-js'; import { Subscription } from 'rxjs'; import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; import { NotificationService } from 'src/app/main/services/notification.service'; @@ -100,6 +100,9 @@ export class AdvancedSearchComponent implements OnInit, OnDestroy, AfterViewChec response.ontologies = response.ontologies.filter(onto => onto.attachedToProject !== Constants.SystemProjectIRI); this.ontologiesMetadata = response; + + this.preSelectFirstOntology(this.ontologiesMetadata.ontologies); + }, (error: ApiResponseError) => { this._notification.openSnackBar(error); @@ -112,18 +115,28 @@ export class AdvancedSearchComponent implements OnInit, OnDestroy, AfterViewChec response.ontologies = response.ontologies.filter(onto => onto.attachedToProject !== Constants.SystemProjectIRI); this.ontologiesMetadata = response; + + this.preSelectFirstOntology(this.ontologiesMetadata.ontologies); + }, (error: ApiResponseError) => { this._notification.openSnackBar(error); this.errorMessage = error; }); } + } setActiveOntology(ontologyIri: string) { this.activeOntology = ontologyIri; } + preSelectFirstOntology(ontologies: OntologyMetadata[]) { + if (ontologies.length === 1) { + this.activeOntology = ontologies[0].id; + } + } + submit() { if (!this.formValid) { diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/resource-and-property-selection.component.html b/src/app/workspace/search/advanced-search/resource-and-property-selection/resource-and-property-selection.component.html index fd01a6227f..246891c220 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/resource-and-property-selection.component.html +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/resource-and-property-selection.component.html @@ -1,31 +1,35 @@ -
+
-
- - -
+ + -
-
+
- + + + -
-
+
-
diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/resource-and-property-selection.component.scss b/src/app/workspace/search/advanced-search/resource-and-property-selection/resource-and-property-selection.component.scss index d7bdb4c4de..f99d25607b 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/resource-and-property-selection.component.scss +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/resource-and-property-selection.component.scss @@ -1,3 +1,7 @@ +.form { + display: inherit; +} + .select-property { margin-left: 16px; @@ -5,3 +9,7 @@ margin: 0 12px 64px 0; } } + +.res-pointer-level { + margin-left: -160px; +} diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.html b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.html index b312b5cd50..c2534c643f 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.html +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.html @@ -1,12 +1,31 @@ - + +
+ + Sort criterion +
+ +
+ + {{ prop.label }} + + [property]="propertySelected" [topLevel]="topLevel"> + + + + + + - - +
diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.scss b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.scss index 98ec786bf3..d3a0b643bc 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.scss +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.scss @@ -1,3 +1,21 @@ -.search-property-field { - margin-right: 8px; +:host { + width: 100%; + + .search-property-header { + width: 100%; + display: inline-flex; + } + + .search-property-line { + display: inline-flex; + width: 100%; + + .search-property-field { + margin-right: 8px; + } + + .sort-criterion-toggle { + margin: 16px 16px 0 0; + } + } } diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.spec.ts b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.spec.ts index f2d8cb29a1..a9619ecd3c 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.spec.ts +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/search-select-property.component.spec.ts @@ -15,10 +15,11 @@ import { ResourcePropertyDefinition } from '@dasch-swiss/dsp-js'; import { MatSelectHarness } from '@angular/material/select/testing'; -import { MatCheckboxHarness } from '@angular/material/checkbox/testing'; +import { MatSlideToggleHarness } from '@angular/material/slide-toggle/testing'; import { MatCheckboxModule } from '@angular/material/checkbox'; import { ComparisonOperatorAndValue, Equals, ValueLiteral } from './specify-property-value/operator'; import { SearchSelectPropertyComponent } from './search-select-property.component'; +import { MatSlideToggleModule } from '@angular/material/slide-toggle'; /** * test host component to simulate parent component. @@ -89,10 +90,11 @@ describe('SearchSelectPropertyComponent', () => { TestBed.configureTestingModule({ imports: [ BrowserAnimationsModule, - ReactiveFormsModule, - MatSelectModule, + MatCheckboxModule, MatOptionModule, - MatCheckboxModule + MatSelectModule, + MatSlideToggleModule, + ReactiveFormsModule ], declarations: [ SearchSelectPropertyComponent, @@ -171,15 +173,15 @@ describe('SearchSelectPropertyComponent', () => { }); - it('should not show the sort checkbox when no property is selected', async () => { + it('should not show the sort slide-toggle when no property is selected', async () => { - const checkbox = await loader.getAllHarnesses(MatCheckboxHarness); + const slideToggle = await loader.getAllHarnesses(MatSlideToggleHarness); - expect(checkbox.length).toEqual(0); + expect(slideToggle.length).toEqual(0); }); - it('should show the sort checkbox when a property with cardinality 1 is selected for the top level resource', async () => { + it('should show the sort slide-toggle when a property with cardinality 1 is selected for the top level resource', async () => { const select = await loader.getHarness(MatSelectHarness); await select.open(); @@ -200,13 +202,13 @@ describe('SearchSelectPropertyComponent', () => { testHostFixture.detectChanges(); - const checkbox = await loader.getAllHarnesses(MatCheckboxHarness); + const slideToggle = await loader.getAllHarnesses(MatSlideToggleHarness); - expect(checkbox.length).toEqual(1); + expect(slideToggle.length).toEqual(1); }); - it('should not show the sort checkbox when a property with cardinality 1 is selected for a linked resource', async () => { + it('should not show the sort slide-toggle when a property with cardinality 1 is selected for a linked resource', async () => { testHostComponent.topLevel = false; @@ -229,9 +231,9 @@ describe('SearchSelectPropertyComponent', () => { testHostFixture.detectChanges(); - const checkbox = await loader.getAllHarnesses(MatCheckboxHarness); + const slideToggle = await loader.getAllHarnesses(MatSlideToggleHarness); - expect(checkbox.length).toEqual(0); + expect(slideToggle.length).toEqual(0); }); diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-boolean-value/search-boolean-value.component.html b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-boolean-value/search-boolean-value.component.html index 6e2b911096..4ce2d9e67c 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-boolean-value/search-boolean-value.component.html +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-boolean-value/search-boolean-value.component.html @@ -1,3 +1,3 @@ - + {{form.controls.booleanValue.value ? '' : 'not '}} checked diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-date-value/search-date-value.component.html b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-date-value/search-date-value.component.html index cde1f5cef2..4ed063c453 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-date-value/search-date-value.component.html +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-date-value/search-date-value.component.html @@ -1,12 +1,5 @@ - + - diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-decimal-value/search-decimal-value.component.html b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-decimal-value/search-decimal-value.component.html index ac04336f55..2116704ede 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-decimal-value/search-decimal-value.component.html +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-decimal-value/search-decimal-value.component.html @@ -1,5 +1,5 @@ - + diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-int-value/search-int-value.component.html b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-int-value/search-int-value.component.html index 81ca55a9c2..a6231afd15 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-int-value/search-int-value.component.html +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-int-value/search-int-value.component.html @@ -1,5 +1,5 @@ - + diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-link-value/search-link-value.component.html b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-link-value/search-link-value.component.html index ac7f59f642..578ff4a85f 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-link-value/search-link-value.component.html +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-link-value/search-link-value.component.html @@ -1,5 +1,5 @@ - + diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-text-value/search-text-value.component.html b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-text-value/search-text-value.component.html index 46111c61aa..e3467f8d29 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-text-value/search-text-value.component.html +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-text-value/search-text-value.component.html @@ -1,5 +1,5 @@ - + diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-uri-value/search-uri-value.component.html b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-uri-value/search-uri-value.component.html index 5e4ed10041..59deda5f6e 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-uri-value/search-uri-value.component.html +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-uri-value/search-uri-value.component.html @@ -1,5 +1,5 @@ - + diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/specify-property-value.component.spec.ts b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/specify-property-value.component.spec.ts index ab9687b137..ad0e093dca 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/specify-property-value.component.spec.ts +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/specify-property-value.component.spec.ts @@ -323,8 +323,8 @@ describe('SpecifyPropertyValueComponent', () => { const select = await loader.getHarness(MatSelectHarness); const initVal = await select.getValueText(); - // placeholder - expect(initVal).toEqual('Comparison Operator'); + // placeholder in case of only one operator: + expect(initVal).toEqual('is equal to'); await select.open(); @@ -334,9 +334,9 @@ describe('SpecifyPropertyValueComponent', () => { }); - it('should set the form to valid when an comparison operator has been chosen', async () => { + it('should set the form to valid when a comparison operator has been chosen', async () => { - expect(testHostComponent.specifyProperty.form.valid).toBe(false); + expect(testHostComponent.specifyProperty.form.valid).toBe(true); const select = await loader.getHarness(MatSelectHarness); diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/specify-property-value.component.ts b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/specify-property-value.component.ts index 78a96d2040..75dc8d5261 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/specify-property-value.component.ts +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/specify-property-value.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, Input, OnChanges, OnDestroy, ViewChild } from '@angular/core'; +import { AfterViewChecked, AfterViewInit, Component, Inject, Input, OnChanges, OnDestroy, ViewChild } from '@angular/core'; import { Constants, ResourcePropertyDefinition } from '@dasch-swiss/dsp-js'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { @@ -95,8 +95,10 @@ export class SpecifyPropertyValueComponent implements OnChanges, OnDestroy { this.formGroup.addControl('comparisonOperator', this.form); }); + this.form.controls.comparisonOperator.setValue(this.comparisonOperators[0]); } + ngOnDestroy() { this._closeComparisonOperatorChangesSubscription(); } @@ -120,6 +122,9 @@ export class SpecifyPropertyValueComponent implements OnChanges, OnDestroy { break; case Constants.BooleanValue: + this.comparisonOperators = [new Equals()]; + break; + case Constants.UriValue: this.comparisonOperators = [new Equals(), new NotEquals(), new Exists()]; break; @@ -152,7 +157,7 @@ export class SpecifyPropertyValueComponent implements OnChanges, OnDestroy { break; default: - console.log('ERROR: Unsupported value type ' + this._property.objectType); + console.error('Advanced search: Unsupported value type ' + this._property.objectType); } diff --git a/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.html b/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.html index 78e6249093..cf38d5664a 100644 --- a/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.html +++ b/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.html @@ -1,6 +1,6 @@ - + {{ onto.label }} diff --git a/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.spec.ts b/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.spec.ts index 289b1d858e..c8d6c34e8a 100644 --- a/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.spec.ts +++ b/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.spec.ts @@ -96,7 +96,7 @@ describe('SearchSelectOntologyComponent', () => { const initVal = await select.getValueText(); // placeholder - expect(initVal).toEqual('Select an Ontology'); + expect(initVal).toEqual('Select a data model'); await select.open(); diff --git a/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.ts b/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.ts index edc608255d..612a923ccc 100644 --- a/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.ts +++ b/src/app/workspace/search/advanced-search/search-select-ontology/search-select-ontology.component.ts @@ -38,6 +38,13 @@ export class SearchSelectOntologyComponent implements OnInit, OnDestroy { // add form to the parent form group this.formGroup.addControl('ontologies', this.form); + + // if only one ontology exists: select this ontology by default + if (this.ontologiesMetadata.ontologies.length === 1) { + this.form.controls.ontologies.setValue(this.ontologiesMetadata.ontologies[0].id); + // this.ontologySelected.emit(this.ontologiesMetadata.ontologies[0].id); + } + } ngOnDestroy() { diff --git a/src/app/workspace/search/expert-search/expert-search.component.html b/src/app/workspace/search/expert-search/expert-search.component.html index c6452da93c..3551edea6d 100644 --- a/src/app/workspace/search/expert-search/expert-search.component.html +++ b/src/app/workspace/search/expert-search/expert-search.component.html @@ -1,5 +1,5 @@
- +