Merge branch 'feature/task-navigation' into dev
This commit is contained in:
@@ -42,8 +42,8 @@ public class Path {
|
||||
public static final String PROPERTY = "property";
|
||||
public static final String PURPOSES = "purposes";
|
||||
|
||||
public static final String READ = "read";
|
||||
public static final String REDIRECT = "redirect";
|
||||
public static final String READ = "read";
|
||||
public static final String REDIRECT = "redirect";
|
||||
|
||||
public static final String SEARCH = "search";
|
||||
public static final String SELECT = "select";
|
||||
|
||||
@@ -81,6 +81,10 @@
|
||||
router.navigate(`/project/${project.id}/view`)
|
||||
}
|
||||
|
||||
function gotoTask(tid){
|
||||
if (id) router.navigate(`/task/${tid}/view`)
|
||||
}
|
||||
|
||||
function handleUpdateEvent(evt){
|
||||
let json = JSON.parse(evt.data);
|
||||
if (json.task) {
|
||||
@@ -119,7 +123,8 @@
|
||||
if (task.show_closed) show_closed = true;
|
||||
loadChildren();
|
||||
if (task.project_id) loadProject();
|
||||
if (task.parent_task_id) loadParent();
|
||||
if (task.parent_task_id) await loadParent();
|
||||
loadSiblings();
|
||||
} else error(resp);
|
||||
}
|
||||
|
||||
@@ -129,13 +134,36 @@
|
||||
if (resp.ok){
|
||||
project = await resp.json();
|
||||
yikes();
|
||||
} else error(await resp.text());
|
||||
} else error(resp);
|
||||
}
|
||||
|
||||
async function loadSiblings(){
|
||||
const url = api(`task/list`);
|
||||
const select = task.parent_task_id ? {parent_task_id:task.parent_task_id} : {project_id: task.project_id};
|
||||
select.show_closed = false;
|
||||
const res = await post(url,select);
|
||||
if (res.ok){
|
||||
task.siblings = await res.json();
|
||||
let last = null;
|
||||
let before = undefined;
|
||||
let after = null;
|
||||
for (let [sid, t] of Object.entries(task.siblings).toSorted((a,b) => a[1].name.localeCompare(b[1].name))){
|
||||
if (before !== undefined) {
|
||||
after = +sid;
|
||||
break;
|
||||
}
|
||||
if (id == sid) before = last;
|
||||
last = +sid;
|
||||
}
|
||||
task.before = before;
|
||||
task.after = after;
|
||||
} else error(res)
|
||||
}
|
||||
|
||||
function parentClick(ev){
|
||||
ev.preventDefault();
|
||||
if (!task.parent_task_id) return;
|
||||
router.navigate(`/task/${task.parent_task_id}/view`);
|
||||
gotoTask(task.parent_task_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -232,10 +260,17 @@
|
||||
{/if}
|
||||
<button class="symbol" title={t('edit')} onclick={parentRightClick}></button>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
<div>{t('task')}</div>
|
||||
<div class="name">
|
||||
<LineEditor bind:value={task.name} editable={true} onSet={val => update({name:val})} />
|
||||
{#if task.before}
|
||||
<button class="symbol" title={task.siblings[task.before].name} onclick={e => gotoTask(task.before)}></button>
|
||||
{/if}
|
||||
{#if task.after}
|
||||
<button class="symbol" title={task.siblings[task.after].name} onclick={e => gotoTask(task.after)}></button>
|
||||
{/if}
|
||||
<button class="symbol" title={t('settings')} onclick={toggleSettings}></button>
|
||||
<button class="symbol" title={t('timetracking')} onclick={addTime}></button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user