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
Tatuya Kamada
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
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
28 deletions
+31
-28
app/models/concerns/relative_positioning.rb
app/models/concerns/relative_positioning.rb
+15
-11
app/services/boards/issues/move_service.rb
app/services/boards/issues/move_service.rb
+1
-0
app/services/issues/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
...
@@ -43,7 +43,6 @@ module RelativePositioning
end
end
def
move_between
(
before
,
after
)
def
move_between
(
before
,
after
)
return
move_nowhere
unless
before
||
after
return
move_after
(
before
)
if
before
&&
!
after
return
move_after
(
before
)
if
before
&&
!
after
return
move_before
(
after
)
if
after
&&
!
before
return
move_before
(
after
)
if
after
&&
!
before
...
@@ -52,11 +51,10 @@ module RelativePositioning
...
@@ -52,11 +51,10 @@ module RelativePositioning
if
pos_before
&&
pos_after
if
pos_before
&&
pos_after
if
pos_before
==
pos_after
if
pos_before
==
pos_after
pos
=
pos_before
self
.
relative_position
=
pos_before
self
.
relative_position
=
pos
before
.
move_before
(
self
)
before
.
move_before
(
self
)
after
.
move_after
(
self
)
after
.
move_after
(
self
)
@positionable_neighbours
=
[
before
,
after
]
@positionable_neighbours
=
[
before
,
after
]
else
else
self
.
relative_position
=
position_between
(
pos_before
,
pos_after
)
self
.
relative_position
=
position_between
(
pos_before
,
pos_after
)
...
@@ -64,47 +62,50 @@ module RelativePositioning
...
@@ -64,47 +62,50 @@ module RelativePositioning
elsif
pos_before
elsif
pos_before
self
.
move_after
(
before
)
self
.
move_after
(
before
)
after
.
move_after
(
self
)
after
.
move_after
(
self
)
@positionable_neighbours
=
[
after
]
@positionable_neighbours
=
[
after
]
elsif
pos_after
elsif
pos_after
self
.
move_before
(
after
)
self
.
move_before
(
after
)
before
.
move_before
(
self
)
before
.
move_before
(
self
)
@positionable_neighbours
=
[
before
]
@positionable_neighbours
=
[
before
]
else
else
move_to_end
move_to_end
before
.
move_before
(
self
)
before
.
move_before
(
self
)
after
.
move_after
(
self
)
after
.
move_after
(
self
)
@positionable_neighbours
=
[
before
,
after
]
@positionable_neighbours
=
[
before
,
after
]
end
end
end
end
def
move_before
(
after
)
def
move_before
(
after
)
pos_after
=
after
.
relative_position
pos_after
=
after
.
relative_position
if
pos_after
if
pos_after
self
.
relative_position
=
position_between
(
MIN_POSITION
,
pos_after
)
self
.
relative_position
=
position_between
(
MIN_POSITION
,
pos_after
)
else
else
move_to_end
move_to_end
after
.
move_after
(
self
)
after
.
move_after
(
self
)
@positionable_neighbours
=
[
after
]
@positionable_neighbours
=
[
after
]
end
end
end
end
def
move_after
(
before
)
def
move_after
(
before
)
pos_before
=
before
.
relative_position
pos_before
=
before
.
relative_position
if
pos_before
if
pos_before
self
.
relative_position
=
position_between
(
pos_before
,
MAX_POSITION
)
self
.
relative_position
=
position_between
(
pos_before
,
MAX_POSITION
)
else
else
move_to_end
move_to_end
before
.
move_before
(
self
)
before
.
move_before
(
self
)
@positionable_neighbours
=
[
before
]
@positionable_neighbours
=
[
before
]
end
end
end
end
def
move_nowhere
self
.
relative_position
=
nil
end
def
move_to_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
end
def
move_between!
(
*
args
)
def
move_between!
(
*
args
)
...
@@ -114,6 +115,9 @@ module RelativePositioning
...
@@ -114,6 +115,9 @@ module RelativePositioning
private
private
def
position_between
(
pos_before
,
pos_after
)
def
position_between
(
pos_before
,
pos_after
)
pos_before
||=
MIN_POSITION
pos_after
||=
MAX_POSITION
pos_before
,
pos_after
=
[
pos_before
,
pos_after
].
sort
pos_before
,
pos_after
=
[
pos_before
,
pos_after
].
sort
rand
(
pos_before
.
next
..
pos_after
.
pred
)
rand
(
pos_before
.
next
..
pos_after
.
pred
)
...
@@ -122,9 +126,9 @@ module RelativePositioning
...
@@ -122,9 +126,9 @@ module RelativePositioning
def
save_positionable_neighbours
def
save_positionable_neighbours
return
unless
@positionable_neighbours
return
unless
@positionable_neighbours
@positionable_neighbours
.
each
(
&
:save
)
status
=
@positionable_neighbours
.
all?
(
&
:save
)
@positionable_neighbours
=
nil
@positionable_neighbours
=
nil
true
status
end
end
end
end
app/services/boards/issues/move_service.rb
View file @
39db04bb
...
@@ -71,6 +71,7 @@ module Boards
...
@@ -71,6 +71,7 @@ module Boards
move_after_iid
=
params
[
:move_after_iid
]
move_after_iid
=
params
[
:move_after_iid
]
move_before_iid
=
params
[
:move_before_iid
]
move_before_iid
=
params
[
:move_before_iid
]
return
unless
move_after_iid
||
move_before_iid
return
unless
move_after_iid
||
move_before_iid
[
move_after_iid
,
move_before_iid
]
[
move_after_iid
,
move_before_iid
]
end
end
end
end
...
...
app/services/issues/update_service.rb
View file @
39db04bb
...
@@ -37,11 +37,13 @@ module Issues
...
@@ -37,11 +37,13 @@ module Issues
end
end
added_labels
=
issue
.
labels
-
old_labels
added_labels
=
issue
.
labels
-
old_labels
if
added_labels
.
present?
if
added_labels
.
present?
notification_service
.
relabeled_issue
(
issue
,
added_labels
,
current_user
)
notification_service
.
relabeled_issue
(
issue
,
added_labels
,
current_user
)
end
end
added_mentions
=
issue
.
mentioned_users
-
old_mentioned_users
added_mentions
=
issue
.
mentioned_users
-
old_mentioned_users
if
added_mentions
.
present?
if
added_mentions
.
present?
notification_service
.
new_mentions_in_issue
(
issue
,
added_mentions
,
current_user
)
notification_service
.
new_mentions_in_issue
(
issue
,
added_mentions
,
current_user
)
end
end
...
@@ -56,27 +58,23 @@ module Issues
...
@@ -56,27 +58,23 @@ module Issues
end
end
def
handle_move_between_iids
(
issue
)
def
handle_move_between_iids
(
issue
)
if
move_between_iids
=
params
.
delete
(
:move_between_iids
)
return
unless
move_between_iids
=
params
.
delete
(
:move_between_iids
)
after_iid
,
before_iid
=
move_between_iids
after_iid
,
before_iid
=
move_between_iids
issue_before
=
nil
issue_before
=
get_issue_if_allowed
(
issue
.
project
,
before_iid
)
if
before_iid
if
before_iid
issue_after
=
get_issue_if_allowed
(
issue
.
project
,
after_iid
)
if
after_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
)
issue
.
move_between
(
issue_before
,
issue_after
)
end
end
end
private
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
)
def
create_confidentiality_note
(
issue
)
SystemNoteService
.
change_issue_confidentiality
(
issue
,
issue
.
project
,
current_user
)
SystemNoteService
.
change_issue_confidentiality
(
issue
,
issue
.
project
,
current_user
)
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