Browse Source

expose task sorting mode options to the user. No clue why anything but the status will be used, but why not.

main
Gisle Aune 3 years ago
parent
commit
c2d7806fd3
  1. 7
      database/postgres/project.go
  2. 4
      svelte-ui/src/components/ProjectEntry.svelte
  3. 7
      svelte-ui/src/forms/ProjectForm.svelte
  4. 3
      svelte-ui/src/models/project.ts

7
database/postgres/project.go

@ -91,9 +91,9 @@ func (r *projectRepository) Insert(ctx context.Context, project models.Project)
_, err := r.db.NamedExecContext(ctx, ` _, err := r.db.NamedExecContext(ctx, `
INSERT INTO project( INSERT INTO project(
project_id, user_id, project_group_id, name, description, icon, active, created_time, start_time, end_time, subtract_amount, status_tag, favorite, tags
project_id, user_id, project_group_id, name, description, icon, active, created_time, start_time, end_time, subtract_amount, status_tag, favorite, tags, task_sort_fields
) VALUES ( ) VALUES (
:project_id, :user_id, :project_group_id, :name, :description, :icon, :active, :created_time, :start_time, :end_time, :subtract_amount, :status_tag, :favorite, :tags
:project_id, :user_id, :project_group_id, :name, :description, :icon, :active, :created_time, :start_time, :end_time, :subtract_amount, :status_tag, :favorite, :tags, :task_sort_fields
) )
`, toProjectDBO(project)) `, toProjectDBO(project))
if err != nil { if err != nil {
@ -120,7 +120,8 @@ func (r *projectRepository) Update(ctx context.Context, project models.Project)
subtract_amount = :subtract_amount, subtract_amount = :subtract_amount,
status_tag = :status_tag, status_tag = :status_tag,
favorite = :favorite, favorite = :favorite,
tags = :tags
tags = :tags,
task_sort_fields = :task_sort_fields
WHERE project_id=:project_id WHERE project_id=:project_id
`, toProjectDBO(project)) `, toProjectDBO(project))
if err != nil { if err != nil {

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

@ -134,7 +134,9 @@
{/if} {/if}
</OptionRow> </OptionRow>
{/if} {/if}
{#if hideInactive}
{#if project.taskSortFields.length > 0 && !project.taskSortFields[0].includes("status")}
<TaskList header="" tasks={project.tasks} project={project} showAllOptions={showAllOptions} />
{:else if hideInactive}
<TaskList header="" tasks={nonHiddenTasks} project={project} showAllOptions={showAllOptions} /> <TaskList header="" tasks={nonHiddenTasks} project={project} showAllOptions={showAllOptions} />
{:else} {:else}
<TaskList header="Active" tasks={activeTasks} project={project} showAllOptions={showAllOptions} /> <TaskList header="Active" tasks={activeTasks} project={project} showAllOptions={showAllOptions} />

7
svelte-ui/src/forms/ProjectForm.svelte

@ -32,6 +32,8 @@
favorite: false, favorite: false,
subtractAmount: 0, subtractAmount: 0,
tags: [], tags: [],
taskSortFields: ["status"],
subtractions: [],
} }
let verb = "Add"; let verb = "Add";
if (md.name === "project.edit" || md.name === "project.delete") { if (md.name === "project.edit" || md.name === "project.delete") {
@ -55,6 +57,7 @@
let error = null; let error = null;
let loading = false; let loading = false;
let tags = project.tags.join(", "); let tags = project.tags.join(", ");
let taskSortFields = project.taskSortFields.join(", ");
function onSubmit() { function onSubmit() {
loading = true; loading = true;
@ -71,6 +74,7 @@
statusTag: statusTag !== "" ? statusTag : null, statusTag: statusTag !== "" ? statusTag : null,
subtractAmount: Math.min(subtractAmount, 0), subtractAmount: Math.min(subtractAmount, 0),
tags: tags.length > 0 ? tags.split(",").map(t => t.trim()) : [], tags: tags.length > 0 ? tags.split(",").map(t => t.trim()) : [],
taskSortFields: taskSortFields.length > 0 ? taskSortFields.split(",").map(t => t.trim()) : [],
name, description, icon, favorite, name, description, icon, favorite,
}).then(newProject => { }).then(newProject => {
@ -104,6 +108,7 @@
clearStatusTag: statusTag === "", clearStatusTag: statusTag === "",
subtractAmount: subtractAmount, subtractAmount: subtractAmount,
setTags: tags.length > 0 ? tags.split(",").map(t => t.trim()) : [], setTags: tags.length > 0 ? tags.split(",").map(t => t.trim()) : [],
taskSortFields: taskSortFields.length > 0 ? taskSortFields.split(",").map(t => t.trim()) : [],
name, description, icon, favorite, name, description, icon, favorite,
}).then(() => { }).then(() => {
@ -149,6 +154,8 @@
<StatusTagSelect disabled={deletion} isProject bind:value={statusTag} /> <StatusTagSelect disabled={deletion} isProject bind:value={statusTag} />
<label for="tags">Tags (Comma Separated)</label> <label for="tags">Tags (Comma Separated)</label>
<input disabled={deletion} name="tags" type="text" bind:value={tags} /> <input disabled={deletion} name="tags" type="text" bind:value={tags} />
<label for="tags">Task sorting fields (Comma Separated; time, name, status)</label>
<input disabled={deletion} name="tags" type="text" bind:value={taskSortFields} />
<Checkbox disabled={deletion} bind:checked={favorite} label="Mark as favorite." /> <Checkbox disabled={deletion} bind:checked={favorite} label="Mark as favorite." />

3
svelte-ui/src/models/project.ts

@ -13,6 +13,7 @@ export default interface Project {
favorite: boolean favorite: boolean
subtractAmount: number subtractAmount: number
tags: string[] tags: string[]
taskSortFields: string[]
startTime?: string startTime?: string
endTime?: string endTime?: string
statusTag?: string statusTag?: string
@ -47,6 +48,7 @@ export interface ProjectInput {
statusTag?: string statusTag?: string
favorite?: boolean favorite?: boolean
tags?: string[] tags?: string[]
taskSortFields?: string[]
} }
export interface ProjectUpdate { export interface ProjectUpdate {
@ -64,4 +66,5 @@ export interface ProjectUpdate {
subtractAmount?: number subtractAmount?: number
favorite?: boolean favorite?: boolean
setTags?: string[] setTags?: string[]
taskSortFields?: string[]
} }
Loading…
Cancel
Save