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 {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";
|
||||||
|
|
||||||
addEventListener("load", (event) => {
|
addEventListener("load", (event) => {
|
||||||
dropdown()
|
dropdown()
|
||||||
colorPicker()
|
colorPicker()
|
||||||
sortReferences()
|
sortReferences()
|
||||||
recordDialog()
|
recordDialog()
|
||||||
|
createRecordEntry()
|
||||||
});
|
});
|
||||||
|
|
||||||
Mustache.escape = function (value) {
|
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";
|
import axios from "axios";
|
||||||
|
|
||||||
export function recordDialog() {
|
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 => {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||||
<title>@yield('title') - Lucent Data Platform</title>
|
<title>{{$title}} - Lucent Data Platform</title>
|
||||||
@if(config("lucent.env") == "production")
|
@if(config("lucent.env") == "production")
|
||||||
<!-- if production -->
|
<!-- if production -->
|
||||||
<link rel="stylesheet" href="/vendor/lucent/dist/{{ $manifest['main.js']["css"][0] }}"/>
|
<link rel="stylesheet" href="/vendor/lucent/dist/{{ $manifest['main.js']["css"][0] }}"/>
|
||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
@yield('content')
|
@yield('content')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,11 @@
|
|||||||
<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">
|
||||||
@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
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
@php
|
@php
|
||||||
$references = $graph->edges
|
// $references = $graph->edges
|
||||||
->filter(fn($edge) => $edge->field === $field->name && $edge->source === $record->id)
|
// ->filter(fn($edge) => $edge->field === $field->name && $edge->source === $record->id)
|
||||||
->map(fn($edge) => $graph->records->firstWhere("id", $edge->target));
|
// ->map(fn($edge) => $graph->records->firstWhere("id", $edge->target));
|
||||||
|
//
|
||||||
|
$references = collect([]);
|
||||||
|
|
||||||
$collectionSchemas = $schemas->whereIn("name",$field->collections);
|
$collectionSchemas = $schemas->whereIn("name",$field->collections);
|
||||||
@endphp
|
@endphp
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
@else
|
@else
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
name="{{$field->name}}"
|
||||||
id="{{$id}}"
|
id="{{$id}}"
|
||||||
value="{{$value}}"
|
value="{{$value}}"
|
||||||
class="form-control {{!empty($errorMessage) ? "is-invalid" : "" }}"
|
class="form-control {{!empty($errorMessage) ? "is-invalid" : "" }}"
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@if($createMode)
|
@if($createMode)
|
||||||
<button
|
<button
|
||||||
|
id="record-create-button"
|
||||||
class="button primary btn-spinner"
|
class="button primary btn-spinner"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -48,6 +49,7 @@
|
|||||||
</button>
|
</button>
|
||||||
@else
|
@else
|
||||||
<button
|
<button
|
||||||
|
id="record-save-button"
|
||||||
type="button"
|
type="button"
|
||||||
class="button primary ms-2 btn btn-primary btn-spinner"
|
class="button primary ms-2 btn btn-primary btn-spinner"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
{{-- on:refresh={refresh}--}}
|
{{-- on:refresh={refresh}--}}
|
||||||
{{-- />--}}
|
{{-- />--}}
|
||||||
{{-- {/if}--}}
|
{{-- {/if}--}}
|
||||||
|
@include("lucent::records.tools")
|
||||||
@include("lucent::records.table")
|
@include("lucent::records.table")
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,5 @@
|
|||||||
|
|
||||||
@section("content")
|
@section("content")
|
||||||
@include("lucent::records.index")
|
@include("lucent::records.index")
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
<div class="toolbar">
|
||||||
|
<div class="toolbar-filters">
|
||||||
|
|
||||||
|
{{-- <SortFields--}}
|
||||||
|
{{-- {schema}--}}
|
||||||
|
{{-- {sortParam}--}}
|
||||||
|
{{-- {sortField}--}}
|
||||||
|
{{-- {systemFields}--}}
|
||||||
|
{{-- {inModal}--}}
|
||||||
|
{{-- {modalUrl}--}}
|
||||||
|
{{-- on:refresh--}}
|
||||||
|
{{-- />--}}
|
||||||
|
|
||||||
|
|
||||||
|
{{-- <FilterFields--}}
|
||||||
|
{{-- bind:schema--}}
|
||||||
|
{{-- {systemFields}--}}
|
||||||
|
{{-- {operators}--}}
|
||||||
|
{{-- {filter}--}}
|
||||||
|
{{-- {inModal}--}}
|
||||||
|
{{-- {modalUrl}--}}
|
||||||
|
{{-- on:refresh--}}
|
||||||
|
{{-- />--}}
|
||||||
|
|
||||||
|
<form method="GET">
|
||||||
|
<input type="search" name="filter[search_regex]" placeholder="Search"
|
||||||
|
class="search" required>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display:flex;align-items: center;gap:4px">
|
||||||
|
@if(get_class($schema) === \Lucent\Schema\CollectionSchema::class)
|
||||||
|
@if(!$inModal && $isWritable)
|
||||||
|
<a
|
||||||
|
href="{{lucent_url("records/new?schema=")}}{{$schema->name}}"
|
||||||
|
class="button"
|
||||||
|
>
|
||||||
|
New Record
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
@else
|
||||||
|
<div>
|
||||||
|
{{-- <Uploader {schema} on:uploadComplete={uploadComplete}/>--}}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if(!$inModal)
|
||||||
|
{{-- <Dropdown orientation="right">--}}
|
||||||
|
{{-- <div slot="button">--}}
|
||||||
|
{{-- <Icon icon="ellipsis-vertical"/>--}}
|
||||||
|
{{-- </div>--}}
|
||||||
|
{{-- {#if filter["status_in"] === "trashed"}--}}
|
||||||
|
{{-- {#if isWritable}--}}
|
||||||
|
{{-- <a--}}
|
||||||
|
{{-- class="dropdown-item"--}}
|
||||||
|
{{-- href="{channel.lucentUrl}/content/{schema.name}/emptyTrash"--}}
|
||||||
|
{{-- >--}}
|
||||||
|
{{-- Empty trash--}}
|
||||||
|
{{-- </a>--}}
|
||||||
|
{{-- {/if}--}}
|
||||||
|
{{-- {:else}--}}
|
||||||
|
|
||||||
|
{{-- <a--}}
|
||||||
|
{{-- class="dropdown-item"--}}
|
||||||
|
{{-- href={csvUrl}--}}
|
||||||
|
{{-- >Export to CSV</a--}}
|
||||||
|
{{-- >--}}
|
||||||
|
{{-- <a--}}
|
||||||
|
{{-- class="dropdown-item"--}}
|
||||||
|
{{-- href="{channel.lucentUrl}/content/{schema.name}?filter[status_in]=trashed"--}}
|
||||||
|
{{-- >View trashed records</a--}}
|
||||||
|
{{-- >--}}
|
||||||
|
{{-- <a--}}
|
||||||
|
{{-- class="dropdown-item"--}}
|
||||||
|
{{-- href="{channel.lucentUrl}/content/{schema.name}?notlinked=*"--}}
|
||||||
|
{{-- >View unlinked records</a--}}
|
||||||
|
{{-- >--}}
|
||||||
|
{{-- {/if}--}}
|
||||||
|
{{-- </Dropdown>--}}
|
||||||
|
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{{--<div class="applied-filters">--}}
|
||||||
|
{{-- <AppliedFilterNotLinked--}}
|
||||||
|
{{-- {inModal}--}}
|
||||||
|
{{-- {modalUrl}--}}
|
||||||
|
{{-- on:refresh--}}
|
||||||
|
{{-- ></AppliedFilterNotLinked>--}}
|
||||||
|
{{-- {#if Object.entries(filter).length > 0}--}}
|
||||||
|
{{-- {#each Object.entries(filter) as [k, v]}--}}
|
||||||
|
{{-- <AppliedFilter--}}
|
||||||
|
{{-- {schema}--}}
|
||||||
|
{{-- {operators}--}}
|
||||||
|
{{-- key={k}--}}
|
||||||
|
{{-- value={v}--}}
|
||||||
|
{{-- {inModal}--}}
|
||||||
|
{{-- {modalUrl}--}}
|
||||||
|
{{-- {graph}--}}
|
||||||
|
{{-- on:refresh--}}
|
||||||
|
{{-- />--}}
|
||||||
|
{{-- {/each}--}}
|
||||||
|
{{-- {/if}--}}
|
||||||
|
{{--</div>--}}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,6 +82,7 @@ class RecordController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
"title" => $schema->label,
|
||||||
"schemas" => $this->channelService->channel->schemas,
|
"schemas" => $this->channelService->channel->schemas,
|
||||||
"schema" => $schema,
|
"schema" => $schema,
|
||||||
"users" => $users,
|
"users" => $users,
|
||||||
@@ -170,6 +171,16 @@ class RecordController extends Controller
|
|||||||
$recordHistory = $this->recordManager->fromSession($request->session())->getRecords();
|
$recordHistory = $this->recordManager->fromSession($request->session())->getRecords();
|
||||||
$record = $this->recordService->createEmpty($schema);
|
$record = $this->recordService->createEmpty($schema);
|
||||||
$queryRecord = QueryRecord::fromRecord($record);
|
$queryRecord = QueryRecord::fromRecord($record);
|
||||||
|
|
||||||
|
return view("lucent::records-editor.edit",[
|
||||||
|
"title"=> "New Record",
|
||||||
|
"schema" => $schema,
|
||||||
|
"record" => $queryRecord,
|
||||||
|
"recordHistory" => $recordHistory,
|
||||||
|
"createMode" => true,
|
||||||
|
"isWritable" => in_array($record->schema, $this->accountService->currentWritableSchemas())
|
||||||
|
]);
|
||||||
|
|
||||||
return $this->svelte->render(
|
return $this->svelte->render(
|
||||||
layout: "channel",
|
layout: "channel",
|
||||||
view: "recordEdit",
|
view: "recordEdit",
|
||||||
@@ -243,6 +254,7 @@ class RecordController extends Controller
|
|||||||
$recordHistory = $this->recordManager->fromSession($request->session())->push($rid)->getRecords($rid);
|
$recordHistory = $this->recordManager->fromSession($request->session())->push($rid)->getRecords($rid);
|
||||||
|
|
||||||
return view("lucent::records-editor.edit",[
|
return view("lucent::records-editor.edit",[
|
||||||
|
"title" => "Edit Record",
|
||||||
"schema" => $schema,
|
"schema" => $schema,
|
||||||
"graph" => $graph,
|
"graph" => $graph,
|
||||||
"record" => $record,
|
"record" => $record,
|
||||||
@@ -304,10 +316,10 @@ class RecordController extends Controller
|
|||||||
if ($request->input("isCreateMode")) {
|
if ($request->input("isCreateMode")) {
|
||||||
$recordId = $this->recordService->create(
|
$recordId = $this->recordService->create(
|
||||||
data: new RecordInputData(
|
data: new RecordInputData(
|
||||||
$request->input("record.schema"),
|
$request->input("schema"),
|
||||||
$recordId ?? "",
|
$recordId ?? "",
|
||||||
$request->input("record.data"),
|
$request->input("data"),
|
||||||
Status::from($request->input("record.status")),
|
Status::from($request->input("status")),
|
||||||
),
|
),
|
||||||
edges: array_map(EdgeInputData::fromArray(...), $request->input("edges") ?? [])
|
edges: array_map(EdgeInputData::fromArray(...), $request->input("edges") ?? [])
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ if (!function_exists('lucent_thumbnail')) {
|
|||||||
if (!function_exists('lucent_url')) {
|
if (!function_exists('lucent_url')) {
|
||||||
function lucent_url(string $path): string
|
function lucent_url(string $path): string
|
||||||
{
|
{
|
||||||
return rtrim(config("lucent.url") ?? "", "/")."/".trim($path, "/");
|
return rtrim(config("lucent.url") ?? "", "/")."/lucent/".trim($path, "/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user