implemented starting time tracking from task view
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -33,7 +33,6 @@
|
||||
if (resp.ok) {
|
||||
const track = await resp.json();
|
||||
timetrack.running = track;
|
||||
console.log(track);
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { timetrack } from '../../user.svelte.js';
|
||||
|
||||
import LineEditor from '../../Components/LineEditor.svelte';
|
||||
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
|
||||
@@ -25,11 +26,26 @@
|
||||
|
||||
$effect(() => updateOn(id));
|
||||
|
||||
function addChild(){
|
||||
router.navigate(`/task/${id}/add_subtask`);
|
||||
}
|
||||
|
||||
async function addMember(entry){
|
||||
const ids = Object.keys(entry);
|
||||
if (ids) update({new_member:+ids.pop()});
|
||||
}
|
||||
|
||||
async function addTime(){
|
||||
const url = api(`time/track_task/${id}`);
|
||||
const resp = await fetch(url,{credentials:'include'}); // create new time or return time with assigned tasks
|
||||
if (resp.ok) {
|
||||
const track = await resp.json();
|
||||
timetrack.running = track;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
async function dropMember(member){
|
||||
update({drop_member:member.user.id});
|
||||
}
|
||||
@@ -42,14 +58,14 @@
|
||||
return Object.fromEntries(candidates);
|
||||
}
|
||||
|
||||
|
||||
function updateOn(id){
|
||||
task = null;
|
||||
loadTask();
|
||||
function gotoParent(){
|
||||
if (!task.parent_task_id) return;
|
||||
router.navigate(`/task/${task.parent_task_id}/view`)
|
||||
}
|
||||
|
||||
function addChild(){
|
||||
router.navigate(`/task/${id}/add_subtask`);
|
||||
function gotoProject(){
|
||||
if (!project) return;
|
||||
router.navigate(`/project/${project.id}/view`)
|
||||
}
|
||||
|
||||
async function loadChildren(){
|
||||
@@ -71,17 +87,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function loadProject(){
|
||||
const url = api(`project/${task.project_id}`);
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
project = await resp.json();
|
||||
error = null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadParent(){
|
||||
const url = api(`task/${task.parent_task_id}`);
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
@@ -108,14 +113,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
function gotoProject(){
|
||||
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`)
|
||||
async function loadProject(){
|
||||
const url = api(`project/${task.project_id}`);
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
project = await resp.json();
|
||||
error = null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSettings(){
|
||||
@@ -147,6 +153,11 @@
|
||||
if (update({no_index:task.no_index})) setTimeout(loadTask,50);
|
||||
}
|
||||
|
||||
function updateOn(id){
|
||||
task = null;
|
||||
loadTask();
|
||||
}
|
||||
|
||||
function updatePermission(user_id,permission){
|
||||
let members = {};
|
||||
members[user_id] = permission.code;
|
||||
@@ -180,7 +191,9 @@
|
||||
<th>{t('task')}</th>
|
||||
<td class="name">
|
||||
<LineEditor bind:value={task.name} editable={true} onSet={val => update({name:val})} />
|
||||
<button class="symbol" onclick={toggleSettings}></button>
|
||||
<button class="symbol" title={t('settings')} onclick={toggleSettings}></button>
|
||||
<button class="symbol" title={t('timetracking')} onclick={addTime}></button>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -130,6 +130,10 @@ td, tr{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.task .name div{
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.symbol{
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user