code cleanup
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script>
|
||||
import {onMount} from 'svelte';
|
||||
|
||||
import { api } from '../urls.svelte.js';
|
||||
import {t} from '../translations.svelte.js';
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<script>
|
||||
import {t} from '../translations.svelte.js';
|
||||
|
||||
let { task, onSelect = (task) => {} } = $props();
|
||||
let {
|
||||
task,
|
||||
onSelect = (task) => {}
|
||||
} = $props();
|
||||
</script>
|
||||
|
||||
<div>
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
const url = api('markdown/render');
|
||||
const resp = await fetch(url,{
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
body: editValue.source
|
||||
method : 'POST',
|
||||
body : editValue.source
|
||||
});
|
||||
editValue.rendered = await resp.text();
|
||||
}
|
||||
|
||||
@@ -75,9 +75,9 @@
|
||||
async function submit(){
|
||||
const url = api('document');
|
||||
const resp = await fetch(url,{
|
||||
method: 'POST',
|
||||
method : 'POST',
|
||||
credentials: 'include',
|
||||
body: JSON.stringify(document)
|
||||
body : JSON.stringify(document)
|
||||
});
|
||||
if (resp.ok){
|
||||
const json = await resp.json();
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
<script>
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { onMount } from 'svelte';
|
||||
import EstimatedTask from '../../Components/EstimatedTask.svelte';
|
||||
let { company_id, onSelect = (task) => {} } = $props();
|
||||
|
||||
let projects = $state(null);
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
import EstimatedTask from '../../Components/EstimatedTask.svelte';
|
||||
|
||||
let {
|
||||
company_id,
|
||||
onSelect = (task) => {}
|
||||
} = $props();
|
||||
|
||||
let error = $state(null);
|
||||
let projects = $state(null);
|
||||
|
||||
async function loadItems(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/task/estimated_times`;
|
||||
const url = api('task/estimated_times');
|
||||
let data = { company_id: company_id };
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
credentials: 'include',
|
||||
method : 'POST',
|
||||
body : JSON.stringify(data)
|
||||
});
|
||||
if (resp.ok){
|
||||
projects = await resp.json();
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
<script>
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
import Item from '../../Components/Item.svelte';
|
||||
let { company_id, onSelect = (item) => {} } = $props();
|
||||
|
||||
let {
|
||||
company_id,
|
||||
onSelect = (item) => {}
|
||||
} = $props();
|
||||
|
||||
let items = $state(null);
|
||||
let error = $state(null);
|
||||
|
||||
|
||||
async function loadItems(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/items/list`;
|
||||
const url = api('items/list');
|
||||
let data = { company_id: company_id };
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
credentials: 'include',
|
||||
method : 'POST',
|
||||
body : JSON.stringify(data)
|
||||
});
|
||||
if (resp.ok){
|
||||
items = await resp.json();
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
<script>
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
import TypeSelector from './TypeSelector.svelte';
|
||||
|
||||
|
||||
|
||||
let error = null;
|
||||
let companies = {};
|
||||
let documents = null;
|
||||
let selected_company = null;
|
||||
let router = useTinyRouter();
|
||||
let company_id = +router.query.company_id;
|
||||
let documents = null;
|
||||
let router = useTinyRouter();
|
||||
let docType = 0;
|
||||
let selected_company = null;
|
||||
|
||||
async function loadCompanies(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/company/list`;
|
||||
const url = api('company/list');
|
||||
const resp = await fetch(url,{ credentials: 'include'});
|
||||
if (resp.ok){
|
||||
companies = await resp.json();
|
||||
@@ -37,7 +40,7 @@
|
||||
async function load(company){
|
||||
router.navigate(`/document?company_id=${company.id}`);
|
||||
selected_company = company;
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/list`;
|
||||
const url = api('document/list');
|
||||
const resp = await fetch(url,{
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
@@ -60,7 +63,7 @@
|
||||
|
||||
async function deleteDoc(ev,doc){
|
||||
if (confirm(t('really_delete',doc.number))){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${doc.id}`;
|
||||
const url = api(`document/${doc.id}`;
|
||||
const resp = await fetch(url,{
|
||||
credentials: 'include',
|
||||
method: 'DELETE'
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
<script>
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
|
||||
import LineEditor from '../../Components/LineEditor.svelte';
|
||||
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
|
||||
import PriceEditor from '../../Components/PriceEditor.svelte';
|
||||
var { currency, editable, pos = $bindable(null), submit = (key,newVal) => {}, movePos = (number,step) => {}, drop = (number) => {} } = $props();
|
||||
|
||||
var {
|
||||
currency,
|
||||
drop = (number) => {},
|
||||
editable,
|
||||
movePos = (number,step) => {},
|
||||
pos = $bindable(null),
|
||||
submit = (key,newVal) => {}
|
||||
} = $props();
|
||||
let prefix = `pos.${pos.number}`
|
||||
|
||||
function moveup(){
|
||||
|
||||
@@ -1,26 +1,33 @@
|
||||
<script>
|
||||
import Position from './Position.svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
|
||||
import { api } from '../../urls.svelte-js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
var { document = $bindable(null), submit = (key,newVal) => {}, error = $bindable(null) } = $props();
|
||||
import Position from './Position.svelte';
|
||||
|
||||
var {
|
||||
document = $bindable(null),
|
||||
error = $bindable(null)
|
||||
submit = (key,newVal) => {},
|
||||
} = $props();
|
||||
|
||||
let editable = $derived(document.state == 1);
|
||||
|
||||
async function updatePositions(resp){
|
||||
let json = await resp.json();
|
||||
document.positions = {};
|
||||
setTimeout(() => document.positions = json,100)
|
||||
error = null;
|
||||
setTimeout(() => document.positions = json,100)
|
||||
}
|
||||
|
||||
async function movePos(number,step){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${document.id}/position`;
|
||||
const url = api(`document/${document.id}/position`;
|
||||
const resp = await fetch(url,{
|
||||
method: 'PATCH',
|
||||
credentials:'include',
|
||||
body:JSON.stringify({position:number,move:step})
|
||||
method : 'PATCH',
|
||||
credentials: 'include',
|
||||
body : JSON.stringify({position:number,move:step})
|
||||
});
|
||||
if (resp.ok){
|
||||
updatePositions(resp);
|
||||
@@ -32,11 +39,11 @@
|
||||
async function drop(number){
|
||||
let confirmed = confirm(t('confirm_deletion').replace('{pos}',document.positions[number].item));
|
||||
if (!confirmed) return;
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${document.id}/position`;
|
||||
const url = api(`document/${document.id}/position`;
|
||||
const resp = await fetch(url,{
|
||||
method: 'DELETE',
|
||||
credentials:'include',
|
||||
body:JSON.stringify({position:number})
|
||||
method : 'DELETE',
|
||||
credentials: 'include',
|
||||
body : JSON.stringify({position:number})
|
||||
});
|
||||
if (resp.ok){
|
||||
updatePositions(resp);
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
<script>
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
import EstimateList from './EstimateList.svelte';
|
||||
import ItemList from './ItemList.svelte';
|
||||
import TimeList from './TimeList.svelte';
|
||||
|
||||
let { close = () => {}, doc = $bindable({}), onSelect = (item) => {} } = $props();
|
||||
let {
|
||||
close = () => {},
|
||||
doc = $bindable({}),
|
||||
onSelect = (item) => {}
|
||||
} = $props();
|
||||
|
||||
let source = $state(0);
|
||||
|
||||
@@ -15,52 +20,52 @@
|
||||
|
||||
function estimateSelected(estimate){
|
||||
select({
|
||||
item_code:t('estimated_time'),
|
||||
title:estimate.name,
|
||||
description:estimate.description.source,
|
||||
amount:estimate.estimated_time,
|
||||
unit:t('hours')
|
||||
item_code : t('estimated_time'),
|
||||
title : estimate.name,
|
||||
description : estimate.description.source,
|
||||
amount : estimate.estimated_time,
|
||||
unit : t('hours')
|
||||
});
|
||||
}
|
||||
|
||||
function itemSelected(item){
|
||||
select({
|
||||
item_code:item.code,
|
||||
title:item.name,
|
||||
description:item.description.source,
|
||||
amount:1,
|
||||
unit:item.unit,
|
||||
unit_price:item.unit_price,
|
||||
tax:item.tax
|
||||
item_code : item.code,
|
||||
title : item.name,
|
||||
description : item.description.source,
|
||||
amount : 1,
|
||||
unit : item.unit,
|
||||
unit_price : item.unit_price,
|
||||
tax : item.tax
|
||||
});
|
||||
}
|
||||
|
||||
function timeSelected(time){
|
||||
select({
|
||||
item_code:t('timetrack'),
|
||||
title:time.subject,
|
||||
description:time.description.source,
|
||||
amount:time.duration,
|
||||
unit:t('hours'),
|
||||
time_id:time.id
|
||||
item_code : t('timetrack'),
|
||||
title : time.subject,
|
||||
description : time.description.source,
|
||||
amount : time.duration,
|
||||
unit : t('hours'),
|
||||
time_id : time.id
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
div{
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 20px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 10px;
|
||||
overflow: auto;
|
||||
position : fixed;
|
||||
top : 0;
|
||||
bottom : 20px;
|
||||
left : 0;
|
||||
right : 0;
|
||||
padding : 10px;
|
||||
overflow : auto;
|
||||
|
||||
}
|
||||
span{
|
||||
position: sticky;
|
||||
top: 0;
|
||||
position : sticky;
|
||||
top : 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
|
||||
const router = useTinyRouter();
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
let { id } = $props();
|
||||
let error = $state(null);
|
||||
let content = $state(null);
|
||||
let doc = $state(null);
|
||||
let email = $state(null);
|
||||
let content = $state(null);
|
||||
let error = $state(null);
|
||||
const router = useTinyRouter();
|
||||
let subject = $state(null);
|
||||
let { id } = $props();
|
||||
|
||||
async function loadDoc(){
|
||||
let url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${id}`;
|
||||
let url = api(`document/${id}`);
|
||||
let resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
doc = await resp.json();
|
||||
@@ -24,7 +25,7 @@
|
||||
error = await resp.text();
|
||||
return;
|
||||
}
|
||||
url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${id}/settings`;
|
||||
url = api(`document/${id}/settings`);
|
||||
resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
const settings = await resp.json();
|
||||
@@ -36,11 +37,11 @@
|
||||
|
||||
async function doSend(){
|
||||
var data = {email:email,subject:subject,content:content};
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${id}/send`;
|
||||
const url = api(`document/${id}/send`);
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
credentials : 'include',
|
||||
method : 'POST',
|
||||
body : JSON.stringify(data)
|
||||
});
|
||||
if (resp.ok){
|
||||
router.navigate(`/document?company_id=${doc.company.id}`);
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
<script>
|
||||
import {onMount} from 'svelte';
|
||||
|
||||
import {api} from '../../urls.svelte.js';
|
||||
import {t} from '../../translations.svelte.js';
|
||||
let { caption = t('select_state'), selected = $bindable(0), onchange = (val) => console.log('changed to '+val)} = $props();
|
||||
|
||||
let {
|
||||
caption = t('select_state'),
|
||||
onchange = (val) => console.log('changed to '+val),
|
||||
selected = $bindable(0)
|
||||
} = $props();
|
||||
|
||||
let message = $state(t('loading'));
|
||||
let states = $state(null);
|
||||
|
||||
async function loadStates(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/states`;
|
||||
var resp = await fetch(url,{credentials: 'include'});
|
||||
const url = api('document/states');
|
||||
const resp = await fetch(url,{credentials: 'include'});
|
||||
if (resp.ok){
|
||||
states = await resp.json();
|
||||
} else {
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
<script>
|
||||
import {onMount} from 'svelte';
|
||||
|
||||
import {api} from '../../urls.svelte.js';
|
||||
import {t} from '../../translations.svelte.js';
|
||||
let { caption, company, value = $bindable(0), onchange = () => console.log('changed')} = $props();
|
||||
|
||||
let {
|
||||
caption,
|
||||
company,
|
||||
value = $bindable(0),
|
||||
onchange = () => console.log('changed')
|
||||
} = $props();
|
||||
|
||||
let message = t('loading');
|
||||
let templates = $state(null);
|
||||
|
||||
async function loadTemplates(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/templates`;
|
||||
const url = api('document/templates');
|
||||
var resp = await fetch(url,{
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
body: JSON.stringify({company:company})
|
||||
credentials : 'include',
|
||||
method : 'POST',
|
||||
body : JSON.stringify({company:company})
|
||||
});
|
||||
if (resp.ok){
|
||||
templates = await resp.json();
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
<script>
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let { company_id, onSelect = (time) => {} } = $props();
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
let {
|
||||
company_id,
|
||||
onSelect = (time) => {}
|
||||
} = $props();
|
||||
|
||||
let error = $state(null);
|
||||
let projects = $state(null);
|
||||
let times = $state(null);
|
||||
let error = $state(null);
|
||||
|
||||
async function loadProjects(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/project/list`;
|
||||
const url = api'project/list');
|
||||
let data = { company_id: company_id };
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
credentials : 'include',
|
||||
method : 'POST',
|
||||
body : JSON.stringify(data)
|
||||
});
|
||||
if (resp.ok){
|
||||
projects = await resp.json();
|
||||
@@ -24,12 +29,12 @@
|
||||
}
|
||||
|
||||
async function loadTimes(projectId){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/times/list`;
|
||||
const url = api('times/list');
|
||||
let data = { company_id: company_id, project_id: projectId };
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
credentials : 'include',
|
||||
method : 'POST',
|
||||
body : JSON.stringify(data)
|
||||
});
|
||||
if (resp.ok){
|
||||
times = await resp.json();
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
<script>
|
||||
import {onMount} from 'svelte';
|
||||
|
||||
import {api} from '../../urls.svelte.js';
|
||||
import {t} from '../../translations.svelte.js';
|
||||
let { caption, value = $bindable(0), onchange = () => console.log('changed')} = $props();
|
||||
|
||||
let {
|
||||
caption,
|
||||
onchange = () => console.log('changed'),
|
||||
value = $bindable(0)
|
||||
} = $props();
|
||||
|
||||
let message = t('loading');
|
||||
let types = $state(null);
|
||||
|
||||
async function loadTypes(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/types`;
|
||||
const url = api('api/document/types');
|
||||
var resp = await fetch(url,{credentials: 'include'});
|
||||
if (resp.ok){
|
||||
types = await resp.json();
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
|
||||
import {api} from '../../urls.svelte.js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { user } from '../../user.svelte.js';
|
||||
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import LineEditor from '../../Components/LineEditor.svelte';
|
||||
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
|
||||
import MultilineEditor from '../../Components/MultilineEditor.svelte';
|
||||
@@ -13,20 +15,19 @@
|
||||
import StateSelector from './StateSelector.svelte';
|
||||
import TemplateSelector from './TemplateSelector.svelte';
|
||||
|
||||
const router = useTinyRouter();
|
||||
|
||||
let { id } = $props();
|
||||
let error = $state(null);
|
||||
let doc = $state(null);
|
||||
let pdfDisabled = $state(false);
|
||||
let sndDisabled = $state(false);
|
||||
let position_select = $state(false);
|
||||
|
||||
let editable = $derived(doc.state == 1);
|
||||
let error = $state(null);
|
||||
let { id } = $props();
|
||||
let pdfDisabled = $state(false);
|
||||
let position_select = $state(false);
|
||||
const router = useTinyRouter();
|
||||
let sndDisabled = $state(false);
|
||||
|
||||
|
||||
async function loadDoc(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${id}`;
|
||||
const url = api(`document/${id}`;
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
doc = await resp.json();
|
||||
@@ -60,11 +61,11 @@
|
||||
data[parts.pop()] = inner;
|
||||
}
|
||||
try {
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${doc.id}`;
|
||||
const url = api(`document/${doc.id}`;
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method:'PATCH',
|
||||
body:JSON.stringify(data)
|
||||
credentials : 'include',
|
||||
method : 'PATCH',
|
||||
body : JSON.stringify(data)
|
||||
});
|
||||
return resp.ok;
|
||||
} catch (err){
|
||||
@@ -73,11 +74,11 @@
|
||||
}
|
||||
|
||||
async function addPosition(selected){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${doc.id}/position`;
|
||||
const url = api(`document/${doc.id}/position`;
|
||||
const resp = await fetch(url,{
|
||||
method: 'POST',
|
||||
credentials:'include',
|
||||
body:JSON.stringify(selected)
|
||||
method : 'POST',
|
||||
credentials : 'include',
|
||||
body : JSON.stringify(selected)
|
||||
});
|
||||
if (resp.ok){
|
||||
doc.positions = await resp.json();
|
||||
@@ -90,7 +91,7 @@
|
||||
async function render(ev){
|
||||
pdfDisabled = true;
|
||||
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${doc.id}/pdf`;
|
||||
const url = api(`document/${doc.id}/pdf`;
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
error = null;
|
||||
|
||||
Reference in New Issue
Block a user