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