BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
39db04bb
Commit
39db04bb
authored
Mar 02, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address review comments
parent
b64020de
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
28 deletions
+31
-28
relative_positioning.rb
app/models/concerns/relative_positioning.rb
+15
-11
move_service.rb
app/services/boards/issues/move_service.rb
+1
-0
update_service.rb
app/services/issues/update_service.rb
+15
-17
No files found.
app/models/concerns/relative_positioning.rb
View file @
39db04bb
...
...
@@ -43,7 +43,6 @@ module RelativePositioning
end
def
move_between
(
before
,
after
)
return
move_nowhere
unless
before
||
after
return
move_after
(
before
)
if
before
&&
!
after
return
move_before
(
after
)
if
after
&&
!
before
...
...
@@ -52,11 +51,10 @@ module RelativePositioning
if
pos_before
&&
pos_after
if
pos_before
==
pos_after
pos
=
pos_before
self
.
relative_position
=
pos
self
.
relative_position
=
pos_before
before
.
move_before
(
self
)
after
.
move_after
(
self
)
@positionable_neighbours
=
[
before
,
after
]
else
self
.
relative_position
=
position_between
(
pos_before
,
pos_after
)
...
...
@@ -64,47 +62,50 @@ module RelativePositioning
elsif
pos_before
self
.
move_after
(
before
)
after
.
move_after
(
self
)
@positionable_neighbours
=
[
after
]
elsif
pos_after
self
.
move_before
(
after
)
before
.
move_before
(
self
)
@positionable_neighbours
=
[
before
]
else
move_to_end
before
.
move_before
(
self
)
after
.
move_after
(
self
)
@positionable_neighbours
=
[
before
,
after
]
end
end
def
move_before
(
after
)
pos_after
=
after
.
relative_position
if
pos_after
self
.
relative_position
=
position_between
(
MIN_POSITION
,
pos_after
)
else
move_to_end
after
.
move_after
(
self
)
@positionable_neighbours
=
[
after
]
end
end
def
move_after
(
before
)
pos_before
=
before
.
relative_position
if
pos_before
self
.
relative_position
=
position_between
(
pos_before
,
MAX_POSITION
)
else
move_to_end
before
.
move_before
(
self
)
@positionable_neighbours
=
[
before
]
end
end
def
move_nowhere
self
.
relative_position
=
nil
end
def
move_to_end
self
.
relative_position
=
position_between
(
max_relative_position
||
MIN_POSITION
,
MAX_POSITION
)
self
.
relative_position
=
position_between
(
max_relative_position
,
MAX_POSITION
)
end
def
move_between!
(
*
args
)
...
...
@@ -114,6 +115,9 @@ module RelativePositioning
private
def
position_between
(
pos_before
,
pos_after
)
pos_before
||=
MIN_POSITION
pos_after
||=
MAX_POSITION
pos_before
,
pos_after
=
[
pos_before
,
pos_after
].
sort
rand
(
pos_before
.
next
..
pos_after
.
pred
)
...
...
@@ -122,9 +126,9 @@ module RelativePositioning
def
save_positionable_neighbours
return
unless
@positionable_neighbours
@positionable_neighbours
.
each
(
&
:save
)
status
=
@positionable_neighbours
.
all?
(
&
:save
)
@positionable_neighbours
=
nil
true
status
end
end
app/services/boards/issues/move_service.rb
View file @
39db04bb
...
...
@@ -71,6 +71,7 @@ module Boards
move_after_iid
=
params
[
:move_after_iid
]
move_before_iid
=
params
[
:move_before_iid
]
return
unless
move_after_iid
||
move_before_iid
[
move_after_iid
,
move_before_iid
]
end
end
...
...
app/services/issues/update_service.rb
View file @
39db04bb
...
...
@@ -37,11 +37,13 @@ module Issues
end
added_labels
=
issue
.
labels
-
old_labels
if
added_labels
.
present?
notification_service
.
relabeled_issue
(
issue
,
added_labels
,
current_user
)
end
added_mentions
=
issue
.
mentioned_users
-
old_mentioned_users
if
added_mentions
.
present?
notification_service
.
new_mentions_in_issue
(
issue
,
added_mentions
,
current_user
)
end
...
...
@@ -56,27 +58,23 @@ module Issues
end
def
handle_move_between_iids
(
issue
)
if
move_between_iids
=
params
.
delete
(
:move_between_iids
)
after_iid
,
before_iid
=
move_between_iids
issue_before
=
nil
if
before_iid
issue_before
=
issue
.
project
.
issues
.
find_by
(
iid:
before_iid
)
issue_before
=
nil
unless
can?
(
current_user
,
:update_issue
,
issue_before
)
end
issue_after
=
nil
if
after_iid
issue_after
=
issue
.
project
.
issues
.
find_by
(
iid:
after_iid
)
issue_after
=
nil
unless
can?
(
current_user
,
:update_issue
,
issue_after
)
end
issue
.
move_between
(
issue_before
,
issue_after
)
end
return
unless
move_between_iids
=
params
.
delete
(
:move_between_iids
)
after_iid
,
before_iid
=
move_between_iids
issue_before
=
get_issue_if_allowed
(
issue
.
project
,
before_iid
)
if
before_iid
issue_after
=
get_issue_if_allowed
(
issue
.
project
,
after_iid
)
if
after_iid
issue
.
move_between
(
issue_before
,
issue_after
)
end
private
def
get_issue_if_allowed
(
project
,
iid
)
issue
=
project
.
issues
.
find_by
(
iid:
iid
)
issue
if
can?
(
current_user
,
:update_issue
,
issue
)
end
def
create_confidentiality_note
(
issue
)
SystemNoteService
.
change_issue_confidentiality
(
issue
,
issue
.
project
,
current_user
)
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