Compare commits

..

No commits in common. "ad796dcb578b79b566559d1c22c99f0231a03251" and "a69c474d1def6148aeedc7073caff4125c890125" have entirely different histories.

10 changed files with 24 additions and 77 deletions

View file

@ -1,7 +1,6 @@
<script lang="ts">
import { mdiClose } from "@mdi/js";
import { onMount } from "svelte";
import { Debouncer } from "$lib/shared/util";
@ -193,23 +192,8 @@
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>
<svelte:window on:keyup={onWindowKeyup} />
<div class="filterbar-outer">
<div class="filterbar-inner input input-sm input-bordered">
{#each activeFilters as fdata, i}

View file

@ -41,15 +41,6 @@
}
} : 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) {
autocomplete.open();
}
@ -127,10 +118,14 @@
}}
on:keypress={(e) => {
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}
{:else}

View file

@ -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">
{#each { length: 4 } as _, i}
<button
name="todo"
class="join-item btn btn-sm"
title={i > 0 ? `Eintrag auf ${dateIn(i)} verschieben` : undefined}
type="submit"
value={i}>
<button name="todo" class="join-item btn btn-sm" type="submit" value={i}>
{#if i === 0}
Notiz
{:else}

View file

@ -130,10 +130,6 @@ class SearchQueryComponents {
* Supported search syntax:
* - Negative 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 {
const regexpParts = /(-)?(?:"([^"]*)"|([^"\s]+))(?:\s|$)/g;

View file

@ -77,13 +77,6 @@ function dateDiffInDays(a: Date, b: Date): number {
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 {
const now = new 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 === 1) return outstr("morgen");
if (diffDays === -1) return outstr("gestern");
return outstr(intl.format(diffDays, "day"));
return intl.format(diffDays, "day");
}
if (time) {

View file

@ -158,11 +158,7 @@ export function defaultVisitUrl(): string {
}, URL_VISIT);
}
export async function moveEntryTodoDate(
id:number,
nTodoDays: number,
init?: TRPCClientInit,
): Promise<Date | null> {
export async function moveEntryTodoDate(id: number, nTodoDays: number, init?: TRPCClientInit) {
if (nTodoDays > 0) {
const entry = await trpc(init).entry.get.query(id);
const newDate = new Date();
@ -175,7 +171,5 @@ export async function moveEntryTodoDate(
date: utcDateToYMD(newDate),
},
});
return newDate;
}
return null;
}

View file

@ -5,7 +5,7 @@ import { superValidate, message } from "sveltekit-superforms";
import { ZUrlEntityId } from "$lib/shared/model/validation";
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";
@ -22,21 +22,18 @@ export const actions: Actions = {
const done = todoDays === null;
const nTodoDays = todoDays ? parseInt(todoDays.toString()) : 0;
if (form.data.text.length > 0) {
await loadWrap(async () => {
await trpc(event).entry.newExecution.mutate({
id,
old_execution_id: form.data.old_execution_id,
execution: { text: form.data.text, done: todoDays === null },
});
}
const newTodoDate = await moveEntryTodoDate(id, nTodoDays, event);
await moveEntryTodoDate(id, nTodoDays, event);
});
if (newTodoDate) {
return message(form, `Eintrag auf ${humanDate(newTodoDate)} verschoben`);
if (nTodoDays > 0) {
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 { form };
return message(form, done ? "Eintrag erledigt" : "Eintrag mit Notiz versehen");
}),
};

View file

@ -1,4 +1,5 @@
<script lang="ts">
import type { PageData } from "./$types";
import { superForm } from "sveltekit-superforms";
@ -32,7 +33,7 @@
label="Eintrag erledigen"
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>
<EntryTodoButton />
</div>

View file

@ -5,7 +5,7 @@ import { superValidate } from "sveltekit-superforms";
import { ZUrlEntityId } from "$lib/shared/model/validation";
import { trpc } from "$lib/shared/trpc";
import { loadWrap } from "$lib/shared/util";
import { loadWrap, moveEntryTodoDate } from "$lib/shared/util";
import { SchemaNewExecution } from "../schema";
@ -29,6 +29,9 @@ export const actions: Actions = {
old_execution_id: form.data.old_execution_id,
});
const nTodoDays = todoDays ? parseInt(todoDays.toString()) : 0;
await moveEntryTodoDate(id, nTodoDays, event);
redirect(302, `/entry/${id}`);
}),
};

View file

@ -7,6 +7,7 @@
import { superformConfig } from "$lib/shared/util";
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 { SchemaNewExecution } from "../schema";
@ -31,9 +32,7 @@
>
<div class="row c-vlight gap-2">
<button class="btn btn-sm btn-primary" type="submit">Speichern</button>
<button name="todo" class="join-item btn btn-sm" type="submit" value="0">
Notiz
</button>
<EntryTodoButton />
</div>
</MarkdownInput>
<input name="old_execution_id" type="hidden" bind:value={$form.old_execution_id} />