Post and post comments now save correctly. The viewed post does not always reflect the update though.

This commit is contained in:
Scott Idem
2024-11-07 14:10:10 -05:00
parent b381cbbc9e
commit d3609764e3
8 changed files with 490 additions and 123 deletions

View File

@@ -201,8 +201,8 @@ export async function create_ae_obj__post(
api_cfg, api_cfg,
account_id, account_id,
data_kv, data_kv,
params={}, params = {},
log_lvl=0 log_lvl = 0
}: { }: {
api_cfg: any, api_cfg: any,
account_id: string, account_id: string,
@@ -589,6 +589,8 @@ export function db_save_ae_obj_li__post(
account_id: obj.account_id_random, account_id: obj.account_id_random,
external_person_id: obj.external_person_id,
topic_id: obj.topic_id, topic_id: obj.topic_id,
topic: obj.topic, topic: obj.topic,
topic_name: obj.topic_name, topic_name: obj.topic_name,

View File

@@ -269,6 +269,8 @@ export function db_save_ae_obj_li__post_comment(
post_id: obj.post_id_random, post_id: obj.post_id_random,
external_person_id: obj.external_person_id,
// name: obj.name, // name: obj.name,
// summary: obj.summary, // summary: obj.summary,
title: obj.title, title: obj.title,

View File

@@ -8,6 +8,7 @@ type key_val = {
* If rm_empty then it will remove/ignore fields matching. Sometimes this is needed. * If rm_empty then it will remove/ignore fields matching. Sometimes this is needed.
* If trim_values then it will trim string values. * If trim_values then it will trim string values.
* If bool_tf_str then it will convert string values of true/false (case insensitive) to boolean values. * If bool_tf_str then it will convert string values of true/false (case insensitive) to boolean values.
* REMINDER: An unchecked checkbox will not be sent in the form data. This is a browser thing.
* Updated 2023-12-22 * Updated 2023-12-22
*/ */
export let extract_prefixed_form_data = function extract_prefixed_form_data( export let extract_prefixed_form_data = function extract_prefixed_form_data(

View File

@@ -62,6 +62,8 @@ export interface Post_Comment {
post_id: string; post_id: string;
// post_id_random: string; // post_id_random: string;
external_person_id?: null|string; // For IDAA this is the Novi UUID
// name: null|string; // name: null|string;
// summary?: null|string; // summary?: null|string;
title: null|string; title: null|string;

View File

@@ -132,6 +132,9 @@ function getContent() {
} }
return ''; return '';
} }
let mouse_entered_timer: any;
let mouse_entered_wait: number = 2500;
</script> </script>
<!-- svelte-ignore a11y-no-static-element-interactions --> <!-- svelte-ignore a11y-no-static-element-interactions -->
@@ -145,11 +148,19 @@ function getContent() {
} }
}} }}
on:mouseleave={() => { on:mouseleave={() => {
if (default_minimal) { mouse_entered_timer = setTimeout(() => {
show_menu = false; if (default_minimal) {
} show_menu = false;
}
}, mouse_entered_wait);
// if (default_minimal) {
// show_menu = false;
// }
}} }}
on:mouseenter={() => { on:mouseenter={() => {
clearTimeout(mouse_entered_timer);
if (default_minimal) { if (default_minimal) {
show_menu = true; show_menu = true;
} }
@@ -164,7 +175,7 @@ function getContent() {
<!-- class:opacity-100={show_menu} --> <!-- class:opacity-100={show_menu} -->
{#if editor && show_menu} {#if editor && show_menu}
<div <div
transition:fade={{delay: 150, duration: 750, easing: cubicOut}} transition:fade={{delay: 250, duration: 750, easing: cubicOut}}
class=" class="
control-group button-group control-group button-group
bg-gray-200 bg-gray-200

View File

@@ -14,25 +14,145 @@ import Tiptap_editor from '$lib/element_tiptap_editor.svelte';
export let lq__post_comment_obj: any; export let lq__post_comment_obj: any;
let prom_api__post_comment_obj: any; let prom_api__post_comment_obj_v2: any;
let disable_submit_btn = true; let disable_submit_btn = false;
async function handle_submit_form(event: any) { async function handle_submit_form(event: any) {
console.log('*** handle_submit_form() ***'); console.log('*** handle_submit_form() ***');
if (log_lvl > 1) {
console.log(event.target);
}
disable_submit_btn = true; disable_submit_btn = true;
let form_data = new FormData(event.target); let form_data = new FormData(event.target);
console.log(form_data); if (log_lvl) {
console.log(form_data);
}
disable_submit_btn = false; // Form Post object data incoming
let post_comment_di = ae_util.extract_prefixed_form_data({prefix: null, form_data: form_data, trim_values: true, bool_tf_str: true, log_lvl: 2});
// console.log(post_comment_di);
return true; // Form Post object data outgoing
let post_comment_do: key_val = {};
if (!$idaa_slct.post_comment_id) {
post_comment_do['post_id_random'] = $ae_loc.post_id;
post_comment_do['enable'] = true;
}
// post_comment_do['title'] = post_comment_di.title;
// Check if the content_new_html exists and is a string
if (typeof $idaa_slct.post_comment_obj.content_new_html === 'string') {
console.log('New content is a string');
post_comment_do['content'] = $idaa_slct.post_comment_obj.content_new_html;
} else {
console.log('New content is not a string. Do nothing.');
// post_comment_do['content'] = event_meeting_fd.content;
}
post_comment_do['anonymous'] = post_comment_di.anonymous;
post_comment_do['external_person_id'] = post_comment_di.external_person_id;
post_comment_do['full_name'] = post_comment_di.full_name;
post_comment_do['email'] = post_comment_di.email;
post_comment_do['hide'] = post_comment_di.hide;
post_comment_do['priority'] = post_comment_di.priority;
if (post_comment_di.sort) {
post_comment_do['sort'] = Number(post_comment_di.sort);
} else {
post_comment_do['sort'] = null;
}
if (post_comment_di.group) {
post_comment_do['group'] = post_comment_di.group;
} else {
post_comment_do['group'] = null;
}
// Check if the enable exists and is a string
console.log(`post_comment_di.enable = ${post_comment_di.enable}`);
// if (typeof post_comment_di.enable !== 'undefined') {
post_comment_do['enable'] = !!post_comment_di.enable;
// }
// // Check if the notes_new_html exists and is a string
// if (typeof $idaa_slct.post_comment_obj.notes_new_html === 'string') {
// console.log('New notes is a string');
// post_comment_do['notes'] = $idaa_slct.post_comment_obj.notes_new_html;
// } else {
// console.log('New notes is not a string. Do nothing.');
// // post_comment_do['notes'] = event_meeting_fd.notes;
// }
console.log(post_comment_do);
if (!$idaa_slct.post_comment_id) {
prom_api__post_comment_obj_v2 = posts_func.create_ae_obj__post_comment({
api_cfg: $ae_api,
post_id: $idaa_slct.post_id,
data_kv: post_comment_do,
log_lvl: log_lvl
})
.then(function (post_comment_obj_create_result) {
if (!post_comment_obj_create_result) {
console.log('The result was null or false.');
return false;
}
$idaa_slct.post_comment_id = post_comment_obj_create_result.obj_id_random;
return post_comment_obj_create_result;
})
.catch(function (error) {
console.log('Something went wrong.');
console.log(error);
return false;
})
.finally(() => {
$idaa_slct.post_comment_obj = $lq__post_comment_obj;
disable_submit_btn = false;
$idaa_sess.bb.show__inline_edit__post_comment_id = false;
});
return prom_api__post_comment_obj_v2;
} else {
prom_api__post_comment_obj_v2 = posts_func.update_ae_obj__post_comment({
api_cfg: $ae_api,
post_comment_id: $idaa_slct.post_comment_id,
data_kv: post_comment_do,
log_lvl: log_lvl
})
.then(function (post_comment_obj_update_result) {
if (!post_comment_obj_update_result) {
console.log('The result was null or false.');
return false;
}
return post_comment_obj_update_result;
})
.catch(function (error) {
console.log('Something went wrong.');
console.log(error);
return false;
})
.finally(() => {
// We need to do this since the comment has changed and the idaa_slct object does automatically update (yet...???).
$idaa_slct.post_comment_obj = $lq__post_comment_obj;
disable_submit_btn = false;
$idaa_sess.bb.show__inline_edit__post_comment_id = false;
});
return prom_api__post_comment_obj_v2;
}
} }
async function handle_delete_post_comment_obj({post_id, method}: key_val) {
async function handle_delete_post_comment_obj({post_comment_id, method}: key_val) {
console.log('*** handle_delete_post_comment_obj() ***'); console.log('*** handle_delete_post_comment_obj() ***');
@@ -43,17 +163,17 @@ async function handle_delete_post_comment_obj({post_id, method}: key_val) {
<section <section
class="svelte_component ae_section ae_edit post_comment_obj edit__post_comment_obj space-y-2 p-2 border border-1 rounded" class="svelte_component ae_section ae_edit post_comment_obj edit__post_comment_obj space-y-2 p-2 border border-1 rounded bg-yellow-100"
class:ae_create={!$idaa_slct.post_id} class:ae_create={!$idaa_slct.post_id}
bind:clientHeight={$ae_loc.iframe_height_modal_body} bind:clientHeight={$ae_loc.iframe_height_modal_body}
> >
<form on:submit|preventDefault={handle_submit_form} class="space-y-1"> <form on:submit|preventDefault={handle_submit_form} class="space-y-1">
{#await prom_api__post_comment_obj} {#await prom_api__post_comment_obj_v2}
<div class="awaiting alert_msg_pulse" out:fade={{ duration: 2000 }}>Saving...</div> <div class="awaiting alert_msg_pulse" out:fade={{ duration: 2000 }}>Saving...</div>
{:then} {:then}
{#if prom_api__post_comment_obj} {#if prom_api__post_comment_obj_v2}
<!-- <div class="awaiting" out:fade={{ duration: 2000 }}>Finished saving</div> --> <!-- <div class="awaiting" out:fade={{ duration: 2000 }}>Finished saving</div> -->
{:else} {:else}
<!-- <div class="awaiting" out:fade={{ duration: 2000 }}>Nothing here yet</div> --> <!-- <div class="awaiting" out:fade={{ duration: 2000 }}>Nothing here yet</div> -->
@@ -198,60 +318,117 @@ async function handle_delete_post_comment_obj({post_id, method}: key_val) {
{$idaa_loc.bb.show__admin_options ? 'Hide' : 'Show'} Admin {$idaa_loc.bb.show__admin_options ? 'Hide' : 'Show'} Admin
</button> </button>
<!-- BEGIN: section post__admin_options -->
<section <section
class="ae_section post__admin_options border border-gray-200 rounded p-2 space-y-2" class="ae_section post__admin_options border border-gray-200 rounded p-2 space-y-2 bg-red-100"
class:hidden={!$idaa_loc.bb.show__admin_options} class:hidden={!$idaa_loc.bb.show__admin_options}
> <!-- BEGIN: section post__admin_options --> >
<h3 class="h3"> <h3 class="h3">
Admin Options Admin Options
</h3> </h3>
<span <span
class="flex flex-row flex-wrap items-center justify-between" class="flex flex-col md:flex-row flex-wrap gap-2 items-center justify-center md:justify-stretch w-full"
> >
<label>Hide <span
<input class="flex flex-row flex-wrap gap-2 items-center justify-evenly grow"
type="checkbox" >
name="hide" <fieldset class="flex flex-row gap-1 items-center justify-center">
id="hide" <legend class="legend text-sm font-semibold">Hide</legend>
bind:checked={$idaa_slct.post_comment_obj.hide} <div>
class="checkbox" <input
> type="radio"
</label> id="hide_yes"
name="hide"
value={true}
bind:group={$idaa_slct.post_comment_obj.hide}
class="radio"
>
<label for="hide_yes">Yes</label>
</div>
<div>
<input
type="radio"
id="hide_no"
name="hide"
value={false}
bind:group={$idaa_slct.post_comment_obj.hide}
class="radio"
>
<label for="hide_no">No</label>
</div>
</fieldset>
<label>Priority <fieldset class="flex flex-row gap-2">
<input <legend class="legend text-sm font-semibold">Priority</legend>
type="checkbox" <div>
name="priority" <input
id="priority" type="radio"
bind:checked={$idaa_slct.post_comment_obj.priority} id="priority_yes"
class="checkbox" name="priority"
> value={true}
</label> bind:group={$idaa_slct.post_comment_obj.priority}
class="radio"
>
<label for="priority_yes">Yes</label>
</div>
<div>
<input
type="radio"
id="priority_no"
name="priority"
value={false}
bind:group={$idaa_slct.post_comment_obj.priority}
class="radio"
>
<label for="priority_no">No</label>
</div>
</fieldset>
</span>
<label>Sort <input type="number" name="sort" value={$lq__post_comment_obj?.sort} class="input w-24" /></label> <span class="flex flex-row flex-wrap gap-1 items-center justify-evenly grow">
<label class="legend text-sm font-semibold">Sort <input type="number" name="sort" value={$idaa_slct.post_comment_obj.sort} class="input w-24" /></label>
<label>Group <input type="text" name="group" value={$lq__post_comment_obj?.group ? $lq__post_comment_obj?.group : ''} max="100" class="input w-40" /></label> <label class="legend text-sm font-semibold">Group <input type="text" name="group" value={$idaa_slct.post_comment_obj.group ?? ''} max="100" class="input w-40" /></label>
</span>
{#if $ae_loc.administrator_access} {#if $ae_loc.administrator_access}
<label>Enable <span class="flex flex-row flex-wrap gap-1 items-center justify-evenly grow">
<input <fieldset class="flex flex-row gap-2">
type="checkbox" <legend class="legend text-sm font-semibold">Enable</legend>
name="enable" <div>
id="enable" <input
bind:checked={$idaa_slct.post_comment_obj.enable} type="radio"
class="checkbox" id="enable_yes"
> name="enable"
</label> value={true}
bind:group={$idaa_slct.post_comment_obj.enable}
class="radio"
>
<label for="enable_yes">Yes</label>
</div>
<div>
<input
type="radio"
id="enable_no"
name="enable"
value={false}
bind:group={$idaa_slct.post_comment_obj.enable}
class="radio"
>
<label for="enable_no">No</label>
</div>
</fieldset>
</span>
{/if} {/if}
</span> </span>
{#if $ae_loc.trusted_access} <!-- {#if $ae_loc.trusted_access}
<label <label
for="notes" for="notes"
> >
Internal Staff Notes <span class="legend text-sm font-semibold">Internal Staff Notes</span>
<Tiptap_editor <Tiptap_editor
default_minimal={true} default_minimal={true}
bind:html_text={$idaa_slct.post_comment_obj.notes} bind:html_text={$idaa_slct.post_comment_obj.notes}
@@ -259,7 +436,7 @@ async function handle_delete_post_comment_obj({post_id, method}: key_val) {
bind:new_html={$idaa_slct.post_comment_obj.notes_new_html} bind:new_html={$idaa_slct.post_comment_obj.notes_new_html}
/> />
</label> </label>
{/if} {/if} -->
</section> <!-- END: section post__admin_options --> </section> <!-- END: section post__admin_options -->
{/if} {/if}
@@ -274,7 +451,7 @@ async function handle_delete_post_comment_obj({post_id, method}: key_val) {
disabled={(disable_submit_btn)} disabled={(disable_submit_btn)}
class="ae_btn btn_primary btn btn-primary variant-ghost-primary hover:variant-filled-primary transition" class="ae_btn btn_primary btn btn-primary variant-ghost-primary hover:variant-filled-primary transition"
> >
{#await prom_api__post_comment_obj} {#await prom_api__post_comment_obj_v2}
<span class="fas fa-spinner fa-spin m-1"></span> Saving <span class="fas fa-spinner fa-spin m-1"></span> Saving
{:then} {:then}
<span class="fas fa-save m-1"></span> Save <span class="fas fa-save m-1"></span> Save
@@ -290,7 +467,7 @@ async function handle_delete_post_comment_obj({post_id, method}: key_val) {
}} }}
class="ae_btn btn_primary btn btn-primary variant-ghost-primary hover:variant-filled-primary transition" class="ae_btn btn_primary btn btn-primary variant-ghost-primary hover:variant-filled-primary transition"
> >
{#await prom_api__post_comment_obj} {#await prom_api__post_comment_obj_v2}
<span class="fas fa-spinner fa-spin m-1"></span> Saving <span class="fas fa-spinner fa-spin m-1"></span> Saving
{:then} {:then}
<span class="fas fa-plus m-1"></span> Save New Event <span class="fas fa-plus m-1"></span> Save New Event

View File

@@ -14,24 +14,151 @@ import Tiptap_editor from '$lib/element_tiptap_editor.svelte';
export let lq__post_obj: any; export let lq__post_obj: any;
let prom_api__post_obj: any; let prom_api__post_obj_v2: any;
let disable_submit_btn = true; let disable_submit_btn = false;
async function handle_submit_form(event: any) { async function handle_submit_form(event: any) {
console.log('*** handle_submit_form() ***'); console.log('*** handle_submit_form() ***');
if (log_lvl > 1) {
console.log(event.target);
}
disable_submit_btn = true; disable_submit_btn = true;
let form_data = new FormData(event.target); let form_data = new FormData(event.target);
console.log(form_data); if (log_lvl) {
console.log(form_data);
}
disable_submit_btn = false; // Form Post object data incoming
let post_di = ae_util.extract_prefixed_form_data({prefix: null, form_data: form_data, trim_values: true, bool_tf_str: true, log_lvl: 2});
// console.log(post_di);
return true; // Form Post object data outgoing
let post_do: key_val = {};
if (!$idaa_slct.post_id) {
post_do['account_id_random'] = $ae_loc.account_id;
post_do['enable'] = true;
}
post_do['title'] = post_di.title;
// Check if the content_new_html exists and is a string
if (typeof $idaa_slct.post_obj.content_new_html === 'string') {
console.log('New content is a string');
post_do['content'] = $idaa_slct.post_obj.content_new_html;
} else {
console.log('New content is not a string. Do nothing.');
// post_do['content'] = event_meeting_fd.content;
}
// Change this to a string later? Or use the group field instead?
if (post_di.topic_id) {
post_do['topic_id'] = Number(post_di.topic_id);
} else {
post_do['topic_id'] = null;
}
post_do['anonymous'] = post_di.anonymous;
post_do['external_person_id'] = post_di.external_person_id;
post_do['full_name'] = post_di.full_name;
post_do['email'] = post_di.email;
post_do['hide'] = !!post_di.hide;
post_do['priority'] = !!post_di.priority;
if (post_di.sort) {
post_do['sort'] = Number(post_di.sort);
} else {
post_do['sort'] = null;
}
if (post_di.group) {
post_do['group'] = post_di.group;
} else {
post_do['group'] = null;
}
// Check if the enable exists and is a string
console.log(`post_di.enable = ${post_di.enable}`);
// if (typeof post_di.enable !== 'undefined') {
post_do['enable'] = !!post_di.enable;
// }
// Check if the notes_new_html exists and is a string
if (typeof $idaa_slct.post_obj.notes_new_html === 'string') {
console.log('New notes is a string');
post_do['notes'] = $idaa_slct.post_obj.notes_new_html;
} else {
console.log('New notes is not a string. Do nothing.');
// post_do['notes'] = event_meeting_fd.notes;
}
console.log(post_do);
if (!$idaa_slct.post_id) {
prom_api__post_obj_v2 = posts_func.create_ae_obj__post({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: post_do,
log_lvl: log_lvl
})
.then(function (post_obj_create_result) {
if (!post_obj_create_result) {
console.log('The result was null or false.');
return false;
}
$idaa_slct.post_id = post_obj_create_result.obj_id_random;
return post_obj_create_result;
})
.catch(function (error) {
console.log('Something went wrong.');
console.log(error);
return false;
})
.finally(() => {
disable_submit_btn = false;
$idaa_sess.bb.show__inline_edit__post_obj = false;
});
return prom_api__post_obj_v2;
} else {
prom_api__post_obj_v2 = posts_func.update_ae_obj__post({
api_cfg: $ae_api,
post_id: $idaa_slct.post_id,
data_kv: post_do,
log_lvl: log_lvl
})
.then(function (post_obj_update_result) {
if (!post_obj_update_result) {
console.log('The result was null or false.');
return false;
}
return post_obj_update_result;
})
.catch(function (error) {
console.log('Something went wrong.');
console.log(error);
return false;
})
.finally(() => {
// We need to do this since the post has changed and the idaa_slct object does automatically update (yet...???).
$idaa_slct.post_obj = $lq__post_obj;
disable_submit_btn = false;
$idaa_sess.bb.show__inline_edit__post_obj = false;
});
return prom_api__post_obj_v2;
}
} }
async function handle_delete_post_obj({post_id, method}: key_val) { async function handle_delete_post_obj({post_id, method}: key_val) {
console.log('*** handle_delete_post_obj() ***'); console.log('*** handle_delete_post_obj() ***');
@@ -43,17 +170,17 @@ async function handle_delete_post_obj({post_id, method}: key_val) {
<section <section
class="svelte_component ae_section ae_edit post_obj edit__post_obj space-y-2 p-2 border border-1 rounded" class="svelte_component ae_section ae_edit post_obj edit__post_obj space-y-2 p-2 border border-1 rounded bg-blue-100"
class:ae_create={!$idaa_slct.post_id} class:ae_create={!$idaa_slct.post_id}
bind:clientHeight={$ae_loc.iframe_height_modal_body} bind:clientHeight={$ae_loc.iframe_height_modal_body}
> >
<form on:submit|preventDefault={handle_submit_form} class="space-y-1"> <form on:submit|preventDefault={handle_submit_form} class="space-y-1">
{#await prom_api__post_obj} {#await prom_api__post_obj_v2}
<div class="awaiting alert_msg_pulse" out:fade={{ duration: 2000 }}>Saving...</div> <div class="awaiting alert_msg_pulse" out:fade={{ duration: 2000 }}>Saving...</div>
{:then} {:then}
{#if prom_api__post_obj} {#if prom_api__post_obj_v2}
<!-- <div class="awaiting" out:fade={{ duration: 2000 }}>Finished saving</div> --> <!-- <div class="awaiting" out:fade={{ duration: 2000 }}>Finished saving</div> -->
{:else} {:else}
<!-- <div class="awaiting" out:fade={{ duration: 2000 }}>Nothing here yet</div> --> <!-- <div class="awaiting" out:fade={{ duration: 2000 }}>Nothing here yet</div> -->
@@ -74,12 +201,14 @@ async function handle_delete_post_obj({post_id, method}: key_val) {
<!-- <h3 class="h3">Post</h3> --> <!-- <h3 class="h3">Post</h3> -->
[{$idaa_slct.post_id}]
<input type="hidden" value={$idaa_slct.post_id} /> <input type="hidden" value={$idaa_slct.post_id} />
<section class="ae_section post__general_information border border-gray-200 rounded p-2 space-y-2"> <!-- BEGIN: section post__general_information --> <section class="ae_section post__general_information border border-gray-200 rounded p-2 space-y-2"> <!-- BEGIN: section post__general_information -->
<label for="title">Title of BB Post: <label for="title">Title of BB Post:
<input type="text" id="title" name="title" required max="200" value={$lq__post_obj?.title} placeholder="Title of Post" autocomplete="off" class="input w-96" /> <input type="text" id="title" name="title" required max="200" value={$idaa_slct.post_obj?.title} placeholder="Title of Post" autocomplete="off" class="input w-96" />
</label> </label>
<label for="content" class="ae_label post__content">Content (post body): <label for="content" class="ae_label post__content">Content (post body):
@@ -99,9 +228,9 @@ async function handle_delete_post_obj({post_id, method}: key_val) {
<label class=""> <label class="">
BB post topic: BB post topic:
<select <select
name="type" name="topic_id"
class="select w-96" class="select w-96"
value={$lq__post_obj?.type} value={$idaa_slct.post_obj?.topic_id}
> >
<option value="">-- None --</option> <option value="">-- None --</option>
<option value={16}>Licensing/ monitoring/ credentialing issues</option> <option value={16}>Licensing/ monitoring/ credentialing issues</option>
@@ -219,60 +348,118 @@ async function handle_delete_post_obj({post_id, method}: key_val) {
{$idaa_loc.bb.show__admin_options ? 'Hide' : 'Show'} Admin {$idaa_loc.bb.show__admin_options ? 'Hide' : 'Show'} Admin
</button> </button>
<!-- BEGIN: section post__admin_options -->
<section <section
class="ae_section post__admin_options border border-gray-200 rounded p-2 space-y-2" class="ae_section post__admin_options border border-gray-200 rounded p-2 space-y-2 bg-red-100"
class:hidden={!$idaa_loc.bb.show__admin_options} class:hidden={!$idaa_loc.bb.show__admin_options}
> <!-- BEGIN: section post__admin_options --> >
<h3 class="h3"> <h3 class="h3">
Admin Options Admin Options
</h3> </h3>
<span <span
class="flex flex-row flex-wrap items-center justify-between" class="flex flex-col md:flex-row flex-wrap gap-2 items-center justify-center md:justify-stretch w-full"
> >
<label>Hide <span
<input class="flex flex-row flex-wrap gap-2 items-center justify-evenly grow"
type="checkbox" >
name="hide" <fieldset class="flex flex-row gap-1 items-center justify-center">
id="hide" <legend class="legend text-sm font-semibold">Hide</legend>
bind:checked={$idaa_slct.post_obj.hide} <div>
class="checkbox" <input
> type="radio"
</label> id="hide_yes"
name="hide"
value={true}
bind:group={$idaa_slct.post_obj.hide}
class="radio"
>
<label for="hide_yes">Yes</label>
</div>
<div>
<input
type="radio"
id="hide_no"
name="hide"
value={false}
bind:group={$idaa_slct.post_obj.hide}
class="radio"
>
<label for="hide_no">No</label>
</div>
</fieldset>
<label>Priority <fieldset class="flex flex-row gap-2">
<input <legend class="legend text-sm font-semibold">Priority</legend>
type="checkbox" <div>
name="priority" <input
id="priority" type="radio"
bind:checked={$idaa_slct.post_obj.priority} id="priority_yes"
class="checkbox" name="priority"
> value={true}
</label> bind:group={$idaa_slct.post_obj.priority}
class="radio"
>
<label for="priority_yes">Yes</label>
</div>
<div>
<input
type="radio"
id="priority_no"
name="priority"
value={false}
bind:group={$idaa_slct.post_obj.priority}
class="radio"
>
<label for="priority_no">No</label>
</div>
</fieldset>
</span>
<label>Sort <input type="number" name="sort" value={$lq__post_obj?.sort} class="input w-24" /></label> <span class="flex flex-row flex-wrap gap-1 items-center justify-evenly grow">
<label class="legend text-sm font-semibold">Sort <input type="number" name="sort" value={$idaa_slct.post_obj.sort} class="input w-24" /></label>
<label>Group <input type="text" name="group" value={$lq__post_obj?.group ? $lq__post_obj?.group : ''} max="100" class="input w-40" /></label> <label class="legend text-sm font-semibold">Group <input type="text" name="group" value={$idaa_slct.post_obj.group ?? ''} max="100" class="input w-40" /></label>
</span>
{#if $ae_loc.administrator_access} {#if $ae_loc.administrator_access}
<label>Enable <span class="flex flex-row flex-wrap gap-1 items-center justify-evenly grow">
<input <fieldset class="flex flex-row gap-2">
type="checkbox" <legend class="legend text-sm font-semibold">Enable</legend>
name="enable" <div>
id="enable" <input
bind:checked={$idaa_slct.post_obj.enable} type="radio"
class="checkbox" id="enable_yes"
> name="enable"
</label> value={true}
bind:group={$idaa_slct.post_obj.enable}
class="radio"
>
<label for="enable_yes">Yes</label>
</div>
<div>
<input
type="radio"
id="enable_no"
name="enable"
value={false}
bind:group={$idaa_slct.post_obj.enable}
class="radio"
>
<label for="enable_no">No</label>
</div>
</fieldset>
</span>
{/if} {/if}
</span> </span>
{#if $ae_loc.trusted_access} {#if $ae_loc.trusted_access}
<label <label
for="notes" for="notes"
> >
Internal Staff Notes <span class="legend text-sm font-semibold">Internal Staff Notes</span>
<Tiptap_editor <Tiptap_editor
default_minimal={true} default_minimal={true}
bind:html_text={$idaa_slct.post_obj.notes} bind:html_text={$idaa_slct.post_obj.notes}
@@ -295,7 +482,7 @@ async function handle_delete_post_obj({post_id, method}: key_val) {
disabled={(disable_submit_btn)} disabled={(disable_submit_btn)}
class="ae_btn btn_primary btn btn-primary variant-ghost-primary hover:variant-filled-primary transition" class="ae_btn btn_primary btn btn-primary variant-ghost-primary hover:variant-filled-primary transition"
> >
{#await prom_api__post_obj} {#await prom_api__post_obj_v2}
<span class="fas fa-spinner fa-spin m-1"></span> Saving <span class="fas fa-spinner fa-spin m-1"></span> Saving
{:then} {:then}
<span class="fas fa-save m-1"></span> Save <span class="fas fa-save m-1"></span> Save
@@ -311,7 +498,7 @@ async function handle_delete_post_obj({post_id, method}: key_val) {
}} }}
class="ae_btn btn_primary btn btn-primary variant-ghost-primary hover:variant-filled-primary transition" class="ae_btn btn_primary btn btn-primary variant-ghost-primary hover:variant-filled-primary transition"
> >
{#await prom_api__post_obj} {#await prom_api__post_obj_v2}
<span class="fas fa-spinner fa-spin m-1"></span> Saving <span class="fas fa-spinner fa-spin m-1"></span> Saving
{:then} {:then}
<span class="fas fa-plus m-1"></span> Save New Event <span class="fas fa-plus m-1"></span> Save New Event
@@ -327,7 +514,7 @@ async function handle_delete_post_obj({post_id, method}: key_val) {
handle_delete_post_obj({post_id: $idaa_slct.post_id, method: 'delete'}); handle_delete_post_obj({post_id: $idaa_slct.post_id, method: 'delete'});
$idaa_slct.post_id = null; $idaa_slct.post_id = null;
// $lq__post_obj = {}; // $idaa_slct.post_obj = {};
}} }}
class="btn btn-sm variant-soft-warning" type="button" class="btn btn-sm variant-soft-warning" type="button"
title="Delete record permanently" title="Delete record permanently"
@@ -341,7 +528,7 @@ async function handle_delete_post_obj({post_id, method}: key_val) {
handle_delete_post_obj({post_id: $idaa_slct.post_id, method: 'disable'}); handle_delete_post_obj({post_id: $idaa_slct.post_id, method: 'disable'});
$idaa_slct.post_id = null; $idaa_slct.post_id = null;
// $lq__post_obj = {}; // $idaa_slct.post_obj = {};
}} }}
class="btn btn-sm variant-soft-warning" type="button" class="btn btn-sm variant-soft-warning" type="button"
title="Disable record to delete" title="Disable record to delete"
@@ -355,7 +542,7 @@ async function handle_delete_post_obj({post_id, method}: key_val) {
handle_delete_post_obj({post_id: $idaa_slct.post_id, method: 'hide'}); handle_delete_post_obj({post_id: $idaa_slct.post_id, method: 'hide'});
$idaa_slct.post_id = null; $idaa_slct.post_id = null;
// $lq__post_obj = {}; // $idaa_slct.post_obj = {};
}} }}
class="btn btn-sm variant-soft-warning" type="button" class="btn btn-sm variant-soft-warning" type="button"
title="Hide record to delete" title="Hide record to delete"

View File

@@ -429,7 +429,7 @@ async function handle_submit_form(event: any) {
obj_type: 'event', obj_type: 'event',
fields: event_do, fields: event_do,
key: $ae_api.api_crud_super_key, key: $ae_api.api_crud_super_key,
log_lvl: 2 log_lvl: 1
}) })
.then(function (event_obj_create_result) { .then(function (event_obj_create_result) {
if (!event_obj_create_result) { if (!event_obj_create_result) {
@@ -440,19 +440,15 @@ async function handle_submit_form(event: any) {
$idaa_slct.event_id = event_obj_create_result.obj_id_random; $idaa_slct.event_id = event_obj_create_result.obj_id_random;
dispatch(
'created__meeting_obj',
{
event_id: $idaa_slct.event_id,
}
);
return event_obj_create_result; return event_obj_create_result;
}) })
.catch(function (error) { .catch(function (error) {
console.log('Something went wrong.'); console.log('Something went wrong.');
console.log(error); console.log(error);
return false; return false;
})
.finally(() => {
disable_submit_btn = false;
}); });
return prom_api__event_obj; return prom_api__event_obj;
@@ -467,33 +463,22 @@ async function handle_submit_form(event: any) {
.then(function (event_obj_update_result) { .then(function (event_obj_update_result) {
if (!event_obj_update_result) { if (!event_obj_update_result) {
console.log('The result was null or false.'); console.log('The result was null or false.');
disable_submit_btn = false; // Enable the submit button even if something didn't go right
return false; return false;
} }
disable_submit_btn = false;
dispatch(
'updated__meeting_obj',
{
event_id: $idaa_slct.event_id,
}
);
return event_obj_update_result; return event_obj_update_result;
}) })
.catch(function (error) { .catch(function (error) {
console.log('Something went wrong.'); console.log('Something went wrong.');
console.log(error); console.log(error);
return false; return false;
})
.finally(() => {
disable_submit_btn = false;
}); });
return prom_api__event_obj; return prom_api__event_obj;
} }
disable_submit_btn = false;
return true;
} }
async function handle_delete_event_obj({event_id, method='disable'}) { async function handle_delete_event_obj({event_id, method='disable'}) {