-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
Issue 662 area order and sorting #696
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Nice! Can you check the preview build? The list is showing up twice |
@vnugent Removed the duplicate listing. |
@tedgeving what do you think if we merge this PR now and create a follow up one when the backend functionality is done? |
@vnugent that works for me. |
@tedgeving any chance you can revive this PR? If you can rebase the PR with |
Let me take a look at it, should not be a problem.
Thanks for keeping me posted, have been busy with the day job and chasing
the good snow we've had here in NM. Hoping to get to contributing
again soon.
…On Wed, Mar 22, 2023 at 9:48 AM Viet Nguyen ***@***.***> wrote:
@tedgeving <https://github.com/tedgeving> any chance you can revive this
PR?
If you can rebase the PR with develop and get the drag-n-drop UI working
again, I can finish the backend integration part.
—
Reply to this email directly, view it on GitHub
<#696 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF5E4PKG7AUDN6DRJCLZ3W5MNNHANCNFSM6AAAAAAUXAG72Y>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I love this feature or ordering areas! Just tracking down the current progress and I see the backend work is done, and looks like the frontend is still a WIP. I'm curious if it makes sense to implement the area sorting UI using the same CSV Power Editor that is used for route sorting (cut/paste areas in the order you want), instead of a drag and drop. While I think drag and drop is just fine, it does create inconsistency. I have limited time to help with this (and no experience yet with the tech stack), but if I do get time I will start looking at code to see if I can help at all. |
f61cec3
to
7dc84c8
Compare
@vnugent Two outstanding problems:
|
The previous version was only one column in the edit mode to avoid this issue IIRC… On May 17, 2023, at 4:05 PM, zkao ***@***.***> wrote:
@vnugent Two outstanding problems:
In testing, I'm hitting the duplicate index error for leftRightIndex. I think it's because I'm sending [{areaId: .., leftRightIndex: 0}, {areaId: .., leftRightIndex: 1}, .., {areaId: .., leftRightIndex: <# of childareas -1>}] and when we try to set the leftRightIndex to be 0 for the first item, there is already another entry in the db with leftRightIndex 0, so throws the error even though later on, that item's leftRightIndex will replaced by a different entry. I could reset everything to -1 and then reassign, but it's not that elegant. Curious if you have a better approach in mind.
The drag and drop works fine in a single column, but you can't drag things across two columns. It doesn't detect the x coordinate, only the y coordinate, so it thinks you're dropping it into the leftmost column.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Unfortunately, wrapped list isn't supported by the DnD library. See this long discussion: atlassian/react-beautiful-dnd#316 An alternative? https://github.com/clauderic/dnd-kit |
a845dfe
to
9831fcc
Compare
Next up, we'd have to update |
A good place to play with the functionality is https://open-tacos-git-issue-662-area-order-openbeta-dev.vercel.app/crag/f3c655b6-9c95-597f-aaa6-fd7d8a4865ec |
9831fcc
to
7110cb3
Compare
7110cb3
to
47a87c5
Compare
@@ -117,7 +117,7 @@ export default function CragSummary ({ area, history }: CragSummaryProps): JSX.E | |||
* Initially set to the childAreas prop coming from Next build, the cache | |||
* may be updated by the users in the AreaCRUD component. | |||
*/ | |||
const [childAreasCache, setChildAreasCache] = useState(childAreas) | |||
const [childAreasCache, setChildAreasCache] = useState(sortByLeftRightIndex(childAreas)) |
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.
One question worth discussing is whether we should be sorting in the frontend or backend. You could argue that frontend is better if we want to allow dynamic sorting (L->R, Alphabetical, Most children) one day, so the backend result remain invariant and can be cached. Backend sorting just simplifies frontend code a bunch especially in the case where we always sort L->R.
I realize that for areas, L->R sorting doesn't make too much sense because areas aren't lined up on a wall like climbs. So the main purpose of the sorting here is just a stable ordering. If stability is what we care about, then perhaps no point enabling multiple sort orders for areas, which would lead to backend sorting being better.
For now I'm just following the design pattern of climbs, and doing sorting on the frontend.
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.
All good points. Agreed we should sort in the backend. Can you create a backend issue?
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.
OpenBeta/openbeta-graphql#294 Sounds good. I can work on this next.
src/components/edit/AreaCRUD.tsx
Outdated
@@ -4,9 +4,28 @@ import { AreaSummaryType } from '../crag/cragSummary' | |||
import { DeleteAreaTrigger, AddAreaTrigger, AddAreaTriggerButtonMd, AddAreaTriggerButtonSm, DeleteAreaTriggerButtonSm } from './Triggers' | |||
import { AreaEntityIcon } from '../EntityIcons' | |||
import NetworkSquareIcon from '../../assets/icons/network-square-icon.svg' | |||
import React, { useState } from 'react' | |||
import useUpdateAreasCmd from '../../js/hooks/useUpdateAreasCmd' | |||
import { useSession } from 'next-auth/react' |
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.
Not super important. I usually place library imports at the top and then our own stuff. ts-standard
doesn't enforce this rule but I think it helps you quickly gain some context when scanning the import section.
https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md
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.
Fixed!
Work In Progress Addresses part of the following Issue
#662
DND Library has been (https://github.com/atlassian/react-beautiful-dnd) added to the Area edit page
https://github.com/OpenBeta/open-tacos/blob/develop/src/components/edit/AreaCRUD.tsx#L43