Skip to content
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

Implement drag & reorder functionality & new API #1995

Merged
merged 1 commit into from
Oct 10, 2020

Conversation

atodorov
Copy link
Member

@atodorov atodorov commented Oct 7, 2020

NOTES:

  • uses Sortable.js for drag & reorder

  • manual sorting button is located after A-Z button in toolbar

  • NEW API method TestPlan.update_case_order()

  • Manual reorder & API require the testcases.change_testcaseplan
    permission

  • toolbarDropdowns() is called from within toolbarEvents() b/c
    it really doesn't make sense to have this as stand-alone function

  • toolbarEvents() is moved within the TestCases.filter() callback
    b/c we need the list of test cases to be fully initialized so we
    can get the initial sorting order and use it later

WARNINGS:

  • may want to unbind the on-click event for rows if users are
    having problems with the rows expanding while dragging them

  • the page doesn't use sortkey for initially displaying the rows
    of test cases because this field isn't available in the API result.

    Specifically sortkey is a field in the TestCasePlan model, which
    is a through model and the .filter() API is querying the TestCase
    model instead.

tcms/rpc/api/testplan.py Outdated Show resolved Hide resolved
Copy link
Contributor

@RMadjev RMadjev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes proposed

Copy link
Contributor

@RMadjev RMadjev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@atodorov
Copy link
Member Author

atodorov commented Oct 8, 2020

Note to self:

Sortable.js seems to not be maintained. There's this alternative:
https://github.com/lukasoppermann/html5sortable

which seems to have all of the functions we need for now and is looking for co-maintainers. We can probably pick it up.

@atodorov
Copy link
Member Author

atodorov commented Oct 9, 2020

@asankov, @RMadjev please check the 2nd commit and tell me what you think.

The original sortable.js library states that it is not maintained anymore and I've replaced it with another llibrary which is vanilla JS. The syntax is less handy but we don't use it that much so it is bearable. The changes from one to the other are minimal and straight forward.

The only thing lacking in html5sortable is the animation capabilities but that is offset by the fact that they are actively looking for co-maintainers and we can join them, see:
https://www.npmjs.com/package/html5sortable#looking-for-co-maintainer
lukasoppermann/html5sortable#541

@atodorov atodorov force-pushed the tp_drag_reorder branch 3 times, most recently from 6b0c2eb to 91e05bf Compare October 10, 2020 20:13
NOTES:

- uses html5sortable for drag & reorder
- manual sorting button is located after A-Z button in toolbar
- NEW API method TestPlan.update_case_order()
- Manual reorder & API require the testcases.change_testcaseplan
  permission

- toolbarDropdowns() is called from within toolbarEvents() b/c
  it really doesn't make sense to have this as stand-alone function
- toolbarEvents() is moved within the TestCases.filter() callback
  b/c we need the list of test cases to be fully initialized so we
  can get the initial sorting order and use it later

WARNINGS:

- may want to unbind the on-click event for rows if users are
  having problems with the rows expanding while dragging them
@atodorov atodorov merged commit 596b7b1 into refactor_testplan_ui Oct 10, 2020
@atodorov atodorov deleted the tp_drag_reorder branch October 10, 2020 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants