wip editor
This commit is contained in:
@@ -2,6 +2,9 @@ import axios from "axios";
|
||||
|
||||
export function createRecordEntry() {
|
||||
const createButton = document.getElementById("record-create-button");
|
||||
if(!createButton){
|
||||
return;
|
||||
}
|
||||
createButton.addEventListener("click", save)
|
||||
}
|
||||
|
||||
@@ -17,28 +20,30 @@ function save(e) {
|
||||
|
||||
let formData = new FormData(recordForm)
|
||||
|
||||
axios
|
||||
.post("/lucent/records", {
|
||||
schema: schemaName,
|
||||
data: Object.fromEntries(formData),
|
||||
status: "draft",
|
||||
// edges: graph.edges,
|
||||
isCreateMode: true,
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log("SAVE: SAVED");
|
||||
window.location.href = "/lucent/records/" + record.id;
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (!error?.response) {
|
||||
}
|
||||
if (typeof error?.response.data.error === "string") {
|
||||
errorMessage = error.response.data.error;
|
||||
} else {
|
||||
validationErrors = error.response.data.error;
|
||||
console.log(validationErrors)
|
||||
}
|
||||
axios
|
||||
.post("/lucent/records", {
|
||||
schema: schemaName,
|
||||
data: Object.fromEntries(formData),
|
||||
status: "draft",
|
||||
// edges: graph.edges,
|
||||
isCreateMode: true,
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log("SAVE: SAVED");
|
||||
window.location = "/lucent/recordss/" + record.id;
|
||||
return;
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (!error?.response) {
|
||||
}
|
||||
if (typeof error?.response.data.error === "string") {
|
||||
errorMessage = error.response.data.error;
|
||||
} else {
|
||||
validationErrors = error.response.data.error;
|
||||
console.log(validationErrors)
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import axios from "axios";
|
||||
|
||||
export function editRecordEntry() {
|
||||
const saveButton = document.getElementById("record-save-button");
|
||||
if(!saveButton){
|
||||
return;
|
||||
}
|
||||
saveButton.addEventListener("click", save)
|
||||
}
|
||||
|
||||
|
||||
function save(e) {
|
||||
e.preventDefault();
|
||||
const recordForm = document.getElementById("record-form");
|
||||
// let validationErrors = null;
|
||||
// let errorMessage = "";
|
||||
console.log("SAVE: Attempt");
|
||||
//
|
||||
let formData = new FormData(recordForm)
|
||||
//
|
||||
axios
|
||||
.post("/lucent/records", {
|
||||
id: recordForm.dataset.recordId,
|
||||
data: Object.fromEntries(formData),
|
||||
status: "draft",
|
||||
// edges: graph.edges,
|
||||
isCreateMode: false,
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log("SAVE: SAVED");
|
||||
})
|
||||
.catch(function (error) {
|
||||
// if (!error?.response) {
|
||||
// }
|
||||
// if (typeof error?.response.data.error === "string") {
|
||||
// errorMessage = error.response.data.error;
|
||||
// } else {
|
||||
// validationErrors = error.response.data.error;
|
||||
// console.log(validationErrors)
|
||||
// }
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
@@ -4,6 +4,7 @@ export function recordDialog() {
|
||||
document.querySelectorAll("[data-open-modal]").forEach(el => {
|
||||
const schema = el.dataset.openModal
|
||||
el.addEventListener("click", e => {
|
||||
e.preventDefault()
|
||||
load(schema)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user