[ui] allow for moving annotations

This commit is contained in:
Tomáš Mládek 2022-02-17 15:14:31 +01:00
parent bd24f1f01d
commit ec094f507a

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) => {