diff --git a/src/app/workspace/resource/resource-instance-form/select-properties/select-properties.component.scss b/src/app/workspace/resource/resource-instance-form/select-properties/select-properties.component.scss
index 5dc2df2458..f54c0aefd1 100644
--- a/src/app/workspace/resource/resource-instance-form/select-properties/select-properties.component.scss
+++ b/src/app/workspace/resource/resource-instance-form/select-properties/select-properties.component.scss
@@ -15,90 +15,38 @@
gap: 16px;
.properties {
- // grid-column: 1 / span 6;
- margin-top: 16px;
+ grid-column: 1 / span 6;
- .border-bottom {
- width: 650px;
- }
-
- .property {
- grid-row: 1 / 1;
- display: grid;
- grid-template-columns: repeat(4, 1fr);
- gap: 16px;
- margin-top: 16px;
-
- .property-label,
- .property-value {
- padding: 2px;
- overflow-wrap: break-word;
- }
-
- .property-label {
- grid-column: 1 / span 1;
-
- .label {
- text-align: right;
- display: block;
- float: left;
- width: 95%;
- }
-
- .label-info {
- cursor: help;
- }
+ .property {
+ grid-row: 1 / 1;
- .propIsRequired {
- color: red;
- display: block;
- float: right;
- width: 5%;
- }
- }
+ display: grid;
+ grid-template-columns: repeat(4, 1fr);
+ gap: 16px;
- .property-value {
- grid-column: 2 / span 3;
-
- // .value {
- // width: 90%;
- // vertical-align: top;
- // }
-
- .buttons {
- // width: 9%;
- // vertical-align: middle;
+ .property-label,
+ .property-value {
+ padding: 2px;
+ overflow-wrap: break-word;
+ }
- button {
- cursor: pointer;
- border: none;
- outline: none;
- background-color: transparent;
- color: #000000;
+ .property-label {
+ grid-column: 1 / span 1;
- .material-icons {
- font-size: 18px;
- }
+ .label {
+ text-align: right;
+ margin-top: 16px;;
+ }
- .mat-icon {
- width: 18px;
- height: 18px;
- vertical-align: middle;
- }
- }
- }
+ .label-info {
+ cursor: help;
+ }
+ }
- // .value,
- // .buttons {
- // display: inline-block;
- // }
- }
+ .property-value {
+ grid-column: 2 / span 3;
+ margin-bottom: 0; // overwrite global value in this case
}
+ }
}
}
-
-// TODO: maybe find a better way to do this
-// ::ng-deep .form-content .large-field {
-// min-width: 0;
-// }
-
diff --git a/src/app/workspace/resource/resource-instance-form/select-properties/select-properties.component.ts b/src/app/workspace/resource/resource-instance-form/select-properties/select-properties.component.ts
index e6b95b792b..f2a3263744 100644
--- a/src/app/workspace/resource/resource-instance-form/select-properties/select-properties.component.ts
+++ b/src/app/workspace/resource/resource-instance-form/select-properties/select-properties.component.ts
@@ -1,4 +1,4 @@
-import { Component, Input, OnInit, QueryList, ViewChildren } from '@angular/core';
+import { Component, Input, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
import { FormGroup } from '@angular/forms';
import {
Cardinality,
@@ -9,7 +9,8 @@ import {
ResourceClassDefinition,
ResourcePropertyDefinition
} from '@dasch-swiss/dsp-js';
-import { ValueService } from '@dasch-swiss/dsp-ui';
+import { BaseValueDirective } from 'src/app/main/directive/base-value.directive';
+import { ValueService } from '../../services/value.service';
import { SwitchPropertiesComponent } from './switch-properties/switch-properties.component';
@Component({
@@ -21,6 +22,8 @@ export class SelectPropertiesComponent implements OnInit {
@ViewChildren('switchProp') switchPropertiesComponent: QueryList;
+ @ViewChild('createVal') createValueComponent: BaseValueDirective;
+
@Input() properties: ResourcePropertyDefinition[];
@Input() ontologyInfo: ResourceClassAndPropertyDefinitions;
@@ -67,7 +70,6 @@ export class SelectPropertiesComponent implements OnInit {
this.parentResource.entityInfo = this.ontologyInfo;
}
-
/**
* given a resource property, check if an add button should be displayed under the property values
*
diff --git a/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.html b/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.html
index 46b253b7af..7d416b0d29 100644
--- a/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.html
+++ b/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.html
@@ -12,14 +12,4 @@
A resource must be selected.
-
- Resource label *
-
-
- Your label must contain and start with at least one character or one number. Cannot start or end with a space.
-
-
- A resource label is required.
-
-
diff --git a/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.spec.ts b/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.spec.ts
index b8cacd0600..bcf563df08 100644
--- a/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.spec.ts
+++ b/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.spec.ts
@@ -1,17 +1,15 @@
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { Component, Inject, OnInit, ViewChild } from '@angular/core';
-import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { MatSelectHarness } from '@angular/material/select/testing';
-import { MatInputHarness } from '@angular/material/input/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MockOntology, ResourceClassDefinition } from '@dasch-swiss/dsp-js';
import { SelectResourceClassComponent } from './select-resource-class.component';
-import { By } from '@angular/platform-browser';
/**
* test host component to simulate parent component.
@@ -22,8 +20,7 @@ import { By } from '@angular/platform-browser';
#selectResource
[formGroup]="form"
[resourceClassDefinitions]="resourceClasses"
- (resourceClassSelected)="selectResourceClass($event)"
- (resourceLabel)="getResourceLabel($event)">
+ (resourceClassSelected)="selectResourceClass($event)">
`
})
class TestHostComponent implements OnInit {
@@ -33,7 +30,6 @@ class TestHostComponent implements OnInit {
form: FormGroup;
resourceClasses: ResourceClassDefinition[];
selectedResourceIri: string;
- resLabel: string;
constructor(@Inject(FormBuilder) private _fb: FormBuilder) {
}
@@ -54,9 +50,6 @@ class TestHostComponent implements OnInit {
this.selectedResourceIri = resourceClassIri;
}
- getResourceLabel(label: string) {
- this.resLabel = label;
- }
}
describe('SelectResourceClassComponent', () => {
@@ -130,21 +123,6 @@ describe('SelectResourceClassComponent', () => {
});
- it('should fill in the label correctly', () => {
-
- const labelInput = testHostFixture.debugElement.query(By.css('input.label'));
-
- const el = labelInput.nativeElement;
-
- expect(el.value).toEqual('');
-
- el.value = 'resource label';
-
- testHostFixture.detectChanges();
-
- expect(el.value).toEqual('resource label');
- });
-
it('should emit the Iri of a selected resource class', async () => {
expect(testHostComponent.selectedResourceIri).toBeUndefined();
@@ -163,18 +141,6 @@ describe('SelectResourceClassComponent', () => {
});
- it('should emit the label of the resource class', async () => {
-
- const inputElement = await loader.getHarness(MatInputHarness.with({ selector: 'input.label' }));
-
- expect(await inputElement.getValue()).toEqual('');
- expect(testHostComponent.resLabel).toBeUndefined();
-
- await inputElement.setValue('resource label');
-
- expect(testHostComponent.resLabel).toEqual('resource label');
- });
-
it('should unsubscribe from from changes on destruction', () => {
expect(testHostComponent.selectResource.resourceChangesSubscription.closed).toBe(false);
diff --git a/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.ts b/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.ts
index 178b1405b9..2d284c3074 100644
--- a/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.ts
+++ b/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.ts
@@ -29,22 +29,16 @@ export class SelectResourceClassComponent implements OnInit, OnDestroy, AfterVie
@Input() selectedResourceClass?: ResourceClassDefinition;
// optional input to provide the component with a pre-chosen label
- @Input() chosenResourceLabel?: string;
+ // @Input() chosenResourceLabel?: string;
@Output() resourceClassSelected = new EventEmitter();
- @Output() resourceLabel = new EventEmitter();
-
- label: string;
-
form: FormGroup;
checkPattern = '^\d*[a-zA-Z0-9\u00C0-\u024F\u1E00-\u1EFF_]+( [a-zA-Z0-9\u00C0-\u024F\u1E00-\u1EFF@_.]+)*$';
resourceChangesSubscription: Subscription;
- labelChangesSubscription: Subscription;
-
constructor(@Inject(FormBuilder) private _fb: FormBuilder) {}
ngOnInit(): void {
@@ -52,7 +46,7 @@ export class SelectResourceClassComponent implements OnInit, OnDestroy, AfterVie
// build a form for the named graph selection
this.form = this._fb.group({
resources: [null, Validators.required],
- label: [null, [Validators.required, Validators.pattern(this.checkPattern)]]
+ // label: [null, [Validators.required, Validators.pattern(this.checkPattern)]]
});
// emit Iri of the resource when selected
@@ -62,13 +56,6 @@ export class SelectResourceClassComponent implements OnInit, OnDestroy, AfterVie
this.formGroup.addControl('resources', this.form);
});
- // emit label of the resource any time it is changed
- this.labelChangesSubscription = this.form.controls.label.valueChanges.subscribe((data) => {
- this.resourceLabel.emit(data);
- this.formGroup.removeControl('resources');
- this.formGroup.addControl('resources', this.form);
- });
-
resolvedPromise.then(() => {
// add form to the parent form group
this.formGroup.addControl('resources', this.form);
@@ -79,11 +66,6 @@ export class SelectResourceClassComponent implements OnInit, OnDestroy, AfterVie
this.form.controls.resources.setValue(this.selectedResourceClass.id);
}
- // check if there is a pre-chosen label, if so, set the value of the form control to this value
- if (this.chosenResourceLabel) {
- this.form.controls.label.setValue(this.chosenResourceLabel);
- }
-
}
@@ -101,9 +83,6 @@ export class SelectResourceClassComponent implements OnInit, OnDestroy, AfterVie
this.resourceChangesSubscription.unsubscribe();
}
- if (this.labelChangesSubscription !== undefined) {
- this.labelChangesSubscription.unsubscribe();
- }
}
}
diff --git a/src/app/workspace/resource/services/value-operation-event.service.ts b/src/app/workspace/resource/services/value-operation-event.service.ts
index ba1252653e..84da15c77d 100644
--- a/src/app/workspace/resource/services/value-operation-event.service.ts
+++ b/src/app/workspace/resource/services/value-operation-event.service.ts
@@ -10,7 +10,9 @@ import { filter, map } from 'rxjs/operators';
* The ValueOperationEventService essentially creates a direct communication channel between
* the emitting component and the listening component.
*/
-@Injectable() // must be provided on component level, i.e. resource view component.
+@Injectable({
+ providedIn: 'root'
+}) // must be provided on component level, i.e. resource view component.
export class ValueOperationEventService {
// create a subject to hold data which can be subscribed to.
diff --git a/src/app/workspace/resource/values/text-value/text-value-as-string/text-value-as-string.component.html b/src/app/workspace/resource/values/text-value/text-value-as-string/text-value-as-string.component.html
index efb8c7100e..ba7cd75e2a 100644
--- a/src/app/workspace/resource/values/text-value/text-value-as-string/text-value-as-string.component.html
+++ b/src/app/workspace/resource/values/text-value/text-value-as-string/text-value-as-string.component.html
@@ -17,7 +17,7 @@
This value already exists for this property. Duplicate values are not allowed.
-