mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-09 05:18:01 +08:00
Add title inline edit to storage locations [SCI-11697]
This commit is contained in:
parent
80222f6e0e
commit
4597c1e4b4
3 changed files with 41 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -5,7 +5,19 @@
|
|||
<div class="content-pane with-grey-background flexible">
|
||||
<div class="content-header">
|
||||
<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 class="content-body " data-e2e="e2e-CO-storageLocations">
|
||||
|
|
|
@ -5,7 +5,17 @@
|
|||
<div class="content-pane flexible with-grey-background">
|
||||
<div class="content-header">
|
||||
<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 class="content-body" data-e2e="e2e-CO-storageLocations-box">
|
||||
|
|
Loading…
Add table
Reference in a new issue