Add gallery view after image update [SCI-5286] (#2993)

* Add gallery view after image update [SCI-5286]
This commit is contained in:
aignatov-bio 2020-12-04 11:47:24 +01:00 committed by GitHub
parent edd774b045
commit 6bd021d88a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,8 +35,11 @@ class AssetsController < ApplicationController
def toggle_view_mode
@asset.view_mode = toggle_view_mode_params[:view_mode]
if @asset.save(touch: false)
gallery_view_id = @assoc.id if @assoc.class == Step
gallery_view_id = if @assoc.is_a?(Step)
@assoc.id
elsif @assoc.is_a?(Result)
@assoc.my_module.id
end
html = render_to_string(partial: 'assets/asset.html.erb', locals: {
asset: @asset,
gallery_view_id: gallery_view_id
@ -102,10 +105,19 @@ class AssetsController < ApplicationController
@asset.post_process_file(@asset.team)
@asset.step&.protocol&.update(updated_at: Time.zone.now)
render_html = if @asset.step || @asset.result
render_html = if [Result, Step].include?(@assoc.class)
gallery_view_id = if @assoc.is_a?(Step)
@assoc.id
elsif @assoc.is_a?(Result)
@assoc.my_module.id
end
render_to_string(
partial: 'assets/asset.html.erb',
locals: { asset: @asset },
locals: {
asset: @asset,
gallery_view_id: gallery_view_id
},
formats: :html
)
else