wip editor
This commit is contained in:
@@ -9,6 +9,7 @@ import {colorPicker} from "./recordEditor/colorPicker.js";
|
|||||||
import {sortReferences} from "./recordEditor/sortReferences.js";
|
import {sortReferences} from "./recordEditor/sortReferences.js";
|
||||||
import {recordDialog} from "./recordEditor/recordDialog.js";
|
import {recordDialog} from "./recordEditor/recordDialog.js";
|
||||||
import {createRecordEntry} from "./recordEditor/createRecordEntry.js";
|
import {createRecordEntry} from "./recordEditor/createRecordEntry.js";
|
||||||
|
import {editRecordEntry} from "./recordEditor/editRecordEntry.js";
|
||||||
|
|
||||||
addEventListener("load", (event) => {
|
addEventListener("load", (event) => {
|
||||||
dropdown()
|
dropdown()
|
||||||
@@ -16,6 +17,7 @@ addEventListener("load", (event) => {
|
|||||||
sortReferences()
|
sortReferences()
|
||||||
recordDialog()
|
recordDialog()
|
||||||
createRecordEntry()
|
createRecordEntry()
|
||||||
|
editRecordEntry()
|
||||||
});
|
});
|
||||||
|
|
||||||
Mustache.escape = function (value) {
|
Mustache.escape = function (value) {
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import axios from "axios";
|
|||||||
|
|
||||||
export function createRecordEntry() {
|
export function createRecordEntry() {
|
||||||
const createButton = document.getElementById("record-create-button");
|
const createButton = document.getElementById("record-create-button");
|
||||||
|
if(!createButton){
|
||||||
|
return;
|
||||||
|
}
|
||||||
createButton.addEventListener("click", save)
|
createButton.addEventListener("click", save)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +30,8 @@ function save(e) {
|
|||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
console.log("SAVE: SAVED");
|
console.log("SAVE: SAVED");
|
||||||
window.location.href = "/lucent/records/" + record.id;
|
window.location = "/lucent/recordss/" + record.id;
|
||||||
|
return;
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (!error?.response) {
|
if (!error?.response) {
|
||||||
@@ -41,4 +45,5 @@ function save(e) {
|
|||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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 => {
|
document.querySelectorAll("[data-open-modal]").forEach(el => {
|
||||||
const schema = el.dataset.openModal
|
const schema = el.dataset.openModal
|
||||||
el.addEventListener("click", e => {
|
el.addEventListener("click", e => {
|
||||||
|
e.preventDefault()
|
||||||
load(schema)
|
load(schema)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -38,13 +38,13 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="main-wrapper">
|
<div class="main-wrapper">
|
||||||
<div class="sidebar-content">
|
<div class="sidebar-content">
|
||||||
<Navbar schema={data.schema}/>
|
<Navbar schema={data.schema}/>
|
||||||
</div>
|
</div>
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<Header />
|
<Header/>
|
||||||
<svelte:component this={components[view]} {title} {...data}/>
|
<svelte:component this={components[view]} {title} {...data}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<div class=" mt-4" style="margin-bottom:150px;position:relative;">
|
<div class=" mt-4" style="margin-bottom:150px;position:relative;">
|
||||||
<x-lucent::tabs :schema="$schema" :createMode="$createMode"></x-lucent::tabs>
|
<x-lucent::tabs :schema="$schema" :createMode="$createMode"></x-lucent::tabs>
|
||||||
</div>
|
</div>
|
||||||
<form id="record-form">
|
<form id="record-form" data-record-id="{{$record->id}}">
|
||||||
@foreach($schema->fields as $field)
|
@foreach($schema->fields as $field)
|
||||||
@include("lucent::records-editor.fields", ["field" => $field])
|
@include("lucent::records-editor.fields", ["field" => $field])
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ class RecordController extends Controller
|
|||||||
|
|
||||||
public function save(Request $request)
|
public function save(Request $request)
|
||||||
{
|
{
|
||||||
$recordId = $request->input("record.id");
|
$recordId = $request->input("id");
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if ($request->input("isCreateMode")) {
|
if ($request->input("isCreateMode")) {
|
||||||
@@ -326,9 +326,9 @@ class RecordController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
$this->recordService->updateWithEdges(
|
$this->recordService->updateWithEdges(
|
||||||
id: $request->input("record.id"),
|
id: $request->input("id"),
|
||||||
data: $request->input("record.data"),
|
data: $request->input("data"),
|
||||||
status: Status::from($request->input("record.status")),
|
status: Status::from($request->input("status")),
|
||||||
edges: array_map(EdgeInputData::fromArray(...), $request->input("edges") ?? []),
|
edges: array_map(EdgeInputData::fromArray(...), $request->input("edges") ?? []),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -345,10 +345,15 @@ class RecordController extends Controller
|
|||||||
} catch (LucentException $th) {
|
} catch (LucentException $th) {
|
||||||
return fail($th);
|
return fail($th);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ok(toArray($newGraph));
|
return ok(toArray($newGraph));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function clone(Request $request)
|
public function clone(Request $request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user