From 9cebc1f82780f0075b69a57fb2aaa44a811c1c69 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 6 Dec 2018 17:08:12 +0100 Subject: Backport some EE helper changes This backports some EE changes made to DropdownsHelper and SelectsHelper. These changes can not easily be moved into an EE specific module, as doing so would require reimplementing all modified methods. Since there is no harm in including these changes in CE directly, we just backport them. --- app/helpers/dropdowns_helper.rb | 9 +++++++++ app/helpers/selects_helper.rb | 5 +++++ 2 files changed, 14 insertions(+) (limited to 'app') diff --git a/app/helpers/dropdowns_helper.rb b/app/helpers/dropdowns_helper.rb index 4b6c5b215e8..8d8c62f1291 100644 --- a/app/helpers/dropdowns_helper.rb +++ b/app/helpers/dropdowns_helper.rb @@ -11,6 +11,10 @@ module DropdownsHelper dropdown_output = dropdown_toggle(toggle_text, data_attr, options) + if options.key?(:toggle_link) + dropdown_output = dropdown_toggle_link(toggle_text, data_attr, options) + end + dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.key?(:dropdown_class)}") do output = [] @@ -49,6 +53,11 @@ module DropdownsHelper end end + def dropdown_toggle_link(toggle_text, data_attr, options = {}) + output = content_tag(:a, toggle_text, class: "dropdown-toggle-text #{options[:toggle_class] if options.key?(:toggle_class)}", id: (options[:id] if options.key?(:id)), data: data_attr) + output.html_safe + end + def dropdown_title(title, options: {}) content_tag :div, class: "dropdown-title" do title_output = [] diff --git a/app/helpers/selects_helper.rb b/app/helpers/selects_helper.rb index cf60696ef39..2f802e4eab8 100644 --- a/app/helpers/selects_helper.rb +++ b/app/helpers/selects_helper.rb @@ -29,6 +29,11 @@ module SelectsHelper classes = Array.wrap(opts[:class]) classes << 'ajax-groups-select' + # EE requires this line to be present, but there is no easy way of injecting + # this into EE without causing merge conflicts. Given this line is very + # simple and not really EE specific on its own, we just include it in CE. + classes << 'multiselect' if opts[:multiple] + opts[:class] = classes.join(' ') select2_tag(id, opts) -- cgit v1.2.1