diff --git a/package-lock.json b/package-lock.json
index c5c83c362..af9eb2d82 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4,6 +4,7 @@
"requires": true,
"packages": {
"": {
+ "name": "dsp-ui-lib",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@angular/animations": "^11.2.9",
diff --git a/projects/dsp-ui/src/assets/style/_viewer.scss b/projects/dsp-ui/src/assets/style/_viewer.scss
index f387cc0b3..487cdee17 100644
--- a/projects/dsp-ui/src/assets/style/_viewer.scss
+++ b/projects/dsp-ui/src/assets/style/_viewer.scss
@@ -82,6 +82,14 @@
.button-container {
+ button.mat-button-disabled {
+
+ .mat-icon {
+ color: #aaaaaa;
+ }
+
+ }
+
button {
cursor: pointer;
border: none;
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 292a02f84..20e1483b0 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
@@ -28,7 +28,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 5f6347dd5..3db3ace8a 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
@@ -256,6 +256,7 @@ class TestDateValueComponent {
`
@@ -270,6 +271,8 @@ class TestHostDisplayValueComponent implements OnInit {
mode: 'read' | 'update' | 'create' | 'search';
+ deleteIsAllowed: boolean;
+
linkValClicked: ReadLinkValue | string = 'init'; // "init" is set because there is a test that checks that this does not emit for standoff links
// (and if it emits undefined because of a bug, we cannot check)
linkValHovered: ReadLinkValue | string = 'init'; // see comment above
@@ -280,6 +283,8 @@ class TestHostDisplayValueComponent implements OnInit {
this.readResource = res;
this.mode = 'read';
+
+ this.deleteIsAllowed = true;
});
}
@@ -1183,5 +1188,14 @@ describe('DisplayEditComponent', () => {
expect(valuesSpy.v2.values.deleteValue).toHaveBeenCalledTimes(1);
});
});
+
+ it('should disable the delete button', async () => {
+ testHostComponent.displayEditValueComponent.canDelete = false;
+
+ testHostFixture.detectChanges();
+
+ const deleteButton = await rootLoader.getHarness(MatButtonHarness.with({selector: '.delete'}));
+ expect(deleteButton.isDisabled).toBeTruthy;
+ });
});
});
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 e5887303f..c0a322be4 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
@@ -75,6 +75,8 @@ export class DisplayEditComponent implements OnInit {
@Input() configuration?: object;
+ @Input() canDelete: boolean;
+
@Output() referredResourceClicked: EventEmitter = new EventEmitter();
@Output() referredResourceHovered: EventEmitter = new EventEmitter();
diff --git a/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.html b/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.html
index ebdc0abca..e62c6675b 100644
--- a/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.html
+++ b/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.html
@@ -25,6 +25,7 @@
[parentResource]="parentResource"
[displayValue]="val"
[propArray]="propArray"
+ [canDelete]="deleteValueIsAllowed(prop)"
(referredResourceClicked)="referredResourceClicked.emit($event)"
(referredResourceHovered)="referredResourceHovered.emit($event)">
diff --git a/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.spec.ts b/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.spec.ts
index 5d9aa9dbd..4fd347fba 100644
--- a/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.spec.ts
+++ b/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.spec.ts
@@ -113,6 +113,7 @@ class TestDisplayValueComponent {
@Input() displayValue: ReadValue;
@Input() propArray: PropertyInfoValues[];
@Input() configuration?: object;
+ @Input() canDelete: boolean;
@Output() referredResourceClicked: EventEmitter = new EventEmitter();
@Output() referredResourceHovered: EventEmitter = new EventEmitter();
diff --git a/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.ts b/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.ts
index 7fad61df6..36ab95993 100644
--- a/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.ts
+++ b/projects/dsp-ui/src/lib/viewer/views/property-view/property-view.component.ts
@@ -131,4 +131,16 @@ export class PropertyViewComponent implements OnInit, OnDestroy {
// user has write permissions
return isAllowed && this.propID !== prop.propDef.id && this.addButtonIsVisible;
}
+
+ /**
+ * Given a resource property, check if its cardinality allows a value to be deleted
+ *
+ * @param prop the resource property
+ */
+ deleteValueIsAllowed(prop: PropertyInfoValues): boolean {
+ const isAllowed = CardinalityUtil.deleteValueForPropertyAllowed(
+ prop.propDef.id, prop.values.length, this.parentResource.entityInfo.classes[this.parentResource.type]);
+
+ return isAllowed;
+ }
}