fix(idaa): complete null-hardening for BB comment editor
- Added optional chaining to all post_comment_obj property accesses. - Resolved TypeError when clicking 'New Comment' button. - Hardened UI stability for asynchronous data loading.
This commit is contained in:
@@ -44,7 +44,7 @@
|
|||||||
// let notes_changed = $state(false);
|
// let notes_changed = $state(false);
|
||||||
let disable_submit_btn = $state(false);
|
let disable_submit_btn = $state(false);
|
||||||
|
|
||||||
function preventDefault<T extends Event>(fn: (event: T) => void) {
|
function prevent_default<T extends Event>(fn: (event: T) => void) {
|
||||||
return function (event: T) {
|
return function (event: T) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
fn(event);
|
fn(event);
|
||||||
@@ -77,7 +77,9 @@
|
|||||||
let post_comment_do: key_val = {};
|
let post_comment_do: key_val = {};
|
||||||
|
|
||||||
if (!$idaa_slct.post_comment_id) {
|
if (!$idaa_slct.post_comment_id) {
|
||||||
post_comment_do['post_id_random'] = $idaa_slct.post_id;
|
const parent_post_id = $idaa_slct.post_id;
|
||||||
|
post_comment_do['post_id'] = parent_post_id;
|
||||||
|
post_comment_do['post_id_random'] = parent_post_id;
|
||||||
post_comment_do['enable'] = true;
|
post_comment_do['enable'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +99,7 @@
|
|||||||
post_comment_do['external_person_id'] = post_comment_di.external_person_id;
|
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['full_name'] = post_comment_di.full_name;
|
||||||
post_comment_do['email'] = post_comment_di.email;
|
post_comment_do['email'] = post_comment_di.email;
|
||||||
post_comment_do['notify'] = post_comment_do.notify;
|
post_comment_do['notify'] = post_comment_di.notify;
|
||||||
|
|
||||||
post_comment_do['hide'] = post_comment_di.hide;
|
post_comment_do['hide'] = post_comment_di.hide;
|
||||||
post_comment_do['priority'] = post_comment_di.priority;
|
post_comment_do['priority'] = post_comment_di.priority;
|
||||||
@@ -144,6 +146,7 @@
|
|||||||
prom_api__post_comment_obj = await posts_func
|
prom_api__post_comment_obj = await posts_func
|
||||||
.create_ae_obj__post_comment({
|
.create_ae_obj__post_comment({
|
||||||
api_cfg: $ae_api,
|
api_cfg: $ae_api,
|
||||||
|
account_id: $ae_api.account_id,
|
||||||
post_id: $idaa_slct.post_id,
|
post_id: $idaa_slct.post_id,
|
||||||
data_kv: post_comment_do,
|
data_kv: post_comment_do,
|
||||||
log_lvl: log_lvl
|
log_lvl: log_lvl
|
||||||
@@ -442,7 +445,7 @@ Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${
|
|||||||
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 onsubmit={preventDefault(handle_submit_form)} class="space-y-1">
|
<form onsubmit={prevent_default(handle_submit_form)} class="space-y-1">
|
||||||
{#await prom_api__post_comment_obj}
|
{#await prom_api__post_comment_obj}
|
||||||
<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}
|
||||||
@@ -539,8 +542,8 @@ Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${
|
|||||||
type="text"
|
type="text"
|
||||||
id="external_person_id"
|
id="external_person_id"
|
||||||
name="external_person_id"
|
name="external_person_id"
|
||||||
value={$idaa_slct.post_comment_obj.external_person_id
|
value={$idaa_slct.post_comment_obj?.external_person_id
|
||||||
? $idaa_slct.post_comment_obj.external_person_id
|
? $idaa_slct.post_comment_obj?.external_person_id
|
||||||
: $idaa_loc.novi_uuid}
|
: $idaa_loc.novi_uuid}
|
||||||
readonly={true}
|
readonly={true}
|
||||||
class="input w-96 form-control"
|
class="input w-96 form-control"
|
||||||
@@ -556,8 +559,8 @@ Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${
|
|||||||
type="text"
|
type="text"
|
||||||
id="external_person_id"
|
id="external_person_id"
|
||||||
name="external_person_id"
|
name="external_person_id"
|
||||||
value={$idaa_slct.post_comment_obj.external_person_id
|
value={$idaa_slct.post_comment_obj?.external_person_id
|
||||||
? $idaa_slct.post_comment_obj.external_person_id
|
? $idaa_slct.post_comment_obj?.external_person_id
|
||||||
: ''}
|
: ''}
|
||||||
readonly={false}
|
readonly={false}
|
||||||
class="input w-96 form-control"
|
class="input w-96 form-control"
|
||||||
@@ -580,8 +583,8 @@ Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${
|
|||||||
type="text"
|
type="text"
|
||||||
id="full_name"
|
id="full_name"
|
||||||
name="full_name"
|
name="full_name"
|
||||||
value={$idaa_slct.post_comment_obj.full_name
|
value={$idaa_slct.post_comment_obj?.full_name
|
||||||
? $idaa_slct.post_comment_obj.full_name
|
? $idaa_slct.post_comment_obj?.full_name
|
||||||
: $idaa_loc.novi_full_name}
|
: $idaa_loc.novi_full_name}
|
||||||
readonly={!$ae_loc.trusted_access}
|
readonly={!$ae_loc.trusted_access}
|
||||||
class="input w-96 form-control"
|
class="input w-96 form-control"
|
||||||
@@ -601,8 +604,8 @@ Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
name="email"
|
name="email"
|
||||||
value={$idaa_slct.post_comment_obj.email
|
value={$idaa_slct.post_comment_obj?.email
|
||||||
? $idaa_slct.post_comment_obj.email
|
? $idaa_slct.post_comment_obj?.email
|
||||||
: $idaa_loc.novi_email}
|
: $idaa_loc.novi_email}
|
||||||
readonly={!$ae_loc.trusted_access}
|
readonly={!$ae_loc.trusted_access}
|
||||||
class="input w-96 form-control"
|
class="input w-96 form-control"
|
||||||
@@ -616,8 +619,8 @@ Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${
|
|||||||
<input
|
<input
|
||||||
type="hidden"
|
type="hidden"
|
||||||
name="email"
|
name="email"
|
||||||
value={$idaa_slct.post_comment_obj.email
|
value={$idaa_slct.post_comment_obj?.email
|
||||||
? $idaa_slct.post_comment_obj.email
|
? $idaa_slct.post_comment_obj?.email
|
||||||
: $idaa_loc.novi_email}
|
: $idaa_loc.novi_email}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user