mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
Merge pull request #3756 from okriuchykhin/ok_SCI_6396
Finalyze repository filter elements management backend [SCI-6396]
This commit is contained in:
commit
4342831dab
4 changed files with 30 additions and 3 deletions
|
@ -10,9 +10,7 @@ class RepositoryTableFiltersController < ApplicationController
|
|||
before_action :check_manage_permissions, only: %i(update destroy)
|
||||
|
||||
def index
|
||||
|
||||
|
||||
render json: @repository.repository_table_filters, each_serializer: RepositoryFilterSerializer
|
||||
render json: @repository.repository_table_filters.order(:name), each_serializer: RepositoryFilterSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -14,6 +14,8 @@ class RepositoryChecklistItem < ApplicationRecord
|
|||
uniqueness: { scope: :repository_column_id },
|
||||
length: { maximum: Constants::NAME_MAX_LENGTH }
|
||||
|
||||
before_destroy :update_table_fiter_elements
|
||||
|
||||
private
|
||||
|
||||
def validate_per_column_limit
|
||||
|
@ -22,4 +24,11 @@ class RepositoryChecklistItem < ApplicationRecord
|
|||
errors.add(:base, :per_column_limit)
|
||||
end
|
||||
end
|
||||
|
||||
def update_table_fiter_elements
|
||||
repository_column.repository_table_filter_elements.find_each do |filter_element|
|
||||
filter_element.parameters['item_ids']&.delete(id)
|
||||
filter_element.parameters['item_ids'].blank? ? filter_element.destroy! : filter_element.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,8 @@ class RepositoryListItem < ApplicationRecord
|
|||
uniqueness: { scope: :repository_column_id },
|
||||
length: { maximum: Constants::TEXT_MAX_LENGTH }
|
||||
|
||||
before_destroy :update_table_fiter_elements
|
||||
|
||||
private
|
||||
|
||||
def validate_per_column_limit
|
||||
|
@ -19,4 +21,11 @@ class RepositoryListItem < ApplicationRecord
|
|||
errors.add(:base, :per_column_limit)
|
||||
end
|
||||
end
|
||||
|
||||
def update_table_fiter_elements
|
||||
repository_column.repository_table_filter_elements.find_each do |filter_element|
|
||||
filter_element.parameters['item_ids']&.delete(id)
|
||||
filter_element.parameters['item_ids'].blank? ? filter_element.destroy! : filter_element.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,18 @@ class RepositoryStatusItem < ApplicationRecord
|
|||
inverse_of: :modified_repository_status_types
|
||||
has_many :repository_status_values, inverse_of: :repository_status_item, dependent: :destroy
|
||||
|
||||
before_destroy :update_table_fiter_elements
|
||||
|
||||
def data
|
||||
"#{icon} #{status}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_table_fiter_elements
|
||||
repository_column.repository_table_filter_elements.find_each do |filter_element|
|
||||
filter_element.parameters['status_ids']&.delete(id)
|
||||
filter_element.parameters['status_ids'].blank? ? filter_element.destroy! : filter_element.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue