POC sign is mostly working now

This commit is contained in:
Scott Idem
2024-06-18 15:52:14 -04:00
parent 519525540c
commit 8044cd0723
7 changed files with 254 additions and 55 deletions

View File

@@ -3,10 +3,12 @@ console.log(`ae_events_pres_mgmt session [slug] form_agree.svelte`);
export let data: any;
import { onMount } from 'svelte';
import { createEventDispatcher, onMount } from 'svelte';
import { clipboard, FileDropzone } from '@skeletonlabs/skeleton';
import { liveQuery } from "dexie";
const dispatch = createEventDispatcher();
import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils';
import { api } from '$lib/api';
@@ -17,7 +19,6 @@ import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_st
import { db_events } from "$lib/db_events";
import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores';
import { events_func } from '$lib/ae_events_functions';
import { hide } from '@floating-ui/dom';
let ae_triggers: key_val = {};
@@ -253,6 +254,46 @@ async function handle_input_upload_files(input_upload_files) {
return hosted_file_result;
}
async function handle_delete__event_file({event_file_id}) {
console.log(`*** handle_delete__event_file() *** event_file_id:`, event_file_id);
let link_to_type = 'event_presenter';
let link_to_id = $events_slct.event_presenter_id;
ae_promises.delete__event_file_obj = await events_func.handle_delete_ae_obj_id__event_file({
api_cfg: $ae_api,
event_file_id: event_file_id,
log_lvl: 2
})
.then(function (event_file_obj_result) {
console.log(event_file_obj_result);
if (!event_file_obj_result) {
console.log('The result was null or false.');
return false;
} else {
console.log(`event_file_obj_result = `, event_file_obj_result);
}
dispatch(
'event_file_obj_deleted',
{
event_file_id: event_file_id,
link_to_type: link_to_type,
link_to_id: link_to_id,
}
);
return event_file_obj_result;
}).catch(function (error) {
console.log('Something went wrong deleting the event file.');
console.log(error);
return false;
});
return ae_promises.delete__event_file_obj;
}
</script>
{#await $lq__event_presenter_obj}
@@ -269,9 +310,11 @@ async function handle_input_upload_files(input_upload_files) {
<!-- Example: /events_pres_mgmt/session/Wh8UnJlbIA0?person_id=fV1dl_IJ0yY&person_pass=abc123 -->
<button
type="button"
class="btn btn-sm variant-ghost-warning float-right m-1"
use:clipboard={encodeURI(`${$ae_loc.url_origin}/events_pres_mgmt/session/${$events_slct.event_session_id}?person_id=${$events_slct.presenter_obj.person_id_random}&person_pass=${$events_slct.presenter_obj.person_passcode}&presentation_id=${$events_slct.presentation_obj.event_presentation_id_random}&presenter_id=${$events_slct.presenter_obj.event_presenter_id_random}`)}
class="btn btn-sm variant-ghost-warning float-right m-1"
title="Copy the presenter access link to the clipboard."
>
<span class="fas fa-copy mx-1"></span>
Copy Access Link
@@ -327,7 +370,7 @@ async function handle_input_upload_files(input_upload_files) {
<h3 class="h4">Files: {$events_slct.presenter_obj.file_count ? `${$events_slct.presenter_obj.file_count}x` : '-- none --'}</h3>
<div class="text-sm text-center bg-orange-100 rounded-md p-2">
WARNING: The file upload and management is a work in progress. You can upload files, but not yet delete or rename them.
WARNING: The file upload and management is a work in progress. You can upload and delete files, but not yet rename them.
</div>
<form
class="modal-form {$ae_loc.hub.classes__form}"
@@ -347,6 +390,7 @@ WARNING: The file upload and management is a work in progress. You can upload fi
if (e.target.files.length) {
ae_placeholder_li.new_file = `Ready to upload: ${e.target.files[0].name}`;
$events_sess.pres_mgmt.disable_submit__event_file_obj = false;
} else {
ae_placeholder_li.new_file = null;
}
@@ -391,7 +435,7 @@ WARNING: The file upload and management is a work in progress. You can upload fi
>{file_obj.filename}</a> -->
<button
class="btn btn-md variant-soft-primary"
class="btn btn-md variant-soft-primary min-w-96"
on:click={() => {
// ae_promises[event_file_obj.event_file_id_random]
ae_promises[event_file_obj.event_file_id_random] = api.download_hosted_file({
@@ -426,6 +470,19 @@ WARNING: The file upload and management is a work in progress. You can upload fi
{event_file_obj.filename.slice(0, 20)}...{event_file_obj.extension}
</button>
<button type="button"
title="Delete this file"
on:click={async () => {
if (!confirm('Are you sure you want to delete this file?')) {return false;}
ae_promises[event_file_obj.event_file_id_random] = handle_delete__event_file({event_file_id: event_file_obj.event_file_id_random});
}}
class="btn btn-sm variant-soft-warning event_file_delete_btn width_100"
>
<span class="fas fa-minus mx-1"></span>
Delete
</button>
</li>
{/each}
</ul>