Commit 6fb90a2c authored by Douwe Maan's avatar Douwe Maan

Include groups in dashboard "New Milestone" select.

parent 5a9a8d03
...@@ -2,25 +2,38 @@ class @ProjectSelect ...@@ -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 @includeGroups
projectsCallback = (projects) ->
groupsCallback = (groups) ->
data = groups.concat(projects)
finalCallback(data)
Api.groups query.term, false, groupsCallback
else
projectsCallback = finalCallback
if @groupId if @groupId
Api.groupProjects @groupId, query.term, callback Api.groupProjects @groupId, query.term, projectsCallback
else else
Api.projects query.term, callback 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 @@ ...@@ -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'
......
- 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]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment