diff options
author | Phil Hughes <me@iamphill.com> | 2016-03-16 18:08:35 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-03-18 15:18:06 +0000 |
commit | 0858cb097afcaa529e5e0fe7154af53f66ce62fe (patch) | |
tree | 0ad7db2dec770e890c7e8002860bbd7dcff127fa | |
parent | 9280fd4acda1da9ed2435bd83d96892d77f37e90 (diff) | |
download | gitlab-ce-0858cb097afcaa529e5e0fe7154af53f66ce62fe.tar.gz |
Fixed issue with labels dropdown getting wrong labels
-rw-r--r-- | app/assets/javascripts/labels_select.js.coffee | 9 | ||||
-rw-r--r-- | app/assets/javascripts/milestone_select.js.coffee | 9 | ||||
-rw-r--r-- | app/controllers/projects/labels_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/projects/milestones_controller.rb | 8 | ||||
-rw-r--r-- | app/views/shared/issuable/_filter.html.haml | 4 |
5 files changed, 17 insertions, 20 deletions
diff --git a/app/assets/javascripts/labels_select.js.coffee b/app/assets/javascripts/labels_select.js.coffee index e6c1446f14f..4f03c367758 100644 --- a/app/assets/javascripts/labels_select.js.coffee +++ b/app/assets/javascripts/labels_select.js.coffee @@ -39,18 +39,9 @@ class @LabelsSelect $dropdown.glDropdown( data: (term, callback) -> - # We have to fetch the JS version of the labels list because there is no - # public facing JSON url for labels $.ajax( url: labelUrl ).done (data) -> - html = $(data) - data = [] - html.find('.label-row a').each -> - data.push( - title: $(@).text().trim() - ) - if showNo data.unshift( id: 0 diff --git a/app/assets/javascripts/milestone_select.js.coffee b/app/assets/javascripts/milestone_select.js.coffee index 0287d98b1ec..5c35107ae6a 100644 --- a/app/assets/javascripts/milestone_select.js.coffee +++ b/app/assets/javascripts/milestone_select.js.coffee @@ -15,15 +15,6 @@ class @MilestoneSelect $.ajax( url: milestonesUrl ).done (data) -> - html = $(data) - data = [] - html.find('.milestone strong a').each -> - link = $(@).attr('href').split('/') - data.push( - id: link[link.length - 1] - title: $(@).text().trim() - ) - if showNo data.unshift( id: '0' diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 40d8098690a..c61793f89af 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -12,6 +12,13 @@ class Projects::LabelsController < Projects::ApplicationController def index @labels = @project.labels.page(params[:page]).per(PER_PAGE) + + respond_to do |format| + format.html + format.json do + render json: @labels.to_json + end + end end def new diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index da46731d945..cfb0435717e 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -19,7 +19,15 @@ class Projects::MilestonesController < Projects::ApplicationController end @milestones = @milestones.includes(:project) + @milestones_all = @milestones @milestones = @milestones.page(params[:page]).per(PER_PAGE) + + respond_to do |format| + format.html + format.json do + render json: @milestones_all.to_json + end + end end def new diff --git a/app/views/shared/issuable/_filter.html.haml b/app/views/shared/issuable/_filter.html.haml index dfdc84ba4cc..318691ac7c3 100644 --- a/app/views/shared/issuable/_filter.html.haml +++ b/app/views/shared/issuable/_filter.html.haml @@ -22,7 +22,7 @@ - if params[:milestone_title] = hidden_field_tag(:milestone_title, params[:milestone_title]) = dropdown_tag(h(params[:milestone_name] || "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: true, data: { show_no: true, show_any: true, field_name: "milestone_title", selected: params[:milestone_title], project_id: (@project.id if @project), milestones: (namespace_project_milestones_path(@project.namespace, @project, :js) if @project) } }) do + placeholder: "Search milestones", footer_content: true, data: { show_no: true, show_any: true, field_name: "milestone_title", selected: params[:milestone_title], project_id: (@project.id if @project), milestones: (namespace_project_milestones_path(@project.namespace, @project, :json) if @project) } }) do - if @project %ul.dropdown-footer-list - if can? current_user, :admin_milestone, @project @@ -40,7 +40,7 @@ - if params[:label_name] = hidden_field_tag(:label_name, params[:label_name]) .dropdown - %button.dropdown-menu-toggle.js-label-select.js-filter-submit{type: "button", data: {toggle: "dropdown", field_name: "label_name", show_no: "true", show_any: "true", selected: params[:label_name], project_id: (@project.id if @project), labels: (namespace_project_labels_path(@project.namespace, @project, :js) if @project)}} + %button.dropdown-menu-toggle.js-label-select.js-filter-submit{type: "button", data: {toggle: "dropdown", field_name: "label_name", show_no: "true", show_any: "true", selected: params[:label_name], project_id: (@project.id if @project), labels: (namespace_project_labels_path(@project.namespace, @project, :json) if @project)}} %span.dropdown-toggle-text = h(params[:label_name] || "Label") = icon('chevron-down') |