spree/spree — pull request #5617 by tiagoamaro (2014-11-16 23:38:29+00:00)
Title: [backend] Hiding option values handle if object is not persisted

Hi @JDutil,

This pull request references the issue #4836.

Since the [update_positions](https://github.com/spree/spree/blob/eaaea6cd21fb5dfbf06a00c871b12934d62ec67e/backend/app/controllers/spree/admin/resource_controller.rb#L72-L80) method did not have any verification on the `params[:position]` null values, I thought the [update_values_positions](https://github.com/spree/spree/blob/eaaea6cd21fb5dfbf06a00c871b12934d62ec67e/backend/app/controllers/spree/admin/option_types_controller.rb#L6-L15) should not have this verification as well, and it should be done on the front end.

As the `@option_type.option_values` are built with the `before_action` [setup_new_option_value](https://github.com/spree/spree/blob/eaaea6cd21fb5dfbf06a00c871b12934d62ec67e/backend/app/controllers/spree/admin/option_types_controller.rb#L33-L35), the only verification I thought it should be done for showing the sorting handle is the persisted state of the option_values nested objects, as you can see in the `_option_value_fields.html.erb` partial of this pull request.

I also noticed that the verification of the emptiness of `@option_type.option_values` on the [option_types/edit.html.erb - L35-L44](https://github.com/spree/spree/blob/eaaea6cd21fb5dfbf06a00c871b12934d62ec67e/backend/app/views/spree/admin/option_types/edit.html.erb#L35-L44) always returned false because of the mentioned `before_action`, so I removed it.

Please, let me know if this helps, or I should work on something else :)