contentful-management.rb icon indicating copy to clipboard operation
contentful-management.rb copied to clipboard

Updating fields_with_locales has weird unintuitive behaviour

Open HQ063 opened this issue 5 years ago • 0 comments

Assigning a hash to field_with_locales doesn't override the current hash. And trying to manipulate the existing field_with_locales hash didn't do anything.

This looks totally weird and unintuitive.

[178] pry(main)> entry.title_with_locales = {'en-CA' => 'Title'}
=> {"en-CA"=>"Title"}
[179] pry(main)> entry.title_with_locales 
=> {"en-CA"=>"Title"}
[180] pry(main)> entry.title_with_locales['fr-CA'] = 'TitleFR'
=> "TitleFR"
[181] pry(main)> entry.title_with_locales 
=> {"en-CA"=>"Title"}
[182] pry(main)> entry.title_with_locales = {'fr-CA' => 'TitleFR'}
=> {"fr-CA"=>"TitleFR"}
[183] pry(main)> entry.title_with_locales 
=> {"en-CA"=>"Title", "fr-CA"=>"TitleFR"}
[184] pry(main)> entry.title_with_locales.delete 'en-CA'
=> "Title"
[185] pry(main)> entry.title_with_locales 
=> {"en-CA"=>"Title", "fr-CA"=>"TitleFR"}

And also it doesn't allow us to delete an existing key.

This issue combined with #204, creates a messy situation that forces us to use a lot of weird workarounds to be able to edit the content in the spaces that are not using the client default locale.

HQ063 avatar Jul 12 '19 00:07 HQ063