add group filter on ProjectSelect.
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-08-09 17:31:33 +02:00
parent d551579d6a
commit 7973373419
5 changed files with 41 additions and 21 deletions
+6 -1
View File
@@ -15,7 +15,12 @@
<Icon name={item.icon} />
</div>
<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>
+29 -17
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import type Project from "../models/project";
import projectStore from "../stores/project";
import projectGroupStore from "../stores/projectGroup";
interface OptGroup {
status: string
projects: Project[]
@@ -8,44 +9,55 @@
export let value = "";
export let name = "";
export let groupId = "";
export let disabled = false;
export let optional = false;
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 = [
{
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}
<optgroup label={group.status}>
{#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}
</optgroup>
{/if}
+1 -1
View File
@@ -72,7 +72,7 @@
$: mdLogAdd = {name: "log.add", task: {...task, project}};
$: mdTaskEdit = {name: "task.edit", 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};
$: isLinked = task.projectId !== project.id;
$: actualParent = (actualProject != null && actualProject.id !== project.id) ? actualProject : null;
+1 -1
View File
@@ -111,7 +111,7 @@ import ProjectSelect from "../components/ProjectSelect.svelte";
<Modal show title="{verb} Task" error={error} closable on:close={modalStore.close}>
<form on:submit|preventDefault={onSubmit}>
<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>
<input disabled={deletion} name="name" type="text" bind:value={name} />
<label for="description">Description</label>
+4 -1
View File
@@ -17,15 +17,18 @@
let projectId = "";
let taskId = "";
let groupId = "";
let verb = "Add";
if (md.name === "tasklink.delete") {
projectId = md.project.id;
taskId = md.task.id;
groupId = md.project.groupId;
verb = "Delete";
} else if (md.name === "tasklink.add") {
projectId = (md.project||{id:""}).id || lastProjectId;
taskId = (md.task||{id:""}).id;
groupId = md.project?.groupId;
} else {
throw new Error(`Wrong form ${md.name}`)
}
@@ -66,7 +69,7 @@
<label for="taskId">Source Task</label>
<TaskSelect disabled={deletion} name="taskId" bind:value={taskId} />
<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 />