Merge pull request #7847 from aignatov-bio/ai-sci-11033-add-missing-interactions-storage-location-table

Fix interactions for box locations [SCI-11033]
This commit is contained in:
Martin Artnik 2024-09-12 16:51:12 +02:00 committed by GitHub
commit 173fdda28a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 63 additions and 20 deletions

View file

@ -127,7 +127,7 @@ export default {
field: 'position_formatted',
headerName: this.i18n.t('storage_locations.show.table.position'),
sortable: true,
notSelectable: true
cellClass: 'text-sn-blue cursor-pointer'
},
{
field: 'reminders',

View file

@ -21,7 +21,7 @@
<input
type="text"
v-model="object.name"
:placeholder="i18n.t(`storage_locations.index.edit_modal.name_placeholder`)"
:placeholder="i18n.t(`storage_locations.index.edit_modal.name_placeholder_${editModalMode}`)"
>
</div>
<span v-if="this.errors.name" class="text-sn-coral text-xs">{{ this.errors.name }}</span>

View file

@ -116,12 +116,7 @@ export default {
sortable: true
},
{
field: 'items',
headerName: this.i18n.t('storage_locations.index.table.items'),
sortable: true
},
{
field: 'shared',
field: 'shared_label',
headerName: this.i18n.t('storage_locations.index.table.shared'),
sortable: true
},
@ -135,6 +130,11 @@ export default {
headerName: this.i18n.t('storage_locations.index.table.created_on'),
sortable: true
},
{
field: 'created_by',
headerName: this.i18n.t('storage_locations.index.table.created_by'),
sortable: true
},
{
field: 'description',
headerName: this.i18n.t('storage_locations.index.table.description'),

View file

@ -41,16 +41,14 @@
</div>
<table v-if="notificationsSettings">
<template v-for="(_subGroups, group) in notificationsGroups" :key="group">
<div class="contents">
<tr>
<td colspan=3 class="pt-6"><h3>{{ i18n.t(`notifications.groups.${group}`) }}</h3></td>
</tr>
<tr>
<td></td>
<td class="p-2.5 text-base w-32">{{ i18n.t('notifications.in_app') }}</td>
<td class="p-2.5 text-base w-32">{{ i18n.t('notifications.email') }}</td>
</tr>
</div>
<tr>
<td colspan=3 class="pt-6"><h3>{{ i18n.t(`notifications.groups.${group}`) }}</h3></td>
</tr>
<tr>
<td></td>
<td class="p-2.5 text-base w-32">{{ i18n.t('notifications.in_app') }}</td>
<td class="p-2.5 text-base w-32">{{ i18n.t('notifications.email') }}</td>
</tr>
<template v-for="(_notifications, subGroup, i) in notificationsGroups[group]" :key="subGroup">
<tr v-if="subGroup !== 'always_on'"
class="text-base border-transparent border-b-sn-super-light-grey border-solid"

View file

@ -36,6 +36,8 @@ module Lists
end
def sub_location_count
return '/' if @object.container
if object.respond_to?(:sub_location_count)
object.sub_location_count
else

View file

@ -15,6 +15,7 @@ module Lists
StorageLocation.joins('LEFT JOIN storage_locations AS sub_locations ' \
'ON storage_locations.id = sub_locations.parent_id')
.viewable_by_user(@user, @team)
.select(shared_sql_select)
.select('storage_locations.*, COUNT(sub_locations.id) AS sub_location_count')
.group(:id)
end
@ -32,5 +33,43 @@ module Lists
@records = @records.where('LOWER(name) ILIKE ?', "%#{@filters[:query].downcase}%") if @filters[:query].present?
@records = @records.where('LOWER(name) ILIKE ?', "%#{@params[:search].downcase}%") if @params[:search].present?
end
private
def shared_sql_select
shared_write_value = TeamSharedObject.permission_levels['shared_write']
team_id = @user.current_team.id
case_statement = <<-SQL.squish
CASE
WHEN EXISTS (
SELECT 1 FROM team_shared_objects
WHERE team_shared_objects.shared_object_id = storage_locations.id
AND team_shared_objects.shared_object_type = 'StorageLocation'
) THEN 1
WHEN EXISTS (
SELECT 1 FROM team_shared_objects
WHERE team_shared_objects.shared_object_id = storage_locations.id
AND team_shared_objects.shared_object_type = 'StorageLocation'
AND team_shared_objects.team_id = :team_id
) THEN
CASE
WHEN EXISTS (
SELECT 1 FROM team_shared_objects
WHERE team_shared_objects.shared_object_id = storage_locations.id
AND team_shared_objects.shared_object_type = 'StorageLocation'
AND team_shared_objects.permission_level = :shared_write_value
AND team_shared_objects.team_id = :team_id
) THEN 2
ELSE 3
END
ELSE 4
END as shared
SQL
ActiveRecord::Base.sanitize_sql_array(
[case_statement, { team_id: team_id , shared_write_value: shared_write_value }]
)
end
end
end

View file

@ -85,7 +85,7 @@ module StorageLocations
column_letter = position[0]
row_number = position[1]
[column_letter.ord - 64, row_number]
[column_letter.ord - 64, row_number.to_i]
end
def convert_position_number_to_letter(item)

View file

@ -691,6 +691,8 @@ class Extends
ReportTemplates_archived_state
Repositories_active_state
Repositories_archived_state
StorageLocationsTable_active_state
StorageLocationsContainer_active_state
task_step_states
results_order
repository_export_file_type

View file

@ -2730,6 +2730,7 @@ en:
shared: "Shared"
owned_by: "Owned by"
created_on: "Created on"
created_by: "Created by"
description: "Description"
filters_modal:
search_tree: "Look inside locations"
@ -2747,7 +2748,8 @@ en:
drag_and_drop_supporting_text: ".png or .jpg file"
warning_box_not_empty: "Box dimensions can be updated only when the box is empty."
description_label: "Description"
name_placeholder: "Big freezer"
name_placeholder_location: "Big freezer"
name_placeholder_container: "Box 1"
description_placeholder: "Keep everyone on the same page. You can also use smart annotations."
dimensions_label: "Dimensions (rows x columns)"
no_grid: "No grid"