feat(events): reorganize badge admin tools and enhance dependency tracking
- Migrated 'Add New Badge' and 'Upload Badge List' to centralized Event Settings hub. - Secured Admin Tools visibility with Administrator access and Edit Mode requirements. - Restored and modernized Badge Template management route with Svelte 5 runes. - Patched 'Archive' and 'Session' database interfaces to resolve compiler errors. - Added project-wide dependency comments to key interfaces (Archive, Badge, Session) to prevent cascading change regressions. - Fixed duplicate import errors in the Settings page.
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import { browser } from '$app/environment';
|
||||
import { goto } from '$app/navigation';
|
||||
import { liveQuery } from 'dexie';
|
||||
import { db_events, type Event } from '$lib/ae_events/db_events';
|
||||
import { onMount } from 'svelte';
|
||||
import { events_func } from '$lib/ae_events_functions';
|
||||
import { ae_api } from '$lib/stores/ae_stores';
|
||||
import { ae_loc, ae_api } from '$lib/stores/ae_stores';
|
||||
import AE_Comp_Editor_CodeMirror from '$lib/elements/AE_Comp_Editor_CodeMirror.svelte';
|
||||
import Ae_comp_event_settings_form from './ae_comp__event_settings_form.svelte';
|
||||
import Ae_comp_event_settings_pres_mgmt_form from './ae_comp__event_settings_pres_mgmt_form.svelte';
|
||||
import Ae_comp_event_settings_basic_form from './ae_comp__event_settings_basic_form.svelte';
|
||||
import Ae_comp_event_settings_badges_form from './ae_comp__event_settings_badges_form.svelte';
|
||||
import Ae_comp_event_settings_abstracts_form from './ae_comp__event_settings_abstracts_form.svelte';
|
||||
import { Modal } from 'flowbite-svelte';
|
||||
import Comp_badge_create_form from '../(badges)/badges/ae_comp__badge_create_form.svelte';
|
||||
import Comp_badge_upload_form from '../(badges)/badges/ae_comp__badge_upload_form.svelte';
|
||||
|
||||
let event_id = page.params.event_id as string;
|
||||
let event_obj: Event | undefined | null = $state(null);
|
||||
@@ -19,6 +24,17 @@
|
||||
let badges_json_view = $state('form');
|
||||
let abstracts_json_view = $state('form');
|
||||
|
||||
let show_create_badge_modal: boolean = $state(false);
|
||||
let show_upload_badge_modal: boolean = $state(false);
|
||||
|
||||
// Guard: Only allow administrators in edit mode
|
||||
if (!$ae_loc.administrator_access || !$ae_loc.edit_mode) {
|
||||
if (browser) {
|
||||
alert('Access Denied: Administrative privileges and Edit Mode required.');
|
||||
goto(`/events/${event_id}`);
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
const observable = liveQuery(() => db_events.event.get(event_id));
|
||||
const subscription = observable.subscribe((value) => {
|
||||
@@ -60,6 +76,62 @@
|
||||
{#if event_obj}
|
||||
<div class="space-y-4">
|
||||
<details class="details" open>
|
||||
<summary class="summary font-bold text-error-500">Admin Tools</summary>
|
||||
<div class="p-4 space-y-4">
|
||||
<div class="card p-4 border rounded-md text-center">
|
||||
<h4 class="h4">Badge Operations</h4>
|
||||
<div class="flex flex-wrap justify-center gap-2 mt-2">
|
||||
<button type="button" class="btn btn-primary" onclick={() => (show_create_badge_modal = true)}>
|
||||
<span class="fas fa-plus mr-2"></span> Add New Badge
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary ml-2" onclick={() => (show_upload_badge_modal = true)}>
|
||||
<span class="fas fa-upload mr-2"></span> Upload Badge List
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card p-4 border rounded-md text-center">
|
||||
<h4 class="h4">Mass Print Options</h4>
|
||||
<div class="flex flex-wrap justify-center gap-2 mt-2">
|
||||
<a
|
||||
href={`/events/${event_id}/badges/print_list?printed_status=not_printed`}
|
||||
class="btn variant-filled-secondary"
|
||||
>
|
||||
<span class="fas fa-print mr-2"></span> Print All Unprinted
|
||||
</a>
|
||||
<a
|
||||
href={`/events/${event_id}/badges/print_list?badge_type_code=guest&printed_status=not_printed`}
|
||||
class="btn variant-filled-secondary"
|
||||
>
|
||||
<span class="fas fa-print mr-2"></span> Print Unprinted Guests
|
||||
</a>
|
||||
<a
|
||||
href={`/events/${event_id}/badges/print_list`}
|
||||
class="btn variant-filled-secondary"
|
||||
>
|
||||
<span class="fas fa-print mr-2"></span> Print All
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap justify-center gap-4 mt-4">
|
||||
<a
|
||||
href={`/events/${event_id}/templates`}
|
||||
class="btn btn-tertiary"
|
||||
>
|
||||
<span class="fas fa-file-alt mr-2"></span> Manage Badge Templates
|
||||
</a>
|
||||
<a
|
||||
href={`/events/${event_id}/badges/stats`}
|
||||
class="btn btn-tertiary"
|
||||
>
|
||||
<span class="fas fa-chart-bar mr-2"></span> Badge Printing Stats
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details class="details">
|
||||
<summary class="summary">Basic Info</summary>
|
||||
<div class="p-4">
|
||||
<Ae_comp_event_settings_basic_form
|
||||
@@ -252,3 +324,33 @@
|
||||
{:else}
|
||||
<p>Loading event data...</p>
|
||||
{/if}
|
||||
|
||||
{#if show_create_badge_modal}
|
||||
<Modal bind:open={show_create_badge_modal}>
|
||||
<div class="card p-4">
|
||||
<h3 class="h3">Create New Badge</h3>
|
||||
<Comp_badge_create_form
|
||||
event_id={event_id}
|
||||
on:success={() => {
|
||||
show_create_badge_modal = false;
|
||||
}}
|
||||
on:cancel={() => (show_create_badge_modal = false)}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
{/if}
|
||||
|
||||
{#if show_upload_badge_modal}
|
||||
<Modal bind:open={show_upload_badge_modal}>
|
||||
<div class="card p-4">
|
||||
<h3 class="h3">Upload Badges (CSV)</h3>
|
||||
<Comp_badge_upload_form
|
||||
event_id={event_id}
|
||||
on:success={() => {
|
||||
show_upload_badge_modal = false;
|
||||
}}
|
||||
on:cancel={() => (show_upload_badge_modal = false)}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user