mirror of
https://github.com/vcscsvcscs/GenerationsHeritage.git
synced 2025-08-12 13:59:08 +02:00
remove person from graph when removed on admin panel
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user