Gisle Aune
4 years ago
20 changed files with 339 additions and 64 deletions
-
20api/goal.go
-
27api/log.go
-
1cmd/stufflog2-local/main.go
-
11database/postgres/goals.go
-
14database/postgres/logs.go
-
15migrations/postgres/20210117171454_add_goal_columns_ct_unweighed_and_item_id.sql
-
15migrations/postgres/20210117172203_add_log_columns_amount_and_secondary_item.sql
-
45models/goal.go
-
53models/log.go
-
52services/loader.go
-
31svelte-ui/src/components/GroupItemSelect.svelte
-
21svelte-ui/src/components/ItemLink.svelte
-
6svelte-ui/src/components/ItemSelect.svelte
-
5svelte-ui/src/components/LogEntry.svelte
-
3svelte-ui/src/components/Modal.svelte
-
10svelte-ui/src/components/TaskEntry.svelte
-
28svelte-ui/src/forms/GoalForm.svelte
-
24svelte-ui/src/forms/LogForm.svelte
-
10svelte-ui/src/models/goal.ts
-
12svelte-ui/src/models/log.ts
@ -0,0 +1,15 @@ |
|||
-- +goose Up |
|||
-- +goose StatementBegin |
|||
ALTER TABLE goal |
|||
ADD COLUMN composition_mode TEXT NOT NULL DEFAULT 'item', |
|||
ADD COLUMN unweighted BOOL NOT NULL DEFAULT false, |
|||
ADD COLUMN item_id CHAR(16) DEFAULT NULL; |
|||
-- +goose StatementEnd |
|||
|
|||
-- +goose Down |
|||
-- +goose StatementBegin |
|||
ALTER TABLE goal |
|||
DROP COLUMN composition_mode, |
|||
DROP COLUMN unweighted, |
|||
DROP COLUMN item_id; |
|||
-- +goose StatementEnd |
@ -0,0 +1,15 @@ |
|||
-- +goose Up |
|||
-- +goose StatementBegin |
|||
ALTER TABLE log |
|||
ADD COLUMN item_amount INT NOT NULL DEFAULT 1, |
|||
ADD COLUMN secondary_item_id CHAR(16) DEFAULT NULL, |
|||
ADD COLUMN secondary_item_amount INT NOT NULL DEFAULT 0; |
|||
-- +goose StatementEnd |
|||
|
|||
-- +goose Down |
|||
-- +goose StatementBegin |
|||
ALTER TABLE log |
|||
DROP COLUMN item_amount, |
|||
DROP COLUMN secondary_item_id, |
|||
DROP COLUMN secondary_item_amount; |
|||
-- +goose StatementEnd |
@ -0,0 +1,31 @@ |
|||
<script lang="ts"> |
|||
import type { GroupResult } from "../models/group"; |
|||
|
|||
export let value = ""; |
|||
export let name = ""; |
|||
export let disabled = false; |
|||
export let optional = false; |
|||
export let optionalLabel = "None"; |
|||
export let group: GroupResult = null; |
|||
|
|||
$: { |
|||
if (group != null && !group.items.find(t => t.id === value)) { |
|||
if (optional) { |
|||
value = ""; |
|||
} else { |
|||
value = group.items[0]?.id || ""; |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<select name={name} bind:value={value} disabled={disabled || group == null || group.items.length === 0}> |
|||
{#if optional} |
|||
<option value={""} selected={"" === value}>{optionalLabel}</option> |
|||
{/if} |
|||
{#if group != null} |
|||
{#each group.items as item (item.id)} |
|||
<option value={item.id} selected={item.id === value}>{item.name} ({item.groupWeight})</option> |
|||
{/each} |
|||
{/if} |
|||
</select> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue