Bug fixes for enable related fields.

This commit is contained in:
Scott Idem
2024-11-19 16:53:24 -05:00
parent fc8ee53724
commit fea392eff7
4 changed files with 132 additions and 52 deletions

View File

@@ -12,9 +12,19 @@ $ae_loc.params = data.params;
console.log(`+layout.svelte data:`, data);
if (browser) {
$idaa_loc.novi_uuid = data.url.searchParams.get('uuid'); // data.params.uuid;
$idaa_loc.novi_email = decodeURIComponent(data.url.searchParams.get('email'));
$idaa_loc.novi_full_name = decodeURIComponent(data.url.searchParams.get('full_name'));
if (data.url.searchParams.get('uuid')) {
$idaa_loc.novi_uuid = data.url.searchParams.get('uuid'); // data.params.uuid;
}
if (data.url.searchParams.get('email')) {
$idaa_loc.novi_email = decodeURIComponent(data.url.searchParams.get('email'));
} else {
$idaa_loc.novi_email = null;
}
if (data.url.searchParams.get('full_name')) {
$idaa_loc.novi_full_name = decodeURIComponent(data.url.searchParams.get('full_name'));
} else {
$idaa_loc.novi_full_name = null;
}
$idaa_loc.novi_admin_li = $ae_loc.site_cfg_json?.novi_admin_li ?? [];
$idaa_loc.novi_trusted_li = $ae_loc.site_cfg_json?.novi_trusted_li ?? [];
// console.log(`$idaa_loc.novi_uuid:`, $idaa_loc.novi_uuid);

View File

@@ -74,11 +74,12 @@ async function handle_submit_form(event: any) {
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;
// }
// NOTE: We only want to set enable value if the input is defined.
if (typeof post_comment_di.enable !== 'undefined') {
post_comment_do.enable = post_comment_di.enable;
}
// NOTE: We want to always default to false if the input is not defined.
// post_comment_do.enable = post_comment_di.enable ?? false;
// // Check if the notes_new_html exists and is a string
// if (typeof $idaa_slct.post_comment_obj.notes_new_html === 'string') {
@@ -338,7 +339,7 @@ async function handle_delete_post_comment_obj(
{#if $ae_loc.trusted_access}
<button
type="button"
class="btn btn-sm variant-soft-secondary float-right"
class="btn btn-sm variant-soft-warning float-right"
on:click={() => {
$idaa_loc.bb.show__admin_options = !$idaa_loc.bb.show__admin_options;
}}

View File

@@ -78,8 +78,8 @@ async function handle_submit_form(event: any) {
post_do['email'] = post_di.email;
post_do['notify'] = post_di.notify;
post_do['hide'] = !!post_di.hide;
post_do['priority'] = !!post_di.priority;
post_do['hide'] = post_di.hide;
post_do['priority'] = post_di.priority;
if (post_di.sort) {
post_do['sort'] = Number(post_di.sort);
} else {
@@ -91,8 +91,14 @@ async function handle_submit_form(event: any) {
post_do['group'] = null;
}
// console.log(`post_di.enable = ${post_di.enable}`);
post_do['enable'] = !!post_di.enable;
// NOTE: We only want to set enable value if the input is defined.
if (typeof post_di.enable !== 'undefined') {
post_do.enable = post_di.enable;
}
// NOTE: We want to always default to false if the input is not defined.
// post_do['enable'] = !!post_di.enable;
console.log(`post_di.enable = ${post_di.enable}`);
console.log(`post_do.enable = ${post_do.enable}`);
// Check if the notes_new_html exists and is a string
if (typeof $idaa_slct.post_obj.notes_new_html === 'string') {
@@ -118,7 +124,8 @@ async function handle_submit_form(event: any) {
return false;
}
$idaa_slct.post_id = post_obj_create_result.obj_id_random;
$idaa_slct.post_id = post_obj_create_result.post_id_random;
// $idaa_slct.post_obj = post_obj_create_result;
return post_obj_create_result;
})
@@ -627,7 +634,7 @@ function send_staff_notification_email() {
<input
type="text"
name="email"
value={($idaa_slct.post_obj.email ? $idaa_slct.post_obj.email : $idaa_loc.novi_email)}
value={($idaa_slct.post_obj.email ? $idaa_slct.post_obj.email : $idaa_loc.novi_email ?? '')}
readonly={!$ae_loc.trusted_access}
class="input w-96"
>
@@ -672,7 +679,7 @@ function send_staff_notification_email() {
{#if $ae_loc.trusted_access}
<button
type="button"
class="btn btn-sm float-right"
class="btn btn-sm variant-soft-warning float-right"
class:variant-filled-secondary={$idaa_loc.bb.show__admin_options}
class:variant-soft-secondary={!$idaa_loc.bb.show__admin_options}
on:click={() => {

View File

@@ -250,7 +250,10 @@ async function handle_submit_form(event: any) {
let event_do: key_val = {}; // Data out for API object
event_do['account_id_random'] = $ae_loc.account_id;
if (!$idaa_slct.event_id) {
event_do['account_id_random'] = $ae_loc.account_id;
event_do['enable'] = true;
}
event_do['name'] = event_meeting_fd.name;
@@ -415,8 +418,10 @@ async function handle_submit_form(event: any) {
} else {
event_do['group'] = null;
}
if (event_meeting_fd['enable']) {
event_do['enable'] = !!event_meeting_fd.enable;
// NOTE: We only want to set enable value if the input is defined.
if (typeof event_meeting_fd.enable !== 'undefined') {
event_do.enable = event_meeting_fd.enable;
}
// Check if the notes_new_html exists and is a string
@@ -1126,7 +1131,7 @@ async function handle_delete_event_obj(
{#if $ae_loc.trusted_access}
<button
type="button"
class="btn btn-sm variant-soft-secondary float-right"
class="btn btn-sm variant-soft-warning float-right"
on:click={() => {
$idaa_loc.recovery_meetings.show__admin_options = !$idaa_loc.recovery_meetings.show__admin_options;
}}
@@ -1135,10 +1140,11 @@ async function handle_delete_event_obj(
{$idaa_loc.recovery_meetings.show__admin_options ? 'Hide' : 'Show'} Admin
</button>
<!-- BEGIN: section event__admin_options -->
<section
class="ae_section event__admin_options border border-gray-200 rounded p-2 space-y-2"
class="ae_section event__admin_options border border-gray-200 rounded p-2 space-y-2 bg-red-100"
class:hidden={!$idaa_loc.recovery_meetings.show__admin_options}
> <!-- BEGIN: section event__admin_options -->
>
<h3 class="h3">
Admin Options
@@ -1147,42 +1153,98 @@ async function handle_delete_event_obj(
<span
class="flex flex-row flex-wrap items-center justify-between"
>
<label>Hide
<input
type="checkbox"
name="hide"
id="hide"
bind:checked={$idaa_slct.event_obj.hide}
class="checkbox"
>
</label>
<span
class="flex flex-row flex-wrap gap-2 items-center justify-evenly grow"
>
<fieldset class="flex flex-row gap-1 items-center justify-center">
<legend class="legend text-sm font-semibold">Hide</legend>
<div>
<input
type="radio"
id="hide_yes"
name="hide"
value={true}
bind:group={$idaa_slct.event_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.event_obj.hide}
class="radio"
>
<label for="hide_no">No</label>
</div>
</fieldset>
<label>Priority
<input
type="checkbox"
name="priority"
id="priority"
bind:checked={$idaa_slct.event_obj.priority}
class="checkbox"
>
</label>
<fieldset class="flex flex-row gap-2">
<legend class="legend text-sm font-semibold">Priority</legend>
<div>
<input
type="radio"
id="priority_yes"
name="priority"
value={true}
bind:group={$idaa_slct.event_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.event_obj.priority}
class="radio"
>
<label for="priority_no">No</label>
</div>
</fieldset>
</span>
<label>Sort <input type="number" name="sort" value={$lq__event_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.event_obj.sort} class="input w-24" /></label>
<label>Group <input type="text" name="group" value={$lq__event_obj?.group ? $lq__event_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.event_obj.group ?? ''} max="100" class="input w-40" /></label>
</span>
{#if $ae_loc.administrator_access}
<label>Enable
<input
type="checkbox"
name="enable"
id="enable"
bind:checked={$idaa_slct.event_obj.enable}
class="checkbox"
>
</label>
<span class="flex flex-row flex-wrap gap-1 items-center justify-evenly grow">
<fieldset class="flex flex-row gap-2">
<legend class="legend text-sm font-semibold">Enable</legend>
<div>
<input
type="radio"
id="enable_yes"
name="enable"
value={true}
bind:group={$idaa_slct.event_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.event_obj.enable}
class="radio"
>
<label for="enable_no">No</label>
</div>
</fieldset>
</span>
{:else}
<input type="hidden" name="enable" value={$lq__event_obj?.enable} />
<input type="hidden" name="enable" value={$idaa_slct.event_obj.enable} />
{/if}
</span>