Page 1 of 1
[REACT] TaskBoard: Need string weight field
Posted: Mon Sep 19, 2022 12:14 am
by plugins-welcome
I have a usecase where I need to set https://www.bryntum.com/docs/taskboard/api/TaskBoard/model/TaskModel#field-weight
but the value of weight is string
instead of number
.
Can you support string
as weight?
Re: [REACT] TaskBoard: Need string weight field
Posted: Mon Sep 19, 2022 8:34 am
by johan.isaksson
Hi,
The purpose of using weight
instead of for example the tasks index
in the store to determine vertical order is to allow for cheaper insertions between two cards. Dropping between 100 and 200 will assign 150, which (mostly) eliminates the need of updating the other tasks. If we used store index for example, we would have to adjust index of all successors, potentially leading to a massive update call to the backend.
Supporting strings would as I see it have the same drawback, if you use A, B, C, D ... and drop between B & C, you would have to adjust from there on and down. With that said, it is unlikely that we will add support for string weights. But nothing is set in stone, could you elaborate on how you intend to use it?
Re: [REACT] TaskBoard: Need string weight field
Posted: Mon Sep 19, 2022 9:18 am
by plugins-welcome
Hi johan,
Basically whenever our users change the vertical order of the task, we save the order.
Dropping between 100 and 200 will assign 150, which (mostly) eliminates the need of updating the other tasks. If we used store index for example, we would have to adjust index of all successors, potentially leading to a massive update call to the backend.
And, we used the same idea as well in our backend. Instead of using number, we used string like this: https://confluence.atlassian.com/adminjiraserver/managing-lexorank-938847803.html
We want to use our own order instead of bryntum's own (weight).
Is there any way to do this?
Re: [REACT] TaskBoard: Need string weight field
Posted: Mon Sep 19, 2022 9:54 am
by johan.isaksson
You could try sorting the TaskStore by your own field, instead of by weight. That will change the display order. Done in this demo: https://bryntum.com/examples/taskboard/sorting/.
It will still assign a weight on drag and drop, but I suppose you can just ignore that by making the weight
field not persistable.
The demo also sets a flag on the taskDrag feature to reorder the store on drop, I suspect you will need that setting too.
Re: [REACT] TaskBoard: Need string weight field
Posted: Wed Sep 21, 2022 9:15 am
by plugins-welcome
I think I failed to explain our use case requirement in my previous post. Sorry for that. Here's the flow:
- After our app fetches the tasks from backend and injects into taskboard, they will be sorted by our field called
taskRank
.
- If user drags and drops a task to another position, the task will persist on that desired position.
- The app needs to know that position so that it can make an api call to backend to change moved task's
taskRank
. For example, if user drags task 5
to between task 2
and task 3
, the app will call backend api with this three ids and backend will change task 5
's taskRank
accordingly. (so that the board persists on the next data fetch)
Let me know if you have any questions.
Re: [REACT] TaskBoard: Need string weight field
Posted: Wed Sep 21, 2022 9:29 am
by johan.isaksson
Two approaches you could try:
1) Mapping taskRank
to a weight
on the backend:
A = 100
, B = 200
...
On drop between A & B, 150 is set and you could with you mapping on the backend figure out it is between A
& B
.
2) Sort by taskRank
locally, listen for taskDrop
, get tasks in the same column and figure out which one is before & after the dropped one.