Versie 0.3.2
This commit is contained in:
1 parent
e77d8fd373
commit
1cf6eeed29
16 files changed
+551
-44
No files matched your search
+12
-5
@@ -1,4 +1,4 @@
|
||||
// Generated, do not edit. sha256:7de3dc53eab20f070a6ac8c7162fee1bd0695f724c6a13e314a994181782906e
|
||||
// Generated, do not edit. sha256:26e9a2b26a7c0fa9e0b6979080609ba55baa351ce8440240a006def072475893
|
||||
import { listAssets, listBookableAssets, createAsset, updateAsset, deleteAsset } from '../data/assets.js';
|
||||
import { hasMetalAssets } from '../data/metals.js';
|
||||
import { tableViewCfg } from '../data/preferences.js';
|
||||
@@ -132,7 +132,14 @@ async function buildTable(el) {
|
||||
};
|
||||
}
|
||||
|
||||
const rijen = await listAssets();
|
||||
const nieuw = new Set();
|
||||
const zichtbaar = async () => {
|
||||
const b = await listBookableAssets();
|
||||
if (!nieuw.size) return b;
|
||||
const ids = new Set(b.map(a => a.id));
|
||||
return [...b, ...(await listAssets()).filter(a => nieuw.has(a.id) && !ids.has(a.id))];
|
||||
};
|
||||
const rijen = await zichtbaar();
|
||||
const bookable = async () => (await listBookableAssets()).filter(r => r.symbol !== baseCurrency()).length;
|
||||
let used = await bookable();
|
||||
tableApi = renderTable(el.querySelector('#tbl'), {
|
||||
@@ -145,11 +152,11 @@ async function buildTable(el) {
|
||||
newLabel: t('table.new'),
|
||||
newDefaults: { kind: 'crypto', decimals: '', displayUnit: 'unit', taxCategory: '', taxScope: '', balanceCapture: '' },
|
||||
saveLabel: t('assets.save'), cancelLabel: t('assets.cancel'),
|
||||
onCreate: async v => { const id = await createAsset(toPayload(v)); used = await bookable(); tableApi.refresh(await listAssets(), { locate: id }); },
|
||||
onSave: async (id, v) => { await updateAsset(id, toPayload(v)); tableApi.refresh(await listAssets()); },
|
||||
onCreate: async v => { const id = await createAsset(toPayload(v)); nieuw.add(id); used = await bookable(); tableApi.refresh(await zichtbaar(), { locate: id }); },
|
||||
onSave: async (id, v) => { await updateAsset(id, toPayload(v)); tableApi.refresh(await zichtbaar()); },
|
||||
onDelete: async id => {
|
||||
if (!(await dialog.confirm({ message: t('assets.confirmDelete'), danger: true }))) return;
|
||||
try { await deleteAsset(id); used = await bookable(); tableApi.refresh(await listAssets()); } catch (e) { dialog.alert({ title: t('dialog.error'), message: e.message }); }
|
||||
try { await deleteAsset(id); used = await bookable(); tableApi.refresh(await zichtbaar()); } catch (e) { dialog.alert({ title: t('dialog.error'), message: e.message }); }
|
||||
},
|
||||
});
|
||||
tableApi.focusRow(takeRowFocus('assets'));
|
||||
|
||||
Reference in new issue
Block a user