Your personal notes, target and achievements with Kanban style.
Built using flutter, moor, boardview, etc.
(よていはかんばんスタイルのあなたの個人的なメモです)
Here is the thing, I'm using flutter board_view that you can find here. But I'm not exactly using their interface for onDragList and onDropItem (I mean, I'm using it but handle it differently).
Here is my table looks like (maybe a little bit different but this is a big picture of it):
****
Board | Category | Panel | Panel Item |
---|---|---|---|
id | id | id | id |
title | name | name | name |
description | description | description | |
category_id | order | order | |
last_updated | board_id | panel_id |
- Before the board get created, I check the category first, like below:
select * from category where name = "your category name"
- If the particular category with given name is already exists, then return id of the category.
- Board instance assign the returning id to the category_id. Example: Board(null, "My board", "My desc", returnedIdCategory, Date.now())
- If the particular category name doesnt exists, then insert a new record to table then return the id and do the same
- Let assume you are inserting a first fresh panel.
- Before inserting to database, I check it first:
select * from panel where board_id = givenBoardId
- If the return is empty (means there is no panel with particualr board_id, set the Panel order to = 1
- Insert new record to db
- If panel are already exists, then get order it by "order" key, and get the last value, then increment the order like order+1
- Its same with panel item, the only different is board_id and panel_id
- For example you get a panel like this below: #Panel 1 Panel 2 Panel 3 Item A Item B Item c
- Example you are moving the Panel 1 to Panel 2, then the order should be like this: Panel 2, Panel 1, Panel 3
- When you are moving a panel or panel item, you are rearranging the list. With above case should look like this in short:
var panels = [Panel 1, Panel 2, Panel 3] var oldPanel = panels[0] panels.remove(0) panels.insert(1, oldPanel) // 0 and 1 is retrieved from onDropList
- So you will get like [Panel 2, Panel 1, Panel 3]
- But, the panel order is not updated, the panel.order still look like this [Order 2, Order 1, Order 3]
- To update the order you need to for loop each panels and update the order with the correct index: (it is a big picture of the code, not the actual code):
for \(int i = 0; i < panelDatas.length; i++\) { panelDatas\[i\] = panelDatas\[i\].copyWith\(order: i\); await \_appDb.panelDao.updatePanelPosition\(panelDatas\[i\]\); }
- It is also used for panel item
- Also used for deleting