mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-23 14:59:36 +02:00
refactor: Update date input fields with min and max values
This commit is contained in:
parent
4e44203239
commit
17498121a3
6 changed files with 45 additions and 2 deletions
|
@ -7,6 +7,9 @@
|
|||
import { addToast } from '$lib/toasts';
|
||||
let modal: HTMLDialogElement;
|
||||
|
||||
export let startDate: string | null = null;
|
||||
export let endDate: string | null = null;
|
||||
|
||||
console.log(adventureToEdit.id);
|
||||
|
||||
let originalName = adventureToEdit.name;
|
||||
|
@ -202,6 +205,8 @@
|
|||
type="date"
|
||||
id="date"
|
||||
name="date"
|
||||
min={startDate || ''}
|
||||
max={endDate || ''}
|
||||
bind:value={adventureToEdit.date}
|
||||
class="input input-bordered w-full max-w-xs mt-1"
|
||||
/>
|
||||
|
|
|
@ -11,6 +11,17 @@
|
|||
|
||||
let originalName = transportationToEdit.name;
|
||||
|
||||
export let startDate: string | null = null;
|
||||
export let endDate: string | null = null;
|
||||
|
||||
let fullStartDate: string = '';
|
||||
let fullEndDate: string = '';
|
||||
|
||||
if (startDate && endDate) {
|
||||
fullStartDate = `${startDate}T00:00`;
|
||||
fullEndDate = `${endDate}T23:59`;
|
||||
}
|
||||
|
||||
import MapMarker from '~icons/mdi/map-marker';
|
||||
import Calendar from '~icons/mdi/calendar';
|
||||
import Notebook from '~icons/mdi/notebook';
|
||||
|
@ -142,6 +153,8 @@
|
|||
type="datetime-local"
|
||||
id="date"
|
||||
name="date"
|
||||
min={fullStartDate || ''}
|
||||
max={fullEndDate || ''}
|
||||
bind:value={transportationToEdit.date}
|
||||
class="input input-bordered w-full max-w-xs mt-1"
|
||||
/>
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
import Wikipedia from '~icons/mdi/wikipedia';
|
||||
import ActivityComplete from './ActivityComplete.svelte';
|
||||
import { appVersion } from '$lib/config';
|
||||
import AdventureCard from './AdventureCard.svelte';
|
||||
|
||||
export let startDate: string | null = null;
|
||||
export let endDate: string | null = null;
|
||||
|
||||
let newAdventure: Adventure = {
|
||||
id: NaN,
|
||||
|
@ -273,6 +275,8 @@
|
|||
type="date"
|
||||
id="date"
|
||||
name="date"
|
||||
min={startDate || ''}
|
||||
max={endDate || ''}
|
||||
bind:value={newAdventure.date}
|
||||
class="input input-bordered w-full max-w-xs mt-1"
|
||||
/>
|
||||
|
|
|
@ -33,6 +33,17 @@
|
|||
import LinkVariant from '~icons/mdi/link-variant';
|
||||
import Airplane from '~icons/mdi/airplane';
|
||||
|
||||
export let startDate: string | null = null;
|
||||
export let endDate: string | null = null;
|
||||
|
||||
let fullStartDate: string = '';
|
||||
let fullEndDate: string = '';
|
||||
|
||||
if (startDate && endDate) {
|
||||
fullStartDate = `${startDate}T00:00`;
|
||||
fullEndDate = `${endDate}T23:59`;
|
||||
}
|
||||
|
||||
let type: string = '';
|
||||
|
||||
onMount(async () => {
|
||||
|
@ -163,6 +174,8 @@
|
|||
type="datetime-local"
|
||||
id="date"
|
||||
name="date"
|
||||
min={fullStartDate || ''}
|
||||
max={fullEndDate || ''}
|
||||
class="input input-bordered w-full max-w-xs mt-1"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
{#if transportation.date}
|
||||
{new Date(transportation.date).toLocaleString()}
|
||||
{/if}
|
||||
{#if user}
|
||||
{#if user?.pk === transportation.user_id}
|
||||
<div class="card-actions justify-end">
|
||||
<button on:click={deleteTransportation} class="btn btn-secondary"
|
||||
><TrashCanOutline class="w-5 h-5 mr-1" /></button
|
||||
|
|
|
@ -197,6 +197,8 @@
|
|||
{transportationToEdit}
|
||||
on:close={() => (isTransportationEditModalOpen = false)}
|
||||
on:saveEdit={saveNewTransportation}
|
||||
startDate={collection.start_date}
|
||||
endDate={collection.end_date}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
|
@ -205,6 +207,8 @@
|
|||
{adventureToEdit}
|
||||
on:close={() => (isEditModalOpen = false)}
|
||||
on:saveEdit={saveEdit}
|
||||
startDate={collection.start_date}
|
||||
endDate={collection.end_date}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
|
@ -214,6 +218,8 @@
|
|||
collection_id={collection.id}
|
||||
on:create={createAdventure}
|
||||
on:close={() => (isShowingCreateModal = false)}
|
||||
startDate={collection.start_date}
|
||||
endDate={collection.end_date}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
|
@ -225,6 +231,8 @@
|
|||
isShowingTransportationModal = false;
|
||||
}}
|
||||
{collection}
|
||||
startDate={collection.start_date}
|
||||
endDate={collection.end_date}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue