-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: move blocks between categories #265
base: main
Are you sure you want to change the base?
Conversation
Hi,i think that there is a possibility to split flows cross categories. Proposed solutions :
NB: Needs to support the case when we act on two or more linked blocks |
f8edf63
to
310d9e4
Compare
Thanks for your feedback 🙏 I worked on the first approch ✔️ 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 comment left 👏
…request-move-blocks-between-categories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @IkbelTalebHssan @yassinedorbozgithub Left some comments.
Testing various scenarios for moving blocks between flows. Everything worked fine 👏. I have one suggestion regarding the move button start icon: Using the hand Swipe icon may give users the impression that they can use a drag-n-drop gesture to move blocks between flows. I recommend replacing the icon with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the functional test again, and everything is working well.
if (criteria._id?.$in && updates?.$set?.category) { | ||
const ids: string[] = criteria._id?.$in || []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (criteria._id?.$in && updates?.$set?.category) { | |
const ids: string[] = criteria._id?.$in || []; | |
if (updates?.$set?.category) { | |
const blocks = await this.find(criteria); | |
const ids = blocks.map(({id}) => id); |
// Step 2: Find other blocks | ||
const otherBlocks = await this.model.find({ | ||
_id: { $nin: objIds }, | ||
category: { $ne: objCategory }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
category: { $ne: objCategory }, | |
category: { $ne: categoryId }, |
// Step 1: Map IDs and Category | ||
const { objIds, objCategory } = this.mapIdsAndCategory(ids, category); | ||
|
||
// Step 2: Find other blocks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const objIds = ids.map((id) => ObjectId(id))
const objCategory = new mongoose.Types.ObjectId(category); | ||
return { objIds, objCategory }; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment function
): Promise<void> { | ||
for (const id of ids) { | ||
const oldState = await this.model.findOne({ | ||
_id: new mongoose.Types.ObjectId(id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_id: new mongoose.Types.ObjectId(id), | |
_id: id, |
: null; | ||
|
||
await this.model.updateOne( | ||
{ _id: new mongoose.Types.ObjectId(id) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ _id: new mongoose.Types.ObjectId(id) }, | |
id, |
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment ...
): Promise<void> { | ||
for (const block of otherBlocks) { | ||
if ( | ||
objIds.some((id) => id.toString() === block.attachedBlock?.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
objIds.includes(block.attachedBlock)
!objIds.some((id) => id.toString() === nextBlock.toString()), | ||
); | ||
|
||
if (updatedNextBlocks.length !== block.nextBlocks.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (updatedNextBlocks.length !== block.nextBlocks.length) { | |
if (updatedNextBlocks.length > 0) { |
if (updatedNextBlocks.length !== block.nextBlocks.length) { | ||
await this.model.updateOne( | ||
{ _id: block.id }, | ||
{ nextBlocks: updatedNextBlocks }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$pull
Motivation
This PR introduces functionality to move one or multiple selected blocks between different categories. This enhancement allows for smoother transitions of grouped blocks across flows, improving workflow organization and flexibility in flow management.
Fixes # (issue)
Type of change:
Please delete options that are not relevant.
Checklist: