[ui] allow for moving annotations

feat/vaults
Tomáš Mládek 2022-02-17 15:14:31 +01:00
parent bd24f1f01d
commit ec094f507a
1 changed files with 17 additions and 7 deletions

View File

@ -144,15 +144,25 @@
anno.on("updateAnnotation", async (annotation) => {
const annotationObject = await fetchEntity(annotation.id);
await Promise.all(
annotationObject.attr["LBL"].map(async (e) => {
fetch(`api/obj/${e.address}`, { method: "DELETE" });
})
annotationObject.attr["LBL"]
.concat(annotationObject.attr["W3C_FRAGMENT_SELECTOR"])
.map(async (e) => {
fetch(`api/obj/${e.address}`, { method: "DELETE" });
})
);
await fetch("api/obj", {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(
annotation.body.map((body) => {
body: JSON.stringify([
{
entity: annotation.id,
attribute: "W3C_FRAGMENT_SELECTOR",
value: {
t: "String",
c: annotation.target.selector.value,
},
},
...annotation.body.map((body) => {
return {
entity: annotation.id,
attribute: "LBL",
@ -161,8 +171,8 @@
c: body.value,
},
};
})
),
}),
]),
});
});
anno.on("deleteAnnotation", async (annotation) => {