code cleanup

This commit is contained in:
2025-07-30 15:35:19 +02:00
parent 631a527a5d
commit fccec9865a
27 changed files with 442 additions and 428 deletions

View File

@@ -11,14 +11,14 @@
let error = null;
let companies = {};
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 = api('company/list');
const url = api('company/list');
const resp = await fetch(url,{ credentials: 'include'});
if (resp.ok){
companies = await resp.json();
@@ -40,7 +40,7 @@
async function load(company){
router.navigate(`/document?company_id=${company.id}`);
selected_company = company;
const url = api('document/list');
const url = api('document/list');
const resp = await fetch(url,{
credentials: 'include',
method: 'POST',
@@ -63,7 +63,7 @@
async function deleteDoc(ev,doc){
if (confirm(t('really_delete',doc.number))){
const url = api(`document/${doc.id}`;
const url = api(`document/${doc.id}`);
const resp = await fetch(url,{
credentials: 'include',
method: 'DELETE'

View File

@@ -2,14 +2,14 @@
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte-js';
import { api } from '../../urls.svelte.js';
import { t } from '../../translations.svelte.js';
import Position from './Position.svelte';
var {
document = $bindable(null),
error = $bindable(null)
error = $bindable(null),
submit = (key,newVal) => {},
} = $props();
@@ -23,7 +23,7 @@
}
async function movePos(number,step){
const url = api(`document/${document.id}/position`;
const url = api(`document/${document.id}/position`);
const resp = await fetch(url,{
method : 'PATCH',
credentials: 'include',
@@ -39,7 +39,7 @@
async function drop(number){
let confirmed = confirm(t('confirm_deletion').replace('{pos}',document.positions[number].item));
if (!confirmed) return;
const url = api(`document/${document.id}/position`;
const url = api(`document/${document.id}/position`);
const resp = await fetch(url,{
method : 'DELETE',
credentials: 'include',

View File

@@ -14,7 +14,7 @@
let times = $state(null);
async function loadProjects(){
const url = api'project/list');
const url = api('project/list');
let data = { company_id: company_id };
const resp = await fetch(url,{
credentials : 'include',

View File

@@ -27,7 +27,7 @@
async function loadDoc(){
const url = api(`document/${id}`;
const url = api(`document/${id}`);
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
doc = await resp.json();
@@ -61,7 +61,7 @@
data[parts.pop()] = inner;
}
try {
const url = api(`document/${doc.id}`;
const url = api(`document/${doc.id}`);
const resp = await fetch(url,{
credentials : 'include',
method : 'PATCH',
@@ -74,7 +74,7 @@
}
async function addPosition(selected){
const url = api(`document/${doc.id}/position`;
const url = api(`document/${doc.id}/position`);
const resp = await fetch(url,{
method : 'POST',
credentials : 'include',
@@ -91,7 +91,7 @@
async function render(ev){
pdfDisabled = true;
const url = api(`document/${doc.id}/pdf`;
const url = api(`document/${doc.id}/pdf`);
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
error = null;