McRange / Material-Kanban-Board

This plugin allows easy integration of a Kanban board into your own application. Your business processes can be grouped and visualized clearly. With Drag'n Drop you can move the cards between a dynamic number of columns. Adjust the icons, colors and other attributes to your personal needs. Expand the cards with any HTML content to display more information and enable more functions.
Other
55 stars 17 forks source link

Rearrange/update items index in each column #17

Closed dianaeb95 closed 1 year ago

dianaeb95 commented 2 years ago

Hello! @McRange, firstly thanks a lot for this amazing plug in! Can you please advise how to change the index of the items in a category? I have 3 columns (for 3 priorities based on FLOW_PRIORTY column) and I need to arrange the items inside each priority based on FLOW_PRIORITY_INSIDE_CATEGORY column. If I move one item up/down, the index will change properly for the item that I have moved, but the others ones will not be updated, they will remain with the old index, even though they are not correct now.

I need something like this, but it's not correct/complete yet:

DECLARE VR_ITEM_ID VARCHAR2(200) := :APEX$ITEM_ID; VR_OLD_GROUP_ID VARCHAR2(200) := :APEX$OLD_GROUP_ID; VR_OLD_COLUMN_ID VARCHAR2(200) := :APEX$OLD_COLUMN_ID; VR_OLD_INDEX VARCHAR2(200) := :APEX$OLD_INDEX; VR_NEW_GROUP_ID VARCHAR2(200) := :APEX$NEW_GROUP_ID; VR_NEW_COLUMN_ID VARCHAR2(200) := :APEX$NEW_COLUMN_ID; VR_NEW_INDEX VARCHAR2(200) := :APEX$NEW_INDEX; BEGIN for c in (select flow_id, flow_name, flow_priority, flow_priority_inside_category from MY_FLOWS where flow_priority = VR_NEW_COLUMN_ID) loop update MY_FLOWS set flow_priority = VR_NEW_COLUMN_ID, flow_priority_inside_category = VR_NEW_INDEX where flow_id = VR_ITEM_ID; end loop; END;

For example, if I have this situation inside column1 (flow_priority=1) and I want to move item4 on second row...

FLOW_NAME FLOW_ID FLOW_PRIORITY FLOW_PRIORITY_INSIDE_CATEGORY item1...................15................1................................0 item2..................23.................1................................1 item3..................11.................1................................2 item4..................79.................1................................3

... it should become: FLOW_NAME FLOW_ID FLOW_PRIORITY FLOW_PRIORITY_INSIDE_CATEGORY item1...................15................1................................0 item4..................79.................1................................1 item2..................23.................1................................2 item3..................11.................1................................3

With the current code, the records look like this: item1...................15................1................................0 item4..................79.................1................................1 item2..................23.................1................................1 item3..................11.................1................................2

Also, the indexes should be updated/arranged if one item moves from a column to another (for example from flow_priority=1 to 2).

Thank you!

matthias-range-ais commented 2 years ago

Hi, there is only one event calling the the PL/SQL code when dropping an item, so you have to recalculate the values in FLOW_PRIORITY_INSIDE_CATEGORY for each item in the group. The sorting behavior depends on your usecase, i.e. is it allowed to move items between groups or not.

In your case there are 3 columns (FLOW_PRIORITY) and each with a defined sort order (FLOW_PRIORITY_INSIDE_CATEGORY) starting with the value "0", right? You can do this in 3 steps (i did not tested it):

hint: recalculate the sort orders of items is more complex when moving items between groups