Skip to content

Commit

Permalink
add more fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mashehu committed Aug 26, 2024
1 parent 521473f commit 62a1471
Show file tree
Hide file tree
Showing 6 changed files with 457 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
class:collapse={property.hidden}
class:show={$showHidden}
>
<div id={title} class="col-12 col-md-3 title border-right border-secondary text-nowrap p-0 pe-2">
<div id={title} class="col-12 col-md-4 title border-right border-secondary text-nowrap p-0 pe-2">
<a class="text-decoration-none d-block overflow-x-scroll" aria-hidden="true" tabindex="-1" href={'#' + title}
><i class="ms-1 fas invisible" aria-hidden="true" />
<span class="">
{#if property.fa_icon}
<i class="fa fa-fw {property.fa_icon}" />
{/if}
<code>{title}<span class="opacity-50">:{property.type}</span></code>
<code>{title}</code><span class="opacity-50 font-monospace small">:{property.type}</span>
</span>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,58 +52,85 @@
// Handle the error, maybe show an error message to the user
}
});
const removeGroup = (name) => {
let result = confirm('Are you sure you want to remove this group?');
if (!result) return;
delete schema?.definitions[name];
schema = { ...schema };
};
</script>

<SchemaBuilderToolbar bind:schema>
<div class="d-flex">
<div>
<SchemaBuilderToolbar bind:schema>
<div class="d-flex">
<button
class="btn btn-outline-secondary"
on:click={() => {
collapseGroups = !collapseGroups;
}}>Collapse Groups</button
>
</div>
<button
class="btn btn-outline-secondary"
id="finish"
class="btn btn-primary"
class:disabled={status !== 'loaded'}
on:click={() => {
collapseGroups = !collapseGroups;
}}>Collapse Groups</button
postSchema('web_builder_edited');
}}>Finish</button
>
</div>
<button
id="finish"
class="btn btn-primary"
class:disabled={status !== 'loaded'}
on:click={() => {
postSchema('web_builder_edited');
}}>Finish</button
>
</SchemaBuilderToolbar>
</SchemaBuilderToolbar>

<div class="border rounded-md" class:border-success={status === 'saved'}>
{#if status === 'loading'}
<p>Loading schema...</p>
{:else if status === 'loaded'}
<div class="p-2" class:collapse={collapseGroups}>
{#each Object.keys(schema[defName]) as key (key)}
<SchemaBuilderListingGroup name={key} {schema}></SchemaBuilderListingGroup>
{/each}
<div data-dnd-indicator hidden style="height: 20px; background-color: red; width: 100%;"></div>
<div class="d-flex flex-column flex-xxl-row">
<div class="w-75">
<div class="border rounded-md" class:border-success={status === 'saved'}>
{#if status === 'loading'}
<p>Loading schema...</p>
{:else if status === 'loaded'}
<div class="p-2" class:collapse={collapseGroups}>
{#each Object.keys(schema[defName]) as key (key)}
<SchemaBuilderListingGroup name={key} {schema}>
<button
slot="delete-group"
class="btn btn-outline-danger delete-btn"
on:click={() => removeGroup(key)}
>
<i class="fas fa-trash"></i>
</button>
</SchemaBuilderListingGroup>
{/each}
<div data-dnd-indicator hidden style="height: 20px; background-color: red; width: 100%;"></div>
</div>
{:else if (status = 'saved')}
<p class="m-2">Schema saved! See terminal log for more details.</p>
{/if}
</div>
</div>
{:else if (status = 'saved')}
<p class="m-2">Schema saved! See terminal log for more details.</p>
{/if}
</div>
<figure>
<figcaption
data-rehype-pretty-code-title=""
data-language="json"
class="d-flex align-items-center justify-content-between"
>
<span><i class="fa-solid fa-database ms-1 me-2"></i>nf-params.json</span><CopyButton
text={JSON.stringify(schema, null, 2)}
label="Copy Schema <i class='fa-regular fa-clipboard'></i>"
copiedLabel="Copied Schema <i class='fa-regular px-1 fa-clipboard-check' />"
classes={'m-2 copy-code-button btn btn-sm btn-outline-secondary opacity-50'}
copiedClasses={'m-2 copy-code-button btn btn-sm btn-outline-success'}
/>
</figcaption>
<pre class="text-secondary p-0">
<figure class="w-25">
<figcaption
data-rehype-pretty-code-title=""
data-language="json"
class="d-flex align-items-center justify-content-between"
>
<span><i class="fa-solid fa-database ms-1 me-2"></i>nf-params.json</span><CopyButton
text={JSON.stringify(schema, null, 2)}
label="Copy Schema <i class='fa-regular fa-clipboard'></i>"
copiedLabel="Copied Schema <i class='fa-regular px-1 fa-clipboard-check' />"
classes={'m-2 copy-code-button btn btn-sm btn-outline-secondary opacity-50'}
copiedClasses={'m-2 copy-code-button btn btn-sm btn-outline-success'}
/>
</figcaption>
<pre class="text-secondary p-0">
<code class="" data-language="json">
{JSON.stringify(schema, null, 2)}
</code>
</pre>
</figure>
</figure>
</div>
</div>

<style lang="scss">
.delete-btn:not(:hover) {
color: var(--bs-tertiary-color);
border-color: var(--bs-tertiary-color);
}
</style>
Loading

0 comments on commit 62a1471

Please sign in to comment.