Now able to do stuff with the locations
This commit is contained in:
@@ -13,7 +13,7 @@ import { core_func } from '$lib/ae_core_functions';
|
||||
// *** Import Aether module components
|
||||
|
||||
// *** Export/Exposed variables and functions for component
|
||||
export let log_lvl: number = 0;
|
||||
export let log_lvl: number = 1;
|
||||
export let trigger_patch: any = null;
|
||||
export let api_cfg: key_val = {'api_crud_super_key': null};
|
||||
// export let api_crud_super_key: null|string = api_cfg.api_crud_super_key;
|
||||
@@ -24,6 +24,7 @@ export let field_type: string = 'text'; // button, text, textarea, template (old
|
||||
export let field_value: any;
|
||||
export let allow_null: boolean = false;
|
||||
export let select_option_li: key_val = {};
|
||||
export let edit_label: string = 'Edit';
|
||||
export let display_inline: boolean = false;
|
||||
export let display_block_edit: boolean = false;
|
||||
|
||||
@@ -35,7 +36,7 @@ export let textarea_rows: number = 5;
|
||||
export let hide_edit_btn = false;
|
||||
export let outline_element = false;
|
||||
export let show_crud = false;
|
||||
export let btn_label = '<span class="fas fa-check mx-1"></span> Save'; // PATCH
|
||||
export let btn_label = null; // '<span class="fas fa-check mx-1"></span> Save'; // PATCH
|
||||
|
||||
// export let show_field_name = true;
|
||||
// export let show_original_value = true;
|
||||
@@ -56,7 +57,8 @@ const dispatch = createEventDispatcher();
|
||||
onMount(() => {
|
||||
// console.log('** Element Mounted: ** Element AE CRUD');
|
||||
if (log_lvl) {
|
||||
console.log(`Element AE CRUD: Object Type: ${object_type}; Object ID: ${object_id}; Field Name: ${field_name}; Field Value: ${field_value}`); // ; Super Key: ${api_crud_super_key}
|
||||
console.log(`Element AE CRUD: Object Type: ${object_type}; Object ID: ${object_id}; Field Name: ${field_name}; Field Value: ${field_value} (Original: ${original_field_value})`);
|
||||
// ; Super Key: ${api_crud_super_key}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -91,7 +93,7 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
|
||||
// let params = {};
|
||||
|
||||
ae_promises.api_update__ae_obj = await core_func.handle_update_ae_obj_id_crud({
|
||||
ae_promises.api_update__ae_obj = core_func.handle_update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
object_type: object_type,
|
||||
object_id: object_id,
|
||||
@@ -107,6 +109,7 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
if (results) {
|
||||
console.log(`Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Original Field Value: ${original_field_value}`);
|
||||
patch_result = 'PATCH complete';
|
||||
original_field_value = new_field_value;
|
||||
} else {
|
||||
console.log(`Not Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Original Field Value: ${original_field_value}`);
|
||||
patch_result = 'PATCH failed';
|
||||
@@ -139,7 +142,12 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
</script>
|
||||
|
||||
|
||||
<div class="{class_li} ae_crud" class:show_crud class:display_inline class:outline_element>
|
||||
<div
|
||||
class="{class_li} ae_crud"
|
||||
class:show_crud
|
||||
class:display_inline
|
||||
class:outline_element
|
||||
>
|
||||
<span class="field_viewing_wrapper">
|
||||
<slot></slot>
|
||||
|
||||
@@ -158,19 +166,25 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
|
||||
<div
|
||||
class:display_block_edit
|
||||
class="field_editing_wrapper flex flex-row items-center justify-center min-w-content w-100 max-w-full"
|
||||
class="field_editing_wrapper min-w-content w-100 max-w-full"
|
||||
>
|
||||
<button
|
||||
class="btn btn-md variant-glass-tertiary hover:variant-ghost-tertiary m-1 transition-all"
|
||||
class:show_crud
|
||||
on:click={() => {
|
||||
show_crud = false;
|
||||
}}
|
||||
title="Close field editing"
|
||||
>
|
||||
<span class="fas fa-window-close"></span>
|
||||
<span class="hidden md:inline">Close</span>
|
||||
</button>
|
||||
<!-- <span class="grow flex flex-row items-center justify-between"> -->
|
||||
<!-- <span class="">
|
||||
{edit_label}
|
||||
</span> -->
|
||||
|
||||
<button
|
||||
class="btn btn-md variant-glass-tertiary hover:variant-ghost-tertiary m-1 transition-all"
|
||||
class:show_crud
|
||||
on:click={() => {
|
||||
show_crud = false;
|
||||
}}
|
||||
title="Close field editing"
|
||||
>
|
||||
<span class="fas fa-window-close"></span>
|
||||
<span class="hidden md:inline">Close</span>
|
||||
</button>
|
||||
<!-- </span> -->
|
||||
|
||||
<span
|
||||
class="field_value grow min-w-content max-w-full"
|
||||
@@ -188,10 +202,12 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
>
|
||||
{#if select_option_li && Object.keys(select_option_li).length == 0}
|
||||
<option value="">-- not set --</option>
|
||||
{:else}
|
||||
{:else if select_option_li && Object.keys(select_option_li).length > 0}
|
||||
{#each Object.keys(select_option_li) as option}
|
||||
<option value={option}>{select_option_li[option]}</option>
|
||||
{/each}
|
||||
{:else}
|
||||
<option value="">-- no list --</option>
|
||||
{/if}
|
||||
</select>
|
||||
|
||||
@@ -216,7 +232,7 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
{#if allow_null}
|
||||
<button
|
||||
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning m-1"
|
||||
on:click={async () => {
|
||||
on:click={() => {
|
||||
field_value = null;
|
||||
}}
|
||||
title="Set value to NULL"
|
||||
@@ -230,20 +246,39 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
<button
|
||||
class="btn btn-lg variant-glass-primary hover:variant-ghost-primary m-1"
|
||||
class:show_crud
|
||||
disabled={field_value == original_field_value}
|
||||
on:click={async () => {
|
||||
handle_obj_field_patch(field_value);
|
||||
}}
|
||||
title="Save new field value"
|
||||
>
|
||||
{@html btn_label}
|
||||
{#if field_value == original_field_value}
|
||||
{#if (btn_label)}
|
||||
{@html btn_label}
|
||||
{:else}
|
||||
<span class="fas fa-check mx-1"></span>
|
||||
<span>Save</span>
|
||||
{/if}
|
||||
<!-- <span>{patch_result}</span> -->
|
||||
{:else}
|
||||
{#if (btn_label)}
|
||||
{@html btn_label}
|
||||
{:else}
|
||||
<span class="fas fa-save mx-1"></span>
|
||||
<span>Save?</span>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
</button>
|
||||
|
||||
<div class="field_patch_result" class:show_crud>
|
||||
{#await ae_promises.api_update__ae_obj}
|
||||
<div>Processing...</div>
|
||||
<span class="fas fa-spinner fa-spin mx-1"></span>
|
||||
<span>Processing...</span>
|
||||
{:then}
|
||||
{#if patch_result}
|
||||
<div>{patch_result}</div>
|
||||
<span class="fas fa-check mx-1"></span>
|
||||
<span>{patch_result}</span>
|
||||
{:else}
|
||||
<!-- <div>Nothing to show yet...</div> -->
|
||||
{/if}
|
||||
@@ -405,14 +440,18 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.ae_crud.ae_crud.show_crud.display_inline .field_editing_wrapper.display_block_edit {
|
||||
.ae_crud.show_crud.display_inline .field_editing_wrapper.display_block_edit {
|
||||
/* display: block; */
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: .5em;
|
||||
|
||||
flex-grow: 1;
|
||||
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user