Commit 7f0ccbac authored by Phil Hughes's avatar Phil Hughes

Fix issue with milestone dropdown submitting the form without selected value

parent a33a67e5
......@@ -79,7 +79,7 @@ class @MilestoneSelect
text: (milestone) ->
_.escape(milestone.title)
id: (milestone) ->
if !useId
if !useId and not $dropdown.is('.js-issuable-form-dropdown')
milestone.name
else
milestone.id
......@@ -90,12 +90,13 @@ class @MilestoneSelect
# display:block overrides the hide-collapse rule
$value.css('display', '')
clicked: (selected) ->
clicked: (selected, $el, e) ->
page = $('body').data 'page'
isIssueIndex = page is 'projects:issues:index'
isMRIndex = page is page is 'projects:merge_requests:index'
if $dropdown.hasClass 'js-filter-bulk-update'
if $dropdown.hasClass('js-filter-bulk-update') or $dropdown.hasClass('js-issuable-form-dropdown')
e.preventDefault()
return
if $dropdown.hasClass('js-filter-submit') and (isIssueIndex or isMRIndex)
......
......@@ -61,7 +61,7 @@
= f.label :milestone_id, "Milestone", class: "control-label #{"col-lg-4" if has_due_date}"
.col-sm-10{ class: ("col-lg-8" if has_due_date) }
.issuable-form-select-holder
= render "shared/issuable/milestone_dropdown", selected: issuable.milestone_id, name: "#{issuable.class.model_name.param_key}[milestone_id]", show_any: false, show_upcoming: false
= render "shared/issuable/milestone_dropdown", selected: issuable.milestone_id, name: "#{issuable.class.model_name.param_key}[milestone_id]", show_any: false, show_upcoming: false, extra_class: 'js-issuable-form-dropdown'
.form-group
- has_labels = issuable.project.labels.any?
- selected_labels = issuable.label_ids.any? ? issuable.label_ids : nil
......
- project = @target_project || @project
- selected_text = project.milestones.find(selected).try(:name)
- if selected.present?
= hidden_field_tag(name, selected)
= dropdown_tag(milestone_dropdown_label(selected), options: { title: "Filter by milestone", toggle_class: 'js-milestone-select js-filter-submit', filter: true, dropdown_class: "dropdown-menu-selectable",
= dropdown_tag(milestone_dropdown_label(selected_text), options: { title: "Filter by milestone", toggle_class: "js-milestone-select js-filter-submit #{extra_class}", filter: true, dropdown_class: "dropdown-menu-selectable",
placeholder: "Search milestones", footer_content: project.present?, data: { show_no: true, show_any: show_any, show_upcoming: show_upcoming, field_name: name, selected: selected, project_id: project.try(:id), milestones: milestones_filter_dropdown_path, default_label: "Milestone" } }) do
- if project
%ul.dropdown-footer-list
......
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