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';
|
import { addToast } from '$lib/toasts';
|
||||||
let modal: HTMLDialogElement;
|
let modal: HTMLDialogElement;
|
||||||
|
|
||||||
|
export let startDate: string | null = null;
|
||||||
|
export let endDate: string | null = null;
|
||||||
|
|
||||||
console.log(adventureToEdit.id);
|
console.log(adventureToEdit.id);
|
||||||
|
|
||||||
let originalName = adventureToEdit.name;
|
let originalName = adventureToEdit.name;
|
||||||
|
@ -202,6 +205,8 @@
|
||||||
type="date"
|
type="date"
|
||||||
id="date"
|
id="date"
|
||||||
name="date"
|
name="date"
|
||||||
|
min={startDate || ''}
|
||||||
|
max={endDate || ''}
|
||||||
bind:value={adventureToEdit.date}
|
bind:value={adventureToEdit.date}
|
||||||
class="input input-bordered w-full max-w-xs mt-1"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -11,6 +11,17 @@
|
||||||
|
|
||||||
let originalName = transportationToEdit.name;
|
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 MapMarker from '~icons/mdi/map-marker';
|
||||||
import Calendar from '~icons/mdi/calendar';
|
import Calendar from '~icons/mdi/calendar';
|
||||||
import Notebook from '~icons/mdi/notebook';
|
import Notebook from '~icons/mdi/notebook';
|
||||||
|
@ -142,6 +153,8 @@
|
||||||
type="datetime-local"
|
type="datetime-local"
|
||||||
id="date"
|
id="date"
|
||||||
name="date"
|
name="date"
|
||||||
|
min={fullStartDate || ''}
|
||||||
|
max={fullEndDate || ''}
|
||||||
bind:value={transportationToEdit.date}
|
bind:value={transportationToEdit.date}
|
||||||
class="input input-bordered w-full max-w-xs mt-1"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -24,7 +24,9 @@
|
||||||
import Wikipedia from '~icons/mdi/wikipedia';
|
import Wikipedia from '~icons/mdi/wikipedia';
|
||||||
import ActivityComplete from './ActivityComplete.svelte';
|
import ActivityComplete from './ActivityComplete.svelte';
|
||||||
import { appVersion } from '$lib/config';
|
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 = {
|
let newAdventure: Adventure = {
|
||||||
id: NaN,
|
id: NaN,
|
||||||
|
@ -273,6 +275,8 @@
|
||||||
type="date"
|
type="date"
|
||||||
id="date"
|
id="date"
|
||||||
name="date"
|
name="date"
|
||||||
|
min={startDate || ''}
|
||||||
|
max={endDate || ''}
|
||||||
bind:value={newAdventure.date}
|
bind:value={newAdventure.date}
|
||||||
class="input input-bordered w-full max-w-xs mt-1"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -33,6 +33,17 @@
|
||||||
import LinkVariant from '~icons/mdi/link-variant';
|
import LinkVariant from '~icons/mdi/link-variant';
|
||||||
import Airplane from '~icons/mdi/airplane';
|
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 = '';
|
let type: string = '';
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
@ -163,6 +174,8 @@
|
||||||
type="datetime-local"
|
type="datetime-local"
|
||||||
id="date"
|
id="date"
|
||||||
name="date"
|
name="date"
|
||||||
|
min={fullStartDate || ''}
|
||||||
|
max={fullEndDate || ''}
|
||||||
class="input input-bordered w-full max-w-xs mt-1"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
{#if transportation.date}
|
{#if transportation.date}
|
||||||
{new Date(transportation.date).toLocaleString()}
|
{new Date(transportation.date).toLocaleString()}
|
||||||
{/if}
|
{/if}
|
||||||
{#if user}
|
{#if user?.pk === transportation.user_id}
|
||||||
<div class="card-actions justify-end">
|
<div class="card-actions justify-end">
|
||||||
<button on:click={deleteTransportation} class="btn btn-secondary"
|
<button on:click={deleteTransportation} class="btn btn-secondary"
|
||||||
><TrashCanOutline class="w-5 h-5 mr-1" /></button
|
><TrashCanOutline class="w-5 h-5 mr-1" /></button
|
||||||
|
|
|
@ -197,6 +197,8 @@
|
||||||
{transportationToEdit}
|
{transportationToEdit}
|
||||||
on:close={() => (isTransportationEditModalOpen = false)}
|
on:close={() => (isTransportationEditModalOpen = false)}
|
||||||
on:saveEdit={saveNewTransportation}
|
on:saveEdit={saveNewTransportation}
|
||||||
|
startDate={collection.start_date}
|
||||||
|
endDate={collection.end_date}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -205,6 +207,8 @@
|
||||||
{adventureToEdit}
|
{adventureToEdit}
|
||||||
on:close={() => (isEditModalOpen = false)}
|
on:close={() => (isEditModalOpen = false)}
|
||||||
on:saveEdit={saveEdit}
|
on:saveEdit={saveEdit}
|
||||||
|
startDate={collection.start_date}
|
||||||
|
endDate={collection.end_date}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -214,6 +218,8 @@
|
||||||
collection_id={collection.id}
|
collection_id={collection.id}
|
||||||
on:create={createAdventure}
|
on:create={createAdventure}
|
||||||
on:close={() => (isShowingCreateModal = false)}
|
on:close={() => (isShowingCreateModal = false)}
|
||||||
|
startDate={collection.start_date}
|
||||||
|
endDate={collection.end_date}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -225,6 +231,8 @@
|
||||||
isShowingTransportationModal = false;
|
isShowingTransportationModal = false;
|
||||||
}}
|
}}
|
||||||
{collection}
|
{collection}
|
||||||
|
startDate={collection.start_date}
|
||||||
|
endDate={collection.end_date}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue