Browse Source

add recalling of last project when navigating out from and into quest log.

main
Gisle Aune 4 years ago
parent
commit
d3f17f867f
  1. 20
      svelte-ui/src/components/Menu.svelte
  2. 5
      svelte-ui/src/components/ParentEntry.svelte
  3. 4
      svelte-ui/src/components/ProjectEntry.svelte
  4. 1
      svelte-ui/src/components/QLListItem.svelte
  5. 19
      svelte-ui/src/components/QuestLog.svelte
  6. 4
      svelte-ui/src/stores/selection.ts

20
svelte-ui/src/components/Menu.svelte

@ -2,14 +2,6 @@
import { link } from "svelte-routing";
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 = {
home: $selectionStore.path === "/",
goals: $selectionStore.path.startsWith("/goals"),
@ -21,12 +13,12 @@
</script>
<nav>
<a on:click={updateLocation} 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="desktop" on:click={updateLocation} 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 on:click={updateLocation} 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.home} use:link href="/">Stufflog</a>
<a class:selected={selected.goals} use:link href="/goals">Goals</a>
<a class="desktop" class:selected={selected.questlog} use:link href="/questlog">Projects</a>
<a class="mobile" class:selected={selected.projects} use:link href="/projects">Projects</a>
<a class:selected={selected.items} use:link href="/items">Items</a>
<a class:selected={selected.logs} use:link href="/logs">Logs</a>
</nav>
<style>

5
svelte-ui/src/components/ParentEntry.svelte

@ -35,6 +35,7 @@ import TimeProgress from "./TimeProgress.svelte";
export let hideIcon: boolean = false;
export let showTimeProgress: boolean = false;
export let annotations: IconName[] = [];
export let removeHook: boolean = false;
let iconName: IconName;
@ -50,7 +51,9 @@ import TimeProgress from "./TimeProgress.svelte";
</script>
<div class="parent-entry" class:full={full}>
<LinkHook id={entry.id} />
{#if !removeHook}
<LinkHook id={entry.id} />
{/if}
{#if !hideIcon}
<div class="icon" class:completed={entry.active === false}>
{#if entry.active != null}

4
svelte-ui/src/components/ProjectEntry.svelte

@ -2,7 +2,7 @@
import type { ProjectResult } from "../models/project";
import type { TaskResult } from "../models/task";
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 OptionRow from "./OptionRow.svelte";
import ParentEntry from "./ParentEntry.svelte";
@ -16,6 +16,7 @@ import IS_MOBILE from "../utils/phone-check";
export let linkProject: boolean = false;
export let hideIcon: boolean = false;
export let isFake: boolean = false;
export let removeHook: boolean = false;
let mdAddTask: ModalData;
let mdProjectEdit: ModalData;
@ -56,6 +57,7 @@ import IS_MOBILE from "../utils/phone-check";
hideProgress={hideProgress}
hideIcon={hideIcon}
showTimeProgress={!hideProgress}
removeHook={removeHook}
annotations={isFake ? ["list"] : []}
>
{#if showAllOptions}

1
svelte-ui/src/components/QLListItem.svelte

@ -14,7 +14,6 @@
let completed: boolean;
function handleClick() {
window.location.hash = "#" + project.id;
selectionStore.change("hash", project.id);
}

19
svelte-ui/src/components/QuestLog.svelte

@ -1,3 +1,7 @@
<script lang="ts" context="module">
let lastQuest = "";
</script>
<script lang="ts">
import type { ProjectResult } from "../models/project";
import selectionStore from "../stores/selection";
@ -26,12 +30,25 @@
$: {
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) {
selectionStore.change("hash", project.id);
}
}
}
$: {
if ($selectionStore.hash.startsWith("P")) {
lastQuest = $selectionStore.hash;
}
}
</script>
<div class="quest-log">

4
svelte-ui/src/stores/selection.ts

@ -22,6 +22,10 @@ function createSelectionStore() {
},
change(key: keyof(SelectionData), value: string) {
if (key === "hash") {
window.location.hash = "#" + value;
}
update(d => ({...d, [key]: value}));
},
}

Loading…
Cancel
Save