-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Unified Handling of Option Values and Product Properties List #3592
Conversation
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.
Thanks @hefan!
I left a couple of questions and I have other two things:
- At the moment, even if the row doesn't have the handle, it's included in the draggable items list, and I think we can easily remove it by adding the
draggable:
option to Sortable, the plugin that takes care of this. In this way, the new non-persisted row will be excluded. - Can we squash some commits? I feel like some of them are useless and can be grouped together, maybe with a better description.
Thanks again!
@@ -128,14 +130,14 @@ def fill_in_property | |||
|
|||
def delete_product_property | |||
accept_alert do | |||
click_icon :trash | |||
find('.delete-resource').click |
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.
Why is this change needed? Shouldn't we be able to intercept the link using the previous version of the code?
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.
before the nonpersistent icons didn't have a remove button. So here are 2 trash icons and we need to distinguish between remove and delete.
end | ||
expect(page).to have_content 'successfully removed' | ||
end | ||
|
||
def check_property_row_count(expected_row_count) | ||
def check_persistent_property_row_count(expected_row_count) |
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.
Maybe persisted
is more used? Just asking cause I never heard about persistent
for this.
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.
you are right
Maybe i squash and rebase it all into one commit. |
ok. added draggable, renamed spec methods and squashed/rebased. |
For draggable, I didn't mean that. I'm not sure what that class actually changes, why do you think it's needed? The problem I'd like to solve is this one: As you can see, dragging an element with the handle at the end of the table, when there's a non-persisted element, will make the non-persisted element move up in the table order. If you read the sortable plugin documentation, there's a draggable option that you can use when initializing the plugin to mark which elements are draggable and which aren't. For commits, it's not true that you can't use just parts of this PR, for example, the deprecation can go in a separate commit and also the controller check that doesn't build the extra row if not empty. Isn't it? |
I assume commits which would have to be reverted with the next commit are not wanted (the tests needs to be changed depending on sortable nonpersistent items or removable nonpersistent items). Also the system should not be let in a poorer state when only applying some commits (for example). So the only commits i see which would make a little bit of sense alone could be like you wrote: a.) Controller Creation of new items only if no items present Would you mind explaining a little bit what the point of splitting commits are here? Shouldn't this PR be added as a whole? Are non working partial commits also ok?
I understood the problem but was not sure about the solution nor i know much about Sortable. I somehow thought that when adding draggable means that non sortable items are no more draggable also. This was wrong. But non draggable also does not mean they are not changed in position when dragging other items below. To change the initialization of the Plugin we would need to mess with https://github.com/solidusio/solidus/blob/master/backend/vendor/assets/javascripts/solidus_admin/Sortable.js This could be a working solution for the problem |
This is the plugin used: https://github.com/SortableJS/Sortable |
Anyway, commits are needed for documentation. When a developer (even the core team reviewing the code) will look at commits, it's a great source of information. They should also contain the reason why that change happened. I suggest you to read this great article: https://mislav.net/2014/02/hidden-documentation/. Anyway, it's pretty personal to balance how to break PRs code down into commits. It's very up to the developer submitting the patch. I use to walk in the shoes of other developers that, some months from now, will debug that code and git blame on a line seeing what changed and why. The smallest and indipendent that piece of information is, the easiest it will be for them to understand and quickly fix the code. |
ok. thank you. i will read and do a commit remix tomorrow! The sortable/draggable stuff is also an extra commit i assume. Couldn't it be also an extra PR? Because it is also an isolated improvement compared to the current code (for both lists)! |
Now its regrouped in some isolated commits which each make sense. I hope its ok. The draggable problem remains (just like before). i would like to tackle that in another Commit. Just altering the |
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.
I left some other questions + I think we can get rid of the last commit.
Thanks for taking the time to improve the PR!
backend/app/views/spree/admin/product_properties/_product_property_fields.html.erb
Show resolved
Hide resolved
Are the above assumptions/suggestions consensual? |
i updated the PR accordingly to the suggestions. |
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 last small thing and we are good to go for me, sorry if I didn't catch that before. And thanks again, this PR is much needed. 🙏
backend/app/views/spree/admin/product_properties/_product_property_fields.html.erb
Show resolved
Hide resolved
Yes you are right. another thing came to my mind: |
…per action to remove resource
…r non persistent items
ok, all done.. |
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.
Thanks @hefan!
backend/app/views/spree/admin/option_types/_option_value_fields.html.erb
Show resolved
Hide resolved
Thanks @hefan! I just left a small comment about extracting the remove links into a helper. |
see also #3561 and #3581
The PR removes the mix of removing(nonpersistent) and deleting(persistent) records.
It also unifies the way new records are added (the are always marked as new and don't copy ids of other table rows)
One Catch is remaining (as already before this PR):
If you delete the first empty default entry you cannot add new entries. You have to reload the Page to see a new empty entry
possible solutions:
do never add remove buttons for non persistent fields. You voted against that in adjust option value handling to work like product properties handling #3561. With Commit a08b022 this would be done, the following commits handle the remove functionality.
Do somehow rewrite the JS
$('.spree_add_fields').click(function() {})
here https://github.com/solidusio/solidus/blob/master/backend/app/assets/javascripts/spree/backend/admin.js to not need a template or to get the template for a new row from another place.Any Suggestions for that?