mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-18 20:39:36 +02:00
commit
28a5d423c2
3 changed files with 98 additions and 38 deletions
|
@ -102,6 +102,8 @@
|
||||||
name={newAdventure.name}
|
name={newAdventure.name}
|
||||||
on:submit={upload}
|
on:submit={upload}
|
||||||
on:close={() => (isImageModalOpen = false)}
|
on:close={() => (isImageModalOpen = false)}
|
||||||
|
bucket="adventures"
|
||||||
|
existingImageKey={newAdventure.imageUrl}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
console.log(adventureToEdit.name);
|
console.log(adventureToEdit.name);
|
||||||
const desc = await generateDescription(adventureToEdit.name);
|
const desc = await generateDescription(adventureToEdit.name);
|
||||||
adventureToEdit.description = desc;
|
adventureToEdit.description = desc;
|
||||||
// Do something with the updated newAdventure object
|
// Do something with the updated adventureToEdit object
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
// Handle the error
|
// Handle the error
|
||||||
|
@ -91,6 +91,11 @@
|
||||||
|
|
||||||
let isImageModalOpen: boolean = false;
|
let isImageModalOpen: boolean = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the upload event and updates the adventure's image URL.
|
||||||
|
*
|
||||||
|
* @param {CustomEvent<any>} e - The custom event containing the key.
|
||||||
|
*/
|
||||||
function upload(e: CustomEvent<any>) {
|
function upload(e: CustomEvent<any>) {
|
||||||
let key = e.detail;
|
let key = e.detail;
|
||||||
console.log("EE" + key);
|
console.log("EE" + key);
|
||||||
|
@ -103,6 +108,8 @@
|
||||||
name={adventureToEdit.name}
|
name={adventureToEdit.name}
|
||||||
on:submit={upload}
|
on:submit={upload}
|
||||||
on:close={() => (isImageModalOpen = false)}
|
on:close={() => (isImageModalOpen = false)}
|
||||||
|
existingImageKey={adventureToEdit.imageUrl}
|
||||||
|
bucket="adventures"
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -110,99 +117,127 @@
|
||||||
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
||||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||||
<div class="modal-box" role="dialog" on:keydown={handleKeydown} tabindex="0">
|
<div class="modal-box" role="dialog" on:keydown={handleKeydown} tabindex="0">
|
||||||
<h3 class="font-bold text-lg">Edit Adventure {originalName}</h3>
|
<h3 class="font-bold text-lg">Edit Adventure: {adventureToEdit.name}</h3>
|
||||||
<p class="py-4">Press ESC key or click the button below to close</p>
|
|
||||||
<div
|
<div
|
||||||
class="modal-action items-center"
|
class="modal-action items-center"
|
||||||
style="display: flex; flex-direction: column; align-items: center; width: 100%;"
|
style="display: flex; flex-direction: column; align-items: center; width: 100%;"
|
||||||
>
|
>
|
||||||
<form method="dialog" style="width: 100%;">
|
<form method="dialog" style="width: 100%;">
|
||||||
<div>
|
<div class="mb-2">
|
||||||
<label for="name">Name</label>
|
<label for="name">Name</label><br />
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="name"
|
id="name"
|
||||||
bind:value={adventureToEdit.name}
|
bind:value={adventureToEdit.name}
|
||||||
class="input input-bordered w-full max-w-xs"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="mb-2">
|
||||||
<label for="location">Location</label>
|
<label for="location"
|
||||||
|
>Location<iconify-icon
|
||||||
|
icon="mdi:map-marker"
|
||||||
|
class="text-lg ml-0.5 -mb-0.5"
|
||||||
|
></iconify-icon></label
|
||||||
|
><br />
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="location"
|
id="location"
|
||||||
bind:value={adventureToEdit.location}
|
bind:value={adventureToEdit.location}
|
||||||
class="input input-bordered w-full max-w-xs"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="mb-2">
|
||||||
<label for="date">Date</label>
|
<label for="date"
|
||||||
|
>Date<iconify-icon icon="mdi:calendar" class="text-lg ml-1 -mb-0.5"
|
||||||
|
></iconify-icon></label
|
||||||
|
><br />
|
||||||
<input
|
<input
|
||||||
type="date"
|
type="date"
|
||||||
id="date"
|
id="date"
|
||||||
bind:value={adventureToEdit.date}
|
bind:value={adventureToEdit.date}
|
||||||
class="input input-bordered w-full max-w-xs"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="mb-2">
|
||||||
<label for="date">Description</label>
|
<label for="date"
|
||||||
<input
|
>Description<iconify-icon
|
||||||
type="text"
|
icon="mdi:notebook"
|
||||||
id="description"
|
class="text-lg ml-1 -mb-0.5"
|
||||||
bind:value={adventureToEdit.description}
|
></iconify-icon></label
|
||||||
class="input input-bordered w-full max-w-xs"
|
><br />
|
||||||
/>
|
<div class="flex">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="description"
|
||||||
|
bind:value={adventureToEdit.description}
|
||||||
|
class="input input-bordered w-full max-w-xs mt-1 mb-2"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
class="btn btn-neutral ml-2"
|
||||||
|
type="button"
|
||||||
|
on:click={generate}
|
||||||
|
><iconify-icon icon="mdi:wikipedia" class="text-xl -mb-1"
|
||||||
|
></iconify-icon>Generate Description</button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="mb-2">
|
||||||
|
<label for="activityTypes"
|
||||||
|
>Activity Types <iconify-icon
|
||||||
|
icon="mdi:clipboard-list"
|
||||||
|
class="text-xl -mb-1"
|
||||||
|
></iconify-icon></label
|
||||||
|
><br />
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
hidden
|
hidden
|
||||||
id="activityTypes"
|
id="activityTypes"
|
||||||
bind:value={activityInput}
|
bind:value={activityInput}
|
||||||
class="input input-bordered w-full max-w-xs"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
<label for="date">Activity Types (Comma Seperated)</label>
|
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
items={activityTypes}
|
items={activityTypes}
|
||||||
bind:selectedItem={selected}
|
bind:selectedItem={selected}
|
||||||
bind:displayValue={activityInput}
|
bind:displayValue={activityInput}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="mb-2">
|
||||||
<label for="rating">Rating</label>
|
<label for="rating"
|
||||||
|
>Rating <iconify-icon icon="mdi:star" class="text-xl -mb-1"
|
||||||
|
></iconify-icon></label
|
||||||
|
><br />
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
min="0"
|
min="0"
|
||||||
max="5"
|
max="5"
|
||||||
id="rating"
|
id="rating"
|
||||||
bind:value={adventureToEdit.rating}
|
bind:value={adventureToEdit.rating}
|
||||||
class="input input-bordered w-full max-w-xs"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-secondary"
|
class="btn btn-neutral"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
isImageModalOpen = true;
|
isImageModalOpen = true;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Upload Image
|
<iconify-icon icon="mdi:upload" class="text-xl"
|
||||||
|
></iconify-icon>Upload Image
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary mr-4 mt-4" on:click={submit}>Save</button
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="btn btn-primary mr-4 mt-4"
|
||||||
|
on:click={submit}>Create</button
|
||||||
>
|
>
|
||||||
<!-- if there is a button in form, it will close the modal -->
|
<!-- if there is a button in form, it will close the modal -->
|
||||||
<button class="btn mt-4" on:click={close}>Close</button>
|
<button class="btn mt-4" on:click={close}>Close</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="flex items-center justify-center flex-wrap gap-4 mt-4">
|
<div class="flex items-center justify-center flex-wrap gap-4 mt-4"></div>
|
||||||
<button class="btn btn-secondary" on:click={generate}
|
|
||||||
>Generate Description</button
|
|
||||||
>
|
|
||||||
<button class="btn btn-secondary" on:click={searchImage}
|
|
||||||
>Search for Image</button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
let modal: HTMLDialogElement;
|
let modal: HTMLDialogElement;
|
||||||
export let name: string;
|
export let name: string;
|
||||||
|
export let existingImageKey: string | undefined;
|
||||||
|
export let bucket: string;
|
||||||
|
|
||||||
let viewType: string = "upload";
|
let viewType: string = "upload";
|
||||||
|
|
||||||
|
@ -104,12 +106,30 @@
|
||||||
// Handle the error
|
// Handle the error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeImage() {
|
||||||
|
existingImageKey = undefined;
|
||||||
|
imageUrl = "";
|
||||||
|
dispatch("submit", "");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<dialog id="my_modal_1" class="modal">
|
<dialog id="my_modal_1" class="modal">
|
||||||
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
||||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||||
<div class="modal-box" role="dialog" on:keydown={handleKeydown} tabindex="0">
|
<div class="modal-box" role="dialog" on:keydown={handleKeydown} tabindex="0">
|
||||||
|
{#if existingImageKey}
|
||||||
|
<h2 class="text-center font-bold text-xl mb-2">Existing Image</h2>
|
||||||
|
|
||||||
|
<img src="/cdn/{bucket}/{existingImageKey}" alt="Existing" class="mb-2" />
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<button class="btn btn-warning" on:click={removeImage}
|
||||||
|
>Remove Image<iconify-icon icon="mdi:delete" class="text-xl -ml-1"
|
||||||
|
></iconify-icon></button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<h3 class="font-bold text-lg">Image Upload</h3>
|
<h3 class="font-bold text-lg">Image Upload</h3>
|
||||||
<div class="join items-center justify-center flex mb-8">
|
<div class="join items-center justify-center flex mb-8">
|
||||||
<input
|
<input
|
||||||
|
@ -162,7 +182,10 @@
|
||||||
</form>
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<button class="btn btn-primary" on:click={submit}>Submit</button>
|
<button class="btn btn-primary" on:click={submit}
|
||||||
|
>Submit <iconify-icon icon="mdi:upload" class="text-xl"
|
||||||
|
></iconify-icon></button
|
||||||
|
>
|
||||||
<button class="btn btn-neutral" on:click={close}>Close</button>
|
<button class="btn btn-neutral" on:click={close}>Close</button>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue