Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d93dbfc11 | ||
|
|
a752cd0ae8 | ||
|
|
ef3e228527 | ||
|
|
3c249b3a08 | ||
|
|
79195494cd | ||
|
|
5eead469d3 |
@@ -16,7 +16,7 @@ public interface AccountDb {
|
||||
|
||||
Collection<UmbrellaUser> getMembers(long accountId);
|
||||
|
||||
Optional<Transaction> lastTransaction(long accountId, String source, String destination, Double amount);
|
||||
Optional<Transaction> lastTransaction(long accountId, String source, String dest, double amount);
|
||||
|
||||
Collection<Account> listAccounts(long userId);
|
||||
|
||||
|
||||
@@ -311,11 +311,12 @@ public class AccountingModule extends BaseHandler implements AccountingService {
|
||||
var source = src.get(src.has(Field.ID) ? Field.ID : Field.DISPLAY).toString();
|
||||
if (!json.has(Field.DESTINATION)) throw missingField(Field.DESTINATION);
|
||||
if (!(json.get(Field.DESTINATION) instanceof JSONObject dst)) throw invalidField(Field.SOURCE,JSON);
|
||||
String destination = dst.has(Field.ID) ? dst.get(Field.ID).toString() : dst.has(Field.DISPLAY) ? dst.get(Field.DISPLAY).toString() : null;
|
||||
Double amount = null;
|
||||
if (json.has(Field.AMOUNT) && json.get(Field.AMOUNT) instanceof Number amt) amount = amt.doubleValue();
|
||||
var dest = dst.get(dst.has(Field.ID) ? Field.ID : Field.DISPLAY).toString();
|
||||
if (!json.has(Field.AMOUNT)) throw missingField(Field.AMOUNT);
|
||||
if (!(json.get(Field.AMOUNT) instanceof Number amt)) throw invalidField(Field.AMOUNT,Text.NUMBER);
|
||||
var amount = amt.doubleValue();
|
||||
|
||||
var transaction = accountDb.lastTransaction(accountId, source, destination, amount);
|
||||
var transaction = accountDb.lastTransaction(accountId, source, dest, amount);
|
||||
return transaction.isPresent() ? sendContent(ex,transaction.get()) : notFound(ex);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,42 +170,22 @@ public class SqliteDb extends BaseDb implements AccountDb {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Transaction> lastTransaction(long accountId, String source, String destination, Double amount) {
|
||||
public Optional<Transaction> lastTransaction(long accountId, String source, String dest, double amount) {
|
||||
try {
|
||||
var query = select(ALL).from(TABLE_TRANSACTIONS).where(ACCOUNT,equal(accountId));
|
||||
if (source != null) query = query.where(SOURCE,equal(source));
|
||||
if (destination != null) query = query.where(DESTINATION,equal(destination));
|
||||
if (amount != null) query = query.where(AMOUNT,equal(amount));
|
||||
var rs = query.sort(ID+" DESC").limit(1).exec(db);
|
||||
var rs = select(ALL).from(TABLE_TRANSACTIONS)
|
||||
.where(ACCOUNT,equal(accountId)).where(SOURCE,equal(source)).where(DESTINATION,equal(dest)).where(AMOUNT,equal(amount))
|
||||
.sort(ID+" DESC")
|
||||
.limit(1)
|
||||
.exec(db);
|
||||
Transaction ta = null;
|
||||
if (rs.next()) ta = Transaction.of(rs);
|
||||
rs.close();
|
||||
|
||||
if (ta == null && amount != null) { // try to search by amount, ignore source and dest
|
||||
rs = select(ALL).from(TABLE_TRANSACTIONS).where(ACCOUNT, equal(accountId)).where(AMOUNT, equal(amount))
|
||||
.sort(ID + " DESC").limit(1).exec(db);
|
||||
if (rs.next()) ta = Transaction.of(rs);
|
||||
rs.close();
|
||||
}
|
||||
|
||||
if (ta == null && source != null && destination != null) { // try to search by amount, ignore source and dest
|
||||
rs = select(ALL).from(TABLE_TRANSACTIONS)
|
||||
.where(SOURCE,equal(source))
|
||||
.where(DESTINATION,equal(destination))
|
||||
.where(ACCOUNT, equal(accountId))
|
||||
.sort(ID + " DESC").limit(1).exec(db);
|
||||
if (rs.next()) ta = Transaction.of(rs);
|
||||
rs.close();
|
||||
}
|
||||
|
||||
|
||||
if (ta != null){
|
||||
var tags = ta.tags();
|
||||
rs = select(TAG).from(TABLE_TAGS_TRANSACTIONS).leftJoin(TAG_ID,TABLE_TAGS,ID).where(TRANSACTION_ID,equal(ta.id())).exec(db);
|
||||
while (rs.next()) tags.add(rs.getString(1));
|
||||
rs.close();
|
||||
}
|
||||
|
||||
return nullable(ta);
|
||||
} catch (SQLException e) {
|
||||
throw failedToSearchDb(t(Text.ACCOUNTING));
|
||||
|
||||
@@ -3,11 +3,13 @@ package de.srsoftware.umbrella.core.api;
|
||||
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.Task;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface TaskService {
|
||||
void clonePermissions(long project_id, UmbrellaUser source, UmbrellaUser dest);
|
||||
Map<Long, Task> listCompanyTasks(long companyId) throws UmbrellaException;
|
||||
Map<Long, Task> listProjectTasks(long projectId) throws UmbrellaException;
|
||||
Map<Long, Task> load(Collection<Long> taskIds);
|
||||
|
||||
@@ -77,10 +77,11 @@ public class Field {
|
||||
public static final String HEAD = "head";
|
||||
public static final String HOURS = "hours";
|
||||
|
||||
public static final String ID = "id";
|
||||
public static final String INSTANTLY = "instantly";
|
||||
public static final String ITEM = "item";
|
||||
public static final String ITEM_CODE = "item_code";
|
||||
public static final String ID = "id";
|
||||
public static final String INHERIT_FROM = "inherit_from";
|
||||
public static final String INSTANTLY = "instantly";
|
||||
public static final String ITEM = "item";
|
||||
public static final String ITEM_CODE = "item_code";
|
||||
|
||||
public static final String KEY = "key";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
*.db-journal
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,74 +0,0 @@
|
||||
{
|
||||
"umbrella": {
|
||||
"base_url": "http://127.0.0.1:5173",
|
||||
"logging": {
|
||||
"rootLevel": "INFO"
|
||||
},
|
||||
"http": {
|
||||
"port": 8080
|
||||
},
|
||||
"threads": 16,
|
||||
"modules": {
|
||||
"accounting": {
|
||||
"database": "demodata/accounting.db"
|
||||
},
|
||||
"bookmark": {
|
||||
"database": "demodata/bookmark.db"
|
||||
},
|
||||
"company": {
|
||||
"database": "demodata/company.db"
|
||||
},
|
||||
"contact": {
|
||||
"database": "demodata/contacts.db"
|
||||
},
|
||||
"document": {
|
||||
"database": "demodata/documents.db",
|
||||
"templates": "demodata/templates"
|
||||
},
|
||||
"files": {
|
||||
"database": "demodata/files.db",
|
||||
"base_dir": "demodata/filestore"
|
||||
},
|
||||
"journal": {
|
||||
"database": "demodata/journal.db"
|
||||
},
|
||||
"message": {
|
||||
"database": "demodata/message.db",
|
||||
"smtp": {
|
||||
"from": "umbrella@example.com",
|
||||
"host": "none",
|
||||
"pass": "none",
|
||||
"port": 587,
|
||||
"user": "none"
|
||||
}
|
||||
},
|
||||
"notes": {
|
||||
"database": "demodata/notes.db"
|
||||
},
|
||||
"poll": {
|
||||
"database": "demodata/poll.db"
|
||||
},
|
||||
"project": {
|
||||
"database": "demodata/projects.db"
|
||||
},
|
||||
"stock": {
|
||||
"database": "demodata/stock.db"
|
||||
},
|
||||
"tags": {
|
||||
"database": "demodata/tags.db"
|
||||
},
|
||||
"task": {
|
||||
"database": "demodata/tasks.db"
|
||||
},
|
||||
"time": {
|
||||
"database": "demodata/times.db"
|
||||
},
|
||||
"user": {
|
||||
"database": "demodata/users.db"
|
||||
},
|
||||
"wiki": {
|
||||
"database": "demodata/wiki.db"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 48 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 34 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 48 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 34 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -4,6 +4,7 @@
|
||||
|
||||
|
||||
let {
|
||||
enabled = true,
|
||||
id = null,
|
||||
autofocus = false,
|
||||
getCandidates = dummyGetCandidates,
|
||||
@@ -115,7 +116,7 @@
|
||||
|
||||
function select(index){
|
||||
candidate = candidates[index];
|
||||
<disableDropdown></disableDropdown>();
|
||||
disableDropdown();
|
||||
onSelect(candidate);
|
||||
}
|
||||
|
||||
@@ -148,7 +149,7 @@
|
||||
</style>
|
||||
|
||||
<span class="autocomplete">
|
||||
<input type="text" bind:value={candidate.display} {onkeyup} autofocus={autofocus} {id} {onblur} />
|
||||
<input type="text" bind:value={candidate.display} {onkeyup} autofocus={autofocus} {id} {onblur} disabled={!enabled} />
|
||||
{#if candidates && candidates.length > 0}
|
||||
<ul bind:this={list_elem} class="suggestions" tabindex="-1">
|
||||
{#each candidates as candidate,i}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
let {
|
||||
addMember = (entry) => console.log(`no handler for addMember(${entry})`),
|
||||
enabled = true,
|
||||
dropMember = (member) => console.log(`no handler for dropMember(${member})`),
|
||||
getCandidates = defaultGetCandidates,
|
||||
members,
|
||||
@@ -61,7 +62,7 @@
|
||||
<tr>
|
||||
<td>{t('add_object',{object:t('member')})}</td>
|
||||
<td>
|
||||
<Autocomplete {getCandidates} onSelect={addMember} />
|
||||
<Autocomplete {getCandidates} onSelect={addMember} {enabled} />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -4,12 +4,47 @@
|
||||
|
||||
import { api } from '../urls.svelte';
|
||||
import { t } from '../translations.svelte';
|
||||
import { error, yikes } from '../warn.svelte';
|
||||
import { msToTime, now } from '../time.svelte';
|
||||
import { timetrack } from '../user.svelte';
|
||||
|
||||
let interval = null;
|
||||
const router = useTinyRouter();
|
||||
|
||||
async function addTime(task_id){
|
||||
const url = api(`time/track_task/${task_id}`);
|
||||
const resp = await fetch(url,{
|
||||
credentials : 'include',
|
||||
method : 'POST',
|
||||
body : now()
|
||||
}); // create new time or return time with assigned tasks
|
||||
if (resp.ok) {
|
||||
const track = await resp.json();
|
||||
timetrack.running = track;
|
||||
yikes();
|
||||
} else {
|
||||
error(resp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function go(){
|
||||
router.navigate('/time');
|
||||
}
|
||||
|
||||
function ondragover(ev){
|
||||
ev.preventDefault();
|
||||
}
|
||||
|
||||
function ondragleave(ev){
|
||||
ev.preventDefault();
|
||||
}
|
||||
|
||||
function ondrop(ev){
|
||||
let task_id = ev.dataTransfer.getData('task');
|
||||
if (task_id) addTime(task_id);
|
||||
}
|
||||
|
||||
async function stopTrack(){
|
||||
if (timetrack.running.id){
|
||||
const url = api(`time/${timetrack.running.id}/stop`);
|
||||
@@ -28,9 +63,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function go(){
|
||||
router.navigate('/time');
|
||||
}
|
||||
|
||||
function updateElapsed(){
|
||||
timetrack.elapsed = msToTime(Date.now() - timetrack.start);
|
||||
@@ -54,7 +86,7 @@
|
||||
|
||||
|
||||
{#if timetrack.running}
|
||||
<span class="timetracking">
|
||||
<span class="timetracking" {ondrop} {ondragover} {ondragleave} >
|
||||
<span onclick={go} >{timetrack.running.subject} {#if timetrack.elapsed}({timetrack.elapsed}){/if}</span>
|
||||
<button onclick={stopTrack} title={t('stop')} class="symbol"></button>
|
||||
</span>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import Autocomplete from './Autocomplete.svelte';
|
||||
|
||||
let {
|
||||
enabled = true,
|
||||
getCandidates = async text => {},
|
||||
heading = t('add_object',{object:t('user')}),
|
||||
users = $bindable({})
|
||||
@@ -37,7 +38,7 @@
|
||||
<tr>
|
||||
<td>{heading}</td>
|
||||
<td>
|
||||
<Autocomplete {getCandidates} {onSelect} />
|
||||
<Autocomplete {getCandidates} {onSelect} {enabled} />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
import { t } from '../../translations.svelte';
|
||||
|
||||
import EntryForm from './add_entry_new.svelte';
|
||||
import EntryForm from './add_entry.svelte';
|
||||
import Transaction from './transaction.svelte';
|
||||
|
||||
let { id } = $props();
|
||||
@@ -173,5 +173,5 @@
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<EntryForm {account} {onSave} {users} />
|
||||
<EntryForm {account} {onSave} />
|
||||
{/if}
|
||||
@@ -1,205 +0,0 @@
|
||||
<script>
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
|
||||
import { t } from '../../translations.svelte';
|
||||
import { api, post } from '../../urls.svelte';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
import { user } from '../../user.svelte';
|
||||
import Autocomplete from '../../Components/Autocomplete.svelte';
|
||||
import Tags from '../tags/TagList.svelte';
|
||||
|
||||
let defaultAccount = {
|
||||
id : 0,
|
||||
name : '',
|
||||
currency : ''
|
||||
};
|
||||
let { account = defaultAccount, new_account = false, onSave = () => {}, users } = $props();
|
||||
|
||||
let entry = $state({
|
||||
account,
|
||||
date : new Date().toISOString().substring(0, 10),
|
||||
source : {
|
||||
display: user.name,
|
||||
id: user.id
|
||||
},
|
||||
destination : {},
|
||||
amount : 0.0,
|
||||
purpose : {},
|
||||
tags : []
|
||||
});
|
||||
let router = useTinyRouter();
|
||||
|
||||
async function dst_selected(destination){
|
||||
destination = JSON.parse(JSON.stringify(destination));
|
||||
let source = JSON.parse(JSON.stringify(entry.source));
|
||||
const url = api(`accounting/${entry.account.id}/tags`)
|
||||
const res = await post(url,{source,destination});
|
||||
if (res.ok) {
|
||||
yikes();
|
||||
const json = await res.json();
|
||||
await proposePurpose();
|
||||
entry.tags = json;
|
||||
} else error(res);
|
||||
}
|
||||
|
||||
function focusOnEnter(ev,id){
|
||||
if (ev.key == 'Enter') {
|
||||
proposePurpose();
|
||||
document.getElementById(id).focus();
|
||||
}
|
||||
}
|
||||
|
||||
async function getAccountTags(text){
|
||||
if (!text) return [];
|
||||
const url = api(`accounting/${entry.account.id}/tags`)
|
||||
return await getProposals(text,url);
|
||||
}
|
||||
|
||||
async function getDestinations(text){
|
||||
const url = api('accounting/destinations');
|
||||
return await getProposals(text,url);
|
||||
}
|
||||
|
||||
async function getProposals(text,url){
|
||||
const res = await post(url,text);
|
||||
if (res.ok){
|
||||
yikes();
|
||||
const input = await res.json();
|
||||
return Object.values(input).map(mapDisplay);
|
||||
} else {
|
||||
error(res);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function getPurposes(text) {
|
||||
const url = api('accounting/purposes');
|
||||
return await getProposals(text,url);
|
||||
}
|
||||
|
||||
async function getSources(text){
|
||||
const url = api('accounting/sources');
|
||||
return await getProposals(text,url);
|
||||
}
|
||||
|
||||
function gotoTags(purpose){
|
||||
document.getElementById('new_tag_input');
|
||||
}
|
||||
|
||||
function mapDisplay(object){
|
||||
if (object.display){
|
||||
return object;
|
||||
} else if (object.name) {
|
||||
return {...object, display: object.name};
|
||||
} else {
|
||||
return { display : object }
|
||||
}
|
||||
}
|
||||
|
||||
async function proposePurpose(){
|
||||
console.log('proposePurpose()');
|
||||
const amount = entry.amount;
|
||||
const source = entry.source;
|
||||
const destination = entry.destination;
|
||||
const url = api(`accounting/${account.id}/purposes`);
|
||||
const res = await post(url,{source,destination,amount});
|
||||
if (res.ok) {
|
||||
yikes();
|
||||
var lastTransaction = await res.json();
|
||||
console.log({lastTransaction,users:JSON.parse(JSON.stringify(users))});
|
||||
entry.purpose = { display: lastTransaction.purpose};
|
||||
entry.tags = lastTransaction.tags;
|
||||
if (lastTransaction.source.value){
|
||||
if (users[lastTransaction.source.value]){
|
||||
let user = users[lastTransaction.source.value];
|
||||
entry.source = { id : +lastTransaction.source.value, display : user.name };
|
||||
} else entry.source = { display: lastTransaction.source.value };
|
||||
}
|
||||
if (lastTransaction.destination.value){
|
||||
if (users[lastTransaction.destination.value]){
|
||||
let user = users[lastTransaction.destination.value];
|
||||
entry.destination = { id : +lastTransaction.destination.value, display : user.name };
|
||||
} else entry.destination = { display: lastTransaction.destination.value };
|
||||
}
|
||||
} else error(res);
|
||||
}
|
||||
|
||||
async function save(){
|
||||
let data = {
|
||||
...entry,
|
||||
purpose: entry.purpose.display
|
||||
}
|
||||
let url = api('accounting');
|
||||
let res = await post(url, data);
|
||||
if (res.ok) {
|
||||
yikes();
|
||||
if (new_account){
|
||||
router.navigate('/accounting');
|
||||
return;
|
||||
}
|
||||
//entry.tags = [];
|
||||
onSave();
|
||||
document.getElementById('date-input').focus();
|
||||
} else error(res);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
hr{
|
||||
grid-column: 1 / -1;
|
||||
margin: 0.5rem 0;
|
||||
border: 0;
|
||||
height: 1px;
|
||||
align-self: center;
|
||||
background: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
<fieldset class="grid2 new_transaction">
|
||||
{#if new_account}
|
||||
<legend>{t('create_new_object',{object:t('account')})}</legend>
|
||||
<span style="display:none"></span>
|
||||
<span>{t('account name')}</span>
|
||||
<span>
|
||||
<input type="text" bind:value={entry.account.name} />
|
||||
</span>
|
||||
<span>{t('currency')}</span>
|
||||
<span>
|
||||
<input type="text" bind:value={entry.account.currency} />
|
||||
</span>
|
||||
<hr/>
|
||||
<span style="grid-column-end: span 2">{t('first transaction')}</span>
|
||||
{:else}
|
||||
<legend>{t('add_object',{object:t('transaction')})}</legend>
|
||||
<span style="display:none"></span>
|
||||
{/if}
|
||||
|
||||
<span>{t('date')}</span>
|
||||
<span>
|
||||
<input type="date" bind:value={entry.date} id="date-input" />
|
||||
</span>
|
||||
|
||||
<span>{t('amount')}</span>
|
||||
<span>
|
||||
<input type="number" bind:value={entry.amount} onkeyup={e => focusOnEnter(e,'source-input')} /> {entry.account.currency}
|
||||
</span>
|
||||
|
||||
<span>{t('source')}</span>
|
||||
<Autocomplete bind:candidate={entry.source} getCandidates={getSources} id="source-input" />
|
||||
|
||||
<span>{t('destination')}</span>
|
||||
<Autocomplete bind:candidate={entry.destination} getCandidates={getDestinations} onSelect={dst_selected} />
|
||||
|
||||
|
||||
<span>{t('purpose')}</span>
|
||||
<Autocomplete bind:candidate={entry.purpose} getCandidates={getPurposes} onCommit={gotoTags} id="purpose_input" />
|
||||
|
||||
<span>{t('tags')}</span>
|
||||
<Tags getCandidates={getAccountTags} module={null} bind:tags={entry.tags} onEmptyCommit={save} />
|
||||
|
||||
<span></span>
|
||||
<span>
|
||||
<button onclick={save}>{t('save')}</button>
|
||||
</span>
|
||||
</fieldset>
|
||||
@@ -207,6 +207,11 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
function ondragstart(ev, task){
|
||||
dragged = task;
|
||||
ev.dataTransfer.setData("task",task.id);
|
||||
}
|
||||
|
||||
function openTask(task_id){
|
||||
window.open(`/task/${task_id}/view`, '_blank').focus();
|
||||
}
|
||||
@@ -306,7 +311,7 @@
|
||||
<div class={['state_'+state, is_custom(state) ? '':'state_custom' ,highlight.user == u.id && highlight.state == state ? 'highlight':'']} ondragover={ev => hover(ev,u.id,state)} ondragleave={e => delete highlight.user} ondrop={ev => drop(u.id,state)} >
|
||||
{#each Object.values(tasks[u.id][state]).sort(byName) as task}
|
||||
{#if !filter || task.name.toLowerCase().includes(filter) || (task.tags && task.tags.filter(tag => tag.toLowerCase().includes(filter)).length)}
|
||||
<Card onclick={e => openTask(task.id)} ondragstart={ev => dragged=task} {task} tag_colors={project.tag_colors} />
|
||||
<Card onclick={e => openTask(task.id)} ondragstart={ev => ondragstart(ev,task)} {task} tag_colors={project.tag_colors} />
|
||||
{/if}
|
||||
{/each}
|
||||
<div class="add_task" onclick={ev => show_task_form(project.id,u.id,+state)}>
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
let tasks = $state(null);
|
||||
let show_closed = $state(false);
|
||||
let new_color = $state({tag:null,color:'#00aa00'})
|
||||
let inherit_from = $state(0);
|
||||
|
||||
let new_state = $state({code:null,name:null})
|
||||
let state_available=$derived(new_state.name && new_state.code && !project.allowed_states[new_state.code]);
|
||||
|
||||
async function addMember(user){
|
||||
return await update({new_member:+user.id});
|
||||
return await update({new_member:+user.id,inherit_from});
|
||||
}
|
||||
|
||||
async function addState(){
|
||||
@@ -239,7 +240,16 @@
|
||||
</label>
|
||||
<div class="em">{t('members')}</div>
|
||||
<div class="em">
|
||||
<PermissionEditor members={project.members} {updatePermission} {addMember} {dropMember} />
|
||||
<PermissionEditor members={project.members} {updatePermission} {addMember} {dropMember} enabled={inherit_from != 0}/>
|
||||
<label>
|
||||
└→ Inherit task permissions from:
|
||||
<select bind:value={inherit_from}>
|
||||
<option value={0}>{t('select user')}</option>
|
||||
{#each Object.values(project.members) as member (member.user.id)}
|
||||
<option value={member.user.id}>{member.user.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
{#if project.allowed_states}
|
||||
{#each Object.keys(project.allowed_states) as key,idx}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -21,4 +21,4 @@ export function t(key,args = {}){
|
||||
}
|
||||
for (var key of Object.keys(args)) set = set.replace(`{${key}}`,args[key]);
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import static de.srsoftware.umbrella.messagebus.MessageBus.messageBus;
|
||||
import static de.srsoftware.umbrella.messagebus.events.Event.EventType.CREATE;
|
||||
import static de.srsoftware.umbrella.project.Constants.CONFIG_DATABASE;
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
import static java.net.HttpURLConnection.HTTP_BAD_REQUEST;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
@@ -138,6 +139,7 @@ public class ProjectModule extends BaseHandler implements ProjectService {
|
||||
private void dropMember(Project project, long userId) {
|
||||
if (project.members().get(userId).permission() == OWNER) throw forbidden("You may not remove the owner of the project");
|
||||
projectDb.dropMember(project.id(),userId);
|
||||
LOG.log(WARNING,"Removing member from project tasks not implemented"); // TODO
|
||||
project.members().remove(userId);
|
||||
}
|
||||
|
||||
@@ -223,7 +225,16 @@ public class ProjectModule extends BaseHandler implements ProjectService {
|
||||
UmbrellaUser newMember = null;
|
||||
if (json.has(DROP_MEMBER) && json.get(DROP_MEMBER) instanceof Number id) dropMember(project,id.longValue());
|
||||
if (json.has(MEMBERS) && json.get(MEMBERS) instanceof JSONObject memberJson) patchMembers(project,memberJson);
|
||||
if (json.has(NEW_MEMBER) && json.get(NEW_MEMBER) instanceof Number num) newMember = addMember(project,num.longValue());
|
||||
if (json.has(NEW_MEMBER) && json.get(NEW_MEMBER) instanceof Number num) {
|
||||
UmbrellaUser inheritFrom = null;
|
||||
if (json.has(INHERIT_FROM)){
|
||||
if (!(json.get(INHERIT_FROM) instanceof Number uid)) throw invalidField(INHERIT_FROM,Text.NUMBER);
|
||||
inheritFrom = userService().loadUser(uid.longValue());
|
||||
if (!project.hasMember(inheritFrom)) throw notAmember(inheritFrom);
|
||||
}
|
||||
newMember = addMember(project,num.longValue());
|
||||
if (inheritFrom != null) taskService().clonePermissions(project.id(),inheritFrom,newMember);
|
||||
}
|
||||
|
||||
project = projectDb.save(project.patch(json), user);
|
||||
messageBus().dispatch(newMember != null ? new ProjectEvent(user,project,newMember) : new ProjectEvent(user,project, old));
|
||||
|
||||
@@ -260,7 +260,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
try {
|
||||
var query = select(ALL).from(TABLE_TASKS).leftJoin(ID,TABLE_TASKS_USERS,TASK_ID).where(USER_ID,equal(userId));
|
||||
if (!showClosed) query.where(STATUS,lessThan(COMPLETE.code()));
|
||||
var rs = query.sort("(CASE due_date WHEN \"\" THEN '9999-99-99' ELSE IFNULL(due_date,'9999-99-99') END), status COLLATE NOCASE").limit(limit).skip(offset).exec(db);
|
||||
var rs = query.sort("(CASE due_date WHEN \"\" THEN '9999-99-99' ELSE IFNULL(due_date,'9999-99-99') END), status COLLATE NOCASE").limit(limit == null ? -1 : limit).skip(offset).exec(db);
|
||||
var map = new ArrayList<Task>();
|
||||
while (rs.next()) map.add(Task.of(rs));
|
||||
rs.close();
|
||||
|
||||
@@ -66,6 +66,28 @@ public class TaskModule extends BaseHandler implements TaskService {
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clonePermissions(long project_id, UmbrellaUser source, UmbrellaUser dest) {
|
||||
var taskMap = taskDb.listProjectTasks(project_id,null,true);
|
||||
loadMembers(taskMap.values());
|
||||
for (var task : taskMap.values()) {
|
||||
var memberShip = task.members().get(source.id());
|
||||
|
||||
Permission granted = memberShip == null ? EDIT : switch (memberShip.permission()) {
|
||||
case ASSIGNEE,
|
||||
EDIT,
|
||||
OWNER ->
|
||||
EDIT;
|
||||
case READ_ONLY ->
|
||||
READ_ONLY;
|
||||
};
|
||||
var newMember = new Member(dest, granted);
|
||||
task.members().put(dest.id(), newMember);
|
||||
task.dirty(MEMBERS);
|
||||
taskDb.save(task);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean deleteTask(HttpExchange ex, long taskId, UmbrellaUser user) throws IOException {
|
||||
var task = loadMembers(taskDb.load(taskId));
|
||||
var member = task.members().get(user.id());
|
||||
|
||||
@@ -335,6 +335,7 @@
|
||||
"select_customer": "Kunde auswählen",
|
||||
"select_property": "Eigenschaft auswählen",
|
||||
"select_state": "Status wählen",
|
||||
"select user": "Nutzer auswählen",
|
||||
"send_document": "Dokument versenden",
|
||||
"sender": "Absender",
|
||||
"sender_bank_account": "Bankverbindung",
|
||||
|
||||
@@ -329,12 +329,13 @@
|
||||
"saved": "saved",
|
||||
"save_object": "save {object}",
|
||||
"search": "search",
|
||||
"searching…": "searhcing…",
|
||||
"searching…": "searching…",
|
||||
"select a new parent for {entity}": "select a new parent for '{entity}'",
|
||||
"select_company" : "select on of you companies:",
|
||||
"select_customer": "select customer",
|
||||
"select_property": "select property",
|
||||
"select_state": "select state",
|
||||
"select user": "select user",
|
||||
"send_document": "send document",
|
||||
"sender": "sender",
|
||||
"sender_bank_account": "bank account",
|
||||
@@ -379,7 +380,7 @@
|
||||
"subtask": "subtask",
|
||||
"subtasks": "subtasks",
|
||||
"succeeding_document": "succeeding document",
|
||||
"sum external";"sum of external positions",
|
||||
"sum external":"sum of external positions",
|
||||
"sum_of_records": "sum of records",
|
||||
"sums": "sums",
|
||||
|
||||
|
||||
@@ -356,6 +356,10 @@ span.timetracking {
|
||||
grid-column-end: span 2;
|
||||
}
|
||||
|
||||
.markdown svg{
|
||||
display: block;
|
||||
}
|
||||
|
||||
.editable:hover{
|
||||
border: 1px dotted;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@ input{
|
||||
color: orange;
|
||||
}
|
||||
|
||||
input:disabled{
|
||||
border: 1px solid gray;
|
||||
background: #444;
|
||||
}
|
||||
|
||||
legend.date,
|
||||
legend.time{
|
||||
background-color: black;
|
||||
|
||||
@@ -450,6 +450,10 @@ span.timetracking {
|
||||
grid-column-end: span 2;
|
||||
}
|
||||
|
||||
.markdown svg{
|
||||
display: block;
|
||||
}
|
||||
|
||||
.editable:hover{
|
||||
border: 1px dotted;
|
||||
}
|
||||
|
||||
@@ -449,6 +449,10 @@ span.timetracking {
|
||||
grid-column-end: span 2;
|
||||
}
|
||||
|
||||
.markdown svg{
|
||||
display: block;
|
||||
}
|
||||
|
||||
.editable:hover{
|
||||
border: 1px dotted;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user