Open abnDK opened 1 year ago
Make us of grid or flex when designing this
When changing / updating budget, you choose a start date
Budget criteria:
Later version:
clean up code in "buildTree" function. Tænk over hvad formålet med funktionen er. Hvis det er at bygge træet, så er koden i virkeligheden meget simpel.
Lige pt. er implementering i budget viewet relativt simpelt, som blot skal bruge et træ. Der er derfor ikke pt. nødvendigt med dfs repræsentation af dataene.
refactor "getCategoriesAsTree" så træet ikke bygges backend og roder API koden sammen. Hent categories via /categories apien, og brug BuildTree funktionen i frontend koden. Lad det være en simpel kode, der ikke bruger dfs/bfs eller lign.
make it possible to delete budget row
Budget criteria:
- UI like screenshot above
[x] Budget is pr. default "locked".
- [x] shows categories as tree with parent/child relationsship
- [x] categories has name and amount
- [x] parent nodes has the sum of children
[x] Budget can be "unlocked" by clicking "edit"
- [x] Editable budgets makes is possible to change name and amount of all categories
- [ ] Categories can be added / [x] deleted
- [x] Adding a category is done by button on parent
- Delete a category is done by button on parent => changed to delete button is on row itself
- [ ] Start date becomes editable. Pr. default will have 1/x-xxxx (1st of the current month)
"locking"/saving a budget does the following
- [ ] every category is saved. If changes are made, there will be created new categories in db => reconsider this - how do we handle budget versions???
- [ ] afterwards, a new budget is created with updated startdate. All categories will get id of this budget as their new budget_id
Later version:
- parent node has field for "margin" that can both be in % or an amount. (they are interlocked)
/**
delete row almost done - refactor to use async / await before doing "add budget row" functions...
consider rewrite of rendering functions to be more verbose / write innerHTML when creating function...
delete row almost done - refactor to use async / await before doing "add budget row" functions...
done
- Add budget row
- [ ] Add new row on all 3 levels (parent, child, grandchild - and not grand-grandchild)
- [ ] Save row to db on save. (might already happen if we just add row like when we populate budget)
TODO
Fix deleterow:
current foreign key constraint problem on constraint table:
Finish function to update budget sums of category tree.
After this write render function that writes updated sums of each category in the tree to it's dom element. Make one for writing it into frozen format and editable format.
After these functions are run when we click save after editing, we can update the amounts to db, and use the returned category as source for updating parent_id in the category tree
Another potentially helpful function would be to render only rows to keep removing those that are set to be deleted upon save.
We are still working on the above...
Next is to fix the function that populates the budget rows when domcontentloaded event is fired.
Next: [] Refactor updateBudgetSums() to use makeCategory... from tree and the helper functions for calculating sums.
refact deleteCategories. Make sure it deletes children before parents. Maybe lokk into dev.podcast on post ... something something... Or we could use BFS and reverse the array getting the last generation first and so forth
when re-rendering the dom with renderFrozenAll / renderEditableAll we should check if we recalculate levels also. Maybe when be synDB and get updated parent id's back from db.
Refact budget structure so it hold the tree from a root node. Make the rendering where we convert from tree to array. We can also filter root out here then.
Also make recursive when calculating sums. Will then be a dfs search recursively to the leafs of the tree and then write that sum to parent
If we do this, we don't have to update parent id's before calcSum as the tre with children nodes enables us to calc sum of children
BuildTree is initial function taking Category interface, and outputs CategoryRow
dfsTree runs on the CategoryRows
BuildTree is done,
now refactor dfsTree and rendering function
This is issue will be split into 3 seperate issues. When each of these are done, this issue can be closed as well. [ ] Toggle edit/save => https://github.com/abnDK/personal-budget-2/issues/49 [ ] Add new budget row => https://github.com/abnDK/personal-budget-2/issues/50 [ ] Edit existing budget row => https://github.com/abnDK/personal-budget-2/issues/51 [ ] Delete existing budget row => https://github.com/abnDK/personal-budget-2/issues/52
Sketch for 3 layer budget.
Do use case analysis before final sketch and implementation.
Needs: