wip create/edit
This commit is contained in:
@@ -8,12 +8,14 @@ import {dropdown} from "./components/dropdown.js";
|
||||
import {colorPicker} from "./recordEditor/colorPicker.js";
|
||||
import {sortReferences} from "./recordEditor/sortReferences.js";
|
||||
import {recordDialog} from "./recordEditor/recordDialog.js";
|
||||
import {createRecordEntry} from "./recordEditor/createRecordEntry.js";
|
||||
|
||||
addEventListener("load", (event) => {
|
||||
dropdown()
|
||||
colorPicker()
|
||||
sortReferences()
|
||||
recordDialog()
|
||||
createRecordEntry()
|
||||
});
|
||||
|
||||
Mustache.escape = function (value) {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import axios from "axios";
|
||||
|
||||
export function createRecordEntry() {
|
||||
const createButton = document.getElementById("record-create-button");
|
||||
createButton.addEventListener("click", save)
|
||||
}
|
||||
|
||||
|
||||
function save(e) {
|
||||
e.preventDefault();
|
||||
const recordForm = document.getElementById("record-form");
|
||||
let validationErrors = null;
|
||||
let errorMessage = "";
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const schemaName = urlParams.get("schema")
|
||||
console.log("SAVE: Attempt");
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import axios from "axios";
|
||||
|
||||
export function recordDialog() {
|
||||
|
||||
document.querySelectorAll("[data-open-modal]").forEach(el => {
|
||||
const schema = el.dataset.openModal
|
||||
el.addEventListener("click", e => {
|
||||
|
||||
Reference in New Issue
Block a user