mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-12 16:14:58 +08:00
Merge branch 'release/1.35.0' into develop
This commit is contained in:
commit
52f9a8411c
14 changed files with 62 additions and 29 deletions
|
@ -21,11 +21,13 @@ class AssetsController < ApplicationController
|
|||
before_action :check_manage_permission, only: %i(edit destroy duplicate rename toggle_view_mode)
|
||||
|
||||
def file_preview
|
||||
editable = can_manage_asset?(@asset) && (@asset.repository_asset_value.blank? ||
|
||||
!@asset.repository_cell.repository_row.repository.is_a?(SoftLockedRepository))
|
||||
render json: { html: render_to_string(
|
||||
partial: 'shared/file_preview/content',
|
||||
locals: {
|
||||
asset: @asset,
|
||||
can_edit: can_manage_asset?(@asset),
|
||||
can_edit: editable,
|
||||
gallery: params[:gallery],
|
||||
preview: params[:preview]
|
||||
},
|
||||
|
|
|
@ -477,7 +477,7 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def set_inline_name_editing
|
||||
return unless can_manage_repository?(@repository)
|
||||
return unless can_manage_repository?(@repository) && !@repository.is_a?(SoftLockedRepository)
|
||||
|
||||
@inline_editable_title_config = {
|
||||
name: 'title',
|
||||
|
|
|
@ -9,7 +9,8 @@ module RepositoryDatatableHelper
|
|||
reminders_enabled = Repository.reminders_enabled?
|
||||
repository_rows = reminders_enabled ? with_reminders_status(repository_rows, repository) : repository_rows
|
||||
stock_managable = has_stock_management && !options[:disable_stock_management] &&
|
||||
can_manage_repository_stock?(repository)
|
||||
can_manage_repository_stock?(repository) &&
|
||||
!repository.is_a?(SoftLockedRepository)
|
||||
stock_consumption_permitted = has_stock_management && options[:include_stock_consumption] && options[:my_module] &&
|
||||
stock_consumption_permitted?(repository, options[:my_module])
|
||||
|
||||
|
@ -36,7 +37,7 @@ module RepositoryDatatableHelper
|
|||
row['hasActiveReminders'] = record.has_active_stock_reminders || record.has_active_datetime_reminders
|
||||
end
|
||||
|
||||
unless options[:view_mode]
|
||||
unless options[:view_mode] || repository.is_a?(SoftLockedRepository)
|
||||
row['recordUpdateUrl'] =
|
||||
Rails.application.routes.url_helpers.repository_repository_row_path(repository, record)
|
||||
row['recordEditable'] = record.editable?
|
||||
|
@ -246,6 +247,19 @@ module RepositoryDatatableHelper
|
|||
}
|
||||
end
|
||||
|
||||
def soft_locked_repository_default_columns(record)
|
||||
{
|
||||
'1': assigned_row(record),
|
||||
'2': record.code,
|
||||
'3': escape_input(record.name),
|
||||
'4': "#{record.parent_connections_count || 0} / #{record.child_connections_count || 0}",
|
||||
'5': I18n.l(record.created_at, format: :full),
|
||||
'6': escape_input(record.created_by.full_name),
|
||||
'7': (record.archived_on ? I18n.l(record.archived_on, format: :full) : ''),
|
||||
'8': escape_input(record.archived_by&.full_name)
|
||||
}
|
||||
end
|
||||
|
||||
def linked_repository_default_columns(record)
|
||||
{
|
||||
'1': assigned_row(record),
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
'max-h-[4rem]': collapsed,
|
||||
'max-h-[40rem]': !collapsed
|
||||
}">
|
||||
{{ colval }}
|
||||
{{ colVal }}
|
||||
</div>
|
||||
<div v-else
|
||||
class="text-sn-dark-grey font-inter text-sm font-normal leading-5">
|
||||
|
|
|
@ -45,12 +45,12 @@ class Result < ApplicationRecord
|
|||
options = {})
|
||||
teams = options[:teams] || current_team || user.teams.select(:id)
|
||||
|
||||
new_query = distinct.left_joins(:result_comments, :result_texts, result_tables: :table)
|
||||
.joins(:my_module)
|
||||
.joins("INNER JOIN user_assignments my_module_user_assignments " \
|
||||
"ON my_module_user_assignments.assignable_type = 'MyModule' " \
|
||||
"AND my_module_user_assignments.assignable_id = my_modules.id")
|
||||
.where(my_module_user_assignments: { user_id: user, team_id: teams })
|
||||
new_query = left_joins(:result_comments, :result_texts, result_tables: :table)
|
||||
.joins(:my_module)
|
||||
.joins("INNER JOIN user_assignments my_module_user_assignments " \
|
||||
"ON my_module_user_assignments.assignable_type = 'MyModule' " \
|
||||
"AND my_module_user_assignments.assignable_id = my_modules.id")
|
||||
.where(my_module_user_assignments: { user_id: user, team_id: teams })
|
||||
|
||||
unless include_archived
|
||||
new_query = new_query.joins(my_module: { experiment: :project })
|
||||
|
@ -60,7 +60,9 @@ class Result < ApplicationRecord
|
|||
projects: { archived: false })
|
||||
end
|
||||
|
||||
new_query.where_attributes_like_boolean(SEARCHABLE_ATTRIBUTES, query, { with_subquery: true, raw_input: new_query })
|
||||
new_query.where_attributes_like_boolean(
|
||||
SEARCHABLE_ATTRIBUTES, query, { with_subquery: true, raw_input: new_query }
|
||||
).distinct
|
||||
end
|
||||
|
||||
def self.search_subquery(query, raw_input)
|
||||
|
|
11
app/models/soft_locked_repository.rb
Normal file
11
app/models/soft_locked_repository.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SoftLockedRepository < Repository
|
||||
# this is for repositories only editable via API
|
||||
|
||||
enum permission_level: Extends::SHARED_OBJECTS_PERMISSION_LEVELS.except(:shared_write)
|
||||
|
||||
def shareable_write?
|
||||
false
|
||||
end
|
||||
end
|
|
@ -31,7 +31,7 @@ module Toolbars
|
|||
private
|
||||
|
||||
def rename_action
|
||||
return unless @single && can_manage_repository?(@repository)
|
||||
return unless @single && can_manage_repository?(@repository) && !@repository.is_a?(SoftLockedRepository)
|
||||
|
||||
{
|
||||
name: :update,
|
||||
|
@ -66,7 +66,9 @@ module Toolbars
|
|||
end
|
||||
|
||||
def archive_action
|
||||
return unless @repositories.all? { |repository| can_archive_repository?(repository) }
|
||||
return unless @repositories.all? do |repository|
|
||||
can_archive_repository?(repository) && !@repository.is_a?(SoftLockedRepository)
|
||||
end
|
||||
|
||||
{
|
||||
name: :archive,
|
||||
|
@ -89,7 +91,9 @@ module Toolbars
|
|||
end
|
||||
|
||||
def restore_action
|
||||
return unless @repositories.all? { |repository| can_archive_repository?(repository) }
|
||||
return unless @repositories.all? do |repository|
|
||||
can_archive_repository?(repository) && !repository.is_a?(SoftLockedRepository)
|
||||
end
|
||||
|
||||
{
|
||||
name: :restore,
|
||||
|
@ -101,7 +105,7 @@ module Toolbars
|
|||
end
|
||||
|
||||
def delete_action
|
||||
return unless @single && can_delete_repository?(@repository)
|
||||
return unless @single && can_delete_repository?(@repository) && !@repository.is_a?(SoftLockedRepository)
|
||||
|
||||
{
|
||||
name: :delete,
|
||||
|
|
|
@ -42,7 +42,7 @@ module Toolbars
|
|||
private
|
||||
|
||||
def restore_action
|
||||
return unless can_manage_repository_rows?(@repository)
|
||||
return unless can_manage_repository_rows?(@repository) && !@repository.is_a?(SoftLockedRepository)
|
||||
|
||||
return unless @repository_rows.all?(&:archived?)
|
||||
|
||||
|
@ -57,7 +57,7 @@ module Toolbars
|
|||
end
|
||||
|
||||
def edit_action
|
||||
return unless can_manage_repository_rows?(@repository)
|
||||
return unless can_manage_repository_rows?(@repository) && !@repository.is_a?(SoftLockedRepository)
|
||||
|
||||
return unless @repository_rows.all?(&:active?)
|
||||
|
||||
|
@ -87,7 +87,7 @@ module Toolbars
|
|||
end
|
||||
|
||||
def duplicate_action
|
||||
return unless can_create_repository_rows?(@repository)
|
||||
return unless can_create_repository_rows?(@repository) && !@repository.is_a?(SoftLockedRepository)
|
||||
|
||||
return unless @repository_rows.all?(&:active?)
|
||||
|
||||
|
@ -151,7 +151,7 @@ module Toolbars
|
|||
end
|
||||
|
||||
def archive_action
|
||||
return unless can_manage_repository_rows?(@repository)
|
||||
return unless can_manage_repository_rows?(@repository) && !@repository.is_a?(SoftLockedRepository)
|
||||
|
||||
return unless @repository_rows.all?(&:active?)
|
||||
|
||||
|
@ -166,7 +166,7 @@ module Toolbars
|
|||
end
|
||||
|
||||
def delete_action
|
||||
return unless can_delete_repository_rows?(@repository)
|
||||
return unless can_delete_repository_rows?(@repository) && !@repository.is_a?(SoftLockedRepository)
|
||||
|
||||
return unless @repository_rows.all?(&:archived?)
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
data-type="<%= column.data_type %>"
|
||||
data-edit-column-url="<%= edit_repository_repository_column_path(repository, column) %>"
|
||||
data-destroy-column-url="<%= repository_columns_destroy_html_path(repository, column) %>"
|
||||
data-editable-row="<%= can_manage_repository_column?(column) %>"
|
||||
data-editable-row="<%= can_manage_repository_column?(column) && !repository.is_a?(SoftLockedRepository) %>"
|
||||
<% column.metadata.each do |k, v| %>
|
||||
<%= "data-metadata-#{k}=#{v}" %>
|
||||
<% end %>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<span class="button-text"><%= t('repositories.index.snapshot_provisioning_in_progress') %></span>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if can_create_repository_rows?(@repository) %>
|
||||
<% if can_create_repository_rows?(@repository) && !@repository.is_a?(SoftLockedRepository) %>
|
||||
<button type="button" data-toggle="tooltip" data-placement="bottom" title="<%= t('repositories.show.button_tooltip.new') %>"
|
||||
class="btn btn-primary editAdd auto-shrink-button"
|
||||
id="addRepositoryRecord" data-view-mode="active">
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<% if can_create_repository_columns?(@repository)%>
|
||||
<% if can_create_repository_columns?(@repository) && !@repository.is_a?(SoftLockedRepository) %>
|
||||
<button id="new-repo-column-modal"
|
||||
data-view-mode="active"
|
||||
class="btn btn-secondary manage-repo-column"
|
||||
|
|
|
@ -12,8 +12,8 @@ json.update_path update_cell_repository_repository_row_path(@repository, @reposi
|
|||
|
||||
json.permissions do
|
||||
json.can_export_repository_stock can_export_repository_stock?(@repository)
|
||||
json.can_manage can_manage_repository_rows?(@repository) if @repository.is_a?(Repository)
|
||||
json.can_connect_rows can_connect_repository_rows?(@repository) if @repository.is_a?(Repository)
|
||||
json.can_manage can_manage_repository_rows?(@repository) if @repository.is_a?(Repository) && !@repository.is_a?(SoftLockedRepository)
|
||||
json.can_connect_rows can_connect_repository_rows?(@repository) if @repository.is_a?(Repository) && !@repository.is_a?(SoftLockedRepository)
|
||||
end
|
||||
|
||||
json.actions do
|
||||
|
|
|
@ -8,8 +8,8 @@ require 'active_storage/downloader'
|
|||
# Enable PDF previews for files
|
||||
Rails.application.config.x.enable_pdf_previews = ENV['ACTIVESTORAGE_ENABLE_PDF_PREVIEWS'] == 'true'
|
||||
|
||||
Rails.application.config.active_storage.previewers = [ActiveStorage::Previewer::PopplerPDFPreviewer,
|
||||
ActiveStorage::Previewer::LibreofficePreviewer]
|
||||
Rails.application.config.active_storage.previewers << ActiveStorage::Previewer::PopplerPDFPreviewer
|
||||
Rails.application.config.active_storage.previewers << ActiveStorage::Previewer::LibreofficePreviewer
|
||||
|
||||
Rails.application.config.active_storage.analyzers.prepend(ActiveStorage::Analyzer::ImageAnalyzer::CustomImageMagick)
|
||||
Rails.application.config.active_storage.analyzers.append(ActiveStorage::Analyzer::TextExtractionAnalyzer)
|
||||
|
|
|
@ -137,7 +137,7 @@ class Extends
|
|||
RepositoryStockValue
|
||||
)
|
||||
|
||||
STI_PRELOAD_CLASSES = %w(LinkedRepository)
|
||||
STI_PRELOAD_CLASSES = %w(LinkedRepository SoftLockedRepository)
|
||||
|
||||
# Array of preload relations used in search query for repository rows
|
||||
REPOSITORY_ROWS_PRELOAD_RELATIONS = []
|
||||
|
|
Loading…
Add table
Reference in a new issue