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
Boxiang Sun
gitlab-ce
Commits
0b00b3da
Commit
0b00b3da
authored
Jun 11, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sorting to merge requests on milestone page
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
1d773577
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
8 deletions
+41
-8
app/assets/javascripts/milestone.js.coffee
app/assets/javascripts/milestone.js.coffee
+16
-0
app/controllers/projects/milestones_controller.rb
app/controllers/projects/milestones_controller.rb
+11
-1
app/views/projects/milestones/_merge_request.html.haml
app/views/projects/milestones/_merge_request.html.haml
+1
-1
app/views/projects/milestones/_merge_requests.html.haml
app/views/projects/milestones/_merge_requests.html.haml
+1
-1
config/routes.rb
config/routes.rb
+1
-0
db/migrate/20140611135229_add_position_to_merge_request.rb
db/migrate/20140611135229_add_position_to_merge_request.rb
+5
-0
db/schema.rb
db/schema.rb
+6
-5
No files found.
app/assets/javascripts/milestone.js.coffee
View file @
0b00b3da
...
@@ -23,6 +23,18 @@ class Milestone
...
@@ -23,6 +23,18 @@ class Milestone
new
Flash
(
"Issues update failed"
,
'alert'
)
new
Flash
(
"Issues update failed"
,
'alert'
)
dataType
:
"json"
dataType
:
"json"
@
sortMergeRequests
:
(
data
)
->
sort_mr_url
=
location
.
href
+
"/sort_merge_requests"
$
.
ajax
type
:
"PUT"
url
:
sort_mr_url
data
:
data
success
:
(
data
)
->
if
data
.
saved
!=
true
new
Flash
(
"MR update failed"
,
'alert'
)
dataType
:
"json"
@
updateMergeRequest
:
(
li
,
merge_request_url
,
data
)
->
@
updateMergeRequest
:
(
li
,
merge_request_url
,
data
)
->
$
.
ajax
$
.
ajax
type
:
"PUT"
type
:
"PUT"
...
@@ -71,6 +83,10 @@ class Milestone
...
@@ -71,6 +83,10 @@ class Milestone
$
(
"#merge_requests-list-unassigned, #merge_requests-list-ongoing, #merge_requests-list-closed"
).
sortable
(
$
(
"#merge_requests-list-unassigned, #merge_requests-list-ongoing, #merge_requests-list-closed"
).
sortable
(
connectWith
:
".merge_requests-sortable-list"
,
connectWith
:
".merge_requests-sortable-list"
,
dropOnEmpty
:
true
,
dropOnEmpty
:
true
,
update
:
(
event
,
ui
)
->
data
=
$
(
this
).
sortable
(
"serialize"
)
Milestone
.
sortMergeRequests
(
data
)
receive
:
(
event
,
ui
)
->
receive
:
(
event
,
ui
)
->
new_state
=
$
(
this
).
data
(
'state'
)
new_state
=
$
(
this
).
data
(
'state'
)
merge_request_id
=
ui
.
item
.
data
(
'iid'
)
merge_request_id
=
ui
.
item
.
data
(
'iid'
)
...
...
app/controllers/projects/milestones_controller.rb
View file @
0b00b3da
class
Projects::MilestonesController
<
Projects
::
ApplicationController
class
Projects::MilestonesController
<
Projects
::
ApplicationController
before_filter
:module_enabled
before_filter
:module_enabled
before_filter
:milestone
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:sort_issues
]
before_filter
:milestone
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:sort_issues
,
:sort_merge_requests
]
# Allow read any milestone
# Allow read any milestone
before_filter
:authorize_read_milestone!
before_filter
:authorize_read_milestone!
...
@@ -82,6 +82,16 @@ class Projects::MilestonesController < Projects::ApplicationController
...
@@ -82,6 +82,16 @@ class Projects::MilestonesController < Projects::ApplicationController
render
json:
{
saved:
true
}
render
json:
{
saved:
true
}
end
end
def
sort_merge_requests
@merge_requests
=
@milestone
.
merge_requests
.
where
(
id:
params
[
'sortable_merge_request'
])
@merge_requests
.
each
do
|
merge_request
|
merge_request
.
position
=
params
[
'sortable_merge_request'
].
index
(
merge_request
.
id
.
to_s
)
+
1
merge_request
.
save
end
render
json:
{
saved:
true
}
end
protected
protected
def
milestone
def
milestone
...
...
app/views/projects/milestones/_merge_request.html.haml
View file @
0b00b3da
%li
{
class:
'mr-row'
,
'data-iid'
=>
merge_request
.
iid
,
'data-url'
=>
project_merge_request_path
(
@project
,
merge_request
)
}
%li
{
id:
dom_id
(
merge_request
,
'sortable'
),
class:
'mr-row'
,
'data-iid'
=>
merge_request
.
iid
,
'data-url'
=>
project_merge_request_path
(
@project
,
merge_request
)
}
%span
.str-truncated
%span
.str-truncated
=
link_to
[
@project
,
merge_request
]
do
=
link_to
[
@project
,
merge_request
]
do
%span
.cgray
##{merge_request.iid}
%span
.cgray
##{merge_request.iid}
...
...
app/views/projects/milestones/_merge_requests.html.haml
View file @
0b00b3da
.panel.panel-default
.panel.panel-default
.panel-heading
=
title
.panel-heading
=
title
%ul
{
class:
"well-list merge_requests-sortable-list"
,
id:
"merge_requests-list-#{id}"
,
"data-state"
=>
id
}
%ul
{
class:
"well-list merge_requests-sortable-list"
,
id:
"merge_requests-list-#{id}"
,
"data-state"
=>
id
}
-
merge_requests
.
each
do
|
merge_request
|
-
merge_requests
.
sort_by
(
&
:position
).
each
do
|
merge_request
|
=
render
'merge_request'
,
merge_request:
merge_request
=
render
'merge_request'
,
merge_request:
merge_request
%li
.light
Drag and drop available
%li
.light
Drag and drop available
config/routes.rb
View file @
0b00b3da
...
@@ -281,6 +281,7 @@ Gitlab::Application.routes.draw do
...
@@ -281,6 +281,7 @@ Gitlab::Application.routes.draw do
resources
:milestones
,
except:
[
:destroy
],
constraints:
{
id:
/\d+/
}
do
resources
:milestones
,
except:
[
:destroy
],
constraints:
{
id:
/\d+/
}
do
member
do
member
do
put
:sort_issues
put
:sort_issues
put
:sort_merge_requests
end
end
end
end
...
...
db/migrate/20140611135229_add_position_to_merge_request.rb
0 → 100644
View file @
0b00b3da
class
AddPositionToMergeRequest
<
ActiveRecord
::
Migration
def
change
add_column
:merge_requests
,
:position
,
:integer
,
default:
0
end
end
db/schema.rb
View file @
0b00b3da
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20140
502125220
)
do
ActiveRecord
::
Schema
.
define
(
version:
20140
611135229
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -135,6 +135,7 @@ ActiveRecord::Schema.define(version: 20140502125220) do
...
@@ -135,6 +135,7 @@ ActiveRecord::Schema.define(version: 20140502125220) do
t
.
integer
"target_project_id"
,
null:
false
t
.
integer
"target_project_id"
,
null:
false
t
.
integer
"iid"
t
.
integer
"iid"
t
.
text
"description"
t
.
text
"description"
t
.
integer
"position"
,
default:
0
end
end
add_index
"merge_requests"
,
[
"assignee_id"
],
name:
"index_merge_requests_on_assignee_id"
,
using: :btree
add_index
"merge_requests"
,
[
"assignee_id"
],
name:
"index_merge_requests_on_assignee_id"
,
using: :btree
...
...
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