- Clear stage prior to implementing replacement for collapsed lanes (with virtual lists)

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-06-28 15:08:26 -04:00
parent 8207a52b6b
commit 2f493c63f8
5 changed files with 313 additions and 325 deletions

View File

@@ -89,42 +89,47 @@ const LaneHelper = {
},
// TODO: This has been updated to new DND Lib, verified.
moveCardAcrossLanes: (state, { fromLaneId, toLaneId, cardId, index }) => {
// Clone the state to avoid mutation
const newLanes = cloneDeep(state.lanes);
// Find the source and destination lanes using the lane indices
const fromLane = newLanes[fromLaneId];
const toLane = newLanes[toLaneId];
// Find the card in the source lane
const cardIndex = fromLane.cards.findIndex((card) => card.id === cardId);
if (cardIndex === -1) {
throw new Error("Card not found in the source lane");
}
// Remove the card from the source lane
const [card] = fromLane.cards.splice(cardIndex, 1);
// Insert the card into the destination lane at the specified index
toLane.cards.splice(index, 0, card);
let idx = 0;
// Update the lane and card indexes for all lanes
newLanes.forEach((lane, laneIndex) => {
lane.cards.forEach((card, cardIndex) => {
card.idx = idx;
card.laneIndex = laneIndex;
card.cardIndex = cardIndex;
card.laneId = lane.id;
idx++;
});
});
return update(state, {
lanes: { $set: newLanes }
});
moveCardAcrossLanes: (state, ...args) => {
return state;
// console.dir({
// state,
// args: { fromLaneId, toLaneId, cardId, index }
// });
// // Clone the state to avoid mutation
// const newLanes = cloneDeep(state.lanes);
//
// // Find the source and destination lanes using the lane indices
// const fromLane = newLanes[fromLaneId];
// const toLane = newLanes[toLaneId];
//
// // Find the card in the source lane
// const cardIndex = fromLane.cards.findIndex((card) => card.id === cardId);
// if (cardIndex === -1) {
// throw new Error("Card not found in the source lane");
// }
//
// // Remove the card from the source lane
// const [card] = fromLane.cards.splice(cardIndex, 1);
//
// // Insert the card into the destination lane at the specified index
// toLane.cards.splice(index, 0, card);
//
// let idx = 0;
//
// // Update the lane and card indexes for all lanes
// newLanes.forEach((lane, laneIndex) => {
// lane.cards.forEach((card, cardIndex) => {
// card.idx = idx;
// card.laneIndex = laneIndex;
// card.cardIndex = cardIndex;
// card.laneId = lane.id;
// idx++;
// });
// });
//
// return update(state, {
// lanes: { $set: newLanes }
// });
},
updateCardsForLane: (state, { laneId, cards }) => {