Commit 5dedc534 authored by Felipe Artur's avatar Felipe Artur

Fix issues list for group boards

parent 65d4a288
...@@ -3,7 +3,7 @@ class Groups::BoardsController < Groups::ApplicationController ...@@ -3,7 +3,7 @@ class Groups::BoardsController < Groups::ApplicationController
before_action :assign_endpoint_vars before_action :assign_endpoint_vars
def index def index
@boards = ::Boards::ListService.new(group, current_user).execute @boards = Boards::ListService.new(group, current_user).execute
respond_to do |format| respond_to do |format|
format.html format.html
......
...@@ -6,7 +6,7 @@ class Projects::BoardsController < Projects::ApplicationController ...@@ -6,7 +6,7 @@ class Projects::BoardsController < Projects::ApplicationController
before_action :assign_endpoint_vars before_action :assign_endpoint_vars
def index def index
@boards = ::Boards::ListService.new(project, current_user).execute @boards = Boards::ListService.new(project, current_user).execute
respond_to do |format| respond_to do |format|
format.html format.html
......
...@@ -34,7 +34,9 @@ class Label < ActiveRecord::Base ...@@ -34,7 +34,9 @@ class Label < ActiveRecord::Base
scope :templates, -> { where(template: true) } scope :templates, -> { where(template: true) }
scope :with_title, ->(title) { where(title: title) } 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 }) }
scope :on_group_boards, ->(group_id) { with_lists_and_board.where(boards: { group_id: group_id }) }
def self.prioritized(project) def self.prioritized(project)
joins(:priorities) joins(:priorities)
......
...@@ -5,7 +5,6 @@ module Boards ...@@ -5,7 +5,6 @@ module Boards
def initialize(parent, user, params = {}) def initialize(parent, user, params = {})
@parent, @current_user, @params = parent, user, params.dup @parent, @current_user, @params = parent, user, params.dup
super
end end
end end
end end
...@@ -11,7 +11,7 @@ module Boards ...@@ -11,7 +11,7 @@ module Boards
private private
def board def board
@board ||= project.boards.find(params[:board_id]) @board ||= parent.boards.find(params[:board_id])
end end
def list def list
...@@ -34,7 +34,7 @@ module Boards ...@@ -34,7 +34,7 @@ module Boards
def filter_params def filter_params
set_default_scope set_default_scope
set_project set_parent
set_state set_state
params params
...@@ -44,8 +44,9 @@ module Boards ...@@ -44,8 +44,9 @@ module Boards
params[:scope] = 'all' params[:scope] = 'all'
end end
def set_project def set_parent
params[:project_id] = project.id param_key = parent.is_a?(Group) ? :group_id : :project_id
params[param_key] = parent.id
end end
def set_state def set_state
......
...@@ -11,7 +11,7 @@ module Boards ...@@ -11,7 +11,7 @@ module Boards
private private
def board def board
@board ||= project.boards.find(params[:board_id]) @board ||= parent.boards.find(params[:board_id])
end end
def move_between_lists? def move_between_lists?
...@@ -28,7 +28,7 @@ module Boards ...@@ -28,7 +28,7 @@ module Boards
end end
def update_service def update_service
::Issues::UpdateService.new(project, current_user, issue_params) ::Issues::UpdateService.new(board.parent, current_user, issue_params)
end end
def issue_params def issue_params
...@@ -60,8 +60,10 @@ module Boards ...@@ -60,8 +60,10 @@ module Boards
label_ids = label_ids =
if moving_to_list.movable? if moving_to_list.movable?
moving_from_list.label_id moving_from_list.label_id
elsif board.is_group_board?
Label.on_group_boards(parent.id).pluck(:label_id)
else else
Label.on_project_boards(project.id).pluck(:label_id) Label.on_project_boards(parent.id).pluck(:label_id)
end end
Array(label_ids).compact Array(label_ids).compact
......
...@@ -3,7 +3,7 @@ module Boards ...@@ -3,7 +3,7 @@ module Boards
class CreateService < BaseService class CreateService < BaseService
def execute(board) def execute(board)
List.transaction do List.transaction do
label = available_labels.find(params[:label_id]) label = available_labels_for(board).find(params[:label_id])
position = next_position(board) position = next_position(board)
create_list(board, label, position) create_list(board, label, position)
...@@ -12,8 +12,11 @@ module Boards ...@@ -12,8 +12,11 @@ module Boards
private private
def available_labels def available_labels_for(board)
LabelsFinder.new(current_user, project_id: project.id).execute label_params =
board.is_group_board? ? { group_id: parent.id } : { project_id: parent.id }
LabelsFinder.new(current_user, label_params).execute
end end
def next_position(board) def next_position(board)
......
...@@ -15,11 +15,11 @@ module Boards ...@@ -15,11 +15,11 @@ module Boards
def create_list(board, params) def create_list(board, params)
label = find_or_create_label(params) label = find_or_create_label(params)
Lists::CreateService.new(project, current_user, label_id: label.id).execute(board) Lists::CreateService.new(parent, current_user, label_id: label.id).execute(board)
end end
def find_or_create_label(params) def find_or_create_label(params)
::Labels::FindOrCreateService.new(current_user, project, params).execute ::Labels::FindOrCreateService.new(current_user, parent, params).execute
end end
def label_params def label_params
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment