diff --git a/app/helpers/reporting_helper.rb b/app/helpers/reporting_helper.rb index 01434b42b8..1181fb3408 100644 --- a/app/helpers/reporting_helper.rb +++ b/app/helpers/reporting_helper.rb @@ -21,21 +21,24 @@ module ReportingHelper [ {:name => :activate_filter, :filter_name => filter.underscore_name, :label => l(filter.label)}, {:name => :operators, :filter_name => filter.underscore_name, :operators => filter.available_operators}, - {:name => :multi_values, :filter_name => filter.underscore_name, :values => filter.available_values(User.current)}] + {:name => :multi_values, :filter_name => filter.underscore_name, :values => filter.available_values(User.current)}, + {:name => :remove_filter, :filter_name => filter.underscore_name}] end def date_elements(filter) [ {:name => :activate_filter, :filter_name => filter.underscore_name, :label => l(filter.label)}, {:name => :operators, :filter_name => filter.underscore_name, :operators => filter.available_operators}, - {:name => :date, :filter_name => filter.underscore_name}] + {:name => :date, :filter_name => filter.underscore_name}, + {:name => :remove_filter, :filter_name => filter.underscore_name}] end def text_elements(filter) [ {:name => :activate_filter, :filter_name => filter.underscore_name, :label => l(filter.label)}, {:name => :operators, :filter_name => filter.underscore_name, :operators => filter.available_operators}, - {:name => :text_box, :filter_name => filter.underscore_name}] + {:name => :text_box, :filter_name => filter.underscore_name}, + {:name => :remove_filter, :filter_name => filter.underscore_name}] end def link_to_project(project) diff --git a/app/views/cost_reports/filters/_activate_filter.rhtml b/app/views/cost_reports/filters/_activate_filter.rhtml index 9b5f530cea..df93f8c3d5 100644 --- a/app/views/cost_reports/filters/_activate_filter.rhtml +++ b/app/views/cost_reports/filters/_activate_filter.rhtml @@ -2,13 +2,10 @@ This partial requires the following locals: element a Hash containing the following keys: - :name => :activate_filter - - :filter_name => String: The name of a filter (e.g. activity_id) - :label => String: A text which is shown to the user as a label for this filter - :width => Integer (optional): The width this partial may consume. If not given, a standard width will be applied %> - - - + + \ No newline at end of file diff --git a/app/views/cost_reports/filters/_remove_filter.rhtml b/app/views/cost_reports/filters/_remove_filter.rhtml new file mode 100644 index 0000000000..9e32cfb131 --- /dev/null +++ b/app/views/cost_reports/filters/_remove_filter.rhtml @@ -0,0 +1,10 @@ +<%# + This partial requires the following locals: + element a Hash containing the following keys: + - :filter_name => String: The name of a filter (e.g. activity_id) + - :hide => Boolean (optional, default = true): whether the content of this partial is initially hidden or not +%> +> + + \ No newline at end of file diff --git a/assets/javascripts/reporting.js b/assets/javascripts/reporting.js index e035c66980..8498b397d0 100644 --- a/assets/javascripts/reporting.js +++ b/assets/javascripts/reporting.js @@ -2,12 +2,12 @@ function toggle_filter(field) { var remove, to_toggle; - remove = $('rm_' + field); - to_toggle = remove.up().siblings(); - if (remove.visible()) { + label = $('label_' + field); + to_toggle = label.up().siblings(); + if (label.visible()) { to_toggle.invoke('show'); - } - else { + $('rm_' + field).hide(); + } else { to_toggle.invoke('hide'); } } @@ -67,8 +67,27 @@ function hide_category(tr_field) { } } +function register_remove_hover(field) { + table = $('tr_' + field); + Event.observe(table, 'mouseover', function(event) { set_remove_button_visibility(field, true) }); + Event.observe(table, 'mouseout', function(event) { set_remove_button_visibility(field, false) }); +} + + +function set_remove_button_visibility(field, value) { + remove = $('rm_' + field); + if (remove !== null) { + if (value == true) { + remove.show(); + } else { + remove.hide(); + } + } +} + function show_filter(field) { var field_el = $('tr_' + field); + register_remove_hover(field); if (field_el !== null) { field_el.show(); toggle_filter(field); diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index cd58645d7c..0e8c5a10d2 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -110,6 +110,17 @@ border-style: none; } +.icon-filter-rem { + background-image: url(../images/remove.png); +} + +.filter { + border: 2px solid #CCC; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border--radius: 5px; +} + .drag_element { cursor: move; background-color: #60D8FB; @@ -133,5 +144,5 @@ .drag_container_accept { background-color: #F5F5C5; - boder: 1px solid #BBBBBB; + border: 1px solid #BBBBBB; }