diff --git a/app/controllers/storage_locations_controller.rb b/app/controllers/storage_locations_controller.rb
index cd3b76934..5c9dc9a62 100644
--- a/app/controllers/storage_locations_controller.rb
+++ b/app/controllers/storage_locations_controller.rb
@@ -123,7 +123,7 @@ class StorageLocationsController < ApplicationController
end
def tree
- records = current_team.storage_locations.where(parent: nil, container: [false, params[:container] == 'true'])
+ records = StorageLocation.viewable_by_user(current_user, current_team).where(parent: nil, container: [false, params[:container] == 'true'])
render json: storage_locations_recursive_builder(records)
end
@@ -253,6 +253,7 @@ class StorageLocationsController < ApplicationController
storage_locations.map do |storage_location|
{
storage_location: storage_location,
+ can_manage: (can_manage_storage_location?(storage_location) unless storage_location.parent_id),
children: storage_locations_recursive_builder(
storage_location.storage_locations.where(container: [false, params[:container] == 'true'])
)
diff --git a/app/javascript/vue/storage_locations/modals/move_tree.vue b/app/javascript/vue/storage_locations/modals/move_tree.vue
index 68b16098b..7972a8b41 100644
--- a/app/javascript/vue/storage_locations/modals/move_tree.vue
+++ b/app/javascript/vue/storage_locations/modals/move_tree.vue
@@ -13,7 +13,7 @@
:class="{
'!bg-sn-super-light-blue': storageLocationTree.storage_location.id == value,
'text-sn-blue cursor-pointer hover:bg-sn-super-light-grey': (
- moveMode === 'locations' || storageLocationTree.storage_location.container
+ (moveMode === 'locations' || storageLocationTree.storage_location.container) && managePermission(storageLocationTree)
)
}">
@@ -25,6 +25,7 @@
@@ -37,7 +38,8 @@ export default {
props: {
storageLocationsTree: Array,
value: Number,
- moveMode: String
+ moveMode: String,
+ canManage: Boolean
},
components: {
MoveTree: () => import('./move_tree.vue')
@@ -49,9 +51,14 @@ export default {
},
methods: {
selectStorageLocation(storageLocationTree) {
+ if (!this.managePermission(storageLocationTree)) return;
+
if (this.moveMode === 'locations' || storageLocationTree.storage_location.container) {
this.$emit('selectStorageLocation', storageLocationTree.storage_location.id);
}
+ },
+ managePermission(loc) {
+ return loc.storage_location.parent_id ? this.canManage : loc.can_manage;
}
}
};