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

Add ability to select multiple rows on Admin Tables #3565

Merged

Conversation

DanielePalombo
Copy link
Contributor

@DanielePalombo DanielePalombo commented Mar 20, 2020

Description

This PR adds the ability to select more elements of admin tables.
Before this PR the ability was present only for return items and with a custom js code.

Adding a selectable-table CSS class to an admin table, and a checkbox (with a selectable class) for every related record, it will be possible to select more than one element.

Screenshot 2020-03-20 at 16 47 39

If a checkbox named select-all is present this check/uncheck all the elements.

Screenshot 2020-03-20 at 16 52 37

Adding the selector CSS class selectable-label on a node HTML it will
be rendered a text depending on the number of the selected row.

Thanks to it will be possible to show different information depending on the selection type.
e.g.
Screenshot 2020-03-20 at 15 49 27
Screenshot 2020-03-20 at 15 48 59

An example of usage is provided at /admin/style_guide under Building Tables section.

This PR uses the selectable code on the return items

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch 2 times, most recently from 1eae7eb to 3e3a792 Compare March 27, 2020 12:55
@DanielePalombo DanielePalombo marked this pull request as ready for review March 27, 2020 14:25
@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch from 3e3a792 to e3eaaba Compare March 27, 2020 14:29
@kennyadsl kennyadsl changed the title Add ability to select more rows on spree admin table model Add ability to select more rows on spree admin tables Mar 27, 2020
@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch from e3eaaba to d79be59 Compare April 3, 2020 07:49
Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Left a couple of notes, only one is blocking. Great work Daniele!

@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch 2 times, most recently from da9f15f to 0314317 Compare April 3, 2020 16:11
@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch 2 times, most recently from 5eb017f to f2f9054 Compare April 10, 2020 13:05
@kennyadsl
Copy link
Member

We discussed IRL, and we are trying to move more things to handlebars templates.

@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch from 5e3dcab to e8382d0 Compare May 22, 2020 16:41
@DanielePalombo
Copy link
Contributor Author

Refactored with handlebars templates
Exported return items selection logic in a Backbone controller and handlebars template

@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch from e8382d0 to b9ce553 Compare May 25, 2020 07:43
@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch 2 times, most recently from cb87120 to 22abbc7 Compare June 12, 2020 11:21
@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch from 22abbc7 to 6a507d1 Compare June 19, 2020 12:14
@kennyadsl
Copy link
Member

@DanielePalombo Not sure how, but the failure doesn't seem a flaky, can you take a look? I'm restarting the suite again just be sure anyway.

@DanielePalombo
Copy link
Contributor Author

@kennyadsl It looks green now

@kennyadsl kennyadsl added Needs Core Team Review changelog:solidus_backend Changes to the solidus_backend gem and removed Needs Work labels Jun 23, 2020
@kennyadsl kennyadsl requested a review from a team June 23, 2020 06:05
@kennyadsl kennyadsl changed the title Add ability to select more rows on spree admin tables Add ability to select multiple rows on Admin Tables Jun 23, 2020
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Is this also persisting any of the changes to the server? Is this only for removing columns or also for exerting multiple items at once?


new Spree.Views.Tables.SelectableTable({el: this, model: selectableTableModel});

if($(this).hasClass('return-items-table')) {
Copy link
Member

Choose a reason for hiding this comment

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

Why hard-code this behavior here? Can we add a dedicated view model for the return items table instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a dedicated view for return items table, let me know if it works for you.


img {
max-width: none;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why is this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This shows the image under style_guide page
Screenshot 2020-06-26 at 16 35 22

Without it, the image doesn't appear
Screenshot 2020-06-26 at 16 35 06

@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch 2 times, most recently from b5d14b7 to cdee859 Compare July 3, 2020 06:05
@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch 2 times, most recently from 9fb2dfb to 83869e7 Compare July 17, 2020 07:35
This commit adds the ability to select more rows on admin resource
tables.
To use this feature, add the `selectable-table` CSS class to the
selected table and the CSS class `selectable` to the checkbox, which
identifies the record id.

It is possible to add a checkbox named `select-all` to check/uncheck all
the elements.

An example of its usage is provided at `/admin/style_guide` under
`Building Tables` section.
This event is triggered when the selectableTable is initialized.
Binding on this event you can add your own logic to the
selectableTable.

e.g.

```
# app/assets/javascript/components/selectable_table/custom.js
Backbone.on('selectableTable:init', function(selectableTable){
  if(selectableTable.$el.find('.selectable').length > 0) {
    new Spree.Views.Tables.SelectableTable.Custom(el: selectableTable.el);
  }
})
```
@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch from 2b6a462 to 399c6bf Compare July 17, 2020 08:34
Copy link
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

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

@DanielePalombo thank you! 💯

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Left a non-blocking comment if you have time to fix it. Thanks!

@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch from 399c6bf to fa9330d Compare July 17, 2020 10:08
@DanielePalombo
Copy link
Contributor Author

@kennyadsl the build is failed because of flaky spec, do you mind re-running the CI?

This component will be rendered above the selectableTable  and will
shown the selected item number label.
This commit updates the JS and HTML code related to return items, to
use the selectable.js code.

You can see the code working on:
/admin/orders/ORDER_NUMBER/customer_returns/new
/admin/orders/ORDER_NUMBER/return_authorizations/new

return_item_selection.js file is removed in favor of HBS template.
@DanielePalombo DanielePalombo force-pushed the nebulab/selectable-table branch from fa9330d to ea23be2 Compare July 17, 2020 12:24
@spaghetticode spaghetticode merged commit 7ae3f53 into solidusio:master Jul 20, 2020
@DanielePalombo DanielePalombo deleted the nebulab/selectable-table branch July 20, 2020 12:48
spaghetticode added a commit to nebulab/solidus that referenced this pull request Jan 20, 2021
This feature got lost with solidusio#3565. It automatically checks rows
where the admin changes something, under the assumption that,
if a value is changed, then the user means to include the row
into the RMA/return.

An integration spec is added to properly track this feature.
spaghetticode added a commit to nebulab/solidus that referenced this pull request Jan 20, 2021
This feature got lost with solidusio#3565. It automatically checks rows
where the admin changes something, under the assumption that,
if a value is changed, then the user means to include the row
into the RMA/return.

An integration spec is added to properly track this feature.
spaghetticode added a commit to nebulab/solidus that referenced this pull request Jan 21, 2021
This feature got lost with solidusio#3565. It automatically checks rows
where the admin changes something, under the assumption that,
if a value is changed, then the user means to include the row
into the RMA/return.

An integration spec is added to properly track this feature.
kennyadsl pushed a commit that referenced this pull request Feb 18, 2021
This feature got lost with #3565. It automatically checks rows
where the admin changes something, under the assumption that,
if a value is changed, then the user means to include the row
into the RMA/return.

An integration spec is added to properly track this feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_backend Changes to the solidus_backend gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants