Done for the night
This commit is contained in:
@@ -138,6 +138,7 @@ let events_session_data_struct: key_val = {
|
||||
entered_passcode: null,
|
||||
|
||||
tmp_license: {
|
||||
'index': null,
|
||||
// 'agree' : false, // The user must agree to the license agreement.
|
||||
'email': '',
|
||||
'full_name': '',
|
||||
|
||||
@@ -182,10 +182,19 @@ $: if ($events_trigger == 'load__event_exhibit_obj' && $events_slct.exhibit_id)
|
||||
async function handle_submit_form_license_update(event) {
|
||||
console.log('*** handle_submit_form_license_update() ***');
|
||||
|
||||
console.log(`$events_sess.leads=`, $events_sess.leads.tmp_license);
|
||||
|
||||
// Data in
|
||||
let tmp_obj = $event_exhibit_obj;
|
||||
console.log('tmp_obj:', tmp_obj);
|
||||
|
||||
if ($events_sess.leads.tmp_license.index >= 0 && $events_sess.leads.tmp_license.email && $events_sess.leads.tmp_license.full_name) {
|
||||
if ($events_sess.leads.tmp_license.index === null && $events_sess.leads.tmp_license.email && $events_sess.leads.tmp_license.full_name) {
|
||||
if (!Array.isArray(tmp_obj.license_li_json)) {
|
||||
tmp_obj.license_li_json = [];
|
||||
}
|
||||
tmp_obj.license_li_json.push($events_sess.leads.tmp_license);
|
||||
console.log('Add license:', tmp_obj);
|
||||
} else if ($events_sess.leads.tmp_license.index >= 0 && $events_sess.leads.tmp_license.email && $events_sess.leads.tmp_license.full_name) {
|
||||
tmp_obj.license_li_json[$events_sess.leads.tmp_license.index] = $events_sess.leads.tmp_license;
|
||||
console.log('Update license:', tmp_obj);
|
||||
} else if ($events_sess.leads.tmp_license.index >= 0 && !$events_sess.leads.tmp_license.email && !$events_sess.leads.tmp_license.full_name) {
|
||||
@@ -196,12 +205,6 @@ async function handle_submit_form_license_update(event) {
|
||||
tmp_obj.license_li_json.splice($events_sess.leads.tmp_license.index, 1);
|
||||
|
||||
console.log('Removed license:', tmp_obj);
|
||||
} else if ($events_sess.leads.tmp_license.email && $events_sess.leads.tmp_license.full_name) {
|
||||
if (!Array.isArray(tmp_obj.license_li_json)) {
|
||||
tmp_obj.license_li_json = [];
|
||||
}
|
||||
tmp_obj.license_li_json.push($events_sess.leads.tmp_license);
|
||||
console.log('Add license:', tmp_obj);
|
||||
} else if ($events_sess.leads.tmp_license.index === -1) {
|
||||
// console.log('No license email and full_name to add or update and index is -1. This was already deleted based on the old index number! Just submit what is already there?', tmp_obj);
|
||||
} else {
|
||||
@@ -605,6 +608,7 @@ function send_init_confirm_email({to_email}) {
|
||||
on:click={() => {
|
||||
// let tmp_obj = $event_exhibit_obj;
|
||||
$events_sess.leads.tmp_license = {
|
||||
'index': null,
|
||||
// 'index': $event_exhibit_obj?.license_li_json.length, // This is the index of the new license in the list.
|
||||
'email': '', // test+z@oneskyit.com
|
||||
'full_name': '', // Scott X
|
||||
@@ -798,7 +802,7 @@ function send_init_confirm_email({to_email}) {
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log('Remove License');
|
||||
if (confirm('Are you sure you want to remove this license?')) {
|
||||
if (confirm('Are you sure you want to remove this license? This only clears their name and email address so that it can be used by someone else. (The same as editing it.')) {
|
||||
// This still needs to be saved to the database.
|
||||
// Signal that this license should be removed from the list.
|
||||
// $events_sess.leads.tmp_license.index = -1;
|
||||
@@ -807,21 +811,10 @@ function send_init_confirm_email({to_email}) {
|
||||
$events_sess.leads.tmp_license.full_name = null;
|
||||
handle_submit_form_license_update(event);
|
||||
}
|
||||
|
||||
// let tmp_obj = $event_exhibit_obj;
|
||||
// tmp_obj?.license_li_json.splice(index, 1);
|
||||
// console.log('Remove License:', tmp_obj);
|
||||
// db_events.exhibits.put(tmp_obj);
|
||||
|
||||
// This still needs to be saved to the database.
|
||||
// $events_sess.leads.tmp_license.index = -1;
|
||||
// Signal that this license should be removed from the list.
|
||||
// $events_sess.leads.tmp_license.index = index;
|
||||
// $events_sess.leads.tmp_license.email = null;
|
||||
// $events_sess.leads.tmp_license.full_name = null;
|
||||
// handle_submit_form_license_update(event);
|
||||
}}
|
||||
class="btn btn-sm variant-soft-error">
|
||||
class:hidden={!$ae_loc.trusted_access}
|
||||
class="btn btn-sm variant-soft-error"
|
||||
>
|
||||
<span class="fas fa-trash mx-1"></span>
|
||||
Remove
|
||||
</button>
|
||||
@@ -967,15 +960,9 @@ function send_init_confirm_email({to_email}) {
|
||||
{/if} -->
|
||||
|
||||
<!-- The email address is used as the key, not the index number from the array of licenses. The email address is used to send the login link to the user. The passcode is used to log in. The full name is used to identify the user. The passcode is generated if not provided. -->
|
||||
<input
|
||||
type="email"
|
||||
name="license_email"
|
||||
placeholder="Email address"
|
||||
bind:value={$events_sess.leads.tmp_license.email}
|
||||
required
|
||||
class="input max-w-48 m-1"
|
||||
/>
|
||||
|
||||
<div class="border border-slate-500/10 p-2 variant-soft-warning">
|
||||
<strong>Do not use the same email address for more than one license.</strong> The email address is used as the key to log in and is linked to leads added. The full name is used to help identify the staff person.
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
name="license_full_name"
|
||||
@@ -985,6 +972,15 @@ function send_init_confirm_email({to_email}) {
|
||||
class="input max-w-48 m-1"
|
||||
/>
|
||||
|
||||
<input
|
||||
type="email"
|
||||
name="license_email"
|
||||
placeholder="Email address"
|
||||
bind:value={$events_sess.leads.tmp_license.email}
|
||||
required
|
||||
class="input max-w-64 m-1"
|
||||
/>
|
||||
|
||||
{#if $ae_loc.trusted_access}
|
||||
<input
|
||||
type="text"
|
||||
@@ -1003,30 +999,39 @@ function send_init_confirm_email({to_email}) {
|
||||
<div class="popover__content__actions">
|
||||
<button
|
||||
type="button"
|
||||
class="btn variant-soft-warning"
|
||||
on:click={() => {
|
||||
if (confirm('Are you sure you want to delete this data store?')) {
|
||||
// trigger = 'delete__ds__code';
|
||||
// $slct_trigger = 'delete__ds__code';
|
||||
console.log('Remove License');
|
||||
if (confirm('Are you sure you want to remove this license? This only clears their name and email address so that it can be used by someone else. (The same as editing it.)')) {
|
||||
// This still needs to be saved to the database.
|
||||
// Signal that this license should be removed from the list.
|
||||
// $events_sess.leads.tmp_license.index = -1;
|
||||
// $events_sess.leads.tmp_license.index = index;
|
||||
$events_sess.leads.tmp_license.email = null;
|
||||
$events_sess.leads.tmp_license.full_name = null;
|
||||
$events_sess.leads.tmp_license.passcode = null;
|
||||
handle_submit_form_license_update(event);
|
||||
|
||||
$events_sess.leads.show_form__license = false;
|
||||
}
|
||||
$events_sess.leads.show_form__license = false;
|
||||
}}
|
||||
class:hidden={$events_sess.leads.tmp_license.index === null}
|
||||
class="btn variant-soft-warning m-1"
|
||||
>
|
||||
<span class="fas fa-trash m-1"></span>
|
||||
Delete
|
||||
<span class="fas fa-broom mx-1"></span>
|
||||
Remove
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
form="form__license_single"
|
||||
class="btn variant-soft-primary"
|
||||
class="btn variant-soft-primary m-1"
|
||||
disabled={license_submit_results instanceof Promise && !license_submit_results}
|
||||
on:click={() => {
|
||||
// trigger = 'save__ds__code';
|
||||
// $slct_trigger = 'save__ds__code';
|
||||
}}
|
||||
>
|
||||
<span class="fas fa-save m-1"></span>
|
||||
<span class="fas fa-save mx-1"></span>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user