diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-08-28 18:56:49 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-08-28 18:56:49 -0300 |
commit | f2a43ff5b7eec188ffc470649bf40d268cbdce2a (patch) | |
tree | f9a59f5d83d883c482c9ebfe811580a0fc8f6be6 /app/models | |
parent | 5f88660a3f5d9f0de0109a3da46e81ea9024c677 (diff) | |
download | gitlab-ce-f2a43ff5b7eec188ffc470649bf40d268cbdce2a.tar.gz |
Group boards CE backport
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/board.rb | 6 | ||||
-rw-r--r-- | app/models/concerns/relative_positioning.rb | 14 | ||||
-rw-r--r-- | app/models/label.rb | 3 | ||||
-rw-r--r-- | app/models/project.rb | 8 |
4 files changed, 24 insertions, 7 deletions
diff --git a/app/models/board.rb b/app/models/board.rb index 97d0f550925..8a6de31ea30 100644 --- a/app/models/board.rb +++ b/app/models/board.rb @@ -3,7 +3,11 @@ class Board < ActiveRecord::Base has_many :lists, -> { order(:list_type, :position) }, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent - validates :project, presence: true + validates :project, presence: true, if: :project_needed? + + def project_needed? + true + end def backlog_list lists.merge(List.backlog).take diff --git a/app/models/concerns/relative_positioning.rb b/app/models/concerns/relative_positioning.rb index 7cb9a28a284..e961c97e337 100644 --- a/app/models/concerns/relative_positioning.rb +++ b/app/models/concerns/relative_positioning.rb @@ -10,8 +10,12 @@ module RelativePositioning after_save :save_positionable_neighbours end + def project_ids + [project.id] + end + def max_relative_position - self.class.in_projects(project.id).maximum(:relative_position) + self.class.in_projects(project_ids).maximum(:relative_position) end def prev_relative_position @@ -19,7 +23,7 @@ module RelativePositioning if self.relative_position prev_pos = self.class - .in_projects(project.id) + .in_projects(project_ids) .where('relative_position < ?', self.relative_position) .maximum(:relative_position) end @@ -32,7 +36,7 @@ module RelativePositioning if self.relative_position next_pos = self.class - .in_projects(project.id) + .in_projects(project_ids) .where('relative_position > ?', self.relative_position) .minimum(:relative_position) end @@ -59,7 +63,7 @@ module RelativePositioning pos_after = before.next_relative_position if before.shift_after? - issue_to_move = self.class.in_projects(project.id).find_by!(relative_position: pos_after) + issue_to_move = self.class.in_projects(project_ids).find_by!(relative_position: pos_after) issue_to_move.move_after @positionable_neighbours = [issue_to_move] @@ -74,7 +78,7 @@ module RelativePositioning pos_before = after.prev_relative_position if after.shift_before? - issue_to_move = self.class.in_projects(project.id).find_by!(relative_position: pos_before) + issue_to_move = self.class.in_projects(project_ids).find_by!(relative_position: pos_before) issue_to_move.move_before @positionable_neighbours = [issue_to_move] diff --git a/app/models/label.rb b/app/models/label.rb index 674bb3f2720..7fb017f9b0c 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -34,7 +34,8 @@ class Label < ActiveRecord::Base scope :templates, -> { where(template: true) } scope :with_title, ->(title) { where(title: title) } - scope :on_project_boards, ->(project_id) { joins(lists: :board).merge(List.movable).where(boards: { project_id: project_id }) } + scope :with_lists_and_board, -> { joins(lists: :board).merge(List.movable) } + scope :on_project_boards, ->(project_id) { with_lists_and_board.where(boards: { project_id: project_id }) } def self.prioritized(project) joins(:priorities) diff --git a/app/models/project.rb b/app/models/project.rb index d5324ceac31..8ade8c3fc38 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1469,6 +1469,14 @@ class Project < ActiveRecord::Base end end + def multiple_issue_boards_available?(user) + feature_available?(:multiple_issue_boards, user) + end + + def issue_board_milestone_available?(user = nil) + feature_available?(:issue_board_milestone, user) + end + def full_path_was File.join(namespace.full_path, previous_changes['path'].first) end |