add recalling of last project when navigating out from and into quest log.
This commit is contained in:
@@ -2,14 +2,6 @@
|
|||||||
import { link } from "svelte-routing";
|
import { link } from "svelte-routing";
|
||||||
import selectionStore from "../stores/selection";
|
import selectionStore from "../stores/selection";
|
||||||
|
|
||||||
export let location: string = window.location.pathname.split("?")[0];
|
|
||||||
|
|
||||||
function updateLocation() {
|
|
||||||
setTimeout(() => {
|
|
||||||
location = window.location.pathname.split("?")[0];
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
$: selected = {
|
$: selected = {
|
||||||
home: $selectionStore.path === "/",
|
home: $selectionStore.path === "/",
|
||||||
goals: $selectionStore.path.startsWith("/goals"),
|
goals: $selectionStore.path.startsWith("/goals"),
|
||||||
@@ -21,12 +13,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<a on:click={updateLocation} class:selected={selected.home} use:link href="/">Stufflog</a>
|
<a class:selected={selected.home} use:link href="/">Stufflog</a>
|
||||||
<a on:click={updateLocation} class:selected={selected.goals} use:link href="/goals">Goals</a>
|
<a class:selected={selected.goals} use:link href="/goals">Goals</a>
|
||||||
<a class="desktop" on:click={updateLocation} class:selected={selected.questlog} use:link href="/questlog">Projects</a>
|
<a class="desktop" class:selected={selected.questlog} use:link href="/questlog">Projects</a>
|
||||||
<a class="mobile" on:click={updateLocation} class:selected={selected.projects} use:link href="/projects">Projects</a>
|
<a class="mobile" class:selected={selected.projects} use:link href="/projects">Projects</a>
|
||||||
<a on:click={updateLocation} class:selected={selected.items} use:link href="/items">Items</a>
|
<a class:selected={selected.items} use:link href="/items">Items</a>
|
||||||
<a on:click={updateLocation} class:selected={selected.logs} use:link href="/logs">Logs</a>
|
<a class:selected={selected.logs} use:link href="/logs">Logs</a>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import TimeProgress from "./TimeProgress.svelte";
|
|||||||
export let hideIcon: boolean = false;
|
export let hideIcon: boolean = false;
|
||||||
export let showTimeProgress: boolean = false;
|
export let showTimeProgress: boolean = false;
|
||||||
export let annotations: IconName[] = [];
|
export let annotations: IconName[] = [];
|
||||||
|
export let removeHook: boolean = false;
|
||||||
|
|
||||||
let iconName: IconName;
|
let iconName: IconName;
|
||||||
|
|
||||||
@@ -50,7 +51,9 @@ import TimeProgress from "./TimeProgress.svelte";
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="parent-entry" class:full={full}>
|
<div class="parent-entry" class:full={full}>
|
||||||
<LinkHook id={entry.id} />
|
{#if !removeHook}
|
||||||
|
<LinkHook id={entry.id} />
|
||||||
|
{/if}
|
||||||
{#if !hideIcon}
|
{#if !hideIcon}
|
||||||
<div class="icon" class:completed={entry.active === false}>
|
<div class="icon" class:completed={entry.active === false}>
|
||||||
{#if entry.active != null}
|
{#if entry.active != null}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import type { ProjectResult } from "../models/project";
|
import type { ProjectResult } from "../models/project";
|
||||||
import type { TaskResult } from "../models/task";
|
import type { TaskResult } from "../models/task";
|
||||||
import type { ModalData } from "../stores/modal";
|
import type { ModalData } from "../stores/modal";
|
||||||
import IS_MOBILE from "../utils/phone-check";
|
import IS_MOBILE from "../utils/phone-check";
|
||||||
import Option from "./Option.svelte";
|
import Option from "./Option.svelte";
|
||||||
import OptionRow from "./OptionRow.svelte";
|
import OptionRow from "./OptionRow.svelte";
|
||||||
import ParentEntry from "./ParentEntry.svelte";
|
import ParentEntry from "./ParentEntry.svelte";
|
||||||
@@ -16,6 +16,7 @@ import IS_MOBILE from "../utils/phone-check";
|
|||||||
export let linkProject: boolean = false;
|
export let linkProject: boolean = false;
|
||||||
export let hideIcon: boolean = false;
|
export let hideIcon: boolean = false;
|
||||||
export let isFake: boolean = false;
|
export let isFake: boolean = false;
|
||||||
|
export let removeHook: boolean = false;
|
||||||
|
|
||||||
let mdAddTask: ModalData;
|
let mdAddTask: ModalData;
|
||||||
let mdProjectEdit: ModalData;
|
let mdProjectEdit: ModalData;
|
||||||
@@ -56,6 +57,7 @@ import IS_MOBILE from "../utils/phone-check";
|
|||||||
hideProgress={hideProgress}
|
hideProgress={hideProgress}
|
||||||
hideIcon={hideIcon}
|
hideIcon={hideIcon}
|
||||||
showTimeProgress={!hideProgress}
|
showTimeProgress={!hideProgress}
|
||||||
|
removeHook={removeHook}
|
||||||
annotations={isFake ? ["list"] : []}
|
annotations={isFake ? ["list"] : []}
|
||||||
>
|
>
|
||||||
{#if showAllOptions}
|
{#if showAllOptions}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
let completed: boolean;
|
let completed: boolean;
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
window.location.hash = "#" + project.id;
|
|
||||||
selectionStore.change("hash", project.id);
|
selectionStore.change("hash", project.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
let lastQuest = "";
|
||||||
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { ProjectResult } from "../models/project";
|
import type { ProjectResult } from "../models/project";
|
||||||
import selectionStore from "../stores/selection";
|
import selectionStore from "../stores/selection";
|
||||||
@@ -26,12 +30,25 @@
|
|||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (project === null && projects.length > 0) {
|
if (project === null && projects.length > 0) {
|
||||||
project = expiringProjects[0] || activeProjects[0] || completedProjects[0] || null;
|
if (lastQuest !== "") {
|
||||||
|
project = projects.find(p => p.id === lastQuest) || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (project === null) {
|
||||||
|
project = expiringProjects[0] || activeProjects[0] || completedProjects[0] || null;
|
||||||
|
}
|
||||||
|
|
||||||
if (project !== null) {
|
if (project !== null) {
|
||||||
selectionStore.change("hash", project.id);
|
selectionStore.change("hash", project.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if ($selectionStore.hash.startsWith("P")) {
|
||||||
|
lastQuest = $selectionStore.hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="quest-log">
|
<div class="quest-log">
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ function createSelectionStore() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
change(key: keyof(SelectionData), value: string) {
|
change(key: keyof(SelectionData), value: string) {
|
||||||
|
if (key === "hash") {
|
||||||
|
window.location.hash = "#" + value;
|
||||||
|
}
|
||||||
|
|
||||||
update(d => ({...d, [key]: value}));
|
update(d => ({...d, [key]: value}));
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user