Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

orderBy filter causes wrong item to be dragged #70

Closed

Description

@bkuhl

Using orderBy such as player in players | orderBy: 'first_name' causes the wrong item to be dragged between two lists. It appears the ui-sortable list is based off of index, prior to sorting.

I started to create a plunker example outside of my project, but it's not quite working, so it's not very useful. I'm experiencing this issue when 2 or more lists are connected and list items are dragged between the two.

plunker: http://plnkr.co/edit/PQlIbjTU5j6IU7uMC0yI?p=preview

It appears to be an issue with ui.sortable indexing items prior to orderBy processing.

Activity

  1. CyborgMaster commented on Dec 3, 2013

    @CyborgMaster

    How interesting. Up to this point we haven't supported orderBy because we looked at from the perspective of a single list. In that case sortable would have no idea how to change the item to reorder them. In your example, what should it do, change the first letter of the two names, swap the names?

    However, I never though about using sortable not to reorder items, but simply to drag them between lists. In which case, orderBy makes sense again.

    Now the question becomes whether this should be supported by ui-sortable, or a new, much simpler library.

  2. bkuhl commented on Dec 3, 2013

    @bkuhl
    Author

    Essentially all I'm trying to do is drag items between lists, but also
    maintain a specific order in the process.

    For example, my objective is for both lists to maintain an order by the
    player's grade. So if I drag a 7th grader to the top of a list where there
    is a 10th grader, it sorts the players correctly as:

    • 10th grader
    • 7th grader
    • 6th grader

    On Tue, Dec 3, 2013 at 5:46 PM, CyborgMaster notifications@github.comwrote:

    How interesting. Up to this point we haven't supported orderBy because we
    looked at from the perspective of a single list. In that case sortable
    would have no idea how to change the item to reorder them. In your example,
    what should it do, change the first letter of the two names, swap the
    names?

    However, I never though about using sortable not to reorder items, but
    simply to drag them between lists. In which case, orderBy makes sense
    again.

    Now the question becomes whether this should be supported by ui-sortable,
    or a new, much simpler library.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/70#issuecomment-29759758
    .

    Ben Kuhl

  3. CyborgMaster commented on Dec 3, 2013

    @CyborgMaster

    Yeah, that makes a lot of sense. Sounds like a perfect use case to me. I don't have time to look at this right now, but hopefully within the next week or two I will. If you want, you can start on a pull-request yourself.

  4. bkuhl commented on Dec 3, 2013

    @bkuhl
    Author

    If I get the chance to, I will.

    On Tue, Dec 3, 2013 at 5:51 PM, CyborgMaster notifications@github.comwrote:

    Yeah, that makes a lot of sense. Sounds like a perfect use case to me. I
    don't have time to look at this right now, but hopefully within the next
    week or two I will. If you want, you can start on a pull-request yourself.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/70#issuecomment-29760170
    .

    Ben Kuhl

  5. thgreasi commented on Jan 5, 2014

    @thgreasi
    Contributor

    @bkuhl Here is an edited version of your plunk. Please verify that this works as intended, since I didn't have much time.

    As already descussed in other issues

    ui-sortable's model should match the ng-repeater's model

    Always prefer applying filters in the controller instead of the 'view'.
    This is:

    Please reopen if applicable.

  6. bkuhl commented on Jan 5, 2014

    @bkuhl
    Author

    Yep, that's the functionality I was looking for... thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions