mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-24 07:19:36 +02:00
notes
This commit is contained in:
parent
860e6d4034
commit
4bbb9f10f6
3 changed files with 172 additions and 113 deletions
|
@ -1,7 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { addToast } from '$lib/toasts';
|
import { addToast } from '$lib/toasts';
|
||||||
import type { Note } from '$lib/types';
|
import type { Note, User } from '$lib/types';
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
import TrashCan from '~icons/mdi/trash-can';
|
import TrashCan from '~icons/mdi/trash-can';
|
||||||
|
|
||||||
export let note: Note;
|
export let note: Note;
|
||||||
|
export let user: User | null = null;
|
||||||
|
|
||||||
function editNote() {
|
function editNote() {
|
||||||
dispatch('edit', note);
|
dispatch('edit', note);
|
||||||
|
@ -39,12 +40,14 @@
|
||||||
<button class="btn btn-neutral mb-2" on:click={editNote}>
|
<button class="btn btn-neutral mb-2" on:click={editNote}>
|
||||||
<Launch class="w-6 h-6" />Open
|
<Launch class="w-6 h-6" />Open
|
||||||
</button>
|
</button>
|
||||||
|
{#if note.user_id == user?.pk}
|
||||||
<button
|
<button
|
||||||
id="delete_adventure"
|
id="delete_adventure"
|
||||||
data-umami-event="Delete Adventure"
|
data-umami-event="Delete Adventure"
|
||||||
class="btn btn-warning"
|
class="btn btn-warning"
|
||||||
on:click={deleteNote}><TrashCan class="w-6 h-6" />Delete</button
|
on:click={deleteNote}><TrashCan class="w-6 h-6" />Delete</button
|
||||||
>
|
>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { isValidUrl } from '$lib';
|
import { isValidUrl } from '$lib';
|
||||||
import type { Collection, Note } from '$lib/types';
|
import type { Collection, Note, User } from '$lib/types';
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
export let note: Note | null = null;
|
export let note: Note | null = null;
|
||||||
export let collection: Collection;
|
export let collection: Collection;
|
||||||
|
export let user: User | null = null;
|
||||||
|
|
||||||
let warning: string | null = '';
|
let warning: string | null = '';
|
||||||
|
|
||||||
|
@ -112,6 +113,7 @@
|
||||||
<p class="font-semibold text-md mb-2">Editing note {initialName}</p>
|
<p class="font-semibold text-md mb-2">Editing note {initialName}</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if user?.pk == note?.user_id}
|
||||||
<form on:submit|preventDefault>
|
<form on:submit|preventDefault>
|
||||||
<div class="form-control mb-2">
|
<div class="form-control mb-2">
|
||||||
<label for="name">Name</label>
|
<label for="name">Name</label>
|
||||||
|
@ -215,9 +217,60 @@
|
||||||
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
||||||
></path>
|
></path>
|
||||||
</svg>
|
</svg>
|
||||||
<span>New software update available.</span>
|
<span>This note is public because it is in a public collection.</span>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</form>
|
</form>
|
||||||
|
{:else}
|
||||||
|
<form>
|
||||||
|
<div class="form-control mb-2">
|
||||||
|
<label for="name">Name</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="name"
|
||||||
|
class="input input-bordered w-full max-w-xs"
|
||||||
|
bind:value={newNote.name}
|
||||||
|
readonly
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="form-control mb-2">
|
||||||
|
<label for="content">Date</label>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
id="date"
|
||||||
|
name="date"
|
||||||
|
min={collection.start_date || ''}
|
||||||
|
max={collection.end_date || ''}
|
||||||
|
bind:value={newNote.date}
|
||||||
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
|
readonly
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="form-control mb-2">
|
||||||
|
<label for="content">Content</label>
|
||||||
|
<textarea
|
||||||
|
id="content"
|
||||||
|
class="textarea textarea-bordered"
|
||||||
|
bind:value={newNote.content}
|
||||||
|
rows="5"
|
||||||
|
readonly
|
||||||
|
></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="form-control mb-2">
|
||||||
|
<label for="content">Links</label>
|
||||||
|
</div>
|
||||||
|
{#if newNote.links.length > 0}
|
||||||
|
<ul class="list-none">
|
||||||
|
{#each newNote.links as link, i}
|
||||||
|
<li class="mb-1">
|
||||||
|
<a href={link} target="_blank">{link}</a>
|
||||||
|
</li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<button class="btn btn-neutral" on:click={close}>Close</button>
|
||||||
|
</form>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
|
@ -246,6 +246,7 @@
|
||||||
{#if isNoteModalOpen}
|
{#if isNoteModalOpen}
|
||||||
<NoteModal
|
<NoteModal
|
||||||
note={noteToEdit}
|
note={noteToEdit}
|
||||||
|
user={data.user}
|
||||||
on:close={() => (isNoteModalOpen = false)}
|
on:close={() => (isNoteModalOpen = false)}
|
||||||
{collection}
|
{collection}
|
||||||
on:save={(event) => {
|
on:save={(event) => {
|
||||||
|
@ -468,6 +469,7 @@
|
||||||
{#each notes as note}
|
{#each notes as note}
|
||||||
<NoteCard
|
<NoteCard
|
||||||
{note}
|
{note}
|
||||||
|
user={data.user || null}
|
||||||
on:edit={(event) => {
|
on:edit={(event) => {
|
||||||
noteToEdit = event.detail;
|
noteToEdit = event.detail;
|
||||||
isNoteModalOpen = true;
|
isNoteModalOpen = true;
|
||||||
|
@ -540,6 +542,7 @@
|
||||||
{#each dayNotes as note}
|
{#each dayNotes as note}
|
||||||
<NoteCard
|
<NoteCard
|
||||||
{note}
|
{note}
|
||||||
|
user={data.user || null}
|
||||||
on:edit={(event) => {
|
on:edit={(event) => {
|
||||||
noteToEdit = event.detail;
|
noteToEdit = event.detail;
|
||||||
isNoteModalOpen = true;
|
isNoteModalOpen = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue