query rewrite
This commit is contained in:
@@ -3,25 +3,25 @@
|
||||
import {onDestroy, onMount} from "svelte";
|
||||
import offcanvas from "bootstrap/js/src/offcanvas.js";
|
||||
export let title = "";
|
||||
let offcanvasEl;
|
||||
let offcanvasInstance;
|
||||
let offCanvasEl;
|
||||
let offCanvasInstance;
|
||||
|
||||
export function show() {
|
||||
offcanvasInstance.show();
|
||||
if(!offCanvasInstance){
|
||||
offCanvasInstance = new offcanvas(offCanvasEl);
|
||||
}
|
||||
offCanvasInstance.show();
|
||||
}
|
||||
onMount(()=>{
|
||||
offcanvasInstance = new offcanvas(offcanvasEl);
|
||||
offCanvasInstance = new offcanvas(offCanvasEl);
|
||||
});
|
||||
|
||||
|
||||
|
||||
export function hide(e) {
|
||||
e.preventDefault();
|
||||
offcanvasInstance.hide();
|
||||
export function hide() {
|
||||
offCanvasInstance.hide();
|
||||
}
|
||||
</script>
|
||||
|
||||
<div bind:this={offcanvasEl} class="offcanvas offcanvas-end" tabindex="-1"
|
||||
<div bind:this={offCanvasEl} class="offcanvas offcanvas-end" tabindex="-1"
|
||||
aria-labelledby="offcanvasEditContent">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title">{title}</h5>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import Table from "./Table.svelte";
|
||||
import {getContext} from "svelte";
|
||||
import Grid from "./Grid.svelte";
|
||||
import Tools from "./tools/Tools.svelte";
|
||||
|
||||
const axios = getContext("axios");
|
||||
export let schema;
|
||||
@@ -53,20 +54,19 @@
|
||||
{#if selected.length > 0 && !inModal && isWritable}
|
||||
<ActionsOnSelected {schema} {selected} {filter}/>
|
||||
{:else}
|
||||
<!-- <Tools-->
|
||||
<!-- bind:schema-->
|
||||
<!-- bind:records-->
|
||||
<!-- {systemFields}-->
|
||||
<!-- {sortParam}-->
|
||||
<!-- {sortField}-->
|
||||
<!-- {operators}-->
|
||||
<!-- {filter}-->
|
||||
<!-- {graph}-->
|
||||
<!-- {inModal}-->
|
||||
<!-- {modalUrl}-->
|
||||
<!-- {isWritable}-->
|
||||
<!-- on:refresh={refresh}-->
|
||||
<!-- />-->
|
||||
<Tools
|
||||
bind:schema
|
||||
bind:records
|
||||
{systemFields}
|
||||
{sortParam}
|
||||
{sortField}
|
||||
{operators}
|
||||
{filter}
|
||||
{inModal}
|
||||
{modalUrl}
|
||||
{isWritable}
|
||||
on:refresh={refresh}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if schema.type === "collection"}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
export let value;
|
||||
export let inModal;
|
||||
export let modalUrl;
|
||||
export let graph;
|
||||
export let records
|
||||
|
||||
let filter = {
|
||||
label: "",
|
||||
@@ -51,13 +51,13 @@
|
||||
|
||||
}
|
||||
|
||||
const filterRecord = extractFilterRecord(graph, value);
|
||||
const filterRecord = extractFilterRecord(records, value);
|
||||
|
||||
function extractFilterRecord(graph, value) {
|
||||
function extractFilterRecord(records, value) {
|
||||
if (!filter.isReference) {
|
||||
return null;
|
||||
}
|
||||
return graph.records.find(r => r.id === value);
|
||||
return records.find(r => r.id === value);
|
||||
}
|
||||
|
||||
function removeFilter(k) {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
export let modalUrl;
|
||||
export let isWritable;
|
||||
export let records;
|
||||
export let graph;
|
||||
export let systemFields = [];
|
||||
// export let visibleFields = [];
|
||||
|
||||
@@ -37,7 +36,7 @@
|
||||
if (inModal) {
|
||||
dispatch("refresh", url);
|
||||
} else {
|
||||
window.location = url;
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -152,7 +151,7 @@
|
||||
value={v}
|
||||
{inModal}
|
||||
{modalUrl}
|
||||
{graph}
|
||||
{records}
|
||||
on:refresh
|
||||
/>
|
||||
{/each}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
// export let isWritable = false;
|
||||
// export let users;
|
||||
$: validationErrors = null;
|
||||
$: errorMessage = null;
|
||||
|
||||
let form;
|
||||
|
||||
@@ -90,6 +91,8 @@
|
||||
{schema}
|
||||
{record}
|
||||
{isCreateMode}
|
||||
{errorMessage}
|
||||
{validationErrors}
|
||||
on:save={save}
|
||||
/>
|
||||
<!-- <Graph {graph} {record}/>-->
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<h3 class="header-normal mt-5 mb-0">
|
||||
<h3 class="header-normal mb-0">
|
||||
<a
|
||||
class="text-muted d-block text-decoration-none fs-6 mb-1"
|
||||
href="{channel.lucentUrl}/content/{schema.name}"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
const channel = getContext("channel");
|
||||
export let record;
|
||||
export let field;
|
||||
export let edge;
|
||||
export let edge = null;
|
||||
export let editable = false;
|
||||
export let classes = "";
|
||||
export let hasDelete = false;
|
||||
@@ -51,7 +51,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<EdgeData bind:this={edgeData} {field} {edge}/>
|
||||
<EdgeData bind:this={edgeData} {record} {field} bind:edge/>
|
||||
{/if}
|
||||
|
||||
<div
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { deepEqual } from 'fast-equals';
|
||||
export function isEqual(obj1, obj2) {
|
||||
|
||||
return deepEqual(obj1, obj2);
|
||||
// if (obj1 === obj2) return true;
|
||||
//
|
||||
|
||||
@@ -7,14 +7,12 @@
|
||||
import ReferenceField from "./ReferenceField.svelte";
|
||||
import SaveButtons from "./SaveButtons.svelte";
|
||||
import EditHeader from "../EditHeader.svelte";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
function save() {
|
||||
dispatch("save", {
|
||||
status: status
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export let title = null;
|
||||
@@ -27,19 +25,18 @@
|
||||
let originalContent;
|
||||
let activeContentTab = "";
|
||||
$: hasUnsavedData = false;
|
||||
$: validationErrors = null;
|
||||
$: errorMessage = validationErrors
|
||||
export let validationErrors = null;
|
||||
export let errorMessage = validationErrors
|
||||
? `Record submission failed. ${
|
||||
Object.entries(validationErrors).length
|
||||
} error(s)`
|
||||
: null;
|
||||
|
||||
|
||||
export function setOriginalData() {
|
||||
originalContent = {
|
||||
data: JSON.parse(JSON.stringify(data)),
|
||||
status: status,
|
||||
edges: JSON.parse(JSON.stringify(graph.map(r => r.edge))),
|
||||
edges: JSON.parse(JSON.stringify(graph?.map(r => r.edge.target+r.edge.field) ?? [])),
|
||||
};
|
||||
hasUnsavedData = checkUnsavedData();
|
||||
|
||||
@@ -49,7 +46,6 @@
|
||||
setOriginalData()
|
||||
})
|
||||
|
||||
|
||||
afterUpdate(() => {
|
||||
hasUnsavedData = checkUnsavedData();
|
||||
});
|
||||
@@ -79,11 +75,9 @@
|
||||
return !isEqual(originalContent, {
|
||||
data: data,
|
||||
status: status,
|
||||
edges: graph.map(r => r.edge),
|
||||
edges: graph?.map(r => r.edge.target+r.edge.field) ?? [],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<svelte:window on:beforeunload={beforeUnload}/>
|
||||
|
||||
@@ -3,13 +3,16 @@
|
||||
import {getContext} from "svelte";
|
||||
import Form from "../Form.svelte";
|
||||
import OffCanvas from "../../../common/OffCanvas.svelte";
|
||||
import Preview from "../../../newPreview/Preview.svelte";
|
||||
import PreviewCard from "../../PreviewCard.svelte";
|
||||
import axios from "axios";
|
||||
|
||||
export let field;
|
||||
export let record;
|
||||
export let edge;
|
||||
let form;
|
||||
let offCanvas;
|
||||
|
||||
$: validationErrors = null;
|
||||
$: errorMessage = null;
|
||||
const channel = getContext("channel");
|
||||
let schema = channel.schemas.find(s => s.name === field.data);
|
||||
|
||||
@@ -17,20 +20,56 @@
|
||||
offCanvas.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function save(e){
|
||||
e.preventDefault();
|
||||
console.log("yo")
|
||||
console.log("SAVE: Attempt");
|
||||
validationErrors = null;
|
||||
return new Promise(function (resolve, reject) {
|
||||
axios
|
||||
.put(channel.lucentUrl + "/edges", edge)
|
||||
.then(function (response) {
|
||||
console.log("SAVE: SAVED");
|
||||
edge = response.data;
|
||||
form.setOriginalData();
|
||||
resolve(null);
|
||||
offCanvas.hide();
|
||||
})
|
||||
.catch(function (error) {
|
||||
// setOriginalContent();
|
||||
if (error.response) {
|
||||
if (typeof error.response.data.error === "string") {
|
||||
errorMessage = error.response.data.error;
|
||||
} else {
|
||||
validationErrors = error.response.data.error;
|
||||
console.log(validationErrors)
|
||||
}
|
||||
}
|
||||
resolve(null);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<OffCanvas bind:this={offCanvas}>
|
||||
<div class="p-4">
|
||||
<PreviewCard
|
||||
{record}
|
||||
hasDelete={false}
|
||||
editable={false}
|
||||
{field}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Form
|
||||
bind:this={form}
|
||||
data={edge.data}
|
||||
title={"Relational Data for " + field.info.label}
|
||||
{schema}
|
||||
isCreateMode={false}
|
||||
{errorMessage}
|
||||
{validationErrors}
|
||||
on:save={save}
|
||||
/>
|
||||
</OffCanvas>
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
hasDelete={true}
|
||||
editable={!!field?.data}
|
||||
{field}
|
||||
edge={reference.edge}
|
||||
bind:edge={reference.edge}
|
||||
on:remove={removeReference}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -10,6 +10,7 @@ export function insertEdges(existingRecords, sourceRecord, targetRecords, fieldN
|
||||
sourceSchema: sourceRecord.schema,
|
||||
targetSchema: r.schema,
|
||||
field: fieldName,
|
||||
data: {},
|
||||
rank: ""
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user