Browse Source

add group filter on ProjectSelect.

main
Gisle Aune 3 years ago
parent
commit
7973373419
  1. 7
      svelte-ui/src/components/ItemLink.svelte
  2. 46
      svelte-ui/src/components/ProjectSelect.svelte
  3. 2
      svelte-ui/src/components/TaskEntry.svelte
  4. 2
      svelte-ui/src/forms/TaskForm.svelte
  5. 5
      svelte-ui/src/forms/TaskLinkForm.svelte

7
svelte-ui/src/components/ItemLink.svelte

@ -15,7 +15,12 @@
<Icon name={item.icon} /> <Icon name={item.icon} />
</div> </div>
<div class="item-name"> <div class="item-name">
<a href="/items#{item.groupId}">{item.name} ({item.groupWeight})</a>
<a href="/items#{item.groupId}">
<span>{item.name}</span>
{#if item.groupWeight !== 1}
<span>({item.groupWeight})</span>
{/if}
</a>
</div> </div>
</div> </div>

46
svelte-ui/src/components/ProjectSelect.svelte

@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import type Project from "../models/project"; import type Project from "../models/project";
import projectStore from "../stores/project"; import projectStore from "../stores/project";
import projectGroupStore from "../stores/projectGroup";
interface OptGroup { interface OptGroup {
status: string status: string
projects: Project[] projects: Project[]
@ -8,44 +9,55 @@
export let value = ""; export let value = "";
export let name = ""; export let name = "";
export let groupId = "";
export let disabled = false; export let disabled = false;
export let optional = false; export let optional = false;
let optGroups: OptGroup[] let optGroups: OptGroup[]
$: { $: {
let projects = $projectStore.projects;
let labels = {};
if (groupId != "") {
const group = $projectGroupStore.groups.find(g => g.id === groupId);
if (group != null) {
projects = group.projects;
labels = group.categoryNames;
}
}
optGroups = [ optGroups = [
{ {
status: "Deadlines",
projects: $projectStore.projects.filter(p => p.active && p.endTime)
status: labels["deadlines"] || "Deadlines",
projects: projects.filter(p => p.active && p.endTime)
}, },
{ {
status: "Active",
projects: $projectStore.projects.filter(p => p.active && !p.endTime)
status: labels["active"] || "Active",
projects: projects.filter(p => p.active && !p.endTime)
}, },
{ {
status: "To Do",
projects: $projectStore.projects.filter(p => !p.active && p.statusTag === "to do")
status: labels["progress"] || "Progress",
projects: projects.filter(p => !p.active && p.statusTag === "progress")
}, },
{ {
status: "On Hold",
projects: $projectStore.projects.filter(p => !p.active && p.statusTag === "on hold")
status: labels["background"] || "Background",
projects: projects.filter(p => !p.active && p.statusTag === "background")
}, },
{ {
status: "Completed",
projects: $projectStore.projects.filter(p => !p.active && p.statusTag === "completed")
status: labels["to do"] || "To Do",
projects: projects.filter(p => !p.active && p.statusTag === "to do")
}, },
{ {
status: "Background",
projects: $projectStore.projects.filter(p => !p.active && p.statusTag === "background")
status: labels["on hold"] || "On Hold",
projects: projects.filter(p => !p.active && p.statusTag === "on hold")
}, },
{ {
status: "Progress",
projects: $projectStore.projects.filter(p => !p.active && p.statusTag === "progress")
status: labels["completed"] || "Completed",
projects: projects.filter(p => !p.active && p.statusTag === "completed")
}, },
{ {
status: "Failed",
projects: $projectStore.projects.filter(p => !p.active && p.statusTag === "failed")
status: labels["failed"] || "Failed",
projects: projects.filter(p => !p.active && p.statusTag === "failed")
}, },
] ]
@ -72,7 +84,7 @@
{#if group.projects.length > 0} {#if group.projects.length > 0}
<optgroup label={group.status}> <optgroup label={group.status}>
{#each group.projects as project (project.id)} {#each group.projects as project (project.id)}
<option value={project.id} selected={project.id === value}>{project.name}</option>
<option value={project.id} selected={project.id === value}>{project.tags.length ? `${project.tags[0]}: ${project.name}` : project.name}</option>
{/each} {/each}
</optgroup> </optgroup>
{/if} {/if}

2
svelte-ui/src/components/TaskEntry.svelte

@ -72,7 +72,7 @@
$: mdLogAdd = {name: "log.add", task: {...task, project}}; $: mdLogAdd = {name: "log.add", task: {...task, project}};
$: mdTaskEdit = {name: "task.edit", task: {...task, project}}; $: mdTaskEdit = {name: "task.edit", task: {...task, project}};
$: mdTaskDelete = {name: "task.delete", task: {...task, project}}; $: mdTaskDelete = {name: "task.delete", task: {...task, project}};
$: mdTaskLink = {name: "tasklink.add", task};
$: mdTaskLink = {name: "tasklink.add", task, project};
$: mdTaskUnlink = {name: "tasklink.delete", task, project}; $: mdTaskUnlink = {name: "tasklink.delete", task, project};
$: isLinked = task.projectId !== project.id; $: isLinked = task.projectId !== project.id;
$: actualParent = (actualProject != null && actualProject.id !== project.id) ? actualProject : null; $: actualParent = (actualProject != null && actualProject.id !== project.id) ? actualProject : null;

2
svelte-ui/src/forms/TaskForm.svelte

@ -111,7 +111,7 @@ import ProjectSelect from "../components/ProjectSelect.svelte";
<Modal show title="{verb} Task" error={error} closable on:close={modalStore.close}> <Modal show title="{verb} Task" error={error} closable on:close={modalStore.close}>
<form on:submit|preventDefault={onSubmit}> <form on:submit|preventDefault={onSubmit}>
<label for="projectName">Project</label> <label for="projectName">Project</label>
<ProjectSelect disabled={deletion || creation} name="projectName" bind:value={projectId} />
<ProjectSelect disabled={deletion || creation} name="projectName" bind:value={projectId} groupId={task.project.groupId} />
<label for="name">Name</label> <label for="name">Name</label>
<input disabled={deletion} name="name" type="text" bind:value={name} /> <input disabled={deletion} name="name" type="text" bind:value={name} />
<label for="description">Description</label> <label for="description">Description</label>

5
svelte-ui/src/forms/TaskLinkForm.svelte

@ -17,15 +17,18 @@
let projectId = ""; let projectId = "";
let taskId = ""; let taskId = "";
let groupId = "";
let verb = "Add"; let verb = "Add";
if (md.name === "tasklink.delete") { if (md.name === "tasklink.delete") {
projectId = md.project.id; projectId = md.project.id;
taskId = md.task.id; taskId = md.task.id;
groupId = md.project.groupId;
verb = "Delete"; verb = "Delete";
} else if (md.name === "tasklink.add") { } else if (md.name === "tasklink.add") {
projectId = (md.project||{id:""}).id || lastProjectId; projectId = (md.project||{id:""}).id || lastProjectId;
taskId = (md.task||{id:""}).id; taskId = (md.task||{id:""}).id;
groupId = md.project?.groupId;
} else { } else {
throw new Error(`Wrong form ${md.name}`) throw new Error(`Wrong form ${md.name}`)
} }
@ -66,7 +69,7 @@
<label for="taskId">Source Task</label> <label for="taskId">Source Task</label>
<TaskSelect disabled={deletion} name="taskId" bind:value={taskId} /> <TaskSelect disabled={deletion} name="taskId" bind:value={taskId} />
<label for="projectId">Destination Project</label> <label for="projectId">Destination Project</label>
<ProjectSelect disabled={deletion} name="projectId" bind:value={projectId} />
<ProjectSelect disabled={deletion} name="projectId" bind:value={projectId} groupId={groupId || ""} />
<hr /> <hr />

Loading…
Cancel
Save