From 52b6a30678520956b0ea62bc6d5f8234691215ae Mon Sep 17 00:00:00 2001 From: Henriette Dinger Date: Tue, 5 Apr 2016 15:24:30 +0200 Subject: [PATCH] Add helping text and set focus --- lib/assets/javascripts/reporting_engine/reporting/filters.js | 4 ++++ lib/widget/filters.rb | 3 +++ lib/widget/filters/operators.rb | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/assets/javascripts/reporting_engine/reporting/filters.js b/lib/assets/javascripts/reporting_engine/reporting/filters.js index 75c6c4ab0d..ab156b6fb0 100644 --- a/lib/assets/javascripts/reporting_engine/reporting/filters.js +++ b/lib/assets/javascripts/reporting_engine/reporting/filters.js @@ -497,7 +497,11 @@ Reporting.onload(function () { $("add_filter_select").observe("change", function () { if (!(Reporting.Filters.exists(this.value))) { Reporting.Filters.add_filter(this.value); + var new_filter = this.value; this.selectedIndex = 0; + setTimeout(function () { + $(document).getElementById('operators['+ new_filter +']').focus(); + }, 300); }; }); } diff --git a/lib/widget/filters.rb b/lib/widget/filters.rb index 0b85984cab..65efc59b7c 100644 --- a/lib/widget/filters.rb +++ b/lib/widget/filters.rb @@ -24,6 +24,9 @@ class Widget::Filters < Widget::Base add_filter = content_tag :li, id: 'add_filter_block', class: 'advanced-filters--add-filter' do add_filter_label = label_tag 'add_filter_select', l(:label_filter_add), class: 'advanced-filters--add-filter-label' + add_filter_label += label_tag 'add_filter_select', I18n.t('js.filter.description.text_open_filter') + ' ' + + I18n.t('js.filter.description.text_close_filter'), + class: 'hidden-for-sighted' add_filter_value = content_tag :div, class: 'advanced-filters--add-filter-value' do value = select_tag 'add_filter_select', diff --git a/lib/widget/filters/operators.rb b/lib/widget/filters/operators.rb index b58841bb41..658a63c95a 100644 --- a/lib/widget/filters/operators.rb +++ b/lib/widget/filters/operators.rb @@ -39,7 +39,7 @@ class Widget::Filters::Operators < Widget::Filters::Base end.join.html_safe end label1 = content_tag :label, - h(filter_class.label) + ' ' + l(:label_operator), + h(filter_class.label) + ' ' + l(:label_operator) + ' ' + I18n.t('js.filter.description.text_open_filter'), for: "operators[#{filter_class.underscore_name}]", class: 'hidden-for-sighted' label = content_tag :label do