implemented various task features:
- saving on CTRL+S
- editing of
- start date
- due date
- members
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { api } from '../../urls.svelte.js';
|
||||
|
||||
import TaskList from '../../Components/TaskList.svelte';
|
||||
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
|
||||
import LineEditor from '../../Components/LineEditor.svelte';
|
||||
@@ -18,7 +20,6 @@
|
||||
|
||||
async function addMember(entry){
|
||||
const ids = Object.keys(entry);
|
||||
console.log({entry:entry,ids:ids});
|
||||
if (ids) update({new_member:+ids.pop()});
|
||||
}
|
||||
|
||||
@@ -36,7 +37,7 @@
|
||||
}
|
||||
|
||||
async function getCandidates(text){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/search`;
|
||||
const url = api('user/search');
|
||||
var resp = await fetch(url,{
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
@@ -51,7 +52,7 @@
|
||||
}
|
||||
|
||||
async function loadProject(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/project/${id}`;
|
||||
const url = api(`project/${id}`);
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
project = await resp.json();
|
||||
@@ -63,7 +64,7 @@
|
||||
}
|
||||
|
||||
async function loadTasks(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/task/list`;
|
||||
const url = api('task/list');
|
||||
const data = {
|
||||
project_id:+id,
|
||||
show_closed:project.show_closed
|
||||
@@ -84,7 +85,7 @@
|
||||
}
|
||||
|
||||
async function update(data){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/project/${id}`;
|
||||
const url = api(`project/${id}`);
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method:'PATCH',
|
||||
@@ -93,11 +94,18 @@
|
||||
if (resp.ok){
|
||||
error = null;
|
||||
project = await resp.json();
|
||||
return true;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSettings(){
|
||||
showSettings = !showSettings;
|
||||
}
|
||||
|
||||
|
||||
function updatePermission(user_id,permission){
|
||||
let members = {};
|
||||
members[user_id] = permission.code;
|
||||
@@ -118,7 +126,7 @@
|
||||
<th>{t('project')}</th>
|
||||
<td class="name">
|
||||
<LineEditor bind:value={project.name} editable={true} onSet={val => update({name:val})} />
|
||||
<button class="symbol" onclick={() => showSettings = true}></button>
|
||||
<button class="symbol" onclick={toggleSettings}></button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -147,6 +155,27 @@
|
||||
<MarkdownEditor bind:value={project.description} editable={true} onSet={val => update({description:val})} />
|
||||
</td>
|
||||
</tr>
|
||||
{#if showSettings}
|
||||
<tr>
|
||||
<th>
|
||||
{t('extended_settings')}
|
||||
</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" bind:checked={project.show_closed} onchange={changeClosed} />
|
||||
{t('display_closed_tasks')}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
{t('members')}
|
||||
</th>
|
||||
<td>
|
||||
<MemberEditor members={project.members} {updatePermission} {addMember} {dropMember} {getCandidates} />
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{#if estimated_time.sum}
|
||||
<tr>
|
||||
<th>{t('estimated_time')}</th>
|
||||
@@ -166,18 +195,4 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
{#if showSettings}
|
||||
<fieldset class="project settings">
|
||||
<legend>{t('settings')}</legend>
|
||||
<MemberEditor members={project.members} {updatePermission} {addMember} {dropMember} {getCandidates} />
|
||||
<fieldset>
|
||||
<legend>{t('miscellaneous_settings')}</legend>
|
||||
<label>
|
||||
<input type="checkbox" bind:checked={project.show_closed} onchange={changeClosed} />
|
||||
{t('display_closed_tasks')}
|
||||
</label>
|
||||
</fieldset>
|
||||
<button onclick={() => showSettings = false}>{t('close_settings')}</button>
|
||||
</fieldset>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user