Include groups in dashboard "New Milestone" select.
This commit is contained in:
parent
5a9a8d03a7
commit
6fb90a2ca3
3 changed files with 22 additions and 9 deletions
|
@ -2,25 +2,38 @@ class @ProjectSelect
|
||||||
constructor: ->
|
constructor: ->
|
||||||
$('.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')
|
||||||
|
|
||||||
|
placeholder = "Search for project"
|
||||||
|
placeholder += " or group" if @includeGroups
|
||||||
|
|
||||||
$(select).select2
|
$(select).select2
|
||||||
placeholder: "Search for project"
|
placeholder: placeholder
|
||||||
multiple: $(select).hasClass('multiselect')
|
|
||||||
minimumInputLength: 0
|
minimumInputLength: 0
|
||||||
query: (query) =>
|
query: (query) =>
|
||||||
callback = (projects) ->
|
finalCallback = (projects) ->
|
||||||
data = { results: projects }
|
data = { results: projects }
|
||||||
query.callback(data)
|
query.callback(data)
|
||||||
|
|
||||||
if @groupId
|
if @includeGroups
|
||||||
Api.groupProjects @groupId, query.term, callback
|
projectsCallback = (projects) ->
|
||||||
|
groupsCallback = (groups) ->
|
||||||
|
data = groups.concat(projects)
|
||||||
|
finalCallback(data)
|
||||||
|
|
||||||
|
Api.groups query.term, false, groupsCallback
|
||||||
else
|
else
|
||||||
Api.projects query.term, callback
|
projectsCallback = finalCallback
|
||||||
|
|
||||||
|
if @groupId
|
||||||
|
Api.groupProjects @groupId, query.term, projectsCallback
|
||||||
|
else
|
||||||
|
Api.projects query.term, projectsCallback
|
||||||
|
|
||||||
id: (project) ->
|
id: (project) ->
|
||||||
project.web_url
|
project.web_url
|
||||||
|
|
||||||
text: (project) ->
|
text: (project) ->
|
||||||
project.name_with_namespace
|
project.name_with_namespace || project.name
|
||||||
|
|
||||||
dropdownCssClass: "ajax-project-dropdown"
|
dropdownCssClass: "ajax-project-dropdown"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
.project-issuable-filter
|
.project-issuable-filter
|
||||||
.controls
|
.controls
|
||||||
= render 'shared/new_project_item_select', path: 'milestones/new', label: "New Milestone"
|
= render 'shared/new_project_item_select', path: 'milestones/new', label: "New Milestone", include_groups: true
|
||||||
|
|
||||||
= render 'shared/milestones_filter'
|
= render 'shared/milestones_filter'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
- if @projects.any?
|
- if @projects.any?
|
||||||
.prepend-left-10.new-project-item-select-holder
|
.prepend-left-10.new-project-item-select-holder
|
||||||
= project_select_tag :project_path, class: "new-project-item-select"
|
= project_select_tag :project_path, class: "new-project-item-select", data: { include_groups: local_assigns[:include_groups] }
|
||||||
%a.btn.btn-new.new-project-item-select-button
|
%a.btn.btn-new.new-project-item-select-button
|
||||||
= icon('plus')
|
= icon('plus')
|
||||||
= local_assigns[:label]
|
= local_assigns[:label]
|
||||||
|
|
Loading…
Reference in a new issue