Commit ff86138d authored by Jacob Schatz's avatar Jacob Schatz

Sidebar milestone updatable via JSON

parent 1c8fff96
class @MilestoneSelect class @MilestoneSelect
constructor: (@opts) -> constructor: () ->
opts = @opts
$('.js-milestone-select').each (i, dropdown) -> $('.js-milestone-select').each (i, dropdown) ->
$dropdown = $(dropdown) $dropdown = $(dropdown)
projectId = $dropdown.data('project-id') projectId = $dropdown.data('project-id')
milestonesUrl = $dropdown.data('milestones') milestonesUrl = $dropdown.data('milestones')
issueUpdateURL = $dropdown.data('issueUpdate')
selectedMilestone = $dropdown.data('selected') selectedMilestone = $dropdown.data('selected')
showNo = $dropdown.data('show-no') showNo = $dropdown.data('show-no')
showAny = $dropdown.data('show-any') showAny = $dropdown.data('show-any')
...@@ -57,12 +57,20 @@ class @MilestoneSelect ...@@ -57,12 +57,20 @@ class @MilestoneSelect
milestone.title is selectedMilestone milestone.title is selectedMilestone
clicked: (e) -> clicked: (e) ->
if $(dropdown).hasClass "js-filter-submit" && opts.submitForm if $dropdown.hasClass "js-filter-submit"
$(dropdown).parents('form').submit() $dropdown.parents('form').submit()
else else
milestoneVal = $(@) selected = $dropdown
.closest('.selectbox') .closest('.selectbox')
.find('input[type="hidden"]') .find('input[type="hidden"]')
.val() .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 ...@@ -108,10 +108,7 @@ class Projects::IssuesController < Projects::ApplicationController
end end
end end
format.json do format.json do
render json: { render json: @issue
saved: @issue.valid?,
assignee_avatar_url: @issue.assignee.try(:avatar_url)
}
end end
end end
end end
......
...@@ -19,7 +19,6 @@ class Projects::MilestonesController < Projects::ApplicationController ...@@ -19,7 +19,6 @@ class Projects::MilestonesController < Projects::ApplicationController
end end
@milestones = @milestones.includes(:project) @milestones = @milestones.includes(:project)
respond_to do |format| respond_to do |format|
format.html do format.html do
@milestones = @milestones.page(params[:page]) @milestones = @milestones.page(params[:page])
......
...@@ -55,9 +55,7 @@ ...@@ -55,9 +55,7 @@
:javascript :javascript
new UsersSelect(); new UsersSelect();
new LabelsSelect(); new LabelsSelect();
new MilestoneSelect({ new MilestoneSelect();
submitForm: true
});
new IssueStatusSelect(); new IssueStatusSelect();
$('form.filter-form').on('submit', function (event) { $('form.filter-form').on('submit', function (event) {
event.preventDefault(); event.preventDefault();
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
.light None .light None
.selectbox.hide-collapsed .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? - if issuable.project.labels.any?
.block.labels .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