This commit is contained in:
2023-10-07 21:18:18 +03:00
parent f2faec67fe
commit 956b8dc4e3
12 changed files with 378 additions and 113 deletions
@@ -1,12 +1,15 @@
<script>
import { createEventDispatcher } from "svelte";
import {createEventDispatcher, getContext} from "svelte";
import Icon from "../../common/Icon.svelte";
import InlineEdit from "../InlineEdit.svelte";
import BrowseModal from "./BrowseModal.svelte";
const dispatch = createEventDispatcher();
// export let field;
// export let buttonLabel = "";
// export let buttonClass = "";
const channel = getContext("channel");
export let schemas;
export let recordId;
$: showOptions = false;
@@ -41,7 +44,7 @@
function createInlineReference(e, schemaUId) {
e.preventDefault();
axios
.get("/records/newInline?schema=" + schemaUId)
.get(channel.lucentUrl + "/records/newInline?schema=" + schemaUId)
.then((response) => {
inLineCreateRecord = response.data;
showOptions = false;
@@ -54,34 +57,36 @@
{#if schemas.length > 1}
<button
type="button"
class:is-first={!recordId}
class=" btn btn-lg btn-link text-decoration-none inline-card-button"
on:click|preventDefault={(e) => (showOptions = !showOptions)}
type="button"
class:is-first={!recordId}
class=" btn btn-lg btn-link text-decoration-none inline-card-button"
on:click|preventDefault={(e) => (showOptions = !showOptions)}
>
<Icon width={24} height={24} icon="circle-plus" />
<Icon width={24} height={24} icon="circle-plus"/>
</button>
{#if showOptions}
<div class="bg-light lx-card d-flex">
{#each schemas as schema}
<div
class="lx-card p-4 text-center me-4"
style="max-width: 250px;"
class="lx-card p-4 text-center me-4"
style="max-width: 250px;"
>
<p>{schema.label}</p>
<div class="mb-2">
<button
class="btn btn-sm btn-primary"
on:click={(e) =>
class="btn btn-sm btn-primary"
on:click={(e) =>
createInlineReference(e, schema.name)}
>New
>New
</button>
<button
class="btn btn-sm btn-outline-primary"
on:click={(e) => openBrowseModal(e, schema.name)}
><Icon icon="magnifying-glass" /></button
class="btn btn-sm btn-outline-primary"
on:click={(e) => openBrowseModal(e, schema.name)}
>
<Icon icon="magnifying-glass"/>
</button
>
</div>
</div>
@@ -92,14 +97,16 @@
<div class="pb-2 text-start">
<div class="mb-2">
<button
class="btn btn-sm btn-primary"
on:click={(e) => createInlineReference(e, schemas[0].name)}
>New
class="btn btn-sm btn-primary"
on:click={(e) => createInlineReference(e, schemas[0].name)}
>New
</button>
<button
class="btn btn-sm btn-outline-primary"
on:click={(e) => openBrowseModal(e, schemas[0].name)}
><Icon icon="magnifying-glass" /></button
class="btn btn-sm btn-outline-primary"
on:click={(e) => openBrowseModal(e, schemas[0].name)}
>
<Icon icon="magnifying-glass"/>
</button
>
</div>
</div>
@@ -107,25 +114,28 @@
{#if inLineCreateRecord}
<InlineEdit
{...inLineCreateRecord}
on:cancel={(e) => (inLineCreateRecord = null)}
on:inlinesaved={save}
{...inLineCreateRecord}
on:cancel={(e) => (inLineCreateRecord = null)}
on:inlinesaved={save}
/>
{/if}
<BrowseModal bind:this={browseModal} on:insert={insert} />
<BrowseModal bind:this={browseModal} on:insert={insert}/>
<style>
:global(.inline-card-wrapper) {
display: flex;
flex-direction: column;
}
:global(.inline-card-wrapper .inline-card-button) {
visibility: hidden;
}
:global(.inline-card-wrapper .inline-card-button.is-first) {
visibility: visible;
}
:global(.inline-card-wrapper:hover .inline-card-button) {
visibility: visible;
}