working on form to add subtask
This commit is contained in:
@@ -74,6 +74,6 @@
|
||||
</style>
|
||||
|
||||
{#if editing}
|
||||
<textarea bind:value={editValue.source} onkeyup={typed} autofocus></textarea>
|
||||
<textarea bind:value={editValue.source} onkeyup={typed} autofocus={!simple}></textarea>
|
||||
{/if}
|
||||
<div ondblclick={startEdit} class={{editable}} title={t('double_click_to_edit')} >{@html editValue.rendered}</div>
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
{companies[project.company_id].name}
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
<td class="state" onclick={() => show(project.id)} >
|
||||
{t("state_"+project.status.name.toLowerCase())}
|
||||
</td>
|
||||
<td class="members" onclick={() => show(project.id)} >
|
||||
|
||||
@@ -25,11 +25,6 @@
|
||||
});
|
||||
let router = useTinyRouter();
|
||||
|
||||
async function load(){
|
||||
if (parent_task_id) await loadParent();
|
||||
if (project_id) loadProject();
|
||||
}
|
||||
|
||||
function addMember(member){
|
||||
for (let uid of Object.keys(member)) task.members[uid] = project.members[uid];
|
||||
}
|
||||
@@ -39,6 +34,11 @@
|
||||
console.log({drop:member.user.id});
|
||||
}
|
||||
|
||||
async function load(){
|
||||
if (parent_task_id) await loadParent();
|
||||
if (project_id) loadProject();
|
||||
}
|
||||
|
||||
async function loadParent(){
|
||||
const url = api(`task/${parent_task_id}`);
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
@@ -60,7 +60,7 @@
|
||||
if (resp.ok){
|
||||
project = await resp.json();
|
||||
task.project_id = +project_id;
|
||||
task.members = JSON.parse(JSON.stringify(project.members)); // deep copy
|
||||
task.members = JSON.parse(JSON.stringify(parent_task?parent_task.members:project.members)); // deep copy
|
||||
error = null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
@@ -68,7 +68,8 @@
|
||||
}
|
||||
|
||||
async function getCandidates(text){
|
||||
const candidates = Object.values(project.members)
|
||||
const origin = parent_task ? parent_task.members : project.members;
|
||||
const candidates = Object.values(origin)
|
||||
.filter(member => member.user.name.toLowerCase().includes(text.toLowerCase()))
|
||||
.map(member => [member.user.id,member.user.name]);
|
||||
return Object.fromEntries(candidates);
|
||||
@@ -107,7 +108,7 @@
|
||||
{t('name')}
|
||||
</th>
|
||||
<td>
|
||||
<input bind:value={task.name}>
|
||||
<input bind:value={task.name} autofocus>
|
||||
</td>
|
||||
</tr>
|
||||
{#if project}
|
||||
|
||||
@@ -55,6 +55,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function loadParent(){
|
||||
const url = api(`task/${task.parent_task_id}`);
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
task.parent = await resp.json();
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadTask(){
|
||||
const url = api(`task/${id}`);
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
@@ -65,6 +75,7 @@
|
||||
children = null;
|
||||
loadChildren();
|
||||
if (task.project_id) loadProject();
|
||||
if (task.parent_task_id) loadParent();
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
@@ -74,6 +85,11 @@
|
||||
if (!project) return;
|
||||
router.navigate(`/project/${project.id}/view`)
|
||||
}
|
||||
|
||||
function gotoParent(){
|
||||
if (!task.parent_task_id) return;
|
||||
router.navigate(`/task/${task.parent_task_id}/view`)
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if error}
|
||||
@@ -88,9 +104,15 @@
|
||||
<td class="project name" onclick={gotoProject}>{project.name}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{#if task.parent}
|
||||
<tr>
|
||||
<th>{t('parent_task')}</th>
|
||||
<td class="parent task" onclick={gotoParent}>{task.parent.name}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<th>{t('task')}</th>
|
||||
<td class="task name">{task.name}</td>
|
||||
<td class="task name" >{task.name}</td>
|
||||
</tr>
|
||||
{#if task.description.rendered}
|
||||
<tr>
|
||||
@@ -127,15 +149,15 @@
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{#if children}
|
||||
<tr>
|
||||
<th>{t('subtasks')}</th>
|
||||
<td class="task children">
|
||||
<button onclick={addChild} >{t('add_subtask')}</button>
|
||||
{#if children}
|
||||
<TaskList tasks={children} {estimated_time} />
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user