mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-11 08:51:32 +08:00
Merge pull request #7901 from aignatov-bio/ai-sci-11117-fix-shared-locations-on-move-modal
Fix shared locations permission in move modal [SCI-11117]
This commit is contained in:
commit
b74b17872f
2 changed files with 11 additions and 3 deletions
|
|
@ -123,7 +123,7 @@ class StorageLocationsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def tree
|
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)
|
render json: storage_locations_recursive_builder(records)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -253,6 +253,7 @@ class StorageLocationsController < ApplicationController
|
||||||
storage_locations.map do |storage_location|
|
storage_locations.map do |storage_location|
|
||||||
{
|
{
|
||||||
storage_location: storage_location,
|
storage_location: storage_location,
|
||||||
|
can_manage: (can_manage_storage_location?(storage_location) unless storage_location.parent_id),
|
||||||
children: storage_locations_recursive_builder(
|
children: storage_locations_recursive_builder(
|
||||||
storage_location.storage_locations.where(container: [false, params[:container] == 'true'])
|
storage_location.storage_locations.where(container: [false, params[:container] == 'true'])
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
:class="{
|
:class="{
|
||||||
'!bg-sn-super-light-blue': storageLocationTree.storage_location.id == value,
|
'!bg-sn-super-light-blue': storageLocationTree.storage_location.id == value,
|
||||||
'text-sn-blue cursor-pointer hover:bg-sn-super-light-grey': (
|
'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)
|
||||||
)
|
)
|
||||||
}">
|
}">
|
||||||
<i v-if="storageLocationTree.storage_location.container" class="sn-icon sn-icon-item"></i>
|
<i v-if="storageLocationTree.storage_location.container" class="sn-icon sn-icon-item"></i>
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
<MoveTree v-if="opendedStorageLocations[storageLocationTree.storage_location.id]"
|
<MoveTree v-if="opendedStorageLocations[storageLocationTree.storage_location.id]"
|
||||||
:storageLocationsTree="storageLocationTree.children"
|
:storageLocationsTree="storageLocationTree.children"
|
||||||
:value="value"
|
:value="value"
|
||||||
|
:canManage="managePermission(storageLocationTree)"
|
||||||
:moveMode="moveMode"
|
:moveMode="moveMode"
|
||||||
@selectStorageLocation="$emit('selectStorageLocation', $event)" />
|
@selectStorageLocation="$emit('selectStorageLocation', $event)" />
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -37,7 +38,8 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
storageLocationsTree: Array,
|
storageLocationsTree: Array,
|
||||||
value: Number,
|
value: Number,
|
||||||
moveMode: String
|
moveMode: String,
|
||||||
|
canManage: Boolean
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
MoveTree: () => import('./move_tree.vue')
|
MoveTree: () => import('./move_tree.vue')
|
||||||
|
|
@ -49,9 +51,14 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
selectStorageLocation(storageLocationTree) {
|
selectStorageLocation(storageLocationTree) {
|
||||||
|
if (!this.managePermission(storageLocationTree)) return;
|
||||||
|
|
||||||
if (this.moveMode === 'locations' || storageLocationTree.storage_location.container) {
|
if (this.moveMode === 'locations' || storageLocationTree.storage_location.container) {
|
||||||
this.$emit('selectStorageLocation', storageLocationTree.storage_location.id);
|
this.$emit('selectStorageLocation', storageLocationTree.storage_location.id);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
managePermission(loc) {
|
||||||
|
return loc.storage_location.parent_id ? this.canManage : loc.can_manage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue