feat: Add basic event settings management page
This commit introduces a new page at /events/[event_id]/settings that allows users to view and edit the JSON configuration fields for an event. The page provides textareas for each config field and a 'Save' button to persist the changes.
This commit is contained in:
110
src/routes/events/[event_id]/settings/+page.svelte
Normal file
110
src/routes/events/[event_id]/settings/+page.svelte
Normal file
@@ -0,0 +1,110 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { liveQuery } from 'dexie';
|
||||
import { db_events } 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';
|
||||
|
||||
let event_id = $page.params.event_id;
|
||||
let event_obj = $state(null);
|
||||
|
||||
onMount(() => {
|
||||
const observable = liveQuery(() => db_events.event.get(event_id));
|
||||
const subscription = observable.subscribe((value) => {
|
||||
event_obj = value;
|
||||
});
|
||||
|
||||
return () => {
|
||||
subscription.unsubscribe();
|
||||
};
|
||||
});
|
||||
|
||||
async function handle_save(field_name: string, json_string: string) {
|
||||
try {
|
||||
const parsed_json = JSON.parse(json_string);
|
||||
const data_kv = { [field_name]: parsed_json };
|
||||
|
||||
await events_func.update_ae_obj__event({
|
||||
api_cfg: $ae_api,
|
||||
event_id: event_id,
|
||||
data_kv: data_kv
|
||||
});
|
||||
|
||||
alert('Settings saved successfully!');
|
||||
} catch (error) {
|
||||
console.error('Error saving settings:', error);
|
||||
alert('Failed to save settings. Please check if the JSON is valid.');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<h1 class="h1">Event Settings</h1>
|
||||
|
||||
{#if event_obj}
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<h2 class="h2">General Config (cfg_json)</h2>
|
||||
<textarea class="textarea w-full h-64" bind:value={event_obj.cfg_json}></textarea>
|
||||
<button
|
||||
class="btn preset-tonal-primary"
|
||||
on:click={() => handle_save('cfg_json', event_obj.cfg_json)}>Save</button
|
||||
>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 class="h2">Presentation Management (mod_pres_mgmt_json)</h2>
|
||||
<textarea
|
||||
class="textarea w-full h-64"
|
||||
bind:value={event_obj.mod_pres_mgmt_json}></textarea>
|
||||
<button
|
||||
class="btn preset-tonal-primary"
|
||||
on:click={() => handle_save('mod_pres_mgmt_json', event_obj.mod_pres_mgmt_json)}
|
||||
>Save</button
|
||||
>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 class="h2">Badges (mod_badges_json)</h2>
|
||||
<textarea class="textarea w-full h-64" bind:value={event_obj.mod_badges_json}></textarea>
|
||||
<button
|
||||
class="btn preset-tonal-primary"
|
||||
on:click={() => handle_save('mod_badges_json', event_obj.mod_badges_json)}>Save</button
|
||||
>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 class="h2">Abstracts (mod_abstracts_json)</h2>
|
||||
<textarea
|
||||
class="textarea w-full h-64"
|
||||
bind:value={event_obj.mod_abstracts_json}></textarea>
|
||||
<button
|
||||
class="btn preset-tonal-primary"
|
||||
on:click={() => handle_save('mod_abstracts_json', event_obj.mod_abstracts_json)}
|
||||
>Save</button
|
||||
>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 class="h2">Exhibits (mod_exhibits_json)</h2>
|
||||
<textarea class="textarea w-full h-64" bind:value={event_obj.mod_exhibits_json}></textarea>
|
||||
<button
|
||||
class="btn preset-tonal-primary"
|
||||
on:click={() => handle_save('mod_exhibits_json', event_obj.mod_exhibits_json)}
|
||||
>Save</button
|
||||
>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 class="h2">Meetings (mod_meetings_json)</h2>
|
||||
<textarea class="textarea w-full h-64" bind:value={event_obj.mod_meetings_json}></textarea>
|
||||
<button
|
||||
class="btn preset-tonal-primary"
|
||||
on:click={() => handle_save('mod_meetings_json', event_obj.mod_meetings_json)}
|
||||
>Save</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<p>Loading event data...</p>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user