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, `
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 (
: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))
if err != nil {
@ -120,7 +120,8 @@ func (r *projectRepository) Update(ctx context.Context, project models.Project)
subtract_amount = :subtract_amount,
status_tag = :status_tag,
favorite = :favorite,
tags = :tags
tags = :tags,
task_sort_fields = :task_sort_fields
WHERE project_id=:project_id
`, toProjectDBO(project))
if err != nil {

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

@ -134,7 +134,9 @@
{/if}
</OptionRow>
{/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} />
{:else}
<TaskList header="Active" tasks={activeTasks} project={project} showAllOptions={showAllOptions} />

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

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

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

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