Sidebar milestone updatable via JSON
This commit is contained in:
parent
1c8fff965c
commit
ff86138d76
5 changed files with 18 additions and 16 deletions
|
@ -1,10 +1,10 @@
|
|||
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
|
||||
)
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue