Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f2a43ff5
Commit
f2a43ff5
authored
Aug 28, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Group boards CE backport
parent
5f88660a
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
380 additions
and
280 deletions
+380
-280
app/controllers/boards/application_controller.rb
app/controllers/boards/application_controller.rb
+21
-0
app/controllers/boards/issues_controller.rb
app/controllers/boards/issues_controller.rb
+89
-0
app/controllers/boards/lists_controller.rb
app/controllers/boards/lists_controller.rb
+74
-0
app/controllers/projects/boards/application_controller.rb
app/controllers/projects/boards/application_controller.rb
+0
-15
app/controllers/projects/boards/issues_controller.rb
app/controllers/projects/boards/issues_controller.rb
+0
-94
app/controllers/projects/boards/lists_controller.rb
app/controllers/projects/boards/lists_controller.rb
+0
-86
app/controllers/projects/boards_controller.rb
app/controllers/projects/boards_controller.rb
+13
-14
app/helpers/boards_helper.rb
app/helpers/boards_helper.rb
+72
-6
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+8
-0
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+4
-3
app/helpers/search_helper.rb
app/helpers/search_helper.rb
+8
-6
app/models/board.rb
app/models/board.rb
+5
-1
app/models/concerns/relative_positioning.rb
app/models/concerns/relative_positioning.rb
+9
-5
app/models/label.rb
app/models/label.rb
+2
-1
app/models/project.rb
app/models/project.rb
+8
-0
app/services/boards/base_service.rb
app/services/boards/base_service.rb
+10
-0
app/services/boards/create_service.rb
app/services/boards/create_service.rb
+3
-3
app/services/boards/issues/create_service.rb
app/services/boards/issues/create_service.rb
+10
-2
app/services/boards/issues/list_service.rb
app/services/boards/issues/list_service.rb
+4
-4
app/services/boards/issues/move_service.rb
app/services/boards/issues/move_service.rb
+10
-10
app/services/boards/list_service.rb
app/services/boards/list_service.rb
+4
-4
app/services/boards/lists/create_service.rb
app/services/boards/lists/create_service.rb
+3
-4
app/services/boards/lists/generate_service.rb
app/services/boards/lists/generate_service.rb
+2
-2
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+7
-7
config/routes.rb
config/routes.rb
+13
-0
config/routes/project.rb
config/routes/project.rb
+1
-13
No files found.
app/controllers/boards/application_controller.rb
0 → 100644
View file @
f2a43ff5
module
Boards
class
ApplicationController
<
::
ApplicationController
respond_to
:json
rescue_from
ActiveRecord
::
RecordNotFound
,
with: :record_not_found
private
def
board
@board
||=
Board
.
find
(
params
[
:board_id
])
end
def
board_parent
@board_parent
||=
board
.
parent
end
def
record_not_found
(
exception
)
render
json:
{
error:
exception
.
message
},
status: :not_found
end
end
end
app/controllers/boards/issues_controller.rb
0 → 100644
View file @
f2a43ff5
module
Boards
class
IssuesController
<
Boards
::
ApplicationController
include
BoardsResponses
before_action
:authorize_read_issue
,
only:
[
:index
]
before_action
:authorize_create_issue
,
only:
[
:create
]
before_action
:authorize_update_issue
,
only:
[
:update
]
def
index
issues
=
Boards
::
Issues
::
ListService
.
new
(
board_parent
,
current_user
,
filter_params
).
execute
issues
=
issues
.
page
(
params
[
:page
]).
per
(
params
[
:per
]
||
20
)
make_sure_position_is_set
(
issues
)
unless
Gitlab
::
Geo
.
secondary?
render
json:
{
issues:
serialize_as_json
(
issues
.
preload
(
:project
)),
size:
issues
.
total_count
}
end
def
create
service
=
Boards
::
Issues
::
CreateService
.
new
(
board_parent
,
project
,
current_user
,
issue_params
)
issue
=
service
.
execute
if
issue
.
valid?
render
json:
serialize_as_json
(
issue
)
else
render
json:
issue
.
errors
,
status: :unprocessable_entity
end
end
def
update
service
=
Boards
::
Issues
::
MoveService
.
new
(
board_parent
,
current_user
,
move_params
)
if
service
.
execute
(
issue
)
head
:ok
else
head
:unprocessable_entity
end
end
private
def
make_sure_position_is_set
(
issues
)
issues
.
each
do
|
issue
|
issue
.
move_to_end
&&
issue
.
save
unless
issue
.
relative_position
end
end
def
issue
@issue
||=
issues_finder
.
execute
.
find
(
params
[
:id
])
end
def
filter_params
params
.
merge
(
board_id:
params
[
:board_id
],
id:
params
[
:list_id
])
.
reject
{
|
_
,
value
|
value
.
nil?
}
end
def
issues_finder
IssuesFinder
.
new
(
current_user
,
project_id:
board_parent
.
id
)
end
def
project
@project
||=
Project
.
find
(
issue_params
[
:project_id
])
end
def
move_params
params
.
permit
(
:board_id
,
:id
,
:from_list_id
,
:to_list_id
,
:move_before_id
,
:move_after_id
)
end
def
issue_params
params
.
require
(
:issue
)
.
permit
(
:title
,
:milestone_id
,
:project_id
)
.
merge
(
board_id:
params
[
:board_id
],
list_id:
params
[
:list_id
],
request:
request
)
end
def
serialize_as_json
(
resource
)
resource
.
as_json
(
labels:
true
,
only:
[
:id
,
:iid
,
:project_id
,
:title
,
:confidential
,
:due_date
,
:relative_position
],
include:
{
project:
{
only:
[
:id
,
:path
]
},
assignees:
{
only:
[
:id
,
:name
,
:username
],
methods:
[
:avatar_url
]
},
milestone:
{
only:
[
:id
,
:title
]
}
},
user:
current_user
)
end
end
end
app/controllers/boards/lists_controller.rb
0 → 100644
View file @
f2a43ff5
module
Boards
class
ListsController
<
Boards
::
ApplicationController
include
BoardsResponses
before_action
:authorize_admin_list
,
only:
[
:create
,
:update
,
:destroy
,
:generate
]
before_action
:authorize_read_list
,
only:
[
:index
]
def
index
lists
=
Boards
::
Lists
::
ListService
.
new
(
board
.
parent
,
current_user
).
execute
(
board
)
render
json:
serialize_as_json
(
lists
)
end
def
create
list
=
Boards
::
Lists
::
CreateService
.
new
(
board
.
parent
,
current_user
,
list_params
).
execute
(
board
)
if
list
.
valid?
render
json:
serialize_as_json
(
list
)
else
render
json:
list
.
errors
,
status: :unprocessable_entity
end
end
def
update
list
=
board
.
lists
.
movable
.
find
(
params
[
:id
])
service
=
Boards
::
Lists
::
MoveService
.
new
(
board_parent
,
current_user
,
move_params
)
if
service
.
execute
(
list
)
head
:ok
else
head
:unprocessable_entity
end
end
def
destroy
list
=
board
.
lists
.
destroyable
.
find
(
params
[
:id
])
service
=
Boards
::
Lists
::
DestroyService
.
new
(
board_parent
,
current_user
)
if
service
.
execute
(
list
)
head
:ok
else
head
:unprocessable_entity
end
end
def
generate
service
=
Boards
::
Lists
::
GenerateService
.
new
(
board_parent
,
current_user
)
if
service
.
execute
(
board
)
render
json:
serialize_as_json
(
board
.
lists
.
movable
)
else
head
:unprocessable_entity
end
end
private
def
list_params
params
.
require
(
:list
).
permit
(
:label_id
)
end
def
move_params
params
.
require
(
:list
).
permit
(
:position
)
end
def
serialize_as_json
(
resource
)
resource
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
label:
true
)
end
end
end
app/controllers/projects/boards/application_controller.rb
deleted
100644 → 0
View file @
5f88660a
module
Projects
module
Boards
class
ApplicationController
<
Projects
::
ApplicationController
respond_to
:json
rescue_from
ActiveRecord
::
RecordNotFound
,
with: :record_not_found
private
def
record_not_found
(
exception
)
render
json:
{
error:
exception
.
message
},
status: :not_found
end
end
end
end
app/controllers/projects/boards/issues_controller.rb
deleted
100644 → 0
View file @
5f88660a
module
Projects
module
Boards
class
IssuesController
<
Boards
::
ApplicationController
before_action
:authorize_read_issue!
,
only:
[
:index
]
before_action
:authorize_create_issue!
,
only:
[
:create
]
before_action
:authorize_update_issue!
,
only:
[
:update
]
def
index
issues
=
::
Boards
::
Issues
::
ListService
.
new
(
project
,
current_user
,
filter_params
).
execute
issues
=
issues
.
page
(
params
[
:page
]).
per
(
params
[
:per
]
||
20
)
make_sure_position_is_set
(
issues
)
render
json:
{
issues:
serialize_as_json
(
issues
),
size:
issues
.
total_count
}
end
def
create
service
=
::
Boards
::
Issues
::
CreateService
.
new
(
project
,
current_user
,
issue_params
)
issue
=
service
.
execute
if
issue
.
valid?
render
json:
serialize_as_json
(
issue
)
else
render
json:
issue
.
errors
,
status: :unprocessable_entity
end
end
def
update
service
=
::
Boards
::
Issues
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
if
service
.
execute
(
issue
)
head
:ok
else
head
:unprocessable_entity
end
end
private
def
make_sure_position_is_set
(
issues
)
issues
.
each
do
|
issue
|
issue
.
move_to_end
&&
issue
.
save
unless
issue
.
relative_position
end
end
def
issue
@issue
||=
IssuesFinder
.
new
(
current_user
,
project_id:
project
.
id
)
.
execute
.
where
(
iid:
params
[
:id
])
.
first!
end
def
authorize_read_issue!
return
render_403
unless
can?
(
current_user
,
:read_issue
,
project
)
end
def
authorize_create_issue!
return
render_403
unless
can?
(
current_user
,
:admin_issue
,
project
)
end
def
authorize_update_issue!
return
render_403
unless
can?
(
current_user
,
:update_issue
,
issue
)
end
def
filter_params
params
.
merge
(
board_id:
params
[
:board_id
],
id:
params
[
:list_id
])
.
reject
{
|
_
,
value
|
value
.
nil?
}
end
def
move_params
params
.
permit
(
:board_id
,
:id
,
:from_list_id
,
:to_list_id
,
:move_before_iid
,
:move_after_iid
)
end
def
issue_params
params
.
require
(
:issue
).
permit
(
:title
).
merge
(
board_id:
params
[
:board_id
],
list_id:
params
[
:list_id
],
request:
request
)
end
def
serialize_as_json
(
resource
)
resource
.
as_json
(
labels:
true
,
only:
[
:id
,
:iid
,
:title
,
:confidential
,
:due_date
,
:relative_position
],
include:
{
assignees:
{
only:
[
:id
,
:name
,
:username
],
methods:
[
:avatar_url
]
},
milestone:
{
only:
[
:id
,
:title
]
}
},
user:
current_user
)
end
end
end
end
app/controllers/projects/boards/lists_controller.rb
deleted
100644 → 0
View file @
5f88660a
module
Projects
module
Boards
class
ListsController
<
Boards
::
ApplicationController
before_action
:authorize_admin_list!
,
only:
[
:create
,
:update
,
:destroy
,
:generate
]
before_action
:authorize_read_list!
,
only:
[
:index
]
def
index
lists
=
::
Boards
::
Lists
::
ListService
.
new
(
project
,
current_user
).
execute
(
board
)
render
json:
serialize_as_json
(
lists
)
end
def
create
list
=
::
Boards
::
Lists
::
CreateService
.
new
(
project
,
current_user
,
list_params
).
execute
(
board
)
if
list
.
valid?
render
json:
serialize_as_json
(
list
)
else
render
json:
list
.
errors
,
status: :unprocessable_entity
end
end
def
update
list
=
board
.
lists
.
movable
.
find
(
params
[
:id
])
service
=
::
Boards
::
Lists
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
if
service
.
execute
(
list
)
head
:ok
else
head
:unprocessable_entity
end
end
def
destroy
list
=
board
.
lists
.
destroyable
.
find
(
params
[
:id
])
service
=
::
Boards
::
Lists
::
DestroyService
.
new
(
project
,
current_user
)
if
service
.
execute
(
list
)
head
:ok
else
head
:unprocessable_entity
end
end
def
generate
service
=
::
Boards
::
Lists
::
GenerateService
.
new
(
project
,
current_user
)
if
service
.
execute
(
board
)
render
json:
serialize_as_json
(
board
.
lists
.
movable
)
else
head
:unprocessable_entity
end
end
private
def
authorize_admin_list!
return
render_403
unless
can?
(
current_user
,
:admin_list
,
project
)
end
def
authorize_read_list!
return
render_403
unless
can?
(
current_user
,
:read_list
,
project
)
end
def
board
@board
||=
project
.
boards
.
find
(
params
[
:board_id
])
end
def
list_params
params
.
require
(
:list
).
permit
(
:label_id
)
end
def
move_params
params
.
require
(
:list
).
permit
(
:position
)
end
def
serialize_as_json
(
resource
)
resource
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
label:
true
)
end
end
end
end
app/controllers/projects/boards_controller.rb
View file @
f2a43ff5
class
Projects::BoardsController
<
Projects
::
ApplicationController
include
IssuableCollections
include
BoardsResponses
before_action
:authorize_read_board!
,
only:
[
:index
,
:show
]
before_action
:assign_endpoint_vars
def
index
@boards
=
::
Boards
::
ListService
.
new
(
project
,
current_user
).
execute
respond_to
do
|
format
|
format
.
html
format
.
json
do
render
json:
serialize_as_json
(
@boards
)
end
end
@boards
=
Boards
::
ListService
.
new
(
project
,
current_user
).
execute
respond_with_boards
end
def
show
@board
=
project
.
boards
.
find
(
params
[
:id
])
respond_to
do
|
format
|
format
.
html
format
.
json
do
render
json:
serialize_as_json
(
@board
)
end
end
respond_with_board
end
private
def
assign_endpoint_vars
@boards_endpoint
=
project_boards_url
(
project
)
@bulk_issues_path
=
bulk_update_project_issues_path
(
project
)
@namespace_path
=
project
.
namespace
.
path
@labels_endpoint
=
project_labels_path
(
project
)
end
def
authorize_read_board!
return
access_denied!
unless
can?
(
current_user
,
:read_board
,
project
)
end
...
...
app/helpers/boards_helper.rb
View file @
f2a43ff5
module
BoardsHelper
def
board_data
board
=
@board
||
@boards
.
first
def
board
@board
||=
@board
||
@boards
.
first
end
def
board_data
{
endpoint:
project_boards_path
(
@project
),
boards_endpoint:
@boards_endpoint
,
lists_endpoint:
board_lists_url
(
board
),
board_id:
board
.
id
,
disabled:
"
#{
!
can?
(
current_user
,
:admin_list
,
@project
)
}
"
,
issue_link_base:
project_issues_path
(
@project
),
board_milestone_title:
board
&
.
milestone
&
.
title
,
disabled:
"
#{
!
can?
(
current_user
,
:admin_list
,
current_board_parent
)
}
"
,
issue_link_base:
build_issue_link_base
,
root_path:
root_path
,
bulk_update_path:
bulk_update_project_issues_path
(
@project
)
,
bulk_update_path:
@bulk_issues_path
,
default_avatar:
image_path
(
default_avatar
)
}
end
def
build_issue_link_base
project_issues_path
(
@project
)
end
def
current_board_json
board
=
@board
||
@boards
.
first
board
.
to_json
(
only:
[
:id
,
:name
,
:milestone_id
],
include:
{
milestone:
{
only:
[
:title
]
}
}
)
end
def
board_base_url
project_boards_path
(
@project
)
end
def
multiple_boards_available?
current_board_parent
.
multiple_issue_boards_available?
(
current_user
)
end
def
board_path
(
board
)
@board_path
||=
project_board_path
(
current_board_parent
,
board
)
end
def
current_board_parent
@current_board_parent
||=
@project
end
def
can_admin_issue?
can?
(
current_user
,
:admin_issue
,
current_board_parent
)
end
def
board_list_data
{
toggle:
"dropdown"
,
list_labels_path:
labels_filter_path
(
true
),
labels:
labels_filter_path
(
true
),
labels_endpoint:
@labels_endpoint
,
namespace_path:
@namespace_path
,
project_path:
@project
&
.
try
(
:path
)
}
end
def
board_sidebar_user_data
dropdown_options
=
issue_assignees_dropdown_options
{
toggle:
'dropdown'
,
field_name:
'issue[assignee_ids][]'
,
first_user:
current_user
&
.
username
,
current_user:
'true'
,
project_id:
@project
&
.
try
(
:id
),
null_user:
'true'
,
multi_select:
'true'
,
'dropdown-header'
:
dropdown_options
[
:data
][
:'dropdown-header'
],
'max-select'
:
dropdown_options
[
:data
][
:'max-select'
]
}
end
end
app/helpers/issuables_helper.rb
View file @
f2a43ff5
...
...
@@ -358,6 +358,14 @@ module IssuablesHelper
end
end
def
labels_path
if
@project
project_labels_path
(
@project
)
elsif
@group
group_labels_path
(
@group
)
end
end
def
issuable_sidebar_options
(
issuable
,
can_edit_issuable
)
{
endpoint:
"
#{
issuable_json_path
(
issuable
)
}
?basic=true"
,
...
...
app/helpers/labels_helper.rb
View file @
f2a43ff5
...
...
@@ -121,13 +121,14 @@ module LabelsHelper
end
end
def
labels_filter_path
return
group_labels_path
(
@group
,
:json
)
if
@group
def
labels_filter_path
(
only_group_labels
=
false
)
project
=
@target_project
||
@project
if
project
project_labels_path
(
project
,
:json
)
elsif
@group
options
=
{
only_group_labels:
only_group_labels
}
if
only_group_labels
group_labels_path
(
@group
,
:json
,
options
)
else
dashboard_labels_path
(
:json
)
end
...
...
app/helpers/search_helper.rb
View file @
f2a43ff5
...
...
@@ -127,19 +127,21 @@ module SearchHelper
end
def
search_filter_input_options
(
type
)
opts
=
{
id:
"filtered-search-
#{
type
}
"
,
placeholder:
'Search or filter results...'
,
data:
{
'username-params'
=>
@users
.
to_json
(
only:
[
:id
,
:username
])
opts
=
{
id:
"filtered-search-
#{
type
}
"
,
placeholder:
'Search or filter results...'
,
data:
{
'username-params'
=>
@users
.
to_json
(
only:
[
:id
,
:username
])
}
}
}
if
@project
.
present?
opts
[
:data
][
'project-id'
]
=
@project
.
id
opts
[
:data
][
'base-endpoint'
]
=
project_path
(
@project
)
else
# Group context
opts
[
:data
][
'group-id'
]
=
@group
.
id
opts
[
:data
][
'base-endpoint'
]
=
group_canonical_path
(
@group
)
end
...
...
app/models/board.rb
View file @
f2a43ff5
...
...
@@ -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
...
...
app/models/concerns/relative_positioning.rb
View file @
f2a43ff5
...
...
@@ -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
]
...
...
app/models/label.rb
View file @
f2a43ff5
...
...
@@ -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
)
...
...
app/models/project.rb
View file @
f2a43ff5
...
...
@@ -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
...
...
app/services/boards/base_service.rb
0 → 100644
View file @
f2a43ff5
module
Boards
class
BaseService
<
::
BaseService
# Parent can either a group or a project
attr_accessor
:parent
,
:current_user
,
:params
def
initialize
(
parent
,
user
,
params
=
{})
@parent
,
@current_user
,
@params
=
parent
,
user
,
params
.
dup
end
end
end
app/services/boards/create_service.rb
View file @
f2a43ff5
module
Boards
class
CreateService
<
BaseService
class
CreateService
<
B
oards
::
B
aseService
def
execute
create_board!
if
can_create_board?
end
...
...
@@ -7,11 +7,11 @@ module Boards
private
def
can_create_board?
p
rojec
t
.
boards
.
size
==
0
p
aren
t
.
boards
.
size
==
0
end
def
create_board!
board
=
p
rojec
t
.
boards
.
create
(
params
)
board
=
p
aren
t
.
boards
.
create
(
params
)
if
board
.
persisted?
board
.
lists
.
create
(
list_type: :backlog
)
...
...
app/services/boards/issues/create_service.rb
View file @
f2a43ff5
module
Boards
module
Issues
class
CreateService
<
BaseService
class
CreateService
<
Boards
::
BaseService
attr_accessor
:project
def
initialize
(
parent
,
project
,
user
,
params
=
{})
@project
=
project
super
(
parent
,
user
,
params
)
end
def
execute
create_issue
(
params
.
merge
(
label_ids:
[
list
.
label_id
]))
end
...
...
@@ -8,7 +16,7 @@ module Boards
private
def
board
@board
||=
p
rojec
t
.
boards
.
find
(
params
.
delete
(
:board_id
))
@board
||=
p
aren
t
.
boards
.
find
(
params
.
delete
(
:board_id
))
end
def
list
...
...
app/services/boards/issues/list_service.rb
View file @
f2a43ff5
module
Boards
module
Issues
class
ListService
<
BaseService
class
ListService
<
B
oards
::
B
aseService
def
execute
issues
=
IssuesFinder
.
new
(
current_user
,
filter_params
).
execute
issues
=
without_board_labels
(
issues
)
unless
movable_list?
||
closed_list?
...
...
@@ -11,7 +11,7 @@ module Boards
private
def
board
@board
||=
p
rojec
t
.
boards
.
find
(
params
[
:board_id
])
@board
||=
p
aren
t
.
boards
.
find
(
params
[
:board_id
])
end
def
list
...
...
@@ -33,13 +33,13 @@ module Boards
end
def
filter_params
set_p
rojec
t
set_p
aren
t
set_state
params
end
def
set_p
rojec
t
def
set_p
aren
t
params
[
:project_id
]
=
project
.
id
end
...
...
app/services/boards/issues/move_service.rb
View file @
f2a43ff5
module
Boards
module
Issues
class
MoveService
<
BaseService
class
MoveService
<
B
oards
::
B
aseService
def
execute
(
issue
)
return
false
unless
can?
(
current_user
,
:update_issue
,
issue
)
return
false
if
issue_params
.
empty?
update
_service
.
execute
(
issue
)
update
(
issue
)
end
private
def
board
@board
||=
p
rojec
t
.
boards
.
find
(
params
[
:board_id
])
@board
||=
p
aren
t
.
boards
.
find
(
params
[
:board_id
])
end
def
move_between_lists?
...
...
@@ -27,8 +27,8 @@ module Boards
@moving_to_list
||=
board
.
lists
.
find_by
(
id:
params
[
:to_list_id
])
end
def
update
_service
::
Issues
::
UpdateService
.
new
(
project
,
current_user
,
issue_params
)
def
update
(
issue
)
::
Issues
::
UpdateService
.
new
(
issue
.
project
,
current_user
,
issue_params
).
execute
(
issue
)
end
def
issue_params
...
...
@@ -42,7 +42,7 @@ module Boards
)
end
attrs
[
:move_between_i
ids
]
=
move_between_iids
if
move_between_i
ids
attrs
[
:move_between_i
ds
]
=
move_between_ids
if
move_between_
ids
attrs
end
...
...
@@ -61,16 +61,16 @@ module Boards
if
moving_to_list
.
movable?
moving_from_list
.
label_id
else
Label
.
on_project_boards
(
p
rojec
t
.
id
).
pluck
(
:label_id
)
Label
.
on_project_boards
(
p
aren
t
.
id
).
pluck
(
:label_id
)
end
Array
(
label_ids
).
compact
end
def
move_between_i
i
ds
return
unless
params
[
:move_after_i
id
]
||
params
[
:move_before_i
id
]
def
move_between_ids
return
unless
params
[
:move_after_i
d
]
||
params
[
:move_before_
id
]
[
params
[
:move_after_i
id
],
params
[
:move_before_i
id
]]
[
params
[
:move_after_i
d
],
params
[
:move_before_
id
]]
end
end
end
...
...
app/services/boards/list_service.rb
View file @
f2a43ff5
module
Boards
class
ListService
<
BaseService
class
ListService
<
B
oards
::
B
aseService
def
execute
create_board!
if
p
rojec
t
.
boards
.
empty?
p
rojec
t
.
boards
create_board!
if
p
aren
t
.
boards
.
empty?
p
aren
t
.
boards
end
private
def
create_board!
Boards
::
CreateService
.
new
(
p
rojec
t
,
current_user
).
execute
Boards
::
CreateService
.
new
(
p
aren
t
,
current_user
).
execute
end
end
end
app/services/boards/lists/create_service.rb
View file @
f2a43ff5
...
...
@@ -3,17 +3,16 @@ 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
)
end
end
private
def
available_labels
LabelsFinder
.
new
(
current_user
,
project_id:
p
rojec
t
.
id
).
execute
def
available_labels
_for
(
board
)
LabelsFinder
.
new
(
current_user
,
project_id:
p
aren
t
.
id
).
execute
end
def
next_position
(
board
)
...
...
app/services/boards/lists/generate_service.rb
View file @
f2a43ff5
...
...
@@ -15,11 +15,11 @@ module Boards
def
create_list
(
board
,
params
)
label
=
find_or_create_label
(
params
)
Lists
::
CreateService
.
new
(
p
rojec
t
,
current_user
,
label_id:
label
.
id
).
execute
(
board
)
Lists
::
CreateService
.
new
(
p
aren
t
,
current_user
,
label_id:
label
.
id
).
execute
(
board
)
end
def
find_or_create_label
(
params
)
::
Labels
::
FindOrCreateService
.
new
(
current_user
,
p
rojec
t
,
params
).
execute
::
Labels
::
FindOrCreateService
.
new
(
current_user
,
p
aren
t
,
params
).
execute
end
def
label_params
...
...
app/services/issues/update_service.rb
View file @
f2a43ff5
...
...
@@ -3,7 +3,7 @@ module Issues
include
SpamCheckService
def
execute
(
issue
)
handle_move_between_i
i
ds
(
issue
)
handle_move_between_ids
(
issue
)
filter_spam_check_params
change_issue_duplicate
(
issue
)
update
(
issue
)
...
...
@@ -55,12 +55,12 @@ module Issues
end
def
handle_move_between_iids
(
issue
)
return
unless
params
[
:move_between_i
i
ds
]
return
unless
params
[
:move_between_ids
]
after_i
id
,
before_iid
=
params
.
delete
(
:move_between_i
ids
)
after_i
d
,
before_id
=
params
.
delete
(
:move_between_
ids
)
issue_before
=
get_issue_if_allowed
(
issue
.
project
,
before_i
id
)
if
before_i
id
issue_after
=
get_issue_if_allowed
(
issue
.
project
,
after_i
id
)
if
after_i
id
issue_before
=
get_issue_if_allowed
(
issue
.
project
,
before_i
d
)
if
before_
id
issue_after
=
get_issue_if_allowed
(
issue
.
project
,
after_i
d
)
if
after_
id
issue
.
move_between
(
issue_before
,
issue_after
)
end
...
...
@@ -76,8 +76,8 @@ module Issues
private
def
get_issue_if_allowed
(
project
,
i
i
d
)
issue
=
project
.
issues
.
find
_by
(
iid:
i
id
)
def
get_issue_if_allowed
(
project
,
id
)
issue
=
project
.
issues
.
find
(
id
)
issue
if
can?
(
current_user
,
:update_issue
,
issue
)
end
...
...
config/routes.rb
View file @
f2a43ff5
...
...
@@ -73,6 +73,19 @@ Rails.application.routes.draw do
# Notification settings
resources
:notification_settings
,
only:
[
:create
,
:update
]
# Boards resources shared between group and projects
resources
:boards
do
resources
:lists
,
module: :boards
,
only:
[
:index
,
:create
,
:update
,
:destroy
]
do
collection
do
post
:generate
end
resources
:issues
,
only:
[
:index
,
:create
,
:update
]
end
resources
:issues
,
module: :boards
,
only:
[
:index
,
:update
]
end
draw
:import
draw
:uploads
draw
:explore
...
...
config/routes/project.rb
View file @
f2a43ff5
...
...
@@ -341,19 +341,7 @@ constraints(ProjectUrlConstrainer.new) do
get
'noteable/:target_type/:target_id/notes'
=>
'notes#index'
,
as:
'noteable_notes'
resources
:boards
,
only:
[
:index
,
:show
]
do
scope
module: :boards
do
resources
:issues
,
only:
[
:index
,
:update
]
resources
:lists
,
only:
[
:index
,
:create
,
:update
,
:destroy
]
do
collection
do
post
:generate
end
resources
:issues
,
only:
[
:index
,
:create
]
end
end
end
resources
:boards
,
only:
[
:index
,
:show
,
:create
,
:update
,
:destroy
]
resources
:todos
,
only:
[
:create
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment