Commit 562a09c1 authored by Phil Hughes's avatar Phil Hughes

milestone dropdown

parent d6e5ed8a
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
group_projects_path: "/api/:version/groups/:id/projects.json" group_projects_path: "/api/:version/groups/:id/projects.json"
projects_path: "/api/:version/projects.json" projects_path: "/api/:version/projects.json"
labels_path: "/api/:version/projects/:id/labels" labels_path: "/api/:version/projects/:id/labels"
milestones_path: "/api/:version/projects/:id/milestones"
group: (group_id, callback) -> group: (group_id, callback) ->
url = Api.buildUrl(Api.group_path) url = Api.buildUrl(Api.group_path)
...@@ -74,6 +75,18 @@ ...@@ -74,6 +75,18 @@
).done (labels) -> ).done (labels) ->
callback(labels) callback(labels)
milestones: (project_id, callback) ->
url = Api.buildUrl(Api.milestones_path)
url = url.replace(':id', project_id)
$.ajax(
url: url
data:
private_token: gon.api_token
dataType: "json"
).done (milestones) ->
callback(milestones)
# Return group projects list. Filtered by query # Return group projects list. Filtered by query
groupProjects: (group_id, query, callback) -> groupProjects: (group_id, query, callback) ->
url = Api.buildUrl(Api.group_projects_path) url = Api.buildUrl(Api.group_projects_path)
......
...@@ -148,7 +148,7 @@ class GitLabDropdown ...@@ -148,7 +148,7 @@ class GitLabDropdown
html = @options.renderRow(data) html = @options.renderRow(data)
else else
selected = if @options.isSelected then @options.isSelected(data) else false selected = if @options.isSelected then @options.isSelected(data) else false
url = if @options.url then @options.url(data) else "" url = if @options.url then @options.url(data) else "#"
text = if @options.text then @options.text(data) else "" text = if @options.text then @options.text(data) else ""
cssClass = ""; cssClass = "";
......
...@@ -2,13 +2,16 @@ class @LabelsSelect ...@@ -2,13 +2,16 @@ class @LabelsSelect
constructor: -> constructor: ->
$('.js-label-select').each (i, dropdown) -> $('.js-label-select').each (i, dropdown) ->
projectId = $(dropdown).data('project-id') projectId = $(dropdown).data('project-id')
selectedLabel = $(dropdown).data('selected')
$(dropdown).glDropdown( $(dropdown).glDropdown(
data: (callback) -> data: (callback) ->
Api.projectLabels 8, callback Api.projectLabels 8, callback
renderRow: (label) -> renderRow: (label) ->
selected = if label.name is selectedLabel then "is-active" else ""
"<li> "<li>
<a href='#'> <a href='#' class='#{selected}'>
#{label.name} #{label.name}
</a> </a>
</li>" </li>"
......
class @MilestoneSelect
constructor: ->
$('.js-milestone-select').each (i, dropdown) ->
projectId = $(dropdown).data('project-id')
selectedMilestone = $(dropdown).data('selected')
$(dropdown).glDropdown(
data: (callback) ->
Api.milestones projectId, callback
filterable: true
search:
fields: ['name']
selectable: true
fieldName: $(dropdown).data('field-name')
text: (milestone) ->
milestone.title
id: (milestone) ->
milestone.title
isSelected: (milestone) ->
milestone.title is selectedMilestone
clicked: ->
$(dropdown).parents('form').submit()
)
...@@ -15,13 +15,8 @@ ...@@ -15,13 +15,8 @@
placeholder: "Search assignee", data: {any_user: "Any Author", first_user: true, null_user: true, current_user: true, project_id: @project.id, selected: params[:assignee_id], field_name: "assignee_id"}) placeholder: "Search assignee", data: {any_user: "Any Author", first_user: true, null_user: true, current_user: true, project_id: @project.id, selected: params[:assignee_id], field_name: "assignee_id"})
.filter-item.inline.milestone-filter .filter-item.inline.milestone-filter
= dropdown_tag("Milestone", title: "Filter by milestone", filter: true, dropdown_class: "dropdown-menu-selectable", = dropdown_tag("Milestone", title: "Filter by milestone", toggle_class: 'js-milestone-select', filter: true, dropdown_class: "dropdown-menu-selectable",
placeholder: "Search milestones", data: {field_name: "milestone_title"}) do placeholder: "Search milestones", data: {field_name: "milestone_title", selected: params[:milestone_title], project_id: @project.id})
%ul
- @project.milestones.each do |milestone|
%li
%a{href: "#", data: {id: milestone.id}}
= milestone.name
.filter-item.inline.labels-filter .filter-item.inline.labels-filter
= dropdown_tag("Label", title: "Filter by label", toggle_class: "js-label-select", filter: true, dropdown_class: "dropdown-menu-labels dropdown-menu-selectable", = dropdown_tag("Label", title: "Filter by label", toggle_class: "js-label-select", filter: true, dropdown_class: "dropdown-menu-labels dropdown-menu-selectable",
...@@ -55,6 +50,7 @@ ...@@ -55,6 +50,7 @@
:javascript :javascript
new UsersSelect(); new UsersSelect();
new LabelsSelect(); new LabelsSelect();
new MilestoneSelect();
$('form.filter-form').on('submit', function (event) { $('form.filter-form').on('submit', function (event) {
event.preventDefault(); event.preventDefault();
Turbolinks.visit(this.action + '&' + $(this).serialize()); Turbolinks.visit(this.action + '&' + $(this).serialize());
......
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