diff --git a/projects/dsp-ui/src/lib/viewer/operations/add-value/add-value.component.html b/projects/dsp-ui/src/lib/viewer/operations/add-value/add-value.component.html
index 38c6e253a..29151c4c7 100644
--- a/projects/dsp-ui/src/lib/viewer/operations/add-value/add-value.component.html
+++ b/projects/dsp-ui/src/lib/viewer/operations/add-value/add-value.component.html
@@ -3,6 +3,7 @@
+
diff --git a/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.html b/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.html
index d17e0fba9..40bd991cf 100644
--- a/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.html
+++ b/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.html
@@ -7,6 +7,7 @@
+
diff --git a/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.spec.ts b/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.spec.ts
index 0416efcae..61a8f56ba 100644
--- a/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.spec.ts
+++ b/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.spec.ts
@@ -513,7 +513,7 @@ describe('DisplayEditComponent', () => {
it('should return the type of a integer value as not readonly', () => {
expect(valueTypeService.getValueTypeOrClass(testHostComponent.displayEditValueComponent.displayValue)).toEqual(Constants.IntValue);
- expect(valueTypeService.isReadOnly(Constants.IntValue)).toBe(false);
+ expect(valueTypeService.isReadOnly(Constants.IntValue, testHostComponent.displayEditValueComponent.displayValue)).toBe(false);
});
it('should return the class of a html text value as readonly', () => {
@@ -523,18 +523,7 @@ describe('DisplayEditComponent', () => {
expect(valueTypeService.getValueTypeOrClass(htmlTextVal)).toEqual('ReadTextValueAsHtml');
- expect(valueTypeService.isReadOnly('ReadTextValueAsHtml')).toBe(true);
-
- });
-
- it('should return the class of an XML text value as readonly', () => {
-
- const xmlTextVal = new ReadTextValueAsXml();
- xmlTextVal.type = Constants.TextValue;
-
- expect(valueTypeService.getValueTypeOrClass(xmlTextVal)).toEqual('ReadTextValueAsXml');
-
- expect(valueTypeService.isReadOnly('ReadTextValueAsXml')).toBe(true);
+ expect(valueTypeService.isReadOnly('ReadTextValueAsHtml', htmlTextVal)).toBe(true);
});
@@ -545,7 +534,7 @@ describe('DisplayEditComponent', () => {
expect(valueTypeService.getValueTypeOrClass(plainTextVal)).toEqual('ReadTextValueAsString');
- expect(valueTypeService.isReadOnly('ReadTextValueAsString')).toBe(false);
+ expect(valueTypeService.isReadOnly('ReadTextValueAsString', plainTextVal)).toBe(false);
});
diff --git a/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.ts b/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.ts
index ccb42cd2d..19355f726 100644
--- a/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.ts
+++ b/projects/dsp-ui/src/lib/viewer/operations/display-edit/display-edit.component.ts
@@ -126,7 +126,7 @@ export class DisplayEditComponent implements OnInit {
this.valueTypeOrClass = this._valueTypeService.getValueTypeOrClass(this.displayValue);
- this.readOnlyValue = this._valueTypeService.isReadOnly(this.valueTypeOrClass);
+ this.readOnlyValue = this._valueTypeService.isReadOnly(this.valueTypeOrClass, this.displayValue);
this._dspApiConnection.admin.usersEndpoint.getUserByIri(this.displayValue.attachedToUser).subscribe(
(response: ApiResponseData) => {
diff --git a/projects/dsp-ui/src/lib/viewer/services/value-type.service.spec.ts b/projects/dsp-ui/src/lib/viewer/services/value-type.service.spec.ts
index 0747d1fa9..2e5913d5d 100644
--- a/projects/dsp-ui/src/lib/viewer/services/value-type.service.spec.ts
+++ b/projects/dsp-ui/src/lib/viewer/services/value-type.service.spec.ts
@@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing';
-import { ReadIntValue, ReadTextValueAsHtml, ReadTextValueAsString } from '@dasch-swiss/dsp-js';
+import { ReadIntValue, ReadTextValueAsHtml, ReadTextValueAsString, ReadTextValueAsXml } from '@dasch-swiss/dsp-js';
import { ValueTypeService } from './value-type.service';
describe('ValueTypeService', () => {
@@ -36,14 +36,30 @@ describe('ValueTypeService', () => {
const readTextValueAsString = new ReadTextValueAsString();
readTextValueAsString.type = 'http://api.knora.org/ontology/knora-api/v2#TextValue';
const valueClass = service.getValueTypeOrClass(readTextValueAsString);
- expect(service.isReadOnly(valueClass)).toBeFalsy();
+ expect(service.isReadOnly(valueClass, readTextValueAsString)).toBeFalsy();
});
it('should mark ReadTextValueAsHtml as ReadOnly', () => {
const readTextValueAsHtml = new ReadTextValueAsHtml();
readTextValueAsHtml.type = 'http://api.knora.org/ontology/knora-api/v2#TextValue';
const valueClass = service.getValueTypeOrClass(readTextValueAsHtml);
- expect(service.isReadOnly(valueClass)).toBeTruthy();
+ expect(service.isReadOnly(valueClass, readTextValueAsHtml)).toBeTruthy();
+ });
+
+ it('should not mark ReadTextValueAsXml with standard mapping as ReadOnly', () => {
+ const readTextValueAsXml = new ReadTextValueAsXml();
+ readTextValueAsXml.type = 'http://api.knora.org/ontology/knora-api/v2#TextValue';
+ readTextValueAsXml.mapping = 'http://rdfh.ch/standoff/mappings/StandardMapping';
+ const valueClass = service.getValueTypeOrClass(readTextValueAsXml);
+ expect(service.isReadOnly(valueClass, readTextValueAsXml)).toBeFalsy();
+ });
+
+ it('should mark ReadTextValueAsXml with custom mapping as ReadOnly', () => {
+ const readTextValueAsXml = new ReadTextValueAsXml();
+ readTextValueAsXml.type = 'http://api.knora.org/ontology/knora-api/v2#TextValue';
+ readTextValueAsXml.mapping = 'http://rdfh.ch/standoff/mappings/CustomMapping';
+ const valueClass = service.getValueTypeOrClass(readTextValueAsXml);
+ expect(service.isReadOnly(valueClass, readTextValueAsXml)).toBeTruthy();
});
});
diff --git a/projects/dsp-ui/src/lib/viewer/services/value-type.service.ts b/projects/dsp-ui/src/lib/viewer/services/value-type.service.ts
index 83726effd..cbfd75eeb 100644
--- a/projects/dsp-ui/src/lib/viewer/services/value-type.service.ts
+++ b/projects/dsp-ui/src/lib/viewer/services/value-type.service.ts
@@ -56,7 +56,7 @@ export class ValueTypeService {
if (resourcePropDef.guiElement === 'http://api.knora.org/ontology/salsah-gui/v2#SimpleText') {
return this._readTextValueAsString;
} else if (resourcePropDef.guiElement === 'http://api.knora.org/ontology/salsah-gui/v2#Richtext') {
- return this._readTextValueAsHtml;
+ return this._readTextValueAsXml;
} else {
throw new Error(`unknown TextValue class ${resourcePropDef}`);
}
@@ -85,10 +85,14 @@ export class ValueTypeService {
* Determines if the given value is readonly.
*
* @param valueTypeOrClass the type or class of the given value.
+ * @param value the given value.
*/
- isReadOnly(valueTypeOrClass: string): boolean {
+ isReadOnly(valueTypeOrClass: string, value: ReadValue): boolean {
+ const xmlValueNonStandardMapping
+ = valueTypeOrClass === this._readTextValueAsXml
+ && (value instanceof ReadTextValueAsXml && value.mapping !== 'http://rdfh.ch/standoff/mappings/StandardMapping');
+
return valueTypeOrClass === this._readTextValueAsHtml ||
- valueTypeOrClass === this._readTextValueAsXml ||
- valueTypeOrClass === this.constants.GeomValue;
+ valueTypeOrClass === this.constants.GeomValue || xmlValueNonStandardMapping;
}
}
diff --git a/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.html b/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.html
index 5b47a4258..0155db956 100644
--- a/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.html
+++ b/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.html
@@ -1,18 +1,30 @@
-
-
-
-
-
-
-
- No mapping or apt configuration was provided for "xmlTransform" in the app's configuration object.
+
+
+
+ {{displayValue?.xml}}
+
+ {{commentFormControl.value}}
+
+
+
+
+
+
+
+
+
+
+
+ No class was provided for CKEditor.
+
+
diff --git a/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.scss b/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.scss
index e13b5d518..7ec769410 100644
--- a/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.scss
+++ b/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.scss
@@ -5,3 +5,9 @@
::ng-deep .ck-content code {
font-family: monospace;
}
+
+.rm-value {
+ ::ng-deep p {
+ margin: 0;
+ }
+}
diff --git a/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.spec.ts b/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.spec.ts
index 52b14e8ec..b259a254d 100644
--- a/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.spec.ts
+++ b/projects/dsp-ui/src/lib/viewer/values/text-value/text-value-as-xml/text-value-as-xml.component.spec.ts
@@ -105,23 +105,6 @@ class TestHostCreateValueComponent implements OnInit {
describe('TextValueAsXMLComponent', () => {
- const appInitServiceMock = {
- config: {
- xmlTransform: {
- 'http://rdfh.ch/standoff/mappings/StandardMapping': {
- '': '',
- '': '',
- '': '',
- '': '',
- '': '',
- '': '',
- '': ''
- }
- }
- }
- };
-
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
@@ -134,9 +117,6 @@ describe('TextValueAsXMLComponent', () => {
ReactiveFormsModule,
MatInputModule,
BrowserAnimationsModule
- ],
- providers: [
- {provide: AppInitService, useValue: appInitServiceMock}
]
})
.compileComponents();
@@ -145,6 +125,12 @@ describe('TextValueAsXMLComponent', () => {
describe('display and edit a text value with xml markup', () => {
let testHostComponent: TestHostDisplayValueComponent;
let testHostFixture: ComponentFixture;
+
+ let valueComponentDe: DebugElement;
+
+ let valueReadModeDebugElement: DebugElement;
+ let valueReadModeNativeElement;
+
let ckeditorDe: DebugElement;
beforeEach(() => {
@@ -153,11 +139,17 @@ describe('TextValueAsXMLComponent', () => {
testHostFixture.detectChanges();
const hostCompDe = testHostFixture.debugElement;
+ valueComponentDe = hostCompDe.query(By.directive(TextValueAsXMLComponent));
+
+ valueReadModeDebugElement = valueComponentDe.query(By.css('.rm-value'));
+ valueReadModeNativeElement = valueReadModeDebugElement.nativeElement;
+
+ // reset before each it
+ ckeditorDe = undefined;
- ckeditorDe = hostCompDe.query(By.directive(TestCKEditorComponent));
});
- it('should display an existing value', () => {
+ it('should display an existing value for the standard mapping as formatted text', () => {
expect(testHostComponent.inputValueComponent.displayValue.xml).toEqual('\n
');
+ });
+
+ it('should display an existing value for a custom mapping as XML source code', () => {
+
+ const newXml = new ReadTextValueAsXml();
+
+ newXml.xml = '