Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/list.rb')
-rw-r--r--app/models/list.rb36
1 files changed, 1 insertions, 35 deletions
diff --git a/app/models/list.rb b/app/models/list.rb
index 1df565c83e6..49834af3dfb 100644
--- a/app/models/list.rb
+++ b/app/models/list.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
class List < ApplicationRecord
+ include Boards::Listable
include Importable
belongs_to :board
@@ -10,30 +11,13 @@ class List < ApplicationRecord
enum list_type: { backlog: 0, label: 1, closed: 2, assignee: 3, milestone: 4, iteration: 5 }
validates :board, :list_type, presence: true, unless: :importing?
- validates :label, :position, presence: true, if: :label?
validates :label_id, uniqueness: { scope: :board_id }, if: :label?
- validates :position, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :movable?
-
- before_destroy :can_be_destroyed
-
- scope :destroyable, -> { where(list_type: list_types.slice(*destroyable_types).values) }
- scope :movable, -> { where(list_type: list_types.slice(*movable_types).values) }
scope :preload_associated_models, -> { preload(:board, label: :priorities) }
- scope :ordered, -> { order(:list_type, :position) }
-
alias_method :preferences, :list_user_preferences
class << self
- def destroyable_types
- [:label]
- end
-
- def movable_types
- [:label]
- end
-
def preload_preferences_for_user(lists, user)
return unless user
@@ -60,18 +44,6 @@ class List < ApplicationRecord
preferences_for(user).update(preferences)
end
- def destroyable?
- self.class.destroyable_types.include?(list_type&.to_sym)
- end
-
- def movable?
- self.class.movable_types.include?(list_type&.to_sym)
- end
-
- def title
- label? ? label.name : list_type.humanize
- end
-
def collapsed?(user)
preferences = preferences_for(user)
@@ -95,12 +67,6 @@ class List < ApplicationRecord
end
end
end
-
- private
-
- def can_be_destroyed
- throw(:abort) unless destroyable? # rubocop:disable Cop/BanCatchThrow
- end
end
List.prepend_if_ee('::EE::List')