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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
260f1593
Commit
260f1593
authored
Jul 28, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract new list position validation to a method
parent
22b8c0b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
app/services/boards/lists/move_service.rb
app/services/boards/lists/move_service.rb
+7
-4
No files found.
app/services/boards/lists/move_service.rb
View file @
260f1593
...
@@ -8,10 +8,7 @@ module Boards
...
@@ -8,10 +8,7 @@ module Boards
def
execute
def
execute
return
false
unless
list
.
label?
return
false
unless
list
.
label?
return
false
if
new_position
.
blank?
return
false
if
invalid_position?
return
false
if
new_position
==
old_position
return
false
if
new_position
==
first_position
return
false
if
new_position
==
last_position
list
.
with_lock
do
list
.
with_lock
do
reorder_intermediate_lists
reorder_intermediate_lists
...
@@ -27,6 +24,12 @@ module Boards
...
@@ -27,6 +24,12 @@ module Boards
@list
||=
board
.
lists
.
find
(
params
[
:list_id
])
@list
||=
board
.
lists
.
find
(
params
[
:list_id
])
end
end
def
invalid_position?
return
true
if
new_position
.
blank?
[
old_position
,
first_position
,
last_position
].
include?
(
new_position
)
end
def
first_position
def
first_position
board
.
lists
.
first
.
try
(
:position
)
board
.
lists
.
first
.
try
(
:position
)
end
end
...
...
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