Allow user to create a board list based on a group label
This commit is contained in:
parent
398ab263fd
commit
bf9d928b45
4 changed files with 17 additions and 2 deletions
|
@ -25,7 +25,10 @@ class Projects::IssuesController < Projects::ApplicationController
|
||||||
def index
|
def index
|
||||||
@issues = issues_collection
|
@issues = issues_collection
|
||||||
@issues = @issues.page(params[:page])
|
@issues = @issues.page(params[:page])
|
||||||
@labels = LabelsFinder.new(current_user, project_id: @project.id, title: params[:label_name]).execute if params[:label_name].presence
|
|
||||||
|
if params[:label_name].presence
|
||||||
|
@labels = LabelsFinder.new(current_user, project_id: @project.id, title: params[:label_name]).execute
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
|
|
@ -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 = project.labels.find(params[:label_id])
|
label = available_labels.find(params[:label_id])
|
||||||
position = next_position(board)
|
position = next_position(board)
|
||||||
|
|
||||||
create_list(board, label, position)
|
create_list(board, label, position)
|
||||||
|
@ -12,6 +12,10 @@ module Boards
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def available_labels
|
||||||
|
LabelsFinder.new(current_user, project_id: project.id).execute
|
||||||
|
end
|
||||||
|
|
||||||
def next_position(board)
|
def next_position(board)
|
||||||
max_position = board.lists.movable.maximum(:position)
|
max_position = board.lists.movable.maximum(:position)
|
||||||
max_position.nil? ? 0 : max_position.succ
|
max_position.nil? ? 0 : max_position.succ
|
||||||
|
|
|
@ -9,6 +9,10 @@ describe Boards::Lists::CreateService, services: true do
|
||||||
|
|
||||||
subject(:service) { described_class.new(project, user, label_id: label.id) }
|
subject(:service) { described_class.new(project, user, label_id: label.id) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
project.team << [user, :developer]
|
||||||
|
end
|
||||||
|
|
||||||
context 'when board lists is empty' do
|
context 'when board lists is empty' do
|
||||||
it 'creates a new list at beginning of the list' do
|
it 'creates a new list at beginning of the list' do
|
||||||
list = service.execute(board)
|
list = service.execute(board)
|
||||||
|
|
|
@ -8,6 +8,10 @@ describe Boards::Lists::GenerateService, services: true do
|
||||||
|
|
||||||
subject(:service) { described_class.new(project, user) }
|
subject(:service) { described_class.new(project, user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
project.team << [user, :developer]
|
||||||
|
end
|
||||||
|
|
||||||
context 'when board lists is empty' do
|
context 'when board lists is empty' do
|
||||||
it 'creates the default lists' do
|
it 'creates the default lists' do
|
||||||
expect { service.execute(board) }.to change(board.lists, :count).by(2)
|
expect { service.execute(board) }.to change(board.lists, :count).by(2)
|
||||||
|
|
Loading…
Reference in a new issue