Cleaning things up before going back to making the forms functional.
This commit is contained in:
@@ -22,6 +22,7 @@ import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$
|
||||
import { idaa_loc, idaa_sess, idaa_slct, idaa_trigger } from '$lib/ae_idaa_stores';
|
||||
import { archives_func } from '$lib/ae_archives/ae_archives_functions';
|
||||
|
||||
import Archive_obj_id_edit from './ae_idaa_comp__archive_obj_id_edit.svelte';
|
||||
import Archive_view from './ae_idaa_comp__archive_obj_id_view.svelte';
|
||||
// import Archive_page_menu from './session_page_menu.svelte';
|
||||
|
||||
@@ -41,7 +42,7 @@ console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
// For some reason data.params.archive_id (or whatever param) is not being passed to this page when loaded by a link from another page. This seems to be a bug with Svelte or SvelteKit. Hopefully fixed in a future version 5? 2024-11-06
|
||||
$idaa_slct.archive_id = ae_acct.slct.archive_id;
|
||||
$idaa_slct.archive_obj = ae_acct.slct.archive_obj;
|
||||
// $idaa_slct.archive_obj = ae_acct.slct.archive_obj;
|
||||
|
||||
|
||||
$: lq__archive_obj = liveQuery(async () => {
|
||||
@@ -148,18 +149,18 @@ if (browser) {
|
||||
|
||||
</svelte:fragment>
|
||||
|
||||
<Comp__archive_obj_id_edit
|
||||
<Archive_obj_id_edit
|
||||
lq__archive_obj={lq__archive_obj}
|
||||
/>
|
||||
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<!-- <svelte:fragment slot="footer">
|
||||
<div class="text-center w-full">
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log('Close modal');
|
||||
$idaa_sess.recovery_meetings.show__modal_edit = false;
|
||||
$idaa_sess.recovery_meetings.show__modal_edit__archive_id = false;
|
||||
}}
|
||||
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning"
|
||||
>
|
||||
@@ -167,12 +168,11 @@ if (browser) {
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</svelte:fragment> -->
|
||||
|
||||
</Modal>
|
||||
|
||||
|
||||
|
||||
<!-- Modal: Archive Content edit ID -->
|
||||
<Modal
|
||||
title="{$lq__archive_content_obj?.name} - {$lq__archive_content_obj?.id}"
|
||||
@@ -215,7 +215,7 @@ if (browser) {
|
||||
/>
|
||||
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<!-- <svelte:fragment slot="footer">
|
||||
<div class="text-center w-full">
|
||||
<button
|
||||
type="button"
|
||||
@@ -229,6 +229,6 @@ if (browser) {
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</svelte:fragment> -->
|
||||
|
||||
</Modal>
|
||||
@@ -334,36 +334,44 @@ async function handle_submit_form(event) {
|
||||
{/if}
|
||||
{/await}
|
||||
|
||||
<h3>Archive Content</h3>
|
||||
<!-- <h3>Archive Content</h3> -->
|
||||
|
||||
<label for="title">Name of Content
|
||||
<input type="text" id="name" name="name" required max="200" value={$idaa_slct.archive_content_obj.name ? $idaa_slct.archive_content_obj.name : '' }
|
||||
class="input w-full"
|
||||
placeholder="Content name"
|
||||
>
|
||||
</label>
|
||||
<section class="ae_section archive_content__general border border-gray-200 rounded p-2 space-y-2">
|
||||
<label for="name">Name of Content
|
||||
<input
|
||||
type="text" id="name" name="name"
|
||||
required max="200" value={$idaa_slct.archive_content_obj.name ? $idaa_slct.archive_content_obj.name : '' }
|
||||
class="input w-full"
|
||||
placeholder="Content name"
|
||||
>
|
||||
</label>
|
||||
|
||||
<label for="description">Description
|
||||
<textarea id="description" name="description" rows="6" cols="80" value={$idaa_slct.archive_content_obj.description ? $idaa_slct.archive_content_obj.description : ''} class="ae_value archive_content__description textarea"></textarea>
|
||||
</label>
|
||||
<label for="description">Description
|
||||
<textarea id="description" name="description" rows="6" cols="80" value={$idaa_slct.archive_content_obj.description ? $idaa_slct.archive_content_obj.description : ''} class="ae_value archive_content__description textarea"></textarea>
|
||||
</label>
|
||||
|
||||
<label for="content_html">Content (HTML)
|
||||
<textarea id="content_html" name="content_html" rows="6" cols="80" value={$idaa_slct.archive_content_obj.content_html ? $idaa_slct.archive_content_obj.content_html : ''} class="ae_value archive_content__content_html textarea"></textarea>
|
||||
</label>
|
||||
<!-- <label for="content_html">Content (HTML)
|
||||
<textarea id="content_html" name="content_html" rows="6" cols="80" value={$idaa_slct.archive_content_obj.content_html ? $idaa_slct.archive_content_obj.content_html : ''} class="ae_value archive_content__content_html textarea"></textarea>
|
||||
</label> -->
|
||||
|
||||
<label for="archive_content_type">Type
|
||||
<select id="archive_content_type" name="archive_content_type" value={$idaa_slct.archive_content_obj.archive_content_type} class="select w-52">
|
||||
<option value="">-- None --</option>
|
||||
<option value="hosted_file">Hosted File in Æ</option>
|
||||
<option value="html">Hosted HTML in Æ</option>
|
||||
<option value="json">Hosted JSON in Æ</option>
|
||||
<option value="url">External URL</option>
|
||||
<option value="other">Other</option>
|
||||
</select>
|
||||
</label>
|
||||
<label for="archive_content_type">Type
|
||||
<select
|
||||
id="archive_content_type"
|
||||
name="archive_content_type"
|
||||
value={$idaa_slct.archive_content_obj.archive_content_type}
|
||||
class="select w-52"
|
||||
>
|
||||
<option value="">-- None --</option>
|
||||
<option value="hosted_file">Hosted File in Æ</option>
|
||||
<option value="html">Hosted HTML in Æ</option>
|
||||
<option value="json">Hosted JSON in Æ</option>
|
||||
<option value="url">External URL</option>
|
||||
<option value="other">Other</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<fieldset class="">
|
||||
<legend class="">Public Access with Rotating Access Key/Passcode</legend>
|
||||
<fieldset class="">
|
||||
<legend class="">Public Access with Rotating Access Key/Passcode</legend>
|
||||
<label for="enable_for_public_no" class="">No, disable public access
|
||||
<input
|
||||
type="radio"
|
||||
@@ -388,127 +396,117 @@ async function handle_submit_form(event) {
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<h3>File?</h3>
|
||||
{#if !$idaa_slct.archive_content_id}
|
||||
FILE INPUT GOES HERE
|
||||
<!-- <Element_input_file_hashing
|
||||
multiple = {false}
|
||||
required = {true}
|
||||
accept = {''}
|
||||
element_id = {'archive_content_file_upload_list'}
|
||||
|
||||
<h3>File?</h3>
|
||||
{#if !$idaa_slct.archive_content_id}
|
||||
FILE INPUT GOES HERE
|
||||
<!-- <Element_input_file_hashing
|
||||
multiple = {false}
|
||||
required = {true}
|
||||
accept = {''}
|
||||
element_id = {'archive_content_file_upload_list'}
|
||||
|
||||
on:input_file_list_updated = {handle_input_file_list_updated}
|
||||
use_selected_file_table={true}
|
||||
/> -->
|
||||
<!-- bind:input_file_list = {$idaa_loc.archives.form_file_upload_list} -->
|
||||
{/if}
|
||||
|
||||
<label for="file_path">File Path
|
||||
{#if !$ae_loc.administrator_access}
|
||||
<span class="fas fa-lock" title="Field is locked"></span>
|
||||
{:else}
|
||||
<span class="fas fa-unlock" title="Field is unlocked"></span>
|
||||
on:input_file_list_updated = {handle_input_file_list_updated}
|
||||
use_selected_file_table={true}
|
||||
/> -->
|
||||
<!-- bind:input_file_list = {$idaa_loc.archives.form_file_upload_list} -->
|
||||
{/if}
|
||||
<input
|
||||
type="text"
|
||||
id="file_path"
|
||||
name="file_path"
|
||||
value={($idaa_slct.archive_content_obj.file_path ? $idaa_slct.archive_content_obj.file_path : '')}
|
||||
readonly={!$ae_loc.administrator_access}
|
||||
class="input w-full"
|
||||
>
|
||||
</label>
|
||||
|
||||
<label for="filename">Filename
|
||||
<input type="text" id="filename" name="filename" value={($idaa_slct.archive_content_obj.filename ? $idaa_slct.archive_content_obj.filename : $idaa_loc.archives.input_filename)} class="input w-full">
|
||||
</label>
|
||||
|
||||
<label for="file_extension">File Extension
|
||||
{#if !$ae_loc.administrator_access}
|
||||
<span class="fas fa-lock" title="Field is locked"></span>
|
||||
{:else}
|
||||
<span class="fas fa-unlock" title="Field is unlocked"></span>
|
||||
{/if}
|
||||
<input
|
||||
type="text"
|
||||
id="file_extension"
|
||||
name="file_extension"
|
||||
value={($idaa_slct.archive_content_obj.file_extension ? $idaa_slct.archive_content_obj.file_extension : $idaa_loc.archives.input_file_extension)}
|
||||
readonly={!$ae_loc.administrator_access}
|
||||
class="input w-24"
|
||||
>
|
||||
</label>
|
||||
|
||||
<h3>Original</h3>
|
||||
<label for="original_datetime">Original Date/Time
|
||||
<input type="date" id="original_datetime_date" name="original_datetime_date" value={($idaa_slct.archive_content_obj.original_datetime ? ae_util.iso_datetime_formatter($idaa_slct.archive_content_obj.original_datetime,'date_iso') : '')} placeholder="YYYY-MM-DD" class="input w-48">
|
||||
<input type="time" id="original_datetime_time" name="original_datetime_time" value={($idaa_slct.archive_content_obj.original_datetime ? ae_util.iso_datetime_formatter($idaa_slct.archive_content_obj.original_datetime,'time_iso') : '')} placeholder="HH:MM AM/PM" class="input w-48">
|
||||
</label>
|
||||
|
||||
<fieldset class="flex_row flex_gap_md flex_justify_around">
|
||||
<label for="original_timezone">Original Timezone
|
||||
{#if lu_time_zone_list}
|
||||
<select
|
||||
id="original_timezone"
|
||||
name="original_timezone"
|
||||
required
|
||||
value={($idaa_slct.archive_content_obj.original_timezone ? $idaa_slct.archive_content_obj.original_timezone : $ae_loc.current_timezone)}
|
||||
class="select w-56"
|
||||
title="Select the original timezone"
|
||||
>
|
||||
<option value="">-- None --</option>
|
||||
{#each lu_time_zone_list as lu_timezone}
|
||||
<option
|
||||
value="{lu_timezone.name}"
|
||||
>
|
||||
{lu_timezone.name}
|
||||
</option>
|
||||
{/each}
|
||||
</select>
|
||||
<label for="file_path">File Path
|
||||
{#if !$ae_loc.administrator_access}
|
||||
<span class="fas fa-lock" title="Field is locked"></span>
|
||||
{:else}
|
||||
<input type="text" name="timezone" value={($idaa_slct.archive_content_obj.original_timezone ? $idaa_slct.archive_content_obj.original_timezone : $ae_loc.current_timezone)} class="input w-56"/>
|
||||
<span class="fas fa-unlock" title="Field is unlocked"></span>
|
||||
{/if}
|
||||
<input
|
||||
type="text"
|
||||
id="file_path"
|
||||
name="file_path"
|
||||
value={($idaa_slct.archive_content_obj.file_path ? $idaa_slct.archive_content_obj.file_path : '')}
|
||||
readonly={!$ae_loc.administrator_access}
|
||||
class="input w-full"
|
||||
>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<!-- <label for="original_timezone">Original Timezone
|
||||
<input type="text" id="original_timezone" name="original_timezone" value={$idaa_slct.archive_content_obj.original_timezone} list="timezones">
|
||||
<datalist id="timezones">
|
||||
<option value="UTC">UTC</option>
|
||||
<option value="America/New_York">America/New York</option>
|
||||
<option value="America/Chicago">America/Chicago</option>
|
||||
<option value="America/Denver">America/Denver</option>
|
||||
<option value="America/Phoenix">America/Phoenix</option>
|
||||
<option value="America/Los_Angeles">America/Los Angeles</option>
|
||||
<option value="America/Anchorage">America/Anchorage</option>
|
||||
<option value="America/Adak">America/Adak</option>
|
||||
<option value="Pacific/Honolulu">Pacific/Honolulu</option>
|
||||
<option value="Pacific/Midway">Pacific/Midway</option>
|
||||
<option value="US/Eastern">US/Eastern</option>
|
||||
<option value="US/Central">US/Central</option>
|
||||
<option value="US/Mountain">US/Mountain</option>
|
||||
<option value="US/Pacific">US/Pacific</option>
|
||||
<option value="US/Alaska">US/Alaska</option>
|
||||
<option value="US/Hawaii">US/Hawaii</option>
|
||||
<option value="US/Samoa">US/Samoa</option>
|
||||
<option value="US/Aleutian">US/Aleutian</option>
|
||||
<option value="US/Arizona">US/Arizona</option>
|
||||
<option value="US/Michigan">US/Michigan</option>
|
||||
</datalist>
|
||||
</label> -->
|
||||
<label for="filename">Filename
|
||||
<input type="text" id="filename" name="filename" value={($idaa_slct.archive_content_obj.filename ? $idaa_slct.archive_content_obj.filename : $idaa_loc.archives.input_filename)} class="input w-full">
|
||||
</label>
|
||||
|
||||
<label for="original_location">Original Location
|
||||
<input type="text" id="original_location" name="original_location" value={$idaa_slct.archive_content_obj.original_location} class="input w-full">
|
||||
</label>
|
||||
<label for="file_extension">File Extension
|
||||
{#if !$ae_loc.administrator_access}
|
||||
<span class="fas fa-lock" title="Field is locked"></span>
|
||||
{:else}
|
||||
<span class="fas fa-unlock" title="Field is unlocked"></span>
|
||||
{/if}
|
||||
<input
|
||||
type="text"
|
||||
id="file_extension"
|
||||
name="file_extension"
|
||||
value={($idaa_slct.archive_content_obj.file_extension ? $idaa_slct.archive_content_obj.file_extension : $idaa_loc.archives.input_file_extension)}
|
||||
readonly={!$ae_loc.administrator_access}
|
||||
class="input w-24"
|
||||
>
|
||||
</label>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="ae_section archive_content__original border border-gray-200 rounded p-2 space-y-2">
|
||||
|
||||
<h3 class="h3">Original</h3>
|
||||
|
||||
<label for="original_datetime">Original Date/Time
|
||||
<input type="date" id="original_datetime_date" name="original_datetime_date" value={($idaa_slct.archive_content_obj.original_datetime ? ae_util.iso_datetime_formatter($idaa_slct.archive_content_obj.original_datetime,'date_iso') : '')} placeholder="YYYY-MM-DD" class="input w-48">
|
||||
<input type="time" id="original_datetime_time" name="original_datetime_time" value={($idaa_slct.archive_content_obj.original_datetime ? ae_util.iso_datetime_formatter($idaa_slct.archive_content_obj.original_datetime,'time_iso') : '')} placeholder="HH:MM AM/PM" class="input w-48">
|
||||
</label>
|
||||
|
||||
<fieldset class="flex_row flex_gap_md flex_justify_around">
|
||||
<label for="original_timezone">Original Timezone
|
||||
{#if lu_time_zone_list}
|
||||
<select
|
||||
id="original_timezone"
|
||||
name="original_timezone"
|
||||
required
|
||||
value={($idaa_slct.archive_content_obj.original_timezone ? $idaa_slct.archive_content_obj.original_timezone : $ae_loc.current_timezone)}
|
||||
class="select w-56"
|
||||
title="Select the original timezone"
|
||||
>
|
||||
<option value="">-- None --</option>
|
||||
{#each lu_time_zone_list as lu_timezone}
|
||||
<option
|
||||
value="{lu_timezone.name}"
|
||||
>
|
||||
{lu_timezone.name}
|
||||
</option>
|
||||
{/each}
|
||||
</select>
|
||||
{:else}
|
||||
<input type="text" name="timezone" value={($idaa_slct.archive_content_obj.original_timezone ? $idaa_slct.archive_content_obj.original_timezone : $ae_loc.current_timezone)} class="input w-56" />
|
||||
{/if}
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<label for="original_location">Original Location
|
||||
<input type="text" id="original_location" name="original_location" value={$idaa_slct.archive_content_obj.original_location} class="input w-full">
|
||||
</label>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
{#if $ae_loc.trusted_access}
|
||||
<section class="ae_section archive_content__admin_options"> <!-- BEGIN: section archive_content__admin_options -->
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm variant-soft-secondary float-right"
|
||||
on:click={() => {
|
||||
$idaa_loc.archives.show__admin_options = !$idaa_loc.archives.show__admin_options;
|
||||
}}
|
||||
>
|
||||
<span class="fas fa-eye m-1"></span>
|
||||
{$idaa_loc.archives.show__admin_options ? 'Hide' : 'Show'} Admin
|
||||
</button>
|
||||
|
||||
<h3>
|
||||
<section class="ae_section archive_content__admin_options border border-gray-200 rounded p-2 space-y-2"> <!-- BEGIN: section archive_content__admin_options -->
|
||||
|
||||
<h3 class="h3">
|
||||
Admin Options
|
||||
<button type="button" class="btn btn-sm variant-soft-secondary" on:click={() => {document.querySelector('.ae_d_none_content').classList.toggle('ae_d_none');}}><span class="fas fa-eye m-1"></span> Show/Hide Admin</button>
|
||||
</h3>
|
||||
|
||||
<span class="ae_d_none_content ae_d_none">
|
||||
@@ -561,7 +559,7 @@ async function handle_submit_form(event) {
|
||||
{/if}
|
||||
|
||||
|
||||
<section class="ae_section ae_options ae_row">
|
||||
<section class="ae_section ae_options flex flex-row gap-1 items-center justify-center">
|
||||
<button type="submit" class="btn btn-md variant-ghost-primary">
|
||||
<span class="fas fa-check m-1"></span> Save Archive Content
|
||||
</button>
|
||||
@@ -575,15 +573,15 @@ async function handle_submit_form(event) {
|
||||
$idaa_slct.archive_content_id = null;
|
||||
$idaa_slct.archive_content_obj = {};
|
||||
}}
|
||||
class="ae_btn ae_smallest btn btn-danger" type="button">
|
||||
<span class="fas fa-minus"></span> Delete
|
||||
class="btn btn-sm variant-soft-warning" type="button">
|
||||
<span class="fas fa-minus m-1"></span> Delete
|
||||
</button>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
</form>
|
||||
|
||||
</section>
|
||||
</section> <!-- END: section ae_edit archive_content_obj -->
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
@@ -133,7 +133,7 @@ onMount(() => {
|
||||
$idaa_sess.archives.show__modal_view__archive_content_id = false;
|
||||
$idaa_sess.archives.show__modal_edit__archive_content_id = $idaa_slct.archive_content_id;
|
||||
}}
|
||||
class="btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
|
||||
class="btn btn-sm variant-glass-warning hover:variant-filled-warning transition"
|
||||
title={`Edit archive: ${idaa_archive_content_obj?.name}`}
|
||||
>
|
||||
<span class="fas fa-edit m-1"></span> Edit Content
|
||||
@@ -144,7 +144,7 @@ onMount(() => {
|
||||
<!-- Doing some checks before the media player/viewer shows. The player should be the only one showing. So there is a sort of global check first. -->
|
||||
{#if idaa_archive_content_obj.archive_content_id == $idaa_sess.archives.show_view__archive_content_media}
|
||||
<!-- <Player_archive_content_obj archive_content_id={idaa_archive_content_obj.archive_content_id_random} /> -->
|
||||
Player Goes Here
|
||||
Player Goes Here
|
||||
{/if}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,478 @@
|
||||
<script lang="ts">
|
||||
export let log_lvl = 1;
|
||||
// *** Import Svelte core
|
||||
import { onMount } from 'svelte';
|
||||
import { fade } from 'svelte/transition';
|
||||
import { Spinner } from 'flowbite-svelte';
|
||||
|
||||
// *** Import Aether core variables and functions
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
import { core_func } from '$lib/ae_core/ae_core_functions';
|
||||
import { api } from '$lib/api';
|
||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
import { idaa_loc, idaa_sess, idaa_slct } from '$lib/ae_idaa_stores';
|
||||
|
||||
import Tiptap_editor from '$lib/element_tiptap_editor.svelte';
|
||||
|
||||
|
||||
export let lq__archive_obj: any;
|
||||
|
||||
|
||||
let create_archive_obj_promise: any;
|
||||
let delete_archive_obj_promise: any;
|
||||
let update_archive_obj_promise: any;
|
||||
let upload__hosted_file_obj_promise: any;
|
||||
|
||||
let disable_submit_btn = true;
|
||||
|
||||
let lu_time_zone_list:any = localStorage.getItem('lu_time_zone_list') ? JSON.parse(localStorage.getItem('lu_time_zone_list')) : [];
|
||||
$ae_loc.lu_time_zone_list = [];
|
||||
// $ae_loc.lu_time_zone_list = [];
|
||||
if (lu_time_zone_list && lu_time_zone_list.length > 0) {
|
||||
// console.log('Already have time zone list!', lu_time_zone_list);
|
||||
} else {
|
||||
console.log('No time zone list');
|
||||
|
||||
let lu_time_zone_li_get_promise = core_func.load_ae_obj_li__time_zone({
|
||||
api_cfg: $ae_api,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (lu_time_zone_li_get_result) {
|
||||
/* We need to save the time zone list to localStore */
|
||||
if (lu_time_zone_li_get_result) {
|
||||
lu_time_zone_list = lu_time_zone_li_get_result;
|
||||
localStorage.setItem('lu_time_zone_list', JSON.stringify(lu_time_zone_li_get_result));
|
||||
if (log_lvl) {
|
||||
console.log(`Time zone list:`, lu_time_zone_list);
|
||||
}
|
||||
} else {
|
||||
console.log(`No time zones returned!`);
|
||||
// $ae_loc.lu_time_zone_list = [];
|
||||
}
|
||||
|
||||
|
||||
if (lu_time_zone_li_get_result) {
|
||||
lu_time_zone_list = lu_time_zone_li_get_result;
|
||||
console.log(`Time zone list:`, lu_time_zone_list);
|
||||
console.log(lu_time_zone_list[0]);
|
||||
console.log(lu_time_zone_list[10]);
|
||||
} else {
|
||||
console.log(`No time zones returned!`);
|
||||
lu_time_zone_list = [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
onMount(() => {
|
||||
console.log('** Component Mounted: ** ID - Archive Obj - Edit');
|
||||
});
|
||||
|
||||
|
||||
|
||||
async function handle_submit_form(event) {
|
||||
console.log('*** handle_submit_form() ***');
|
||||
|
||||
disable_submit_btn = true;
|
||||
|
||||
let form_data = new FormData(event.target);
|
||||
console.log(form_data);
|
||||
|
||||
let form_archive_data = ae_util.extract_prefixed_form_data({prefix: null, form_data: form_data, trim_values: true, bool_tf_str: true, log_lvl: 0});
|
||||
console.log(form_archive_data);
|
||||
|
||||
let archive_data: key_val = {};
|
||||
|
||||
if (!$idaa_slct.archive_id) {
|
||||
archive_data['account_id_random'] = $ae_loc.account_id;
|
||||
archive_data['enable'] = true;
|
||||
}
|
||||
|
||||
archive_data['name'] = form_archive_data.name;
|
||||
if (tinyMCE.get('description')) {
|
||||
archive_data['description'] = tinyMCE.get('description').getContent();
|
||||
} else {
|
||||
archive_data['description'] = form_archive_data.description;
|
||||
}
|
||||
|
||||
if (tinyMCE.get('content_html')) {
|
||||
archive_data['content_html'] = tinyMCE.get('content_html').getContent();
|
||||
} else {
|
||||
archive_data['content_html'] = form_archive_data.content_html;
|
||||
}
|
||||
|
||||
let date_time_str = null;
|
||||
let date_part = form_archive_data.original_datetime_date.trim();
|
||||
let time_part = form_archive_data.original_datetime_time.trim();
|
||||
if (date_part && time_part) {
|
||||
date_time_str = `${date_part} ${time_part}`;
|
||||
} else if (date_part) {
|
||||
date_time_str = `${date_part}T00:00:00`;
|
||||
} else if (time_part) {
|
||||
// date_time_str = `${time_part}`;
|
||||
date_time_str = false;
|
||||
}
|
||||
archive_data['original_datetime'] = date_time_str;
|
||||
|
||||
archive_data['original_timezone'] = form_archive_data.original_timezone;
|
||||
|
||||
archive_data['original_location'] = form_archive_data.original_location;
|
||||
|
||||
archive_data['original_url'] = form_archive_data.original_url;
|
||||
archive_data['original_url_text'] = form_archive_data.original_url_text;
|
||||
|
||||
archive_data['hide'] = !!form_archive_data.hide;
|
||||
archive_data['priority'] = !!form_archive_data.priority;
|
||||
if (form_archive_data.sort) {
|
||||
archive_data['sort'] = Number(form_archive_data.sort);
|
||||
} else {
|
||||
archive_data['sort'] = null;
|
||||
}
|
||||
if (form_archive_data.group) {
|
||||
archive_data['group'] = form_archive_data.group;
|
||||
} else {
|
||||
archive_data['group'] = null;
|
||||
}
|
||||
|
||||
if (form_archive_data.enable) {
|
||||
archive_data['enable'] = !!form_archive_data.enable;
|
||||
}
|
||||
|
||||
if (tinyMCE.get('notes')) {
|
||||
archive_data['notes'] = tinyMCE.get('notes').getContent();
|
||||
} else {
|
||||
archive_data['notes'] = form_archive_data.notes;
|
||||
}
|
||||
|
||||
console.log(archive_data);
|
||||
|
||||
if (!$idaa_slct.archive_id) {
|
||||
create_archive_obj_promise = api.create_ae_obj_crud({
|
||||
api_cfg: $ae_api,
|
||||
obj_type: 'archive',
|
||||
fields: archive_data,
|
||||
key: $ae_api.api_crud_super_key,
|
||||
log_lvl: 1
|
||||
})
|
||||
.then(function (archive_obj_create_result) {
|
||||
if (!archive_obj_create_result) {
|
||||
console.log('The result was null or false.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$idaa_slct.archive_id = archive_obj_create_result.obj_id_random;
|
||||
|
||||
dispatch(
|
||||
'created__archive_obj',
|
||||
{
|
||||
archive_id: $idaa_slct.archive_id,
|
||||
}
|
||||
);
|
||||
|
||||
return archive_obj_create_result;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('Something went wrong.');
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
|
||||
return create_archive_obj_promise;
|
||||
|
||||
} else {
|
||||
update_archive_obj_promise = api.update_ae_obj_id_crud({
|
||||
api_cfg: $ae_api,
|
||||
obj_type: 'archive',
|
||||
obj_id: $idaa_slct.archive_id,
|
||||
fields: archive_data,
|
||||
key: $ae_api.api_crud_super_key,
|
||||
log_lvl: 1
|
||||
})
|
||||
.then(function (archive_obj_update_result) {
|
||||
if (!archive_obj_update_result) {
|
||||
console.log('The result was null or false.');
|
||||
return false;
|
||||
}
|
||||
|
||||
dispatch(
|
||||
'updated__archive_obj',
|
||||
{
|
||||
archive_id: $idaa_slct.archive_id,
|
||||
}
|
||||
);
|
||||
|
||||
return archive_obj_update_result;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('Something went wrong.');
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
|
||||
return update_archive_obj_promise;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<section
|
||||
class="svelte_component ae_edit archive_obj"
|
||||
class:ae_create={!$idaa_slct.archive_id}
|
||||
bind:clientHeight={$ae_loc.iframe_height_modal_body}
|
||||
>
|
||||
|
||||
<form on:submit|preventDefault={handle_submit_form} class="space-y-2">
|
||||
|
||||
{#await update_archive_obj_promise}
|
||||
<div class="awaiting alert_msg_pulse" out:fade={{ duration: 2000 }}>Saving...</div>
|
||||
{:then}
|
||||
{#if update_archive_obj_promise}
|
||||
<div class="awaiting" out:fade={{ duration: 2000 }}>Finished saving</div>
|
||||
{:else}
|
||||
<!-- <div class="awaiting" out:fade={{ duration: 2000 }}>Nothing here yet</div> -->
|
||||
{/if}
|
||||
{/await}
|
||||
|
||||
<!-- <h2 class="h2">Archive</h2> -->
|
||||
|
||||
<section class="ae_section archive__general border border-gray-200 rounded p-2 space-y-2">
|
||||
<label for="name">Name of Archive
|
||||
<input
|
||||
type="text" id="name" name="name"
|
||||
required max="20" value={$idaa_slct.archive_obj.name ? $idaa_slct.archive_obj.name : 'Testing!' }
|
||||
class="input w-full"
|
||||
placeholder="Name of Archive"
|
||||
>
|
||||
</label>
|
||||
|
||||
<label for="description">
|
||||
Description
|
||||
<Tiptap_editor
|
||||
default_minimal={true}
|
||||
bind:html_text={$idaa_slct.archive_obj.description}
|
||||
show_button_kv={{'heading__h1': false, 'heading__h2': false, 'heading__h3': false}}
|
||||
bind:new_html={$idaa_slct.archive_obj.description_new_html}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<!-- <label for="content_html">Content (HTML)
|
||||
<Tiptap_editor
|
||||
default_minimal={true}
|
||||
bind:html_text={$idaa_slct.archive_obj.content_html}
|
||||
show_button_kv={{'heading__h1': false, 'heading__h2': false, 'heading__h3': false}}
|
||||
bind:new_html={$idaa_slct.archive_obj.content_html_new_html}
|
||||
/>
|
||||
</label> -->
|
||||
|
||||
</section>
|
||||
|
||||
<section class="ae_section archive__original border border-gray-200 rounded p-2 space-y-2">
|
||||
|
||||
<h3 class="h3">Original</h3>
|
||||
|
||||
<label for="original_datetime">Original Date/Time
|
||||
<input type="date" id="original_datetime_date" name="original_datetime_date" value={($idaa_slct.archive_obj.original_datetime ? ae_util.iso_datetime_formatter($idaa_slct.archive_obj.original_datetime,'date_iso') : '')} placeholder="YYYY-MM-DD" class="input w-48">
|
||||
<input type="time" id="original_datetime_time" name="original_datetime_time" value={($idaa_slct.archive_obj.original_datetime ? ae_util.iso_datetime_formatter($idaa_slct.archive_obj.original_datetime,'time_iso') : '')} placeholder="HH:MM AM/PM" class="input w-48">
|
||||
</label>
|
||||
|
||||
<fieldset class="flex_row flex_gap_md flex_justify_around">
|
||||
<label for="original_timezone">Original Timezone
|
||||
{#if lu_time_zone_list}
|
||||
<select
|
||||
name="original_timezone"
|
||||
id="original_timezone"
|
||||
required
|
||||
value={(($idaa_slct.archive_obj.original_timezone ? $idaa_slct.archive_obj.original_timezone : $ae_loc.current_timezone))}
|
||||
class="select w-56"
|
||||
title="Select the original timezone"
|
||||
>
|
||||
<option value="">-- None --</option>
|
||||
{#each lu_time_zone_list as lu_timezone}
|
||||
<option value="{lu_timezone.name}">
|
||||
{lu_timezone.name}
|
||||
</option>
|
||||
{/each}
|
||||
</select>
|
||||
{:else}
|
||||
<input type="text" name="timezone" value={($idaa_slct.archive_obj.original_timezone ? $idaa_slct.archive_obj.original_timezone : $ae_loc.current_timezone)} class="input w-56" />
|
||||
{/if}
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<!-- <label for="original_timezone">Original Timezone
|
||||
<input type="text" id="original_timezone" name="original_timezone" value={($idaa_slct.archive_obj.original_timezone ? $idaa_slct.archive_obj.original_timezone : $ae_loc.current_timezone)} placeholder="Timezone" list="timezones">
|
||||
<datalist id="timezones">
|
||||
<option value="UTC">UTC</option>
|
||||
<option value="America/New_York">America/New York</option>
|
||||
<option value="America/Chicago">America/Chicago</option>
|
||||
<option value="America/Denver">America/Denver</option>
|
||||
<option value="America/Phoenix">America/Phoenix</option>
|
||||
<option value="America/Los_Angeles">America/Los Angeles</option>
|
||||
<option value="America/Anchorage">America/Anchorage</option>
|
||||
<option value="America/Adak">America/Adak</option>
|
||||
<option value="Pacific/Honolulu">Pacific/Honolulu</option>
|
||||
<option value="Pacific/Midway">Pacific/Midway</option>
|
||||
<option value="US/Eastern">US/Eastern</option>
|
||||
<option value="US/Central">US/Central</option>
|
||||
<option value="US/Mountain">US/Mountain</option>
|
||||
<option value="US/Pacific">US/Pacific</option>
|
||||
<option value="US/Alaska">US/Alaska</option>
|
||||
<option value="US/Hawaii">US/Hawaii</option>
|
||||
<option value="US/Samoa">US/Samoa</option>
|
||||
<option value="US/Aleutian">US/Aleutian</option>
|
||||
<option value="US/Arizona">US/Arizona</option>
|
||||
<option value="US/Michigan">US/Michigan</option>
|
||||
</datalist>
|
||||
</label> -->
|
||||
|
||||
<label for="original_location">Original Location
|
||||
<input type="text" id="original_location" name="original_location" value={($idaa_slct.archive_obj.original_location ? $idaa_slct.archive_obj.original_location : '')} placeholder="Location" class="input w-full">
|
||||
</label>
|
||||
|
||||
<label for="original_url">Original URL
|
||||
<input type="text" id="original_url" name="original_url" max="255" value={$idaa_slct.archive_obj.original_url ? $idaa_slct.archive_obj.original_url : '' } placeholder="URL" class="input w-full">
|
||||
</label>
|
||||
|
||||
<label for="original_url_text">Original URL Text/Title
|
||||
<input type="text" id="original_url_text" name="original_url_text" max="255" value={$idaa_slct.archive_obj.original_url_text ? $idaa_slct.archive_obj.original_url_text : '' } placeholder="URL text or title" class="input w-full">
|
||||
</label>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<!-- <h3>Archiver's Options</h3> -->
|
||||
|
||||
<!-- <fieldset class="">
|
||||
<legend class="">Official or Member Archive</legend>
|
||||
<div class="">
|
||||
<input type="radio" class="" id="group_official" name="group" value="official">
|
||||
<label for="group_official" class="">Archive as Official/Leadership</label>
|
||||
</div>
|
||||
<div class="">
|
||||
<input type="radio" class="" id="group_member" name="group" value="member" checked="">
|
||||
<label for="group_member" class="">Archive as Member</label>
|
||||
</div>
|
||||
</fieldset> -->
|
||||
|
||||
<!-- <fieldset class="">
|
||||
<legend class="">Enable Comments</legend>
|
||||
<div class="">
|
||||
<input type="radio" class="" id="enable_comments_no" name="enable_comments" value="0">
|
||||
<label for="enable_comments_no" class="">No, do not allow comments</label>
|
||||
</div>
|
||||
<div class="">
|
||||
<input type="radio" class="" id="enable_comments_yes" name="enable_comments" value="1" checked>
|
||||
<label for="enable_comments_yes" class="">Yes, allow comments</label>
|
||||
</div>
|
||||
</fieldset> -->
|
||||
|
||||
|
||||
{#if $ae_loc.trusted_access}
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm variant-soft-secondary float-right"
|
||||
on:click={() => {
|
||||
$idaa_loc.archives.show__admin_options = !$idaa_loc.archives.show__admin_options;
|
||||
}}
|
||||
>
|
||||
<span class="fas fa-eye m-1"></span>
|
||||
{$idaa_loc.archives.show__admin_options ? 'Hide' : 'Show'} Admin
|
||||
</button>
|
||||
|
||||
<section
|
||||
class="ae_section archive__admin_options border border-gray-200 rounded p-2 space-y-2"
|
||||
class:hidden={!$idaa_loc.archives.show__admin_options}
|
||||
> <!-- BEGIN: section archive__admin_options -->
|
||||
<!-- <div
|
||||
class="border border-gray-200 rounded p-2"
|
||||
class:hidden={!$idaa_loc.archives.show__admin_options}
|
||||
> -->
|
||||
|
||||
<h3 class="h3">
|
||||
Admin Options
|
||||
</h3>
|
||||
|
||||
<label>Hide
|
||||
<input
|
||||
type="checkbox"
|
||||
name="hide"
|
||||
id="hide"
|
||||
bind:checked={$idaa_slct.archive_obj.hide}
|
||||
class="checkbox"
|
||||
>
|
||||
<!-- <input type="checkbox" name="hide" value={$idaa_slct.archive_obj.hide} /> -->
|
||||
</label>
|
||||
|
||||
<label>Priority
|
||||
<input
|
||||
type="checkbox"
|
||||
name="priority"
|
||||
id="priority"
|
||||
bind:checked={$idaa_slct.archive_obj.priority}
|
||||
class="checkbox"
|
||||
>
|
||||
<!-- <input type="checkbox" name="priority" value={$idaa_slct.archive_obj.priority} /> -->
|
||||
</label>
|
||||
|
||||
<label>Sort <input type="number" name="sort" value={$idaa_slct.archive_obj.sort} /></label>
|
||||
|
||||
<label>Group <input type="text" name="group" value={$idaa_slct.archive_obj.group} max="100" /></label>
|
||||
|
||||
{#if $ae_loc.administrator_access}
|
||||
<label>Enable
|
||||
<input
|
||||
type="checkbox"
|
||||
name="enable"
|
||||
id="enable"
|
||||
bind:checked={$idaa_slct.archive_obj.enable}
|
||||
class="checkbox"
|
||||
>
|
||||
<!-- <input type="checkbox" name="enable" value={$idaa_slct.archive_obj.enable} checked={$idaa_slct.archive_obj.enable} /> -->
|
||||
</label>
|
||||
{/if}
|
||||
|
||||
<label>
|
||||
Internal Staff Notes
|
||||
<Tiptap_editor
|
||||
default_minimal={true}
|
||||
bind:html_text={$idaa_slct.archive_obj.notes}
|
||||
show_button_kv={{'heading__h1': false, 'heading__h2': false, 'heading__h3': false}}
|
||||
bind:new_html={$idaa_slct.archive_obj.notes_new_html}
|
||||
/>
|
||||
</label>
|
||||
|
||||
</section> <!-- END: section archive__admin_options -->
|
||||
{/if}
|
||||
|
||||
|
||||
<section class="ae_section ae_options flex flex-row gap-1 items-center justify-center">
|
||||
<button type="submit" class="btn btn-md variant-ghost-primary hover:variant-filled-primary transition"><span class="fas fa-check m-1"></span> Save Archive</button>
|
||||
|
||||
{#if $idaa_slct.archive_id}
|
||||
<button
|
||||
on:click={() => {
|
||||
if (!confirm('Are you sure you want to delete this archive?')) {return false;}
|
||||
handle_delete_archive_obj({archive_id: $idaa_slct.archive_id});
|
||||
|
||||
$idaa_slct.archive_id = null;
|
||||
$idaa_slct.archive_obj = {};
|
||||
}}
|
||||
class="btn btn-sm variant-soft-warning" type="button">
|
||||
<span class="fas fa-minus m-1"></span> Delete
|
||||
</button>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
</form>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<style>
|
||||
</style>
|
||||
@@ -71,12 +71,12 @@ onMount(() => {
|
||||
on:click={() => {
|
||||
$slct.archive_content_id = null;
|
||||
$slct.archive_content_obj = {};
|
||||
$idaa_loc.archives.show_edit__archive_content_id = true;
|
||||
$idaa_sess.archives.show_edit__archive_content_id = true;
|
||||
}}
|
||||
class="ae_btn ae_smallest btn btn-warning"
|
||||
class="btn btn-sm variant-glass-warning"
|
||||
title={`Add content for: ${$lq__archive_obj?.name}`}
|
||||
>
|
||||
<span class="fas fa-plus"></span> Add Content
|
||||
<span class="fas fa-plus m-1"></span> Add Content
|
||||
</button>
|
||||
|
||||
<button
|
||||
@@ -84,19 +84,21 @@ onMount(() => {
|
||||
// $slct.archive_id = $lq__archive_obj?.archive_id_random;
|
||||
// $lq__archive_obj? = $lq__archive_obj?;
|
||||
|
||||
$idaa_slct.archive_obj = $lq__archive_obj;
|
||||
|
||||
// const url = new URL(location);
|
||||
// url.searchParams.set('archive_id', $lq__archive_obj?.archive_id_random);
|
||||
// history.pushState({}, '', url);
|
||||
|
||||
// $idaa_loc.archives.show_main__options = false;
|
||||
// $idaa_loc.archives.show_list__archive_obj_li = false;
|
||||
$idaa_loc.archives.show_view__archive_obj = false;
|
||||
$idaa_loc.archives.show_edit__archive_obj = true;
|
||||
// $idaa_sess.archives.show_main__options = false;
|
||||
// $idaa_sess.archives.show_list__archive_obj_li = false;
|
||||
$idaa_sess.archives.show__modal_view__archive_id = false;
|
||||
$idaa_sess.archives.show__modal_edit__archive_id = $idaa_slct.archive_id;
|
||||
}}
|
||||
class="ae_btn ae_smallest btn btn-xs btn-warning"
|
||||
class="btn btn-sm variant-glass-warning"
|
||||
title={`Edit archive: ${$lq__archive_obj?.name}`}
|
||||
>
|
||||
<span class="fas fa-edit"></span> Edit Archive
|
||||
<span class="fas fa-edit m-1"></span> Edit Archive
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -93,8 +93,8 @@ onMount(() => {
|
||||
$idaa_slct.archive_id = idaa_archive_obj.archive_id;
|
||||
$idaa_slct.archive_obj = idaa_archive_obj;
|
||||
|
||||
$idaa_sess.archives.show__modal_view = false;
|
||||
$idaa_sess.archives.show__modal_edit__archive_obj = true;
|
||||
$idaa_sess.archives.show__modal_view__archive_id = false;
|
||||
$idaa_sess.archives.show__modal_edit__archive_id = $idaa_slct.archive_id;
|
||||
}}
|
||||
class="btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
|
||||
title={`Edit archive: ${idaa_archive_obj.title}`}
|
||||
|
||||
@@ -1248,7 +1248,7 @@ async function handle_delete_event_obj({event_id, method='disable'}) {
|
||||
if (!confirm('Are you sure you want to create this event?')) {return false;}
|
||||
// handle_save_event_obj({event_id: $idaa_slct.event_id, method: 'create'});
|
||||
}}
|
||||
class="ae_btn btn_primary btn btn-primary variant-ghost-primary hover:variant-filled-primary transition"
|
||||
class="btn btn-md variant-ghost-primary hover:variant-filled-primary transition"
|
||||
>
|
||||
{#await prom_api__event_obj}
|
||||
<span class="fas fa-spinner fa-spin m-1"></span> Saving
|
||||
|
||||
Reference in New Issue
Block a user