fetch gfix

This commit is contained in:
2026-05-07 13:29:49 +03:00
parent fcadc8d7a1
commit 8cf1dd9bfd
5 changed files with 39 additions and 43 deletions
+2
View File
@@ -65,6 +65,7 @@ export function apiPost(url, body, options = {}) {
body: JSON.stringify(body), body: JSON.stringify(body),
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest",
"X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]').content, "X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]').content,
...options.headers, ...options.headers,
}, },
@@ -77,6 +78,7 @@ export function apiGet(url, options = {}) {
method: "GET", method: "GET",
headers: { headers: {
"X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]').content, "X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]').content,
"X-Requested-With": "XMLHttpRequest",
...options.headers, ...options.headers,
}, },
}).then((r) => r.json()); }).then((r) => r.json());
+11 -12
View File
@@ -4,8 +4,8 @@
import ActionsOnSelected from "./ActionsOnSelected.svelte"; import ActionsOnSelected from "./ActionsOnSelected.svelte";
import Table from "./Table.svelte"; import Table from "./Table.svelte";
import { getContext } from "svelte"; import { getContext } from "svelte";
import { apiGet } from "../../helpers";
const axios = getContext("axios");
export let schema; export let schema;
export let users; export let users;
export let records; export let records;
@@ -26,18 +26,17 @@
function refresh(e) { function refresh(e) {
const newUrl = e.detail; const newUrl = e.detail;
axios apiGet(newUrl)
.get(newUrl)
.then((response) => { .then((response) => {
records = response.data.records; records = response.records;
sortParam = response.data.sortParam; sortParam = response.sortParam;
sortField = response.data.sortField; sortField = response.sortField;
operators = response.data.operators; operators = response.operators;
filter = response.data.filter; filter = response.filter;
skip = response.data.skip; skip = response.skip;
limit = response.data.limit; limit = response.limit;
total = response.data.total; total = response.total;
modalUrl = response.data.modalUrl; modalUrl = response.modalUrl;
document.querySelector("dialog h3").scrollIntoView(); document.querySelector("dialog h3").scrollIntoView();
}) })
.catch((error) => { .catch((error) => {
+1 -1
View File
@@ -26,7 +26,7 @@
function select(record) { function select(record) {
selected = selectRecord(record, selected); selected = selectRecord(record, selected);
} }
console.log(schema);
$: visibleColumns = schema.fields.filter( $: visibleColumns = schema.fields.filter(
(c) => schema.visible?.includes(c.name) ?? [], (c) => schema.visible?.includes(c.name) ?? [],
); );
+24 -29
View File
@@ -1,9 +1,8 @@
<script> <script>
import { createEventDispatcher, getContext } from "svelte";
import {createEventDispatcher, getContext} from "svelte";
import Icon from "../common/Icon.svelte"; import Icon from "../common/Icon.svelte";
import Index from "../content/Index.svelte"; import Index from "../content/Index.svelte";
import axios from "axios"; import { apiGet } from "../../helpers";
let dialogEl; let dialogEl;
@@ -15,21 +14,19 @@
// load(); // load();
// }); // });
export function close(e) { export function close(e) {
if(e){ if (e) {
e.preventDefault(); e.preventDefault();
} }
dialogEl.close() dialogEl.close();
selectedRecords = []; selectedRecords = [];
} }
function load(schema) { function load(schema) {
axios apiGet(channel.lucentUrl + "/content/" + schema)
.get(channel.lucentUrl + "/content/" + schema)
.then((response) => { .then((response) => {
data = response.data; data = response;
}) })
.catch((error) => console.log(error)); .catch((error) => console.log(error));
} }
@@ -52,42 +49,41 @@
} }
export function open(schema) { export function open(schema) {
dialogEl.showModal() dialogEl.showModal();
load(schema); load(schema);
} }
</script> </script>
<dialog bind:this={dialogEl}> <dialog bind:this={dialogEl}>
{#if data.schema} {#if data.schema}
<div class="dialog-header"> <div class="dialog-header">
<button <button
type="button" type="button"
class="button" class="button"
on:click={insert} on:click={insert}
disabled={selectedRecords.length === 0} disabled={selectedRecords.length === 0}
> >
Insert Insert
</button> </button>
<button <button
type="button" type="button"
class="button" class="button"
on:click={replace} on:click={replace}
disabled={selectedRecords.length === 0} disabled={selectedRecords.length === 0}
> >
Replace Replace
</button> </button>
{#if selectedRecords.length > 0} {#if selectedRecords.length > 0}
<span class=""> <span class="">
{selectedRecords.length} records selected {selectedRecords.length} records selected
</span> </span>
{/if} {/if}
<button <button
on:click|preventDefault={close} on:click|preventDefault={close}
type="button" type="button"
class="button close" class="button close"
aria-label="Close" aria-label="Close"
> >
<Icon icon="close"></Icon> <Icon icon="close"></Icon>
</button> </button>
@@ -96,6 +92,5 @@
<div class="dialog-body"> <div class="dialog-body">
<Index {...data} bind:selected={selectedRecords}></Index> <Index {...data} bind:selected={selectedRecords}></Index>
</div> </div>
{/if} {/if}
</dialog> </dialog>
+1 -1
View File
@@ -56,6 +56,7 @@ class RecordController extends Controller
$users = $this->accountService->all(); $users = $this->accountService->all();
$schema = $this->channelService->getSchema($schemaName)->get(); $schema = $this->channelService->getSchema($schemaName)->get();
$urlParams = $request->all(); $urlParams = $request->all();
$sort = data_get($urlParams, "sort") ?? $schema->sortBy; $sort = data_get($urlParams, "sort") ?? $schema->sortBy;
$filter = data_get($urlParams, "filter") ?? []; $filter = data_get($urlParams, "filter") ?? [];
@@ -114,7 +115,6 @@ class RecordController extends Controller
$this->accountService->currentWritableSchemas(), $this->accountService->currentWritableSchemas(),
), ),
]; ];
if ($request->ajax()) { if ($request->ajax()) {
$data["modalUrl"] = $request->fullUrl(); $data["modalUrl"] = $request->fullUrl();
if (str_starts_with(config("lucent.url"), "https")) { if (str_starts_with(config("lucent.url"), "https")) {