diff --git a/src/app/components/data-page/data-page.component.ts b/src/app/components/data-page/data-page.component.ts
index ab6b273..618e1a0 100644
--- a/src/app/components/data-page/data-page.component.ts
+++ b/src/app/components/data-page/data-page.component.ts
@@ -197,6 +197,13 @@ export class DataPageComponent implements OnInit, OnDestroy {
this.data[object.propertyPrefixToOverwrite + '.' + newProperty] =
newObjectFlattened[newProperty];
}
+ } else if (selectedObject === null) {
+ this.data[object.propertyNameOfReferenceId] = null;
+ for (const prop in this.data) {
+ if (prop.startsWith(object.propertyPrefixToOverwrite)) {
+ this.data[prop] = null;
+ }
+ }
}
});
}
diff --git a/src/app/components/select-object-dialog/select-object-dialog.component.html b/src/app/components/select-object-dialog/select-object-dialog.component.html
index 13a2084..590ca8b 100644
--- a/src/app/components/select-object-dialog/select-object-dialog.component.html
+++ b/src/app/components/select-object-dialog/select-object-dialog.component.html
@@ -10,7 +10,19 @@
(selectedElementChange)="onObjectClicked($event)"
>
- aktuell ausgewählt: {{getSelectedObjectName()}}
+ aktuell ausgewählt: {{ getSelectedObjectName() }}
+
diff --git a/src/app/components/select-object-dialog/select-object-dialog.component.ts b/src/app/components/select-object-dialog/select-object-dialog.component.ts
index b7b9bee..b2db5ad 100644
--- a/src/app/components/select-object-dialog/select-object-dialog.component.ts
+++ b/src/app/components/select-object-dialog/select-object-dialog.component.ts
@@ -15,10 +15,13 @@ export class SelectObjectDialogComponent implements OnInit {
ngOnInit(): void {}
onObjectClicked(object: any) {
- this.data.currentlySelectedObjectId = object.id;
+ this.data.currentlySelectedObjectId = object?.id || null;
}
getSelectedObject() {
+ if (this.data.currentlySelectedObjectId === null) {
+ return null;
+ }
return this.data.possibleObjects.find(
(object) => object.id === this.data.currentlySelectedObjectId
);
diff --git a/src/app/components/table/table.component.ts b/src/app/components/table/table.component.ts
index 12a0ddf..7da38a1 100644
--- a/src/app/components/table/table.component.ts
+++ b/src/app/components/table/table.component.ts
@@ -357,15 +357,22 @@ export class TableComponent implements AfterViewInit {
},
});
dialogRef.afterClosed().subscribe((selectedObject) => {
+ console.log(selectedObject);
if (selectedObject) {
row[column.propertyNameOfReferenceId] = selectedObject.id;
- //row[column.dataPath] = column.valueToOverwriteDataPath(selectedObject);
- }
- const newObjectFlattened = flatten(selectedObject);
+ const newObjectFlattened = flatten(selectedObject);
for (const newProperty in newObjectFlattened) {
row[column.propertyPrefixToOverwrite + '.' + newProperty] =
newObjectFlattened[newProperty];
}
+ } else if (selectedObject === null) {
+ row[column.propertyNameOfReferenceId] = null;
+ for (const prop in row) {
+ if (prop.startsWith(column.propertyPrefixToOverwrite)) {
+ row[prop] = null;
+ }
+ }
+ }
});
}