Add title inline edit to storage locations [SCI-11697]

This commit is contained in:
Anton 2025-03-20 11:49:08 +01:00
parent 80222f6e0e
commit 4597c1e4b4
3 changed files with 41 additions and 2 deletions

View file

@ -9,6 +9,7 @@ class StorageLocationsController < ApplicationController
before_action :switch_team_with_param, only: %i(index show) before_action :switch_team_with_param, only: %i(index show)
before_action :check_storage_locations_enabled, except: :unassign_rows before_action :check_storage_locations_enabled, except: :unassign_rows
before_action :load_storage_location, only: %i(update destroy duplicate move show available_positions unassign_rows export_container import_container) before_action :load_storage_location, only: %i(update destroy duplicate move show available_positions unassign_rows export_container import_container)
before_action :set_inline_name_editing, only: %i(show)
before_action :check_read_permissions, except: %i(index create tree actions_toolbar import_container unassign_rows) before_action :check_read_permissions, except: %i(index create tree actions_toolbar import_container unassign_rows)
before_action :check_manage_repository_rows_permissions, only: %i(import_container unassign_rows) before_action :check_manage_repository_rows_permissions, only: %i(import_container unassign_rows)
before_action :check_create_permissions, only: :create before_action :check_create_permissions, only: :create
@ -20,6 +21,8 @@ class StorageLocationsController < ApplicationController
render_403 if @parent_location && !can_read_storage_location?(@parent_location) render_403 if @parent_location && !can_read_storage_location?(@parent_location)
set_inline_name_editing
respond_to do |format| respond_to do |format|
format.html format.html
format.json do format.json do
@ -311,6 +314,20 @@ class StorageLocationsController < ApplicationController
) )
end end
def set_inline_name_editing
location = @storage_location || @parent_location
if location
@inline_editable_title_config = {
name: 'title',
params_group: nil,
item_id: location.id,
field_to_udpate: 'name',
path_to_update: storage_location_path(location)
}
end
end
def log_unassign_activities def log_unassign_activities
@storage_location_repository_rows.each do |storage_location_repository_row| @storage_location_repository_rows.each do |storage_location_repository_row|
Activities::CreateActivityService Activities::CreateActivityService

View file

@ -5,7 +5,19 @@
<div class="content-pane with-grey-background flexible"> <div class="content-pane with-grey-background flexible">
<div class="content-header"> <div class="content-header">
<div class="title-row"> <div class="title-row">
<h1><%= @parent_location ? @parent_location.name : t('storage_locations.index.head_title') %></h1> <% if @parent_location && can_manage_storage_location?(@parent_location) %>
<h1 class="storage-locations-title">
<%= render partial: "shared/inline_editing",
locals: {
initial_value: @parent_location.name,
config: @inline_editable_title_config
} %>
</h1>
<% elsif @parent_location %>
<h1><%= @parent_location.name %></h1>
<% else %>
<h1><%= t('storage_locations.index.head_title') %></h1>
<% end %>
</div> </div>
</div> </div>
<div class="content-body " data-e2e="e2e-CO-storageLocations"> <div class="content-body " data-e2e="e2e-CO-storageLocations">

View file

@ -5,7 +5,17 @@
<div class="content-pane flexible with-grey-background"> <div class="content-pane flexible with-grey-background">
<div class="content-header"> <div class="content-header">
<div class="title-row"> <div class="title-row">
<h1><%= @storage_location.name %></h1> <h1 class="storage-location-title">
<% if can_manage_storage_location?(@storage_location)%>
<%= render partial: "shared/inline_editing",
locals: {
initial_value: @storage_location.name,
config: @inline_editable_title_config
} %>
<% else %>
<%= @storage_location.name %>
<% end %>
</h1>
</div> </div>
</div> </div>
<div class="content-body" data-e2e="e2e-CO-storageLocations-box"> <div class="content-body" data-e2e="e2e-CO-storageLocations-box">