From 4597c1e4b4579aabd8143bb45dbb9885e17c44ef Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 20 Mar 2025 11:49:08 +0100 Subject: [PATCH] Add title inline edit to storage locations [SCI-11697] --- app/controllers/storage_locations_controller.rb | 17 +++++++++++++++++ app/views/storage_locations/index.html.erb | 14 +++++++++++++- app/views/storage_locations/show.html.erb | 12 +++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/app/controllers/storage_locations_controller.rb b/app/controllers/storage_locations_controller.rb index 3bae95dd8..7a21c38c1 100644 --- a/app/controllers/storage_locations_controller.rb +++ b/app/controllers/storage_locations_controller.rb @@ -9,6 +9,7 @@ class StorageLocationsController < ApplicationController before_action :switch_team_with_param, only: %i(index show) 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 :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_manage_repository_rows_permissions, only: %i(import_container unassign_rows) 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) + set_inline_name_editing + respond_to do |format| format.html format.json do @@ -311,6 +314,20 @@ class StorageLocationsController < ApplicationController ) 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 @storage_location_repository_rows.each do |storage_location_repository_row| Activities::CreateActivityService diff --git a/app/views/storage_locations/index.html.erb b/app/views/storage_locations/index.html.erb index 110898cbf..54d9156a6 100644 --- a/app/views/storage_locations/index.html.erb +++ b/app/views/storage_locations/index.html.erb @@ -5,7 +5,19 @@
-

<%= @parent_location ? @parent_location.name : t('storage_locations.index.head_title') %>

+ <% if @parent_location && can_manage_storage_location?(@parent_location) %> +

+ <%= render partial: "shared/inline_editing", + locals: { + initial_value: @parent_location.name, + config: @inline_editable_title_config + } %> +

+ <% elsif @parent_location %> +

<%= @parent_location.name %>

+ <% else %> +

<%= t('storage_locations.index.head_title') %>

+ <% end %>
diff --git a/app/views/storage_locations/show.html.erb b/app/views/storage_locations/show.html.erb index 48a9a1af8..c22e00d12 100644 --- a/app/views/storage_locations/show.html.erb +++ b/app/views/storage_locations/show.html.erb @@ -5,7 +5,17 @@
-

<%= @storage_location.name %>

+

+ <% 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 %> +