Things are working!
This commit is contained in:
@@ -181,19 +181,63 @@ async function handle_load_ae_obj_id__event_exhibit({event_exhibit_id, try_cache
|
||||
return ae_event_exhibit_get_promise;
|
||||
}
|
||||
|
||||
async function handle_submit_form_other(event) {
|
||||
async function handle_submit_form_license_update(event) {
|
||||
console.log('*** handle_submit_form_license_update() ***');
|
||||
|
||||
// Data in
|
||||
let tmp_obj = $event_exhibit_obj;
|
||||
|
||||
tmp_obj.license_li_json.push($events_sess.leads.tmp_license);
|
||||
console.log('Add License:', tmp_obj);
|
||||
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) {
|
||||
console.log('No license email and full_name to update and there is an index number. Remove the license.');
|
||||
|
||||
console.log('Remove License');
|
||||
let tmp_obj = $event_exhibit_obj;
|
||||
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) {
|
||||
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 {
|
||||
return false;
|
||||
}
|
||||
|
||||
// tmp_obj.license_li_json.push($events_sess.leads.tmp_license);
|
||||
|
||||
// Save to local IDB
|
||||
await db_events.exhibits.put(tmp_obj);
|
||||
|
||||
// Save to the database
|
||||
// Data out
|
||||
let exhibit_do: key_val = {};
|
||||
exhibit_do['license_li_json'] = $event_exhibit_obj?.license_li_json;
|
||||
|
||||
console.log('exhibit_do:', exhibit_do);
|
||||
|
||||
console.log(`ae_ Exhibit Update:`, exhibit_do);
|
||||
exhibit_submit_results = handle_update__exhibit({
|
||||
obj_type: 'event_exhibit',
|
||||
obj_id: $events_slct.exhibit_id,
|
||||
data: exhibit_do
|
||||
})
|
||||
.then( function (exhibit_results) {
|
||||
console.log(`ae_ Exhibit Update Results:`, exhibit_results);
|
||||
if (exhibit_results) {
|
||||
}
|
||||
return exhibit_results;
|
||||
})
|
||||
.finally(function () {
|
||||
$events_trigger == 'load__event_exhibit_obj'
|
||||
// $ae_sess.ds.submit_status = 'updated';
|
||||
});
|
||||
|
||||
$events_sess.leads.show_form__license = false;
|
||||
$events_loc.leads.edit_license_li = false;
|
||||
|
||||
// This still needs to be saved to the database.
|
||||
}
|
||||
|
||||
|
||||
@@ -497,12 +541,13 @@ function send_init_confirm_email({to_email}) {
|
||||
<h2 class="h3">License List (max {$event_exhibit_obj?.license_max})</h2>
|
||||
<section class="ae_license_list">
|
||||
|
||||
{#if $event_exhibit_obj?.license_li_json.length < $event_exhibit_obj?.license_max}
|
||||
{#if $event_exhibit_obj?.license_li_json && $event_exhibit_obj?.license_li_json.length < $event_exhibit_obj?.license_max}
|
||||
<button
|
||||
class="btn btn-sm variant-soft-primary w-40"
|
||||
on:click={() => {
|
||||
// let tmp_obj = $event_exhibit_obj;
|
||||
$events_sess.leads.tmp_license = {
|
||||
// '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',
|
||||
'passcode': 'abcdefg',
|
||||
@@ -521,7 +566,7 @@ function send_init_confirm_email({to_email}) {
|
||||
Add License
|
||||
</button>
|
||||
{:else}
|
||||
<button
|
||||
<!-- <button
|
||||
class="btn btn-sm variant-soft-warning w-40"
|
||||
on:click={() => {
|
||||
console.log('No more licenses available. Remove the last one from the list?');
|
||||
@@ -534,7 +579,7 @@ function send_init_confirm_email({to_email}) {
|
||||
>
|
||||
<span class="fas fa-trash mx-1"></span>
|
||||
Delete License
|
||||
</button>
|
||||
</button> -->
|
||||
{/if} <!-- $event_exhibit_obj?.license_li_json.length < $event_exhibit_obj?.license_max -->
|
||||
|
||||
<div>Use one of the options below to log in using one of the licenses.</div>
|
||||
@@ -628,6 +673,7 @@ function send_init_confirm_email({to_email}) {
|
||||
type="button"
|
||||
use:clipboard={$events_slct.exhibit_obj.url}
|
||||
class="btn btn-sm text-sm variant-soft-tertiary"
|
||||
class:hidden={!$ae_loc.trusted_access || !$events_loc.show_details}
|
||||
title={`Copy link to this exhibit (ID: ${$events_slct.exhibit_id})`}
|
||||
>
|
||||
<span class="fas fa-copy mx-1"></span>
|
||||
@@ -699,7 +745,7 @@ function send_init_confirm_email({to_email}) {
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{#if $events_loc.leads.edit_license_li}
|
||||
<!-- {#if $events_loc.leads.edit_license_li}
|
||||
<button
|
||||
type="submit"
|
||||
disabled={index >= $event_exhibit_obj?.license_max}
|
||||
@@ -707,25 +753,47 @@ function send_init_confirm_email({to_email}) {
|
||||
<span class="fas fa-save mx-1"></span>
|
||||
Save
|
||||
</button>
|
||||
{:else}
|
||||
{:else} -->
|
||||
<div class="btn-group">
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log('Edit License');
|
||||
$events_loc.leads.edit_license_li = true;
|
||||
|
||||
$events_sess.leads.tmp_license = license;
|
||||
$events_sess.leads.tmp_license['index'] = index; // This is the index of the license in the list. It will need to be removed before saving back to the list based on the index value.
|
||||
$events_sess.leads.tmp_license['updated_on'] = new Date().toISOString();
|
||||
|
||||
// $events_loc.leads.edit_license_li = true;
|
||||
|
||||
$events_sess.leads.show_form__license = true;
|
||||
}}
|
||||
class="btn btn-sm variant-soft-warning">
|
||||
<span class="fas fa-edit mx-1"></span>
|
||||
Edit
|
||||
</button>
|
||||
{/if}
|
||||
<!-- <button
|
||||
type="submit"
|
||||
disabled={index >= $event_exhibit_obj?.license_max}
|
||||
class="btn btn-sm variant-soft-warning">
|
||||
<span class="fas fa-save mx-1"></span>
|
||||
Save
|
||||
</button> -->
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log('Remove License');
|
||||
// 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">
|
||||
<span class="fas fa-trash mx-1"></span>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
{#if $events_loc.show_details}
|
||||
@@ -764,6 +832,17 @@ function send_init_confirm_email({to_email}) {
|
||||
{#if $events_loc?.leads.auth_exhibit_li && $events_loc.leads.auth_exhibit_li[$events_slct.exhibit_id]}
|
||||
<div>Manage: Logged in. Nothing here yet</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log('Show/Hide Details');
|
||||
$events_loc.show_details = !$events_loc.show_details;
|
||||
}}
|
||||
>
|
||||
<span class="fas fa-eye mx-1"></span>
|
||||
Show/Hide Details
|
||||
</button>
|
||||
|
||||
{#if $events_loc?.leads.auth_exhibit_li && $events_loc.leads.auth_exhibit_li[$events_slct.exhibit_id]}
|
||||
<button
|
||||
type="button"
|
||||
@@ -846,7 +925,7 @@ function send_init_confirm_email({to_email}) {
|
||||
<form
|
||||
id="form__license_single"
|
||||
class="form"
|
||||
on:submit|preventDefault={handle_submit_form_other}
|
||||
on:submit|preventDefault={handle_submit_form_license_update}
|
||||
>
|
||||
|
||||
<!-- <input
|
||||
|
||||
Reference in New Issue
Block a user