remove person from graph when removed on admin panel

This commit is contained in:
2025-06-26 18:55:46 +02:00
parent d393959c0d
commit 8358a38f4d
2 changed files with 11 additions and 7 deletions

View File

@@ -15,13 +15,13 @@
let {
closeModal,
editProfile = () => {},
onChange = () => {},
removePersonFromGraph = () => {},
addRelationship = () => {},
createProfile = () => {},
createRelationshipAndProfile = () => {}
} = $props<{
closeModal: () => void;
onChange?: () => void;
removePersonFromGraph?: (id: any) => void;
addRelationship?: (id: number) => void;
createRelationshipAndProfile?: (id: number) => void;
editProfile?: (id: number) => void;
@@ -65,7 +65,7 @@
})
.then((response) => {
if (response.ok) {
onChange();
removePersonFromGraph(id);
managed_profiles_list.forEach((profile) => {
if (profile.id === id) {
profile.label = ['DeletedPerson'];
@@ -90,7 +90,6 @@
})
.then((response) => {
if (response.ok) {
onChange();
managed_profiles_list = managed_profiles_list.filter((profile) => profile.id !== id);
return;
} else {

View File

@@ -54,6 +54,12 @@
let clientWidth: number | undefined = $state();
let clientHeight: number | undefined = $state();
let removePersonFromGraph = (id: any) => {
nodes = nodes.filter((n) => n.data.id !== id);
edges = edges.filter((e) => e.source !== 'person' + id && e.target !== 'person' + id);
};
let delete_profile = (id: any) => {
fetch('/api/person/' + id, {
method: 'DELETE',
@@ -63,8 +69,7 @@
})
.then((response) => {
if (response.ok) {
nodes = nodes.filter((n) => n.data.id !== id);
edges = edges.filter((e) => e.source !== 'person' + id && e.target !== 'person' + id);
removePersonFromGraph(id);
} else {
alert('Error deleting person');
}
@@ -361,7 +366,7 @@
}
});
}}
onChange={() => {}}
removePersonFromGraph={removePersonFromGraph}
/>
{/if}
</SvelteFlow>