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
before_action :assign_endpoint_vars
def index
@boards = ::Boards::ListService.new(group, current_user).execute
@boards = Boards::ListService.new(group, current_user).execute
respond_to do |format|
format.html
......
......@@ -6,7 +6,7 @@ class Projects::BoardsController < Projects::ApplicationController
before_action :assign_endpoint_vars
def index
@boards = ::Boards::ListService.new(project, current_user).execute
@boards = Boards::ListService.new(project, current_user).execute
respond_to do |format|
format.html
......
......@@ -34,7 +34,9 @@ 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 }) }
scope :on_group_boards, ->(group_id) { with_lists_and_board.where(boards: { group_id: group_id }) }
def self.prioritized(project)
joins(:priorities)
......
......@@ -5,7 +5,6 @@ module Boards
def initialize(parent, user, params = {})
@parent, @current_user, @params = parent, user, params.dup
super
end
end
end
......@@ -11,7 +11,7 @@ module Boards
private
def board
@board ||= project.boards.find(params[:board_id])
@board ||= parent.boards.find(params[:board_id])
end
def list
......@@ -34,7 +34,7 @@ module Boards
def filter_params
set_default_scope
set_project
set_parent
set_state
params
......@@ -44,8 +44,9 @@ module Boards
params[:scope] = 'all'
end
def set_project
params[:project_id] = project.id
def set_parent
param_key = parent.is_a?(Group) ? :group_id : :project_id
params[param_key] = parent.id
end
def set_state
......
......@@ -11,7 +11,7 @@ module Boards
private
def board
@board ||= project.boards.find(params[:board_id])
@board ||= parent.boards.find(params[:board_id])
end
def move_between_lists?
......@@ -28,7 +28,7 @@ module Boards
end
def update_service
::Issues::UpdateService.new(project, current_user, issue_params)
::Issues::UpdateService.new(board.parent, current_user, issue_params)
end
def issue_params
......@@ -60,8 +60,10 @@ module Boards
label_ids =
if moving_to_list.movable?
moving_from_list.label_id
elsif board.is_group_board?
Label.on_group_boards(parent.id).pluck(:label_id)
else
Label.on_project_boards(project.id).pluck(:label_id)
Label.on_project_boards(parent.id).pluck(:label_id)
end
Array(label_ids).compact
......
......@@ -3,7 +3,7 @@ module Boards
class CreateService < BaseService
def execute(board)
List.transaction do
label = available_labels.find(params[:label_id])
label = available_labels_for(board).find(params[:label_id])
position = next_position(board)
create_list(board, label, position)
......@@ -12,8 +12,11 @@ module Boards
private
def available_labels
LabelsFinder.new(current_user, project_id: project.id).execute
def available_labels_for(board)
label_params =
board.is_group_board? ? { group_id: parent.id } : { project_id: parent.id }
LabelsFinder.new(current_user, label_params).execute
end
def next_position(board)
......
......@@ -15,11 +15,11 @@ module Boards
def create_list(board, 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
def find_or_create_label(params)
::Labels::FindOrCreateService.new(current_user, project, params).execute
::Labels::FindOrCreateService.new(current_user, parent, params).execute
end
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