Commit 0a986081 authored by Phil Hughes's avatar Phil Hughes

GL dropdown default toggle color

parent 82ef4f1e
......@@ -617,7 +617,14 @@ class GitLabDropdown
$dropdownContent.scrollTop(listItemTop - dropdownContentTop)
updateLabel: (selected = null, el = null, instance = null, added = false) =>
$(@el).find(".dropdown-toggle-text").text @options.toggleLabel(selected, el, instance, added)
$toggleText = $(@el).find(".dropdown-toggle-text")
$toggleText.text @options.toggleLabel(selected, el, instance, added)
if @options.defaultLabel
if $toggleText.text().trim() is @options.defaultLabel
$toggleText.addClass('is-default')
else
$toggleText.removeClass('is-default')
$.fn.glDropdown = (opts) ->
return @.each ->
......
......@@ -4,6 +4,7 @@ class @LabelsSelect
$('.js-label-select').each (i, dropdown) ->
$dropdown = $(dropdown)
$toggleText = $dropdown.find('.dropdown-toggle-text')
projectId = $dropdown.data('project-id')
labelUrl = $dropdown.data('labels')
issueUpdateURL = $dropdown.data('issueUpdate')
......@@ -280,12 +281,16 @@ class @LabelsSelect
index = selectedLabels.indexOf selected.title
selectedLabels.splice index, 1
if selected.id? and selected.id is 0
selectedLabels = []
if selectedLabels.length > 1
"#{selectedLabels[0]} +#{selectedLabels.length - 1} more"
else if selectedLabels.length is 1
selectedLabels[0]
else
defaultLabel
defaultLabel: defaultLabel
fieldName: $dropdown.data('field-name')
id: (label) ->
if $dropdown.hasClass('js-issuable-form-dropdown')
......
......@@ -70,11 +70,12 @@ class @MilestoneSelect
search:
fields: ['title']
selectable: true
toggleLabel: (selected) ->
if selected && 'id' of selected
toggleLabel: (selected, el, e, added) ->
if selected and 'id' of selected and added
selected.title
else
defaultLabel
defaultLabel: defaultLabel
fieldName: $dropdown.data('field-name')
text: (milestone) ->
_.escape(milestone.title)
......
......@@ -142,12 +142,12 @@ class @UsersSelect
selectable: true
fieldName: $dropdown.data('field-name')
toggleLabel: (selected) ->
if selected && 'id' of selected
toggleLabel: (selected, el, e, added) ->
if selected and 'id' of selected and added
if selected.text then selected.text else selected.name
else
defaultLabel
defaultLabel: defaultLabel
inputId: 'issue_assignee_id'
hidden: (e) ->
......
......@@ -562,3 +562,9 @@
display: block;
color: $gl-placeholder-color;
}
.dropdown-toggle-text {
&.is-default {
color: $gl-placeholder-color;
}
}
......@@ -40,8 +40,9 @@ module DropdownsHelper
end
def dropdown_toggle(toggle_text, data_attr, options = {})
default_label = options[:data][:default_label]
content_tag(:button, class: "dropdown-menu-toggle #{options[:toggle_class] if options.has_key?(:toggle_class)}", id: (options[:id] if options.has_key?(:id)), type: "button", data: data_attr) do
output = content_tag(:span, toggle_text, class: "dropdown-toggle-text")
output = content_tag(:span, toggle_text, class: "dropdown-toggle-text #{'is-default' if toggle_text == default_label}")
output << icon('chevron-down')
output.html_safe
end
......
......@@ -18,7 +18,7 @@
= hidden_field_tag data_options[:field_name], label, id: nil
.dropdown
%button.dropdown-menu-toggle.js-label-select.js-multiselect{class: classes.join(' '), type: "button", data: dropdown_data}
%span.dropdown-toggle-text
%span.dropdown-toggle-text{ class: ("is-default" if selected_toggle) }
= h(multi_label_name(selected_toggle || selected, "Label"))
= icon('chevron-down')
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
......
- project = @target_project || @project
- selected_text = project.milestones.find(selected).try(:name)
- selected_text = project.milestones.find_by_id(selected).try(:name)
- if selected.present?
= hidden_field_tag(name, selected)
= 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",
......
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