Merge pull request #8510 from aignatov-bio/ai-sci-11917-fix-redirect-for-locations

Fix redirect for storage locations in activities [SCI-11917]
This commit is contained in:
Martin Artnik 2025-05-26 12:55:10 +02:00 committed by GitHub
commit edeb24e6e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 6 deletions

View file

@ -29,7 +29,7 @@ class StorageLocationRepositoryRowsController < ApplicationController
end
storage_location_repository_row = StorageLocationRepositoryRow.new(
repository_row: @repository_row,
storage_location: @storage_location,
container_storage_location: @storage_location,
metadata: { position: position[0..1] },
created_by: current_user
)
@ -41,7 +41,7 @@ class StorageLocationRepositoryRowsController < ApplicationController
else
storage_location_repository_row = StorageLocationRepositoryRow.new(
repository_row: @repository_row,
storage_location: @storage_location,
container_storage_location: @storage_location,
created_by: current_user
)
storage_location_repository_row.with_lock do

View file

@ -38,7 +38,9 @@ class StorageLocationsController < ApplicationController
end
end
def show; end
def show
redirect_to storage_locations_path(parent_id: @storage_location.id) and return unless @storage_location.container
end
def create
ActiveRecord::Base.transaction do

View file

@ -115,10 +115,10 @@ module GlobalActivitiesHelper
project_folder_path(obj, team: obj.team.id)
end
when StorageLocation
path = if obj.new_record?
storage_locations_path(team: activity.team.id)
path = if obj.container
storage_location_path(obj, team: obj.team_id)
else
storage_location_path(obj, team: activity.team.id)
storage_locations_path(parent_id: obj.id, team: obj.team_id)
end
when Form
path = form_path(obj, team: obj.team.id)

View file

@ -7,6 +7,10 @@ class StorageLocationRepositoryRow < ApplicationRecord
default_scope -> { kept }
belongs_to :storage_location, inverse_of: :storage_location_repository_rows
belongs_to :container_storage_location, -> { where(container: true) },
class_name: 'StorageLocation',
foreign_key: 'storage_location_id',
inverse_of: :storage_location_repository_rows
belongs_to :repository_row, inverse_of: :storage_location_repository_rows
belongs_to :created_by, class_name: 'User'