mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-31 04:32:06 +08:00
Speedup generating of storage locations tree for move modal [SCI-10863]
This commit is contained in:
parent
ae0bf4bb0d
commit
793dc22991
1 changed files with 5 additions and 7 deletions
|
@ -78,10 +78,8 @@ class StorageLocationsController < ApplicationController
|
|||
end
|
||||
|
||||
def tree
|
||||
records = StorageLocation.inner_storage_locations(current_team)
|
||||
.order(:name)
|
||||
.select(:id, :name, :parent_id, :container)
|
||||
render json: storage_locations_recursive_builder(nil, records)
|
||||
records = current_team.storage_locations.where(parent: nil, container: false)
|
||||
render json: storage_locations_recursive_builder(records)
|
||||
end
|
||||
|
||||
def actions_toolbar
|
||||
|
@ -151,11 +149,11 @@ class StorageLocationsController < ApplicationController
|
|||
}
|
||||
end
|
||||
|
||||
def storage_locations_recursive_builder(parent_storage_location, records)
|
||||
records.where(parent: parent_storage_location, container: false).map do |storage_location|
|
||||
def storage_locations_recursive_builder(storage_locations)
|
||||
storage_locations.map do |storage_location|
|
||||
{
|
||||
storage_location: storage_location,
|
||||
children: storage_locations_recursive_builder(storage_location, records)
|
||||
children: storage_locations_recursive_builder(storage_location.storage_locations.where(container: false))
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue