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

Bulk editing of mappings #118

merged 66 commits into from
Dec 20, 2013

Bulk editing of mappings #118

merged 66 commits into from
Dec 20, 2013


Copy link

@jennyd jennyd commented Dec 18, 2013

Opening this to start more visible discussion, since it's a big one.

  • select multiple mappings from a site mappings index page
    • individually without javascript
    • using header checkbox for all or shift-click for ranges with javascript
  • choose to archive or redirect the selected mappings
  • see a pre-save confirmation page or modal, with a new URL input if redirecting
  • if all mappings are successfully updated, redirect to the last-seen site mappings index page
  • if the submitted new URL is invalid, (re)display the confirmation page with all mappings and the error message
  • if some mappings can't be updated for another reason (e.g. they are already invalid, probably because import bypasses validation), redisplay the confirmation page with only the ones which failed

The only acceptance criterion from the story which this doesn't address at all is client-side validation of the new URL input, but we think that is done adequately server-side for now.

Paul Hayes and others added 30 commits December 10, 2013 14:32
* Prepare table for form and checkboxes
* Switch add button from green to grey
* Add new table styles to style guide
* Style labels and checkboxes to make entire cell clickable
* Add examples to style guide
* Stub actual pages with the expected HTML
* Move padding helper from hits to base
* Toggle row class and checkbox state on selection
* Toggle all when using the header checkbox
* Use indeterminate state in header when only some of the rows are
* Update style guide example
* Use the previously interacted with checkbox and the newly clicked
checkbox to determine the range
* Currently only toggles on
Specify js interaction using class name so that only clicking the
header checkbox toggles table rows.
* Shift click above and below previously selected rows
* Shift clicking now toggles the range based on the state of the
clicked row, eg. you can now unselect in groups
* The browser maintains the state of checkboxes when moving
back/forward, our page needs to respond by applying the selected row
* The header state should also remain in sync
* Refactor so that shift clicking and normal clicking use the same code
* Toggling a checkbox with shift click when no previous toggles have
been changed should work as normal
Display new url input on the edit multiple page if redirecting.
Include new_status hidden in the form to post to update.
Various issues remain unresolved, relating to error handling, data
consistency and post-save redirect preserving filter and pagination.
* The toggle on the checkbox in the header wasn’t specific enough and
was affecting the default state of the radio buttons
* Update module and tests to use js prefixed class names rather than
*  Tweak alignment of radio buttons by removing padding and adding
* Adding the class attribute introduce a bug wherein the new parameter
evaluated to true and the input became checked.
* Use same table header text
* Use table header class
This is a bit simpler and more consistent than using
'redirect'/'archive' in forms.
This mappings helper method was changed in 62a5440 and the comment now
matches its existing behaviour.
* Separate table and mappings, avoid grouping behaviour based on where
it’s being used
* Rename spec to use _ to match file conventions
* Break into parts for re-use in a modal
* Create an edit multiple modal
* Modify table slightly based on modal local variable passed in
* Matches styles of other non-input type buttons
* Put back previously removed jquery_ujs so that ‘remote: true’ works
as expected
* Use javascript hooks to select an input type and submit the edit
multiple form, displaying the resulting HTML in a bootstrap modal window
* When the modal window is hidden remove it from the dom
* Extend selectable table module to include the wrapping form
* Known issues: Submitting the form without anything selected breaks
the modal. There’s no ajax loading indicator or error handling.
This still had the official description for the codes, rather than
our more user-friendly ones.
Feature: Editing multiple mappings for a site
As a GDS User,
I want to update many existing mappings at once
so that I can efficiently improve the quailty of mappings
Copy link

Choose a reason for hiding this comment

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

Mmm, quailty 🥚

Copy link

As a rule, I'd much prefer to see big things like this broken down. In this case, I might have split it into a non-JS Pull Request and then a JS enhancement.

* Fowl begone
| 301 | /about/branding | |
| 410 | /about/corporate | |
And I visit the path /sites/directgov/mappings

Copy link

Choose a reason for hiding this comment

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

The next block's getting a bit too implementation-specific. This will make the tests resistant to change. Comments inline about how we might be less specific about implementation without altering the goal (while also acknowledging that I've been guilty of similar elsewhere and pledging to reform my character):

@update_data = { http_status: @http_status }
if @http_status == '301'
@update_data[:new_url] = @new_url = params[:new_url]
Copy link

Choose a reason for hiding this comment

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

@update_data isn't used in any view I can see. It should just be a variable, and in the one case it's required elsewhere (bulk_update_mappings) passed as a parameter. To save time, you could cherry-pick 6cd6a6d7b34b844ff0c093a7b605e6826b703e02

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks 🍒

jennyd and others added 10 commits December 18, 2013 15:46
* Break the redirect field and logic out of the edit_multiple_table
partial and into its own
* Change the order of the elements when being shown in a modal
* Hide check-all checkbox when we aren’t using JavaScript, it won’t do
* Update the label ‘for’ attribute so that labels are clickable again
* Refer to selecting mappings, not clicking checkboxes
* Refer to editing a selection, not clicking a specific button
* Refer to a form containing a selection, not a list of URLs
* Refer to saving changes, rather than clicking a save button

(Mostly implementing @rgarner’s suggestions)
* Helps edit/update_multiple read ok
* May violate SRP slightly, but probably less than we were doing
* Make sure would_fail_on_url? works not just by coincidence
* Tidy test_mapping
* Whitespace in update_multiple
* Better naming for failed_updates (becomes failures)
* Rename would_fail_on_url? to would_fail_on_new_url?
Copy link

Awesome work, @fofr and @jennyd. Its great to have this feature in :)

jamiecobbett added a commit that referenced this pull request Dec 20, 2013
@jamiecobbett jamiecobbett merged commit e291050 into master Dec 20, 2013
@jamiecobbett jamiecobbett deleted the bulk-editing branch December 20, 2013 11:47
Copy link

1,340 lines MERGINATED

Copy link

rgarner commented Dec 20, 2013

🍖 🍈 📣 📝 🚹

Ok, who moved :merginator:?

Copy link


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

Successfully merging this pull request may close these issues.

None yet

4 participants