preparing creation of successor document
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -12,26 +12,24 @@
|
||||
let router = useTinyRouter();
|
||||
let company_id = +router.query.company_id;
|
||||
let documents = null;
|
||||
let docType = 0;
|
||||
let selected_company = null;
|
||||
|
||||
async function loadCompanies(){
|
||||
const url = api('company/list');
|
||||
const resp = await fetch(url,{ credentials: 'include'});
|
||||
if (resp.ok){
|
||||
companies = await resp.json();
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
function createDoc(type){
|
||||
router.navigate(`/document/add?company_id=${selected_company.id}&document_type=${type}`)
|
||||
}
|
||||
|
||||
if (company_id) {
|
||||
for (let comp of companies){
|
||||
if (comp.id == company_id){
|
||||
load(comp);
|
||||
break;
|
||||
}
|
||||
async function deleteDoc(ev,doc){
|
||||
if (confirm(t('really_delete',doc.number))){
|
||||
const url = api(`document/${doc.id}`);
|
||||
const resp = await fetch(url,{
|
||||
credentials: 'include',
|
||||
method: 'DELETE'
|
||||
});
|
||||
if (resp.ok){
|
||||
load(selected_company); // relaod docs
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,29 +49,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
function createDoc(){
|
||||
router.navigate(`/document/add?company_id=${selected_company.id}&document_type=${docType}`)
|
||||
async function loadCompanies(){
|
||||
const url = api('company/list');
|
||||
const resp = await fetch(url,{ credentials: 'include'});
|
||||
if (resp.ok){
|
||||
companies = await resp.json();
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
|
||||
if (company_id) {
|
||||
for (let comp of companies){
|
||||
if (comp.id == company_id){
|
||||
load(comp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function show(id){
|
||||
router.navigate(`/document/${id}/view`);
|
||||
}
|
||||
|
||||
async function deleteDoc(ev,doc){
|
||||
if (confirm(t('really_delete',doc.number))){
|
||||
const url = api(`document/${doc.id}`);
|
||||
const resp = await fetch(url,{
|
||||
credentials: 'include',
|
||||
method: 'DELETE'
|
||||
});
|
||||
if (resp.ok){
|
||||
load(selected_company); // relaod docs
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMount(loadCompanies);
|
||||
</script>
|
||||
|
||||
@@ -100,7 +99,7 @@
|
||||
<th>{t('state')}</th>
|
||||
<th>
|
||||
{t('actions')}
|
||||
<TypeSelector caption={t('create_new_document')} bind:value={docType} onchange={createDoc} />
|
||||
<TypeSelector caption={t('create_new_object',{object:t('document')})} onSelect={createDoc} />
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Reference in New Issue
Block a user