BigW Consortium Gitlab

Commit 88024b17 by Phil Hughes

Standardised the output of the JSON to always include the name

The frontend will then always use the name as the ID - like previous
parent 3aeda8c9
...@@ -50,19 +50,22 @@ class @MilestoneSelect ...@@ -50,19 +50,22 @@ class @MilestoneSelect
extraOptions = [] extraOptions = []
if showAny if showAny
extraOptions.push( extraOptions.push(
isAny: true id: 0
name: ''
title: 'Any Milestone' title: 'Any Milestone'
) )
if showNo if showNo
extraOptions.push( extraOptions.push(
id: '0' id: -1
name: 'No Milestone'
title: 'No Milestone' title: 'No Milestone'
) )
if showUpcoming if showUpcoming
extraOptions.push( extraOptions.push(
id: '#upcoming' id: -2
name: '#upcoming'
title: 'Upcoming' title: 'Upcoming'
) )
>>>>>>> Updated to only include upcoming on filters >>>>>>> Updated to only include upcoming on filters
...@@ -84,14 +87,11 @@ class @MilestoneSelect ...@@ -84,14 +87,11 @@ class @MilestoneSelect
milestone.title milestone.title
id: (milestone) -> id: (milestone) ->
if !useId if !useId
if !milestone.isAny? milestone.name
milestone.title
else
''
else else
milestone.id milestone.id
isSelected: (milestone) -> isSelected: (milestone) ->
milestone.title is selectedMilestone milestone.name is selectedMilestone
hidden: -> hidden: ->
$selectbox.hide() $selectbox.hide()
$value.show() $value.show()
...@@ -99,8 +99,10 @@ class @MilestoneSelect ...@@ -99,8 +99,10 @@ class @MilestoneSelect
if $dropdown.hasClass 'js-filter-bulk-update' if $dropdown.hasClass 'js-filter-bulk-update'
return return
if $dropdown.hasClass 'js-filter-submit' if $dropdown.hasClass('js-filter-submit') and (isIssueIndex or isMRIndex)
if selected.title? if selected.name?
selectedMilestone = selected.name
else if selected.title?
selectedMilestone = selected.title selectedMilestone = selected.title
$dropdown.parents('form').submit() $dropdown.parents('form').submit()
else else
......
...@@ -24,7 +24,7 @@ class Projects::MilestonesController < Projects::ApplicationController ...@@ -24,7 +24,7 @@ class Projects::MilestonesController < Projects::ApplicationController
@milestones = @milestones.page(params[:page]) @milestones = @milestones.page(params[:page])
end end
format.json do format.json do
render json: @milestones render json: @milestones.to_json(methods: :name)
end end
end end
end end
......
...@@ -243,7 +243,7 @@ class IssuableFinder ...@@ -243,7 +243,7 @@ class IssuableFinder
end end
def filter_by_upcoming_milestone? def filter_by_upcoming_milestone?
params[:milestone_title] == 'Upcoming' params[:milestone_title] == Milestone::Upcoming.name
end end
def by_milestone(items) def by_milestone(items)
......
...@@ -47,6 +47,20 @@ module IssuablesHelper ...@@ -47,6 +47,20 @@ module IssuablesHelper
end end
end end
def milestone_dropdown_label(milestone_title, default_label)
milestone_title = if milestone_title == Milestone::Upcoming.name
Milestone::Upcoming.title
else
milestone_title
end
if !milestone_title.nil? && !milestone_title.empty?
h(milestone_title)
else
default_label
end
end
private private
def sidebar_gutter_collapsed? def sidebar_gutter_collapsed?
......
...@@ -14,6 +14,7 @@ class GlobalMilestone ...@@ -14,6 +14,7 @@ class GlobalMilestone
def initialize(title, milestones) def initialize(title, milestones)
@title = title @title = title
@name = title
@milestones = milestones @milestones = milestones
end end
......
- if params[:milestone_title] - if params[:milestone_title]
= hidden_field_tag(:milestone_title, params[:milestone_title]) = hidden_field_tag(:milestone_title, params[:milestone_title])
= dropdown_tag(h(params[:milestone_title].presence || "Milestone"), 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(params[:milestone_title], "Milestone"), options: { title: "Filter by milestone", toggle_class: 'js-milestone-select js-filter-submit', filter: true, dropdown_class: "dropdown-menu-selectable",
placeholder: "Search milestones", footer_content: @project.present?, data: { show_no: true, show_any: true, show_upcoming: true, field_name: "milestone_title", selected: params[:milestone_title], project_id: @project.try(:id), milestones: milestones_filter_dropdown_path, default_label: "Milestone" } }) do placeholder: "Search milestones", footer_content: @project.present?, data: { show_no: true, show_any: true, show_upcoming: true, field_name: "milestone_title", selected: params[:milestone_title], project_id: @project.try(:id), milestones: milestones_filter_dropdown_path, default_label: "Milestone" } }) do
- if @project - if @project
%ul.dropdown-footer-list %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