Commit ff86138d authored by Jacob Schatz's avatar Jacob Schatz

Sidebar milestone updatable via JSON

parent 1c8fff96
class @MilestoneSelect
constructor: (@opts) ->
opts = @opts
constructor: () ->
$('.js-milestone-select').each (i, dropdown) ->
$dropdown = $(dropdown)
projectId = $dropdown.data('project-id')
milestonesUrl = $dropdown.data('milestones')
issueUpdateURL = $dropdown.data('issueUpdate')
selectedMilestone = $dropdown.data('selected')
showNo = $dropdown.data('show-no')
showAny = $dropdown.data('show-any')
......@@ -57,12 +57,20 @@ class @MilestoneSelect
milestone.title is selectedMilestone
clicked: (e) ->
if $(dropdown).hasClass "js-filter-submit" && opts.submitForm
$(dropdown).parents('form').submit()
if $dropdown.hasClass "js-filter-submit"
$dropdown.parents('form').submit()
else
milestoneVal = $(@)
selected = $dropdown
.closest('.selectbox')
.find('input[type="hidden"]')
.val()
Api.issues.update(projectId, issuableId, milestone_id: milestoneVal, (data) => console.log 'data', data)
$.ajax(
type: 'PUT'
url: issueUpdateURL
data:
issue:
milestone_id: selected
).done (data) ->
console.log 'databack', data
)
\ No newline at end of file
......@@ -108,10 +108,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
end
format.json do
render json: {
saved: @issue.valid?,
assignee_avatar_url: @issue.assignee.try(:avatar_url)
}
render json: @issue
end
end
end
......
......@@ -19,7 +19,6 @@ class Projects::MilestonesController < Projects::ApplicationController
end
@milestones = @milestones.includes(:project)
respond_to do |format|
format.html do
@milestones = @milestones.page(params[:page])
......
......@@ -55,9 +55,7 @@
:javascript
new UsersSelect();
new LabelsSelect();
new MilestoneSelect({
submitForm: true
});
new MilestoneSelect();
new IssueStatusSelect();
$('form.filter-form').on('submit', function (event) {
event.preventDefault();
......
......@@ -64,7 +64,7 @@
.light None
.selectbox.hide-collapsed
= dropdown_tag("Milestone", options: { title: "Assign milestone", toggle_class: 'js-milestone-select', filter: true, dropdown_class: "dropdown-menu-selectable", placeholder: "Search milestones", data: { show_no: true, field_name: "milestone_id", project_id: @project.id, issuable_id: issuable.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :js), use_id: true }})
= dropdown_tag("Milestone", options: { title: "Assign milestone", toggle_class: 'js-milestone-select', filter: true, dropdown_class: "dropdown-menu-selectable", placeholder: "Search milestones", data: { show_no: true, field_name: "milestone_id", project_id: @project.id, issuable_id: issuable.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :json), issue_update: namespace_project_issue_path(@project.namespace, @project, issuable.id, :json), use_id: true }})
- if issuable.project.labels.any?
.block.labels
......
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