Gisle Aune
4 years ago
11 changed files with 196 additions and 12 deletions
-
90database/postgres/project.go
-
11migrations/postgres/20210418164739_add_project_column_tags.sql
-
5models/project.go
-
30models/projectgroup.go
-
1svelte-ui/src/components/ParentEntry.svelte
-
4svelte-ui/src/components/ProjectEntry.svelte
-
5svelte-ui/src/components/QLListItem.svelte
-
33svelte-ui/src/components/Tag.svelte
-
18svelte-ui/src/components/TagList.svelte
-
6svelte-ui/src/forms/ProjectForm.svelte
-
3svelte-ui/src/models/project.ts
@ -0,0 +1,11 @@ |
|||
-- +goose Up |
|||
-- +goose StatementBegin |
|||
ALTER TABLE project |
|||
ADD COLUMN tags TEXT[] DEFAULT ARRAY[]::TEXT[]; |
|||
-- +goose StatementEnd |
|||
|
|||
-- +goose Down |
|||
-- +goose StatementBegin |
|||
ALTER TABLE project |
|||
DROP COLUMN tags; |
|||
-- +goose StatementEnd |
@ -0,0 +1,30 @@ |
|||
package models |
|||
|
|||
import "context" |
|||
|
|||
type ProjectGroup struct { |
|||
ID string `json:"id" db:"id"` |
|||
UserID string `json:"-" db:"user_id"` |
|||
Name string `json:"name" db:"name"` |
|||
Abbreviation string `json:"abbreviation" db:"abbreviation"` |
|||
CategoryNames map[string]string `json:"categoryNames" db:"category_names"` |
|||
} |
|||
|
|||
type ProjectGroupUpdate struct { |
|||
Name *string `json:"name"` |
|||
Abbreviation *string `json:"abbreviation"` |
|||
SetCategoryNames map[string]string `json:"setCategoryNames"` |
|||
ResetCategoryName *string `json:"resetCategoryName"` |
|||
} |
|||
|
|||
type ProjectGroupFilter struct { |
|||
UserID string `json:"userId"` |
|||
} |
|||
|
|||
type ProjectGroupRepository interface { |
|||
Find(ctx context.Context, id string) (*ProjectGroup, error) |
|||
List(ctx context.Context, filter ProjectGroupFilter) ([]*ProjectGroup, error) |
|||
Insert(ctx context.Context, group ProjectGroup) error |
|||
Update(ctx context.Context, group ProjectGroup) error |
|||
Delete(ctx context.Context, group ProjectGroup) error |
|||
} |
@ -0,0 +1,33 @@ |
|||
<script lang="ts"> |
|||
export let value = ""; |
|||
export let small = false; |
|||
|
|||
let style = ""; |
|||
|
|||
$: { |
|||
let hash = 0; |
|||
for (let i = 0; i < value.length; i++) { |
|||
hash = value.charCodeAt(i) + ((hash << 5) - hash); |
|||
hash = hash & hash; |
|||
} |
|||
|
|||
console.log(value, hash); |
|||
|
|||
style = `color: hsl(${(hash << 4) % 360}, ${40 + (hash % 8)}%, ${50+(hash % 4)}%)` |
|||
} |
|||
</script> |
|||
|
|||
<div style={style} class="tag" class:small>{value}</div> |
|||
|
|||
<style> |
|||
div.tag { |
|||
padding: 0.25em 0.75ch; |
|||
margin: 0.25em 0.5ch; |
|||
font-size: 0.75em; |
|||
border: 1px solid; |
|||
} |
|||
|
|||
div.tag.small { |
|||
padding: 0em 0.5ch; |
|||
} |
|||
</style> |
@ -0,0 +1,18 @@ |
|||
<script lang="ts"> |
|||
import Tag from "./Tag.svelte"; |
|||
|
|||
export let tags: string[] = []; |
|||
</script> |
|||
|
|||
<div class="tag-list"> |
|||
{#each tags as tag (tag)} |
|||
<Tag value={tag} /> |
|||
{/each} |
|||
</div> |
|||
|
|||
<style> |
|||
div.tag-list { |
|||
display: flex; |
|||
margin-top: 0.15em; |
|||
} |
|||
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue