From e44b8b4831260addfafa6c66dda6c50e7c3ca997 Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Wed, 9 Mar 2022 22:01:49 +0100 Subject: [PATCH] figure out scope handling, and add EntryStatusLine. --- src/app.d.ts | 15 ++-- .../frontpage/RequirementLink.svelte | 2 + .../components/frontpage/SprintLink.svelte | 5 +- .../components/layout/EntryStatusLine.svelte | 62 +++++++++++++++ src/lib/models/scope.ts | 2 + src/routes/[scope].json.ts | 78 +++++++++++++++++++ src/routes/[scope]/__layout.svelte | 32 ++++++++ src/routes/[scope]/index.svelte | 20 +++++ 8 files changed, 209 insertions(+), 7 deletions(-) create mode 100644 src/lib/components/layout/EntryStatusLine.svelte create mode 100644 src/routes/[scope].json.ts create mode 100644 src/routes/[scope]/__layout.svelte create mode 100644 src/routes/[scope]/index.svelte diff --git a/src/app.d.ts b/src/app.d.ts index 9cbf1c5..2adaf08 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -1,10 +1,15 @@ /// +import type Scope from "$lib/models/scope"; + // See https://kit.svelte.dev/docs/types#the-app-namespace // for information about these interfaces -declare namespace App { - // interface Locals {} - // interface Platform {} - // interface Session {} - // interface Stuff {} +declare global { + declare namespace App { + // interface Platform {} + // interface Session {} + interface Stuff { + scope?: Scope + } + } } diff --git a/src/lib/components/frontpage/RequirementLink.svelte b/src/lib/components/frontpage/RequirementLink.svelte index ef64a08..8c8904d 100644 --- a/src/lib/components/frontpage/RequirementLink.svelte +++ b/src/lib/components/frontpage/RequirementLink.svelte @@ -9,6 +9,7 @@ import EntryProgress from "../layout/EntryProgress.svelte"; import EntryProgressRow from "../layout/EntryProgressRow.svelte"; import EntryStatusIcon from "../layout/EntryStatusIcon.svelte"; +import EntryStatusLine from "../layout/EntryStatusLine.svelte"; import Icon from "../layout/Icon.svelte"; export let requirement: StandaloneRequirement @@ -26,6 +27,7 @@ {requirement.name} {#if !compact} + {requirement.description} {/if} diff --git a/src/lib/components/frontpage/SprintLink.svelte b/src/lib/components/frontpage/SprintLink.svelte index 5b7a2ba..5212ae4 100644 --- a/src/lib/components/frontpage/SprintLink.svelte +++ b/src/lib/components/frontpage/SprintLink.svelte @@ -50,9 +50,10 @@ import Status from "$lib/models/status"; break; } case "requirements": { + // Completed, failed or dropped should fix. aggregate = calculateAggregate(sprint.requirements.map(r => ( - r.status >= Status.Completed - ? r.stats.map(s => ({...s, acquired: s.required})) + r.status >= Status.Completed + ? r.stats.map(s => ({...s, acquired: Math.max(s.required, s.acquired)})) : r.stats )).flat()); break; diff --git a/src/lib/components/layout/EntryStatusLine.svelte b/src/lib/components/layout/EntryStatusLine.svelte new file mode 100644 index 0000000..749eb63 --- /dev/null +++ b/src/lib/components/layout/EntryStatusLine.svelte @@ -0,0 +1,62 @@ + + +
+ + + {statusText} + +
+ + diff --git a/src/lib/models/scope.ts b/src/lib/models/scope.ts index 9182423..2cf073c 100644 --- a/src/lib/models/scope.ts +++ b/src/lib/models/scope.ts @@ -1,7 +1,9 @@ import type { ProjectEntry } from "./project"; +import type Stat from "./stat"; export default interface Scope extends ScopeEntry { activeProjects: ProjectEntry[] + stats: Stat[] } export interface ScopeEntry { diff --git a/src/routes/[scope].json.ts b/src/routes/[scope].json.ts new file mode 100644 index 0000000..ba0e393 --- /dev/null +++ b/src/routes/[scope].json.ts @@ -0,0 +1,78 @@ +import type { RequestHandler } from "@sveltejs/kit" +import Status from "$lib/models/status" +import type Scope from "$lib/models/scope" + +export const get: RequestHandler = async({params}) => { + const scopeId = parseInt(params.scope); + const scope = scopes.find(s => s.id === scopeId); + if (scope === null) { + return { + status: 404, + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + message: "Scope not found", + }), + } + } + + return { + status: 200, + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + scope + }), + } +} + +const scopes: Scope[] = [ + { + id: 1, name: "3D Modeling", abbreviation: "3D", + stats: [ + {id: 101, name: "Asset", weight: 0.1, description: "Some description"}, + {id: 102, name: "Tweak", weight: 0.2, description: "Some description"}, + { + id: 103, name: "Complexity", weight: 1, description: "Some description", + allowedAmounts: { + "Basic": 1, + "Medium": 3, + "Complex": 6, + "Excessive": 12, + } + }, + {id: 104, name: "Hard Surface", weight: 0.4, description: "Some description"}, + {id: 105, name: "UV Mapping", weight: 0.2, description: "Some description"}, + {id: 106, name: "Third-Party Asset", weight: 0.1, description: "Some description"}, + {id: 107, name: "Material", weight: 0.1, description: "Some description"}, + ], + activeProjects: [ + {id: 1001, name: "3D Maps: Proving the Concept", status: Status.Active}, + {id: 1002, name: "Redrock HQ", status: Status.Active}, + {id: 1003, name: "Tutorial: Realistic Environments", status: Status.Background}, + ] + }, + { + id: 2, name: "Roleplay", abbreviation: "RP", + stats: [ + {id: 201, name: "Story", weight: 3, description: "Some description"}, + {id: 202, name: "Story Word", weight: 0.002, description: "Some description"}, + {id: 203, name: "Worldbuilding", weight: 0.50, description: "Some description"}, + {id: 204, name: "Characterbuilding", weight: 0.50, description: "Some description"}, + {id: 205, name: "Note", weight: 1, description: "Some description"}, + {id: 206, name: "Wiki Section", weight: 1, description: "Some description"}, + {id: 207, name: "Wiki Research", weight: 0.5, description: "Some description"}, + {id: 208, name: "Wiki Complexity", weight: 0.5, description: "Some description"}, + ], + activeProjects: [ + {id: 2001, name: "Ilyna T'Rea", status: Status.Active}, + {id: 2002, name: "Renala T'Iavay", status: Status.Active}, + {id: 2003, name: "Background Stories", status: Status.Background}, + ] + }, + //{id: 3, name: "Minecraft", abbreviation: "MC"}, + //{id: 4, name: "Coding", abbreviation: "CODE"}, + //{id: 5, name: "System Administration", abbreviation: "SA"}, +] \ No newline at end of file diff --git a/src/routes/[scope]/__layout.svelte b/src/routes/[scope]/__layout.svelte new file mode 100644 index 0000000..d707e8f --- /dev/null +++ b/src/routes/[scope]/__layout.svelte @@ -0,0 +1,32 @@ + + + + +

{scope.name}

+ + \ No newline at end of file diff --git a/src/routes/[scope]/index.svelte b/src/routes/[scope]/index.svelte new file mode 100644 index 0000000..8848950 --- /dev/null +++ b/src/routes/[scope]/index.svelte @@ -0,0 +1,20 @@ + + + + +

{$page.stuff.scope.name}

\ No newline at end of file