Merge branch 'sort-projects-dropdown' into 'master'
Sort projects by last activity for project switcher in header Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Fixes #13172 See merge request !2692
This commit is contained in:
commit
8d94874446
|
@ -47,7 +47,7 @@
|
||||||
callback(namespaces)
|
callback(namespaces)
|
||||||
|
|
||||||
# Return projects list. Filtered by query
|
# Return projects list. Filtered by query
|
||||||
projects: (query, callback) ->
|
projects: (query, order, callback) ->
|
||||||
url = Api.buildUrl(Api.projects_path)
|
url = Api.buildUrl(Api.projects_path)
|
||||||
|
|
||||||
$.ajax(
|
$.ajax(
|
||||||
|
@ -55,6 +55,7 @@
|
||||||
data:
|
data:
|
||||||
private_token: gon.api_token
|
private_token: gon.api_token
|
||||||
search: query
|
search: query
|
||||||
|
order_by: order
|
||||||
per_page: 20
|
per_page: 20
|
||||||
dataType: "json"
|
dataType: "json"
|
||||||
).done (projects) ->
|
).done (projects) ->
|
||||||
|
|
|
@ -3,6 +3,7 @@ class @ProjectSelect
|
||||||
$('.ajax-project-select').each (i, select) ->
|
$('.ajax-project-select').each (i, select) ->
|
||||||
@groupId = $(select).data('group-id')
|
@groupId = $(select).data('group-id')
|
||||||
@includeGroups = $(select).data('include-groups')
|
@includeGroups = $(select).data('include-groups')
|
||||||
|
@orderBy = $(select).data('order-by') || 'id'
|
||||||
|
|
||||||
placeholder = "Search for project"
|
placeholder = "Search for project"
|
||||||
placeholder += " or group" if @includeGroups
|
placeholder += " or group" if @includeGroups
|
||||||
|
@ -28,7 +29,7 @@ class @ProjectSelect
|
||||||
if @groupId
|
if @groupId
|
||||||
Api.groupProjects @groupId, query.term, projectsCallback
|
Api.groupProjects @groupId, query.term, projectsCallback
|
||||||
else
|
else
|
||||||
Api.projects query.term, projectsCallback
|
Api.projects query.term, @orderBy, projectsCallback
|
||||||
|
|
||||||
id: (project) ->
|
id: (project) ->
|
||||||
project.web_url
|
project.web_url
|
||||||
|
|
|
@ -57,7 +57,11 @@ module ProjectsHelper
|
||||||
link_output = simple_sanitize(project.name)
|
link_output = simple_sanitize(project.name)
|
||||||
link_output += content_tag :span, nil, { class: "fa fa-chevron-down dropdown-toggle-caret" } if current_user
|
link_output += content_tag :span, nil, { class: "fa fa-chevron-down dropdown-toggle-caret" } if current_user
|
||||||
|
|
||||||
link_output += project_select_tag :project_path, class: "project-item-select js-projects-dropdown", data: { include_groups: false } if current_user
|
if current_user
|
||||||
|
link_output += project_select_tag :project_path,
|
||||||
|
class: "project-item-select js-projects-dropdown",
|
||||||
|
data: { include_groups: false, order_by: 'last_activity_at' }
|
||||||
|
end
|
||||||
|
|
||||||
link_output
|
link_output
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue