summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/labels_select.js.coffee1
-rw-r--r--app/helpers/issuables_helper.rb5
-rw-r--r--app/views/shared/issuable/_label_dropdown.html.haml6
-rw-r--r--app/views/shared/issuable/_milestone_dropdown.html.haml1
-rw-r--r--app/views/shared/issuable/_sidebar.html.haml8
5 files changed, 13 insertions, 8 deletions
diff --git a/app/assets/javascripts/labels_select.js.coffee b/app/assets/javascripts/labels_select.js.coffee
index 39a32f903d4..ce630dcacb3 100644
--- a/app/assets/javascripts/labels_select.js.coffee
+++ b/app/assets/javascripts/labels_select.js.coffee
@@ -293,6 +293,7 @@ class @LabelsSelect
else if selectedLabels.length is 1
selectedLabels[0]
else
+ console.log selectedLabels.length, defaultLabel
defaultLabel
defaultLabel: defaultLabel
fieldName: $dropdown.data('field-name')
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index a3a8c7d5ff9..114cf804d6f 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -10,10 +10,11 @@ module IssuablesHelper
def multi_label_name(current_labels, default_label)
# current_labels may be a string from before
if current_labels.is_a?(Array) && current_labels.any?
+ title = current_labels[0].try(:title) || current_labels[0]
if current_labels.count > 1
- "#{current_labels[0]} +#{current_labels.count - 1} more"
+ "#{title} +#{current_labels.count - 1} more"
else
- current_labels[0]
+ title
end
elsif current_labels.is_a?(String)
if current_labels.nil? || current_labels.empty?
diff --git a/app/views/shared/issuable/_label_dropdown.html.haml b/app/views/shared/issuable/_label_dropdown.html.haml
index 937dc210193..36a1ac7664e 100644
--- a/app/views/shared/issuable/_label_dropdown.html.haml
+++ b/app/views/shared/issuable/_label_dropdown.html.haml
@@ -14,9 +14,11 @@
- if selected.present?
- if selected.respond_to?('any?')
- - selected = project.labels.find(selected)
+ - selected = project.labels.find_by_id(selected) || selected
- selected.each do |label|
- = hidden_field_tag data_options[:field_name], label.id, id: nil, data: { title: label.title }
+ - id = label.try(:id) || label
+ - title = label.try(:title) || label
+ = hidden_field_tag data_options[:field_name], id, id: nil, data: { title: title }
.dropdown
%button.dropdown-menu-toggle.js-label-select.js-multiselect{class: classes.join(' '), type: "button", data: dropdown_data}
%span.dropdown-toggle-text{ class: ("is-default" if selected.nil?) }
diff --git a/app/views/shared/issuable/_milestone_dropdown.html.haml b/app/views/shared/issuable/_milestone_dropdown.html.haml
index ec1864b5536..9dd54546cb6 100644
--- a/app/views/shared/issuable/_milestone_dropdown.html.haml
+++ b/app/views/shared/issuable/_milestone_dropdown.html.haml
@@ -1,4 +1,5 @@
- project = @target_project || @project
+- extra_class = extra_class || ''
- selected_text = project.milestones.find_by_id(selected).try(:name)
- if selected.present?
= hidden_field_tag(name, selected)
diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml
index e020a7d4d00..61fb1bd1642 100644
--- a/app/views/shared/issuable/_sidebar.html.haml
+++ b/app/views/shared/issuable/_sidebar.html.haml
@@ -126,11 +126,11 @@
%span.no-value None
.selectbox.hide-collapsed
- issuable.labels_array.each do |label|
- = hidden_field_tag "#{issuable.to_ability_name}[label_names][]", label.id, id: nil
+ = hidden_field_tag "#{issuable.to_ability_name}[label_names][]", label.id, id: nil, data: { title: label.title }
.dropdown
- %button.dropdown-menu-toggle.js-label-select.js-multiselect{type: "button", data: {toggle: "dropdown", field_name: "#{issuable.to_ability_name}[label_names][]", ability_name: issuable.to_ability_name, show_no: "true", show_any: "true", project_id: (@project.id if @project), issue_update: issuable_json_path(issuable), labels: (namespace_project_labels_path(@project.namespace, @project, :json) if @project)}}
- %span.dropdown-toggle-text
- Label
+ %button.dropdown-menu-toggle.js-label-select.js-multiselect{type: "button", data: {toggle: "dropdown", default_label: "Labels", field_name: "#{issuable.to_ability_name}[label_names][]", ability_name: issuable.to_ability_name, show_no: "true", show_any: "true", project_id: (@project.id if @project), issue_update: issuable_json_path(issuable), labels: (namespace_project_labels_path(@project.namespace, @project, :json) if @project)}}
+ %span.dropdown-toggle-text{ class: ("is-default" if issuable.labels_array.empty?)}
+ = multi_label_name(issuable.labels_array, "Labels")
= icon('chevron-down')
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
= render partial: "shared/issuable/label_page_default"