Browse Source

add more squil and rename Entry to CardEntry as its child components may be useful in other contexts.

mian
Gisle Aune 3 years ago
parent
commit
ad28d0f827
  1. 2
      scripts/goose-mysql/20220326173144_stat.sql
  2. 6
      scripts/goose-mysql/20220326174046_project.sql
  3. 16
      scripts/goose-mysql/20220404144911_project_requirement.sql
  4. 19
      scripts/goose-mysql/20220404144914_item.sql
  5. 17
      scripts/goose-mysql/20220404144947_item_stat_progress.sql
  6. 15
      scripts/goose-mysql/20220404184237_project_requirement_stat.sql
  7. 16
      src/lib/components/frontpage/ItemLink.svelte
  8. 6
      src/lib/components/frontpage/RequirementLink.svelte
  9. 6
      src/lib/components/frontpage/ScopeLink.svelte
  10. 10
      src/lib/components/frontpage/SprintLink.svelte
  11. 0
      src/lib/components/layout/CardEntry.svelte
  12. 2
      src/lib/database/mysql/database.ts
  13. 2
      src/lib/database/mysql/scopes.ts
  14. 6
      src/lib/models/item.ts

2
scripts/goose-mysql/20220326173144_stat.sql

@ -14,5 +14,5 @@ CREATE TABLE stat (
-- +goose Down -- +goose Down
-- +goose StatementBegin -- +goose StatementBegin
SELECT 'down SQL query';
DROP TABLE IF EXISTS stat;
-- +goose StatementEnd -- +goose StatementEnd

6
scripts/goose-mysql/20220326174046_project.sql

@ -1,7 +1,7 @@
-- +goose Up -- +goose Up
-- +goose StatementBegin -- +goose StatementBegin
CREATE TABLE IF NOT EXISTS 'project' (
`id` INT NOT NULL AUTO_INCREMENT,
CREATE TABLE project (
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`scope_id` INT NOT NULL, `scope_id` INT NOT NULL,
`author_id` CHAR(36) NOT NULL, `author_id` CHAR(36) NOT NULL,
`name` VARCHAR(255) NOT NULL, `name` VARCHAR(255) NOT NULL,
@ -14,5 +14,5 @@ CREATE TABLE IF NOT EXISTS 'project' (
-- +goose Down -- +goose Down
-- +goose StatementBegin -- +goose StatementBegin
SELECT 'down SQL query';
DROP TABLE IF EXISTS project;
-- +goose StatementEnd -- +goose StatementEnd

16
scripts/goose-mysql/20220404144911_project_requirement.sql

@ -0,0 +1,16 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE project_requirement (
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`scope_id` INT NOT NULL,
`project_id` INT NOT NULL,
`name` VARCHAR(255) NOT NULL,
`status` INT NOT NULL,
`description` TEXT NOT NULL
)
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS project_requirement;
-- +goose StatementEnd

19
scripts/goose-mysql/20220404144914_item.sql

@ -0,0 +1,19 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE item (
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`scope_id` INT NOT NULL,
`project_requirement_id` INT,
`name` VARCHAR(255) NOT NULL,
`description` TEXT NOT NULL,
`created_time` DATETIME NOT NULL,
`created_user_id` CHAR(36) NOT NULL,
`acquired_time` DATETIME,
`scheduled_date` DATE
)
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS item;
-- +goose StatementEnd

17
scripts/goose-mysql/20220404144947_item_stat_progress.sql

@ -0,0 +1,17 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE item_stat_progress (
`item_id` INT NOT NULL,
`stat_id` INT NOT NULL,
`acquired` INT NOT NULL,
`required` INT NOT NULL,
PRIMARY KEY (`item_id`, `stat_id`),
UNIQUE (`stat_id`, `item_id`)
)
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS item_stat_progress;
-- +goose StatementEnd

15
scripts/goose-mysql/20220404184237_project_requirement_stat.sql

@ -0,0 +1,15 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE project_requirement_stat (
`project_requirement_id` INT NOT NULL,
`stat_id` INT NOT NULL,
`required` INT NOT NULL,
PRIMARY KEY (`project_requirement_id`, `stat_id`)
)
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS project_requirement_stat;
-- +goose StatementEnd

16
src/lib/components/frontpage/ItemLink.svelte

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { StandaloneItem } from "$lib/models/item"; import type { StandaloneItem } from "$lib/models/item";
import Entry from "../layout/Entry.svelte";
import CardEntry from "../layout/CardEntry.svelte";
import EntryAmounts from "../layout/EntryAmounts.svelte"; import EntryAmounts from "../layout/EntryAmounts.svelte";
import EntryButton from "../layout/EntryButton.svelte"; import EntryButton from "../layout/EntryButton.svelte";
import EntryCompletionIcon from "../layout/EntryCompletionIcon.svelte"; import EntryCompletionIcon from "../layout/EntryCompletionIcon.svelte";
@ -27,8 +27,8 @@ import EntryDate from "../layout/EntryDate.svelte";
</script> </script>
<a href={link}> <a href={link}>
<Entry>
{#if !item.acquireDate}
<CardEntry>
{#if !item.acquireTime}
<EntryButton> <EntryButton>
<Icon name="check" /> <Icon name="check" />
</EntryButton> </EntryButton>
@ -37,18 +37,18 @@ import EntryDate from "../layout/EntryDate.svelte";
<Icon name="pen" /> <Icon name="pen" />
</EntryButton> </EntryButton>
{/if} {/if}
<EntryCompletionIcon condition={!!item.acquireDate} />
<EntryCompletionIcon condition={!!item.acquireTime} />
<EntryName subtitle={subtitle}>{item.name}</EntryName> <EntryName subtitle={subtitle}>{item.name}</EntryName>
{#if !compact} {#if !compact}
{#if !!item.acquireDate}
<EntryDate green value={item.acquireDate} verb="Acquired" />
{#if !!item.acquireTime}
<EntryDate green value={item.acquireTime} verb="Acquired" />
{:else} {:else}
<EntryDate value={item.createdDate} verb="Created" />
<EntryDate value={item.createdTime} verb="Created" />
{/if} {/if}
<EntryDescription>{item.description}</EntryDescription> <EntryDescription>{item.description}</EntryDescription>
{/if} {/if}
<EntryAmounts values={amounts} /> <EntryAmounts values={amounts} />
</Entry>
</CardEntry>
</a> </a>
<style> <style>

6
src/lib/components/frontpage/RequirementLink.svelte

@ -2,7 +2,7 @@
import type { StandaloneRequirement } from "$lib/models/project"; import type { StandaloneRequirement } from "$lib/models/project";
import Status from "$lib/models/status"; import Status from "$lib/models/status";
import Entry from "../layout/Entry.svelte";
import CardEntry from "../layout/CardEntry.svelte";
import EntryButton from "../layout/EntryButton.svelte"; import EntryButton from "../layout/EntryButton.svelte";
import EntryDescription from "../layout/EntryDescription.svelte"; import EntryDescription from "../layout/EntryDescription.svelte";
import EntryName from "../layout/EntryName.svelte"; import EntryName from "../layout/EntryName.svelte";
@ -18,7 +18,7 @@
</script> </script>
<a href="/{requirement.scope.id}/{requirement.project.id}?requirement={requirement.id}"> <a href="/{requirement.scope.id}/{requirement.project.id}?requirement={requirement.id}">
<Entry>
<CardEntry>
{#if requirement.status === Status.Active} {#if requirement.status === Status.Active}
<EntryButton> <EntryButton>
<Icon name="plus" /> <Icon name="plus" />
@ -35,7 +35,7 @@
<EntryProgress boat={boat} name={stat.name} acquired={stat.acquired} required={stat.required} /> <EntryProgress boat={boat} name={stat.name} acquired={stat.acquired} required={stat.required} />
{/each} {/each}
</EntryProgressRow> </EntryProgressRow>
</Entry>
</CardEntry>
</a> </a>
<style> <style>

6
src/lib/components/frontpage/ScopeLink.svelte

@ -1,15 +1,15 @@
<script lang="ts"> <script lang="ts">
import type { ScopeEntry } from "$lib/models/scope"; import type { ScopeEntry } from "$lib/models/scope";
import Entry from "../layout/Entry.svelte";
import CardEntry from "../layout/CardEntry.svelte";
import EntryName from "../layout/EntryName.svelte"; import EntryName from "../layout/EntryName.svelte";
export let scope: ScopeEntry export let scope: ScopeEntry
</script> </script>
<a href="/{scope.id}/"> <a href="/{scope.id}/">
<Entry>
<CardEntry>
<EntryName subtitle={scope.abbreviation}>{scope.name}</EntryName> <EntryName subtitle={scope.abbreviation}>{scope.name}</EntryName>
</Entry>
</CardEntry>
</a> </a>
<style> <style>

10
src/lib/components/frontpage/SprintLink.svelte

@ -5,7 +5,7 @@
import currentTime from "$lib/stores/currentTime"; import currentTime from "$lib/stores/currentTime";
import Entry from "../layout/Entry.svelte";
import CardEntry from "../layout/CardEntry.svelte";
import EntryDescription from "../layout/EntryDescription.svelte"; import EntryDescription from "../layout/EntryDescription.svelte";
import EntryName from "../layout/EntryName.svelte"; import EntryName from "../layout/EntryName.svelte";
import EntryProgress from "../layout/EntryProgress.svelte"; import EntryProgress from "../layout/EntryProgress.svelte";
@ -35,7 +35,7 @@ import Status from "$lib/models/status";
$: { $: {
if (sprint.items != null) { if (sprint.items != null) {
itemsAcquired = sprint.items.filter(i => !!i.acquireDate).length;
itemsAcquired = sprint.items.filter(i => !!i.acquireTime).length;
itemsRequired = sprint.items.length; itemsRequired = sprint.items.length;
} else { } else {
itemsAcquired = 0; itemsAcquired = 0;
@ -76,7 +76,7 @@ import Status from "$lib/models/status";
</script> </script>
<a href="/{sprint.scope.id}/sprints?sprint={sprint.id}"> <a href="/{sprint.scope.id}/sprints?sprint={sprint.id}">
<Entry>
<CardEntry>
{#if sprint.kind === "stats"} {#if sprint.kind === "stats"}
<EntryButton> <EntryButton>
<Icon name="plus" /> <Icon name="plus" />
@ -114,7 +114,7 @@ import Status from "$lib/models/status";
{/if} {/if}
</EntryProgressRow> </EntryProgressRow>
{#each sprint.items as item (item.id)} {#each sprint.items as item (item.id)}
{#if !item.acquireDate}
{#if !item.acquireTime}
<ItemLink compact item={item} /> <ItemLink compact item={item} />
{/if} {/if}
{/each} {/each}
@ -123,7 +123,7 @@ import Status from "$lib/models/status";
<RequirementLink compact boat={boat} requirement={requirement} /> <RequirementLink compact boat={boat} requirement={requirement} />
{/if} {/if}
{/each} {/each}
</Entry>
</CardEntry>
</a> </a>
<style lang="scss"> <style lang="scss">

0
src/lib/components/layout/Entry.svelte → src/lib/components/layout/CardEntry.svelte

2
src/lib/database/mysql/database.ts

@ -9,7 +9,7 @@ export default class MysqlDB implements Database {
connection: Pool connection: Pool
userId: string; userId: string;
private constructor(userId: string, connection: Connection) {
private constructor(userId: string, connection: Pool) {
this.userId = userId; this.userId = userId;
this.connection = connection; this.connection = connection;
} }

2
src/lib/database/mysql/scopes.ts

@ -33,8 +33,6 @@ export default class MysqlDBScopes implements ScopeRepo {
`, [id]).catch(() => []), `, [id]).catch(() => []),
]); ]);
console.log(scopeRows, statRows, statRows)
const r = scopeRows[0] as any; const r = scopeRows[0] as any;
if (!r) { if (!r) {
return null; return null;

6
src/lib/models/item.ts

@ -6,8 +6,10 @@ export default interface Item {
id: number id: number
name: string name: string
description: string description: string
acquireDate?: string
createdDate: string
createdTime: Date
createdBy: string
acquireTime?: Date
scheduledDate?: string
stats: StatProgressEntry[] stats: StatProgressEntry[]
} }

Loading…
Cancel
Save