Compare commits
No commits in common. "ad796dcb578b79b566559d1c22c99f0231a03251" and "a69c474d1def6148aeedc7073caff4125c890125" have entirely different histories.
ad796dcb57
...
a69c474d1d
10 changed files with 24 additions and 77 deletions
|
@ -1,7 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
import { mdiClose } from "@mdi/js";
|
import { mdiClose } from "@mdi/js";
|
||||||
import { onMount } from "svelte";
|
|
||||||
|
|
||||||
import { Debouncer } from "$lib/shared/util";
|
import { Debouncer } from "$lib/shared/util";
|
||||||
|
|
||||||
|
@ -193,23 +192,8 @@
|
||||||
searchDebounce.now();
|
searchDebounce.now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWindowKeyup(e: KeyboardEvent): void {
|
|
||||||
// Dont catch keybinds when inputting text
|
|
||||||
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return;
|
|
||||||
if (e.key === "f") {
|
|
||||||
e.preventDefault();
|
|
||||||
focusInput();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
if (hiddenIds.size === 0) activeFilters = activeFilters;
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keyup={onWindowKeyup} />
|
|
||||||
|
|
||||||
<div class="filterbar-outer">
|
<div class="filterbar-outer">
|
||||||
<div class="filterbar-inner input input-sm input-bordered">
|
<div class="filterbar-inner input input-sm input-bordered">
|
||||||
{#each activeFilters as fdata, i}
|
{#each activeFilters as fdata, i}
|
||||||
|
|
|
@ -41,15 +41,6 @@
|
||||||
}
|
}
|
||||||
} : undefined;
|
} : undefined;
|
||||||
|
|
||||||
function acceptTextInput(e: Event): void {
|
|
||||||
// @ts-expect-error Event is from HTML input
|
|
||||||
if (e.target?.value) {
|
|
||||||
// @ts-expect-error Input value is checked
|
|
||||||
fdata.selection = { id: null, name: e.target.value };
|
|
||||||
}
|
|
||||||
stopEditing(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$: if (fdata.editing && autocomplete) {
|
$: if (fdata.editing && autocomplete) {
|
||||||
autocomplete.open();
|
autocomplete.open();
|
||||||
}
|
}
|
||||||
|
@ -127,10 +118,14 @@
|
||||||
}}
|
}}
|
||||||
on:keypress={(e) => {
|
on:keypress={(e) => {
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
acceptTextInput(e);
|
// @ts-expect-error Input value is checked
|
||||||
|
if (e.target?.value) {
|
||||||
|
// @ts-expect-error Input value is checked
|
||||||
|
fdata.selection = { id: null, name: e.target.value };
|
||||||
|
}
|
||||||
|
stopEditing(true);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
on:blur={acceptTextInput}
|
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
@ -1,21 +1,6 @@
|
||||||
<script lang="ts">
|
|
||||||
import { humanDate } from "$lib/shared/util";
|
|
||||||
|
|
||||||
function dateIn(n: number): string {
|
|
||||||
const date = new Date();
|
|
||||||
date.setDate(date.getDate() + n);
|
|
||||||
return humanDate(date);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="join">
|
<div class="join">
|
||||||
{#each { length: 4 } as _, i}
|
{#each { length: 4 } as _, i}
|
||||||
<button
|
<button name="todo" class="join-item btn btn-sm" type="submit" value={i}>
|
||||||
name="todo"
|
|
||||||
class="join-item btn btn-sm"
|
|
||||||
title={i > 0 ? `Eintrag auf ${dateIn(i)} verschieben` : undefined}
|
|
||||||
type="submit"
|
|
||||||
value={i}>
|
|
||||||
{#if i === 0}
|
{#if i === 0}
|
||||||
Notiz
|
Notiz
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
@ -130,10 +130,6 @@ class SearchQueryComponents {
|
||||||
* Supported search syntax:
|
* Supported search syntax:
|
||||||
* - Negative query `-word`
|
* - Negative query `-word`
|
||||||
* - Exact query `"word"`
|
* - Exact query `"word"`
|
||||||
*
|
|
||||||
* The last word in a search query is prefix-matched (i.e.
|
|
||||||
* the search returns all results starting with the given characters).
|
|
||||||
* This allows for meaningful results in Search-as-you-type applications.
|
|
||||||
*/
|
*/
|
||||||
export function parseSearchQuery(q: string): SearchQueryComponents {
|
export function parseSearchQuery(q: string): SearchQueryComponents {
|
||||||
const regexpParts = /(-)?(?:"([^"]*)"|([^"\s]+))(?:\s|$)/g;
|
const regexpParts = /(-)?(?:"([^"]*)"|([^"\s]+))(?:\s|$)/g;
|
||||||
|
|
|
@ -77,13 +77,6 @@ function dateDiffInDays(a: Date, b: Date): number {
|
||||||
return Math.round((ts2 - ts1) / MS_PER_DAY);
|
return Math.round((ts2 - ts1) / MS_PER_DAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Format a date with a human-readable format
|
|
||||||
* - If the date is within +/- 3 days, output a textual format ("heute", "morgen", "vor 2 Tagen")
|
|
||||||
* - Otherwise, format it as DD.MM.YYYY (or DD.MM.YYYY, hh:mm if `time=true`)
|
|
||||||
*
|
|
||||||
* @param [time=false] Enable time display
|
|
||||||
* @param [cap=false] Enable capitalized format
|
|
||||||
*/
|
|
||||||
export function humanDate(date: Date | string, time = false, cap = false): string {
|
export function humanDate(date: Date | string, time = false, cap = false): string {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const dt = coerceDate(date);
|
const dt = coerceDate(date);
|
||||||
|
@ -103,7 +96,7 @@ export function humanDate(date: Date | string, time = false, cap = false): strin
|
||||||
if (diffDays !== 0) {
|
if (diffDays !== 0) {
|
||||||
if (diffDays === 1) return outstr("morgen");
|
if (diffDays === 1) return outstr("morgen");
|
||||||
if (diffDays === -1) return outstr("gestern");
|
if (diffDays === -1) return outstr("gestern");
|
||||||
return outstr(intl.format(diffDays, "day"));
|
return intl.format(diffDays, "day");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time) {
|
if (time) {
|
||||||
|
|
|
@ -158,11 +158,7 @@ export function defaultVisitUrl(): string {
|
||||||
}, URL_VISIT);
|
}, URL_VISIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function moveEntryTodoDate(
|
export async function moveEntryTodoDate(id: number, nTodoDays: number, init?: TRPCClientInit) {
|
||||||
id:number,
|
|
||||||
nTodoDays: number,
|
|
||||||
init?: TRPCClientInit,
|
|
||||||
): Promise<Date | null> {
|
|
||||||
if (nTodoDays > 0) {
|
if (nTodoDays > 0) {
|
||||||
const entry = await trpc(init).entry.get.query(id);
|
const entry = await trpc(init).entry.get.query(id);
|
||||||
const newDate = new Date();
|
const newDate = new Date();
|
||||||
|
@ -175,7 +171,5 @@ export async function moveEntryTodoDate(
|
||||||
date: utcDateToYMD(newDate),
|
date: utcDateToYMD(newDate),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return newDate;
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { superValidate, message } from "sveltekit-superforms";
|
||||||
|
|
||||||
import { ZUrlEntityId } from "$lib/shared/model/validation";
|
import { ZUrlEntityId } from "$lib/shared/model/validation";
|
||||||
import { trpc } from "$lib/shared/trpc";
|
import { trpc } from "$lib/shared/trpc";
|
||||||
import { humanDate, loadWrap, moveEntryTodoDate } from "$lib/shared/util";
|
import { loadWrap, moveEntryTodoDate } from "$lib/shared/util";
|
||||||
|
|
||||||
import { SchemaNewExecution } from "./schema";
|
import { SchemaNewExecution } from "./schema";
|
||||||
|
|
||||||
|
@ -22,21 +22,18 @@ export const actions: Actions = {
|
||||||
const done = todoDays === null;
|
const done = todoDays === null;
|
||||||
const nTodoDays = todoDays ? parseInt(todoDays.toString()) : 0;
|
const nTodoDays = todoDays ? parseInt(todoDays.toString()) : 0;
|
||||||
|
|
||||||
if (form.data.text.length > 0) {
|
await loadWrap(async () => {
|
||||||
await trpc(event).entry.newExecution.mutate({
|
await trpc(event).entry.newExecution.mutate({
|
||||||
id,
|
id,
|
||||||
old_execution_id: form.data.old_execution_id,
|
old_execution_id: form.data.old_execution_id,
|
||||||
execution: { text: form.data.text, done: todoDays === null },
|
execution: { text: form.data.text, done: todoDays === null },
|
||||||
});
|
});
|
||||||
}
|
await moveEntryTodoDate(id, nTodoDays, event);
|
||||||
const newTodoDate = await moveEntryTodoDate(id, nTodoDays, event);
|
});
|
||||||
|
|
||||||
if (newTodoDate) {
|
if (nTodoDays > 0) {
|
||||||
return message(form, `Eintrag auf ${humanDate(newTodoDate)} verschoben`);
|
return message(form, `Eintrag um ${nTodoDays} Tage in die Zukunft verschoben`);
|
||||||
}
|
}
|
||||||
if (form.data.text.length > 0) {
|
return message(form, done ? "Eintrag erledigt" : "Eintrag mit Notiz versehen");
|
||||||
return message(form, done ? "Eintrag erledigt" : "Eintrag mit Notiz versehen");
|
|
||||||
}
|
|
||||||
return { form };
|
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
import type { PageData } from "./$types";
|
import type { PageData } from "./$types";
|
||||||
|
|
||||||
import { superForm } from "sveltekit-superforms";
|
import { superForm } from "sveltekit-superforms";
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
label="Eintrag erledigen"
|
label="Eintrag erledigen"
|
||||||
bind:value={$form.text}
|
bind:value={$form.text}
|
||||||
>
|
>
|
||||||
<div class="row c-vlight gap-2 flex-wrap">
|
<div class="row c-vlight gap-2">
|
||||||
<button class="btn btn-sm btn-primary" type="submit">Erledigt</button>
|
<button class="btn btn-sm btn-primary" type="submit">Erledigt</button>
|
||||||
<EntryTodoButton />
|
<EntryTodoButton />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { superValidate } from "sveltekit-superforms";
|
||||||
|
|
||||||
import { ZUrlEntityId } from "$lib/shared/model/validation";
|
import { ZUrlEntityId } from "$lib/shared/model/validation";
|
||||||
import { trpc } from "$lib/shared/trpc";
|
import { trpc } from "$lib/shared/trpc";
|
||||||
import { loadWrap } from "$lib/shared/util";
|
import { loadWrap, moveEntryTodoDate } from "$lib/shared/util";
|
||||||
|
|
||||||
import { SchemaNewExecution } from "../schema";
|
import { SchemaNewExecution } from "../schema";
|
||||||
|
|
||||||
|
@ -29,6 +29,9 @@ export const actions: Actions = {
|
||||||
old_execution_id: form.data.old_execution_id,
|
old_execution_id: form.data.old_execution_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const nTodoDays = todoDays ? parseInt(todoDays.toString()) : 0;
|
||||||
|
await moveEntryTodoDate(id, nTodoDays, event);
|
||||||
|
|
||||||
redirect(302, `/entry/${id}`);
|
redirect(302, `/entry/${id}`);
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
import { superformConfig } from "$lib/shared/util";
|
import { superformConfig } from "$lib/shared/util";
|
||||||
|
|
||||||
import EntryBody from "$lib/components/entry/EntryBody.svelte";
|
import EntryBody from "$lib/components/entry/EntryBody.svelte";
|
||||||
|
import EntryTodoButton from "$lib/components/ui/EntryTodoButton.svelte";
|
||||||
import MarkdownInput from "$lib/components/ui/markdown/MarkdownInput.svelte";
|
import MarkdownInput from "$lib/components/ui/markdown/MarkdownInput.svelte";
|
||||||
|
|
||||||
import { SchemaNewExecution } from "../schema";
|
import { SchemaNewExecution } from "../schema";
|
||||||
|
@ -31,9 +32,7 @@
|
||||||
>
|
>
|
||||||
<div class="row c-vlight gap-2">
|
<div class="row c-vlight gap-2">
|
||||||
<button class="btn btn-sm btn-primary" type="submit">Speichern</button>
|
<button class="btn btn-sm btn-primary" type="submit">Speichern</button>
|
||||||
<button name="todo" class="join-item btn btn-sm" type="submit" value="0">
|
<EntryTodoButton />
|
||||||
Notiz
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</MarkdownInput>
|
</MarkdownInput>
|
||||||
<input name="old_execution_id" type="hidden" bind:value={$form.old_execution_id} />
|
<input name="old_execution_id" type="hidden" bind:value={$form.old_execution_id} />
|
||||||
|
|
Loading…
Reference in a new issue