Include groups in dashboard "New Milestone" select.

This commit is contained in:
Douwe Maan 2015-12-07 17:24:15 +01:00
parent 5a9a8d03a7
commit 6fb90a2ca3
3 changed files with 22 additions and 9 deletions

View file

@ -2,25 +2,38 @@ class @ProjectSelect
constructor: ->
$('.ajax-project-select').each (i, select) ->
@groupId = $(select).data('group-id')
@includeGroups = $(select).data('include-groups')
placeholder = "Search for project"
placeholder += " or group" if @includeGroups
$(select).select2
placeholder: "Search for project"
multiple: $(select).hasClass('multiselect')
placeholder: placeholder
minimumInputLength: 0
query: (query) =>
callback = (projects) ->
finalCallback = (projects) ->
data = { results: projects }
query.callback(data)
if @groupId
Api.groupProjects @groupId, query.term, callback
if @includeGroups
projectsCallback = (projects) ->
groupsCallback = (groups) ->
data = groups.concat(projects)
finalCallback(data)
Api.groups query.term, false, groupsCallback
else
Api.projects query.term, callback
projectsCallback = finalCallback
if @groupId
Api.groupProjects @groupId, query.term, projectsCallback
else
Api.projects query.term, projectsCallback
id: (project) ->
project.web_url
text: (project) ->
project.name_with_namespace
project.name_with_namespace || project.name
dropdownCssClass: "ajax-project-dropdown"

View file

@ -3,7 +3,7 @@
.project-issuable-filter
.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'

View file

@ -1,6 +1,6 @@
- if @projects.any?
.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
= icon('plus')
= local_assigns[:label]