-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Make positions possibly negatives #5690
Conversation
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.
PR Summary
- Updated
RecordBoard.tsx
to usegetDraggedRecordPosition
utility for calculating new positions, allowing negative values. - Added
get-dragged-record-position.util.ts
utility function to handle negative positions. - Added unit tests for
getDraggedRecordPosition
inget-dragged-record-position.util.test.ts
. - Modified
record-position.factory.ts
to support negative positions and updated related tests. - Updated
position.scalar.ts
to validate and allow negative number positions.
.../modules/object-record/record-board/utils/__tests__/get-dragged-record-position.util.test.ts
Outdated
Show resolved
Hide resolved
.../modules/object-record/record-board/utils/__tests__/get-dragged-record-position.util.test.ts
Outdated
Show resolved
Hide resolved
...wenty-front/src/modules/object-record/record-board/utils/get-dragged-record-position.util.ts
Show resolved
Hide resolved
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.
LGTM
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.
LGTM @thomtrp left a small comment
recordAfterPosition?: number, | ||
): number => { | ||
if (isDefined(recordAfterPosition) && isDefined(recordBeforePosition)) { | ||
return (recordBeforePosition + recordAfterPosition) / 2; |
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.
Since you return in your if, I think we can have something with less indentation and more readable like this. Wdyt?
export const getDraggedRecordPosition = (
recordBeforePosition?: number,
recordAfterPosition?: number,
): number => {
if (isDefined(recordAfterPosition) && isDefined(recordBeforePosition)) {
return (recordBeforePosition + recordAfterPosition) / 2;
}
if (isDefined(recordAfterPosition)) {
return recordAfterPosition - 1;
}
if (isDefined(recordBeforePosition)) {
return recordBeforePosition + 1;
}
return 1;
};
Closes #5427