From 8ce3318d34b22897dcbfcb67cd782cc08f14666c Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Fri, 1 Apr 2011 11:47:48 +0200 Subject: [PATCH 01/52] Added Help Widget and put one next to the filter selection for demonstration. --- assets/stylesheets/reporting.css | 24 ++++++++++++++++++++++++ config/locales/de.yml | 6 +++++- config/locales/en.yml | 2 ++ lib/widget/controls/help.rb | 11 +++++++++++ lib/widget/filters.rb | 4 +++- 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 lib/widget/controls/help.rb diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index ab071f4e75..4e443c9dbf 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -495,3 +495,27 @@ html>body #ajax-indicator { position: fixed; } padding-left: 26px; vertical-align: bottom; } + +a.help { + margin-left: 10px; +} + +a.help span { + display: none; + text-decoration: none; +} + +a.help:hover span { + display: block; + position: absolute; + margin-top: 3px; + margin-bottom: 3px; + padding: 3px; + width: 300px; + z-index: 9999; + color: #000000; + border: 1px dashed #000000; + background: #FFFFCC; + font: 12px Verdana, sans-serif; + text-align: left; +} diff --git a/config/locales/de.yml b/config/locales/de.yml index 8177695523..dc8f7dc5e3 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -9,7 +9,7 @@ de: label_rows: "Zeilen" label_group_by: "Gruppieren nach" - label_group_by_add: "Grouppierung hinzufügen" + label_group_by_add: "Gruppierung hinzufügen" label_filter: "Filter" label_filter_plural: "Filter" label_filter_add: "Filter hinzufügen" @@ -18,7 +18,11 @@ de: label_sum: Summe label_none: "(no value)" + label_help: Hilfe + description_drill_down: Details anzeigen validation_failure_date: "ist kein gültiges Datum" validation_failure_integer: "ist keine ganze Zahl" + + help_filters: Über Filter:
Mit Hilfe von Filtern kann die Ergebnismenge reduziert werden. Beispielsweise möchte man vielleicht einen Bericht nur für ein bestimmtes Land erhalten ... diff --git a/config/locales/en.yml b/config/locales/en.yml index a879c64de6..af4dd584eb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -18,6 +18,8 @@ en: label_sum: Sum label_none: "(no value)" + label_help: Help + description_drill_down: Show details validation_failure_date: "is not a valid date" diff --git a/lib/widget/controls/help.rb b/lib/widget/controls/help.rb new file mode 100644 index 0000000000..147a13333e --- /dev/null +++ b/lib/widget/controls/help.rb @@ -0,0 +1,11 @@ +## +# Usgae: render_widget Widget::Controls::Help, :text +# +# Where :text is a i18n key. +class Widget::Controls::Help < Widget::Base + def render + icon = tag :img, :src => '/images/help.png', :alt => '?' + span = content_tag_string :span, l(@query), {}, false + content_tag :a, icon + span, :href => "#", :class => "help" + end +end \ No newline at end of file diff --git a/lib/widget/filters.rb b/lib/widget/filters.rb index 0d082eefd9..d728048472 100644 --- a/lib/widget/filters.rb +++ b/lib/widget/filters.rb @@ -12,10 +12,12 @@ class Widget::Filters < Widget::Base end end select = content_tag :div, :id => "add_filter_block" do - select_tag 'add_filter_select', + add_filter = select_tag 'add_filter_select', options_for_select([["-- #{l(:label_filter_add)} --",'']] + selectables), :class => "select-small", :name => nil + help = render_widget Widget::Controls::Help, :help_filters + add_filter + help end content_tag(:div, table + select) end From 7a25eacab817888f7221f653a0a26cf733f2384d Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 4 Apr 2011 12:07:59 +0200 Subject: [PATCH 02/52] cleaned up debris --- assets/stylesheets/reporting.css | 8 -------- 1 file changed, 8 deletions(-) diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index eadd10a44a..256783023b 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -523,12 +523,4 @@ a.help:hover span { background: #FFFFCC; font: 12px Verdana, sans-serif; text-align: left; -} - -#content p, -#content label, -#content a, -#content div { - font-size: 11px; - line-height: 16px; } \ No newline at end of file From 2d2d4f9a6df18d76546877121d96f5d3d40e0605 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 4 Apr 2011 18:13:10 +0200 Subject: [PATCH 03/52] Integrated help widget rendering into Widget Base. Implemented custom rendering for Filters and GroupBy Widgets. --- assets/stylesheets/reporting.css | 26 +++++++++++++++++++++-- lib/widget/base.rb | 21 +++++++++++++++++++ lib/widget/controls/help.rb | 36 ++++++++++++++++++++++++++++---- lib/widget/filters.rb | 10 +++++++-- lib/widget/group_bys.rb | 9 +++++++- 5 files changed, 93 insertions(+), 9 deletions(-) diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index 256783023b..281cdf6f5f 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -505,6 +505,10 @@ a.help { margin-left: 10px; } +a.help div { + position: relative; +} + a.help span { display: none; text-decoration: none; @@ -519,8 +523,26 @@ a.help:hover span { width: 300px; z-index: 9999; color: #000000; - border: 1px dashed #000000; + border: 1px solid #000000; background: #FFFFCC; font: 12px Verdana, sans-serif; text-align: left; -} \ No newline at end of file + padding: -50px; +} + +.filter-icon { + +} + +.filter-tip { + top: -120px; +} + +.group-by-icon { + float: right; + margin-right: 5px; +} + +.group-by-tip { + left: -315px; +} diff --git a/lib/widget/base.rb b/lib/widget/base.rb index b44567b4d6..a58e92b050 100644 --- a/lib/widget/base.rb +++ b/lib/widget/base.rb @@ -17,4 +17,25 @@ class Widget::Base < Widget render(&block) end end + + ## + # An optional help text. If defined the Help Widget + # displaying the given text is going to be placed + # next to this Widget, if it supports that. + def help_text; end + + ## + # Appends the Help Widget with this Widget's help text + # if it is defined to the input. + # If the help text is not defined the input is returned. + def maybe_with_help(html, options = {}) + if help_text + help = render_widget Widget::Controls::Help, help_text do + options + end + html + help + else + html + end + end end diff --git a/lib/widget/controls/help.rb b/lib/widget/controls/help.rb index 147a13333e..b08a93f5a4 100644 --- a/lib/widget/controls/help.rb +++ b/lib/widget/controls/help.rb @@ -4,8 +4,36 @@ # Where :text is a i18n key. class Widget::Controls::Help < Widget::Base def render - icon = tag :img, :src => '/images/help.png', :alt => '?' - span = content_tag_string :span, l(@query), {}, false - content_tag :a, icon + span, :href => "#", :class => "help" + options = {:icon => {}, :tooltip => {}} + options.merge!(yield) if block_given? + icon = tag :img, :src => '/images/help.png' + span = content_tag_string :span, l(@query), options[:tooltip], false + hull = content_tag :div, span + icon_options = icon_config(options[:icon]) + content_tag :a, icon + hull, icon_options end -end \ No newline at end of file + + def icon_config(options) + add_class = lambda do |cl| + if cl + "help #{cl}" + else + "help" + end + end + options.mega_merge! :href => '#', :class => add_class + end +end + +class Hash + def mega_merge!(hash) + hash.each do |key, value| + if value.kind_of?(Proc) + self[key] = value.call(self[key]) + else + self[key] = value + end + end + self + end +end diff --git a/lib/widget/filters.rb b/lib/widget/filters.rb index 4b40acd5a7..829b646631 100644 --- a/lib/widget/filters.rb +++ b/lib/widget/filters.rb @@ -16,8 +16,14 @@ class Widget::Filters < Widget::Base options_for_select([["-- #{l(:label_filter_add)} --",'']] + selectables), :class => "select-small", :name => nil - help = render_widget Widget::Controls::Help, :help_filters - add_filter + help + maybe_with_help add_filter, { + :icon => { + :class => 'filter-icon' + }, + :tooltip => { + :class => 'filter-tip' + } + } end content_tag(:div, table + select) end diff --git a/lib/widget/group_bys.rb b/lib/widget/group_bys.rb index 5265204d6a..35ba298f10 100644 --- a/lib/widget/group_bys.rb +++ b/lib/widget/group_bys.rb @@ -46,7 +46,14 @@ class Widget::GroupBys < Widget::Base end.join.html_safe content end - out.html_safe + maybe_with_help out.html_safe, { + :icon => { + :class => 'group-by-icon' + }, + :tooltip => { + :class => 'group-by-tip' + } + } end end From 733a1dbe0663dd0bcce31b4cc3bd7e5cad884de9 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 4 Apr 2011 18:13:30 +0200 Subject: [PATCH 04/52] Removed UR specific translation. --- config/locales/de.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index dc8f7dc5e3..a9f1957af6 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -24,5 +24,4 @@ de: validation_failure_date: "ist kein gültiges Datum" validation_failure_integer: "ist keine ganze Zahl" - - help_filters: Über Filter:
Mit Hilfe von Filtern kann die Ergebnismenge reduziert werden. Beispielsweise möchte man vielleicht einen Bericht nur für ein bestimmtes Land erhalten ... + From d4139e31474e93f6448d30467bad4ac755c63d44 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 4 Apr 2011 18:58:50 +0200 Subject: [PATCH 05/52] changed help icon --- assets/images/icon_info_red.gif | Bin 0 -> 67 bytes lib/widget/controls/help.rb | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 assets/images/icon_info_red.gif diff --git a/assets/images/icon_info_red.gif b/assets/images/icon_info_red.gif new file mode 100644 index 0000000000000000000000000000000000000000..34de8c6b9824f786fcc7f571bfccb69c3248a11a GIT binary patch literal 67 zcmZ?wbhEHb {}, :tooltip => {}} options.merge!(yield) if block_given? - icon = tag :img, :src => '/images/help.png' + icon = tag :img, :src => '/images/icon_info_red.gif' span = content_tag_string :span, l(@query), options[:tooltip], false hull = content_tag :div, span icon_options = icon_config(options[:icon]) From cc9889d479cb064e2632f0029a20cbde85d40885 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 4 Apr 2011 18:59:17 +0200 Subject: [PATCH 06/52] only render a help icon next to one of the two group-by selections --- lib/widget/group_bys.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/widget/group_bys.rb b/lib/widget/group_bys.rb index 35ba298f10..1ae29b8afa 100644 --- a/lib/widget/group_bys.rb +++ b/lib/widget/group_bys.rb @@ -24,7 +24,7 @@ class Widget::GroupBys < Widget::Base end end - def render_group(type, initially_selected) + def render_group(type, initially_selected, show_help = false) initially_selected = initially_selected.map do |group_by| [group_by.class.underscore_name, l(group_by.class.label)] end @@ -46,20 +46,24 @@ class Widget::GroupBys < Widget::Base end.join.html_safe content end - maybe_with_help out.html_safe, { - :icon => { - :class => 'group-by-icon' - }, - :tooltip => { - :class => 'group-by-tip' + if show_help + maybe_with_help out.html_safe, { + :icon => { + :class => 'group-by-icon' + }, + :tooltip => { + :class => 'group-by-tip' + } } - } + else + out.html_safe + end end end def render content_tag :div, :id => 'group_by_area' do - out = render_group 'columns', @query.group_bys(:column) + out = render_group 'columns', @query.group_bys(:column), true out += render_group 'rows', @query.group_bys(:row) out.html_safe end From 24aaed4c510c11aed98007fd627e48faf8711363 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 5 Apr 2011 14:34:35 +0200 Subject: [PATCH 07/52] Mitigate 'info icon hover deformation' in Chrome & Safari a tiny bit. --- assets/stylesheets/reporting.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index 281cdf6f5f..9b17ab3d63 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -514,6 +514,10 @@ a.help span { text-decoration: none; } +a.help div { + display: none; +} + a.help:hover span { display: block; position: absolute; @@ -530,6 +534,10 @@ a.help:hover span { padding: -50px; } +a.help:hover div { + display: block; +} + .filter-icon { } From 83c0fb03784f41d4628acdfd47a72661413fae9f Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 5 Apr 2011 14:38:34 +0200 Subject: [PATCH 08/52] Make help text an instance variable and overridable in maybe_with_help. --- lib/widget/base.rb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/widget/base.rb b/lib/widget/base.rb index a58e92b050..2923cc86a0 100644 --- a/lib/widget/base.rb +++ b/lib/widget/base.rb @@ -11,26 +11,35 @@ class Widget::Base < Widget end def render_with_options(options = {}, &block) + help_text = options[:help_text] if canvas = options[:to] canvas << "\n" << render(&block) else render(&block) end end - + ## # An optional help text. If defined the Help Widget # displaying the given text is going to be placed # next to this Widget, if it supports that. - def help_text; end - + def help_text + @help_text + end + + def help_text=(text) + @help_text = text + end + ## # Appends the Help Widget with this Widget's help text # if it is defined to the input. # If the help text is not defined the input is returned. def maybe_with_help(html, options = {}) - if help_text - help = render_widget Widget::Controls::Help, help_text do + text = options[:text] + text ||= help_text unless options[:ignore_default] + if text + help = render_widget Widget::Controls::Help, text do options end html + help From 2d38aebbd13bbd94db9befc2693cbb614a41c9c0 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 5 Apr 2011 15:13:41 +0200 Subject: [PATCH 09/52] Help texts for individual filters. --- lib/report/chainable.rb | 16 +++++++++++++++- lib/widget/filters.rb | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/report/chainable.rb b/lib/report/chainable.rb index ed116c5a30..85f77a208a 100644 --- a/lib/report/chainable.rb +++ b/lib/report/chainable.rb @@ -309,7 +309,6 @@ class Report < ActiveRecord::Base value.to_s end - def self.mapping_for(field) @field_map ||= (engine::Filter.all + engine.GroupBy.all).inject(Hash.new {|h,k| h[k] = []}) do |hash,cbl| hash[cbl.field] << cbl.mapping @@ -317,5 +316,20 @@ class Report < ActiveRecord::Base @field_map[field] end + def help_text + self.class.help_text + end + + ## + # Sets a help text to be displayed for this kind of Chainable. + def self.help_text=(sym) + @help_text = sym + end + + def self.help_text(sym = nil) + @help_text = sym if sym + @help_text + end + end end diff --git a/lib/widget/filters.rb b/lib/widget/filters.rb index 829b646631..48cc5256aa 100644 --- a/lib/widget/filters.rb +++ b/lib/widget/filters.rb @@ -78,6 +78,20 @@ class Widget::Filters < Widget::Base render_widget Filters::MultiValues, f, :to => html end end + render_filter_help f, :to => html render_widget Filters::RemoveButton, f, :to => html end + + def render_filter_help(filter, options = {}) + html = content_tag :td, :width => "25px" do + if filter.help_text + render_widget Widget::Controls::Help, filter.help_text + end + end + if canvas = options[:to] + canvas << "\n" << html + else + html + end + end end From 233ff32a79bf14d1e8e133419be1801b208f967b Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 5 Apr 2011 18:46:04 +0200 Subject: [PATCH 10/52] Enabled help text for Clear Control. --- lib/widget/controls/clear.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/widget/controls/clear.rb b/lib/widget/controls/clear.rb index f460105a8d..c58570e7ab 100644 --- a/lib/widget/controls/clear.rb +++ b/lib/widget/controls/clear.rb @@ -1,5 +1,6 @@ class Widget::Controls::Clear < Widget::Base def render - link_to content_tag(:span, content_tag(:em, l(:"button_clear"), :class => "button-icon icon-clear")), '#', :id => 'query-link-clear', :class => 'button secondary' + html = link_to content_tag(:span, content_tag(:em, l(:"button_clear"), :class => "button-icon icon-clear")), '#', :id => 'query-link-clear', :class => 'button secondary' + maybe_with_help html end end From b71bf13c57cfc5d19c9f4d99af23c54d61e8df4a Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Fri, 8 Apr 2011 10:09:08 +0200 Subject: [PATCH 11/52] Use cordinc_tooltip; made icon and diff customizable. --- assets/javascripts/cordinc_tooltip.js | 155 ++++++++++++++++++++++++++ assets/stylesheets/reporting.css | 34 ++---- lib/widget/controls/help.rb | 23 +++- 3 files changed, 182 insertions(+), 30 deletions(-) create mode 100644 assets/javascripts/cordinc_tooltip.js diff --git a/assets/javascripts/cordinc_tooltip.js b/assets/javascripts/cordinc_tooltip.js new file mode 100644 index 0000000000..cb8e48ae44 --- /dev/null +++ b/assets/javascripts/cordinc_tooltip.js @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2009 Charles Cordingley (www.cordinc.com) + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * cordinc_tooltip.js, v1.0.2 - 27 August 2008 + * For help see www.cordinc.com/projects/tooltips.html + */ +var Tooltip = Class.create({ + initialize: function(target, tooltip) { + var options = Object.extend({ + start_effect: function(element) {}, + end_effect: function(element) {}, + zindex: 1000, + offset: {x:0, y:0}, + hook: {target:'topRight', tip:'bottomLeft'}, + trigger: false, + DOM_location: false, + className: false, + delay: {} + }, arguments[2] || {}); + + this.target = $(target); + this.tooltip = $(tooltip); + this.options = options; + this.event_target = this.options.trigger?$(this.options.trigger):this.target; + + if (this.options.className) { + this.tooltip.addClassName(this.options.className); + } + this.tooltip.hide(); + this.display=false; + + this.mouse_over = this.displayTooltip.bindAsEventListener(this); + this.mouse_out = this.removeTooltip.bindAsEventListener(this); + this.event_target.observe("mouseover", this.mouse_over); + this.event_target.observe("mouseout", this.mouse_out); + }, + + displayTooltip: function(event){ + event.stop(); + + if (this.display) {return;} + if (this.options.delay.start) { + var self = this; + this.timer_id = setTimeout(function(){self.timer_id = false; self.showTooltip(event);}, this.options.delay.start*1000); + } else { + this.showTooltip(event); + } + }, + + showTooltip: function(event) { + this.display=true; + position = this.positionTooltip(event); + + this.clone = this.tooltip.cloneNode(true); + parentId = this.options.DOM_location?$(this.options.DOM_location.parentId):this.target.parentNode; + successorId = this.options.DOM_location?$(this.options.DOM_location.successorId):this.target; + parentId.insertBefore(this.clone, successorId); + + this.clone.setStyle({ + position:'absolute', + top: position.top + "px", + left: position.left + "px", + display: "inline", + zIndex:this.options.zindex + }); + + if (this.options.start_effect) { + this.options.start_effect(this.clone); + } + }, + + positionTooltip: function(event) { + target_position = this.target.cumulativeOffset(); + + tooltip_dimensions = this.tooltip.getDimensions(); + target_dimensions = this.target.getDimensions(); + + this.positionModify(target_position, target_dimensions, this.options.hook.target, 1); + this.positionModify(target_position, tooltip_dimensions, this.options.hook.tip, -1); + + target_position.top += this.options.offset.y; + target_position.left += this.options.offset.x; + + return target_position; + }, + + positionModify: function(position, box, corner, neg) { + if (corner == 'topRight') { + position.left += box.width*neg; + } else if (corner == 'topLeft') { + } else if (corner == 'bottomLeft') { + position.top += box.height*neg; + } else if (corner == 'bottomRight') { + position.top += box.height*neg; + position.left += box.width*neg; + } else if (corner == 'topMid') { + position.left += (box.width/2)*neg; + } else if (corner == 'leftMid') { + position.top += (box.height/2)*neg; + } else if (corner == 'bottomMid') { + position.top += box.height*neg; + position.left += (box.width/2)*neg; + } else if (corner == 'rightMid') { + position.top += (box.height/2)*neg; + position.left += box.width*neg; + } + }, + + removeTooltip: function(event) { + if (this.timer_id) { + clearTimeout(this.timer_id); + this.timer_id = false; + return; + } + + if (this.options.end_effect) { + this.options.end_effect(this.clone); + } + + if (this.options.delay.end) { + var self = this; + setTimeout(function(){self.clearTooltip();}, this.options.delay.end*1000); + } else { + this.clearTooltip(); + } + }, + + clearTooltip: function() { + if (this.clone !== undefined && this.clone !== null) { + this.clone.remove(); + this.clone = null; + this.display=false; + } + }, + + destroy: function() { + this.event_target.stopObserving("mouseover", this.mouse_over); + this.event_target.stopObserving("mouseout", this.mouse_out); + this.clearTooltip(); + } +}) \ No newline at end of file diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index 9b17ab3d63..bce9ba64a2 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -501,31 +501,18 @@ html>body #ajax-indicator { position: fixed; } vertical-align: bottom; } -a.help { - margin-left: 10px; -} - -a.help div { - position: relative; -} - -a.help span { - display: none; - text-decoration: none; -} - -a.help div { - display: none; +.help { + margin-left: 5px; + margin-right: 5px; } -a.help:hover span { - display: block; +.tooltip { position: absolute; margin-top: 3px; margin-bottom: 3px; padding: 3px; - width: 300px; - z-index: 9999; + width: 400px; + z-index: 256; color: #000000; border: 1px solid #000000; background: #FFFFCC; @@ -534,16 +521,12 @@ a.help:hover span { padding: -50px; } -a.help:hover div { - display: block; -} - .filter-icon { } .filter-tip { - top: -120px; + } .group-by-icon { @@ -552,5 +535,6 @@ a.help:hover div { } .group-by-tip { - left: -315px; + margin-top: -300px; + margin-left: -475px; } diff --git a/lib/widget/controls/help.rb b/lib/widget/controls/help.rb index 3f0e1e6293..62650239d5 100644 --- a/lib/widget/controls/help.rb +++ b/lib/widget/controls/help.rb @@ -4,13 +4,15 @@ # Where :text is a i18n key. class Widget::Controls::Help < Widget::Base def render + id = "tip:#{@query}" options = {:icon => {}, :tooltip => {}} options.merge!(yield) if block_given? - icon = tag :img, :src => '/images/icon_info_red.gif' - span = content_tag_string :span, l(@query), options[:tooltip], false - hull = content_tag :div, span - icon_options = icon_config(options[:icon]) - content_tag :a, icon + hull, icon_options + icon = tag :img, :src => '/images/icon_info_red.gif', :id => "target:#{@query}" + tip = content_tag_string :div, l(@query), tip_config(options[:tooltip]), false + script = content_tag_string :script, "new Tooltip('target:#{@query}', 'tip:#{@query}', {className: 'tooltip'});", + {:type => 'text/javascript'}, false + target = content_tag :a, icon + tip, icon_config(options[:icon]) + target + script end def icon_config(options) @@ -23,6 +25,17 @@ class Widget::Controls::Help < Widget::Base end options.mega_merge! :href => '#', :class => add_class end + + def tip_config(options) + add_class = lambda do |cl| + if cl + "#{cl} tooltip" + else + "tooltip" + end + end + options.mega_merge! :id => "tip:#{@query}", :class => add_class + end end class Hash From f275bfbec091ed2e115bbeb9fb31926a2871208c Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Fri, 8 Apr 2011 12:27:04 +0200 Subject: [PATCH 12/52] Ensure tooltip visibility and size. Tooltip JS fix specifically for UR. --- assets/javascripts/cordinc_tooltip.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/cordinc_tooltip.js b/assets/javascripts/cordinc_tooltip.js index cb8e48ae44..8335c035ed 100644 --- a/assets/javascripts/cordinc_tooltip.js +++ b/assets/javascripts/cordinc_tooltip.js @@ -71,11 +71,14 @@ var Tooltip = Class.create({ parentId.insertBefore(this.clone, successorId); this.clone.setStyle({ - position:'absolute', + position: 'absolute', top: position.top + "px", left: position.left + "px", display: "inline", - zIndex:this.options.zindex + zIndex:this.options.zindex, + /* fix for ur dashboard */ + visibility: 'visible', + width: "400px" }); if (this.options.start_effect) { From 96f62eb32ee2dd8c376b8c31ecf46a2d62a82000 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Fri, 8 Apr 2011 12:27:22 +0200 Subject: [PATCH 13/52] Moved help/tooltip css into extra file. --- assets/stylesheets/help.css | 39 ++++++++++++++++++++++++++++++++ assets/stylesheets/reporting.css | 38 ------------------------------- 2 files changed, 39 insertions(+), 38 deletions(-) create mode 100644 assets/stylesheets/help.css diff --git a/assets/stylesheets/help.css b/assets/stylesheets/help.css new file mode 100644 index 0000000000..d8b800e38c --- /dev/null +++ b/assets/stylesheets/help.css @@ -0,0 +1,39 @@ +.help { + margin-left: 5px; + margin-right: 5px; +} + +.tooltip { + position: absolute; + margin-top: 3px; + margin-bottom: 3px; + padding: 3px; + width: 400px; + z-index: 256; + color: #000000; + border: 1px solid #000000; + background: #FFFFCC; + font: 12px Verdana, sans-serif; + text-align: left; + padding: -50px; + line-height: 16px; + font-size: 11px; +} + +.filter-icon { + +} + +.filter-tip { + +} + +.group-by-icon { + float: right; + margin-right: 5px; +} + +.group-by-tip { + margin-top: -300px; + margin-left: -475px; +} \ No newline at end of file diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index bce9ba64a2..9bffd0b6ab 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -500,41 +500,3 @@ html>body #ajax-indicator { position: fixed; } padding-left: 26px; vertical-align: bottom; } - -.help { - margin-left: 5px; - margin-right: 5px; -} - -.tooltip { - position: absolute; - margin-top: 3px; - margin-bottom: 3px; - padding: 3px; - width: 400px; - z-index: 256; - color: #000000; - border: 1px solid #000000; - background: #FFFFCC; - font: 12px Verdana, sans-serif; - text-align: left; - padding: -50px; -} - -.filter-icon { - -} - -.filter-tip { - -} - -.group-by-icon { - float: right; - margin-right: 5px; -} - -.group-by-tip { - margin-top: -300px; - margin-left: -475px; -} From 4aa20a8e7759d34b980248fa6c37fb601aaba82e Mon Sep 17 00:00:00 2001 From: Philipp Tessenow Date: Wed, 13 Apr 2011 14:37:24 +0200 Subject: [PATCH 14/52] fix filters.js bug - under certain circumstances too many filters were selected as source for narrowing values --- assets/javascripts/reporting/filters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/javascripts/reporting/filters.js b/assets/javascripts/reporting/filters.js index 1cd6785d50..29658c8cc2 100644 --- a/assets/javascripts/reporting/filters.js +++ b/assets/javascripts/reporting/filters.js @@ -293,7 +293,7 @@ Reporting.Filters = { // return an array of all filters that depend on the given filter plus the given filter dependent_for: function(field) { var deps = $$('.filters-select[data-all-dependents]').findAll(function(selectBox) { - return Reporting.Filters.get_dependents(selectBox).include(field) + return selectBox.up('tr').visible() && Reporting.Filters.get_dependents(selectBox).include(field) }).map(function(selectBox) { return selectBox.getAttribute("data-filter-name"); }); From 32fb32fdd8d1ba39d69e1886225931afe414fc57 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 17:45:58 +0200 Subject: [PATCH 15/52] New option to place tooltip somewhere else than next to the target. --- assets/javascripts/cordinc_tooltip.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/cordinc_tooltip.js b/assets/javascripts/cordinc_tooltip.js index 8335c035ed..51891ede30 100644 --- a/assets/javascripts/cordinc_tooltip.js +++ b/assets/javascripts/cordinc_tooltip.js @@ -31,8 +31,8 @@ var Tooltip = Class.create({ className: false, delay: {} }, arguments[2] || {}); - this.target = $(target); + this.show_at = (options.show_at_id !== undefined) ? $(options.show_at_id) : undefined this.tooltip = $(tooltip); this.options = options; this.event_target = this.options.trigger?$(this.options.trigger):this.target; @@ -62,12 +62,13 @@ var Tooltip = Class.create({ }, showTooltip: function(event) { + var show_at = (this.show_at !== undefined) ? this.show_at : this.target this.display=true; position = this.positionTooltip(event); this.clone = this.tooltip.cloneNode(true); - parentId = this.options.DOM_location?$(this.options.DOM_location.parentId):this.target.parentNode; - successorId = this.options.DOM_location?$(this.options.DOM_location.successorId):this.target; + parentId = this.options.DOM_location?$(this.options.DOM_location.parentId):show_at.parentNode; + successorId = this.options.DOM_location?$(this.options.DOM_location.successorId):show_at.target; parentId.insertBefore(this.clone, successorId); this.clone.setStyle({ From 96e6775361ca46367b901b86b3d029def20fc492 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 17:47:21 +0200 Subject: [PATCH 16/52] Consider help text from render_with_options (bugfix). --- lib/widget/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widget/base.rb b/lib/widget/base.rb index 2923cc86a0..a96299e4f9 100644 --- a/lib/widget/base.rb +++ b/lib/widget/base.rb @@ -11,7 +11,7 @@ class Widget::Base < Widget end def render_with_options(options = {}, &block) - help_text = options[:help_text] + self.help_text = options[:help_text] if canvas = options[:to] canvas << "\n" << render(&block) else From 0d7bf4a0a47d586ddd54bd892564a538579666c5 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 17:48:51 +0200 Subject: [PATCH 17/52] Enable show_at_id for tooltips. --- lib/widget/controls/help.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/widget/controls/help.rb b/lib/widget/controls/help.rb index 62650239d5..0283e9bc49 100644 --- a/lib/widget/controls/help.rb +++ b/lib/widget/controls/help.rb @@ -7,9 +7,12 @@ class Widget::Controls::Help < Widget::Base id = "tip:#{@query}" options = {:icon => {}, :tooltip => {}} options.merge!(yield) if block_given? + sai = options[:show_at_id] ? ", show_at_id: '#{options[:show_at_id]}'" : "" + icon = tag :img, :src => '/images/icon_info_red.gif', :id => "target:#{@query}" tip = content_tag_string :div, l(@query), tip_config(options[:tooltip]), false - script = content_tag_string :script, "new Tooltip('target:#{@query}', 'tip:#{@query}', {className: 'tooltip'});", + script = content_tag :script, + "new Tooltip('target:#{@query}', 'tip:#{@query}', {className: 'tooltip'#{sai}});", {:type => 'text/javascript'}, false target = content_tag :a, icon + tip, icon_config(options[:icon]) target + script From bdf200bbfa8fd8bee64c58194b2f4938051e77c7 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 17:56:15 +0200 Subject: [PATCH 18/52] fixed indentation --- lib/widget/group_bys.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widget/group_bys.rb b/lib/widget/group_bys.rb index 1ae29b8afa..49cf7b84c7 100644 --- a/lib/widget/group_bys.rb +++ b/lib/widget/group_bys.rb @@ -50,7 +50,7 @@ class Widget::GroupBys < Widget::Base maybe_with_help out.html_safe, { :icon => { :class => 'group-by-icon' - }, + }, :tooltip => { :class => 'group-by-tip' } From 87e162b09a84c19ed0d1f9ae4dc34f4fb1d4c7d1 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 17:56:36 +0200 Subject: [PATCH 19/52] enabled help for SaveAs button --- lib/widget/controls/save_as.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widget/controls/save_as.rb b/lib/widget/controls/save_as.rb index 5ae48ed33e..e89f4f72ed 100644 --- a/lib/widget/controls/save_as.rb +++ b/lib/widget/controls/save_as.rb @@ -10,7 +10,7 @@ class Widget::Controls::SaveAs < Widget::Base button = link_to content_tag(:span, content_tag(:em, link_name, :class => "button-icon icon-save-as")), "#", :class => "button secondary", :id => 'query-icon-save-as', :title => link_name - button + render_popup + maybe_with_help(button) + render_popup end def render_popup_form From d0a8d43de657c831b4058b87137fa19d48832af7 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 18:00:36 +0200 Subject: [PATCH 20/52] Enabled help for filter and group-by legends. --- assets/stylesheets/help.css | 16 ++++++++++++++++ lib/widget/settings/fieldset.rb | 8 +++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/assets/stylesheets/help.css b/assets/stylesheets/help.css index d8b800e38c..4330734532 100644 --- a/assets/stylesheets/help.css +++ b/assets/stylesheets/help.css @@ -36,4 +36,20 @@ .group-by-tip { margin-top: -300px; margin-left: -475px; +} + +.filter-legend-icon { + +} + +.filter-legend-tip { + margin-left: 10px; +} + +.group_by-legend-icon { + +} + +.group_by-legend-tip { + margin-left: 10px; } \ No newline at end of file diff --git a/lib/widget/settings/fieldset.rb b/lib/widget/settings/fieldset.rb index c4f71d2d22..82ea1f4ef6 100644 --- a/lib/widget/settings/fieldset.rb +++ b/lib/widget/settings/fieldset.rb @@ -7,8 +7,14 @@ class Widget::Settings::Fieldset < Widget::Base end def render + hash = self.hash content_tag :fieldset, :id => @id, :class => "collapsible collapsed" do - html = content_tag :legend, l(@label), :onclick => "toggleFieldset(this);" #FIXME: onclick + content = maybe_with_help l(@label), + :show_at_id => hash.to_s, + :icon => { :class => "#{@type}-legend-icon" }, + :tooltip => { :class => "#{@type}-legend-tip" } + html = content_tag :legend, content, + {:onclick => "toggleFieldset(this);", :id => hash.to_s}, false #FIXME: onclick html + yield end end From f423fbfd4a6e3cdc49453752416784dbf4c295db Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 18:01:00 +0200 Subject: [PATCH 21/52] Set help texts for filter and group-by legends. --- lib/widget/settings.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/widget/settings.rb b/lib/widget/settings.rb index f134cef9c2..b10eabdf36 100644 --- a/lib/widget/settings.rb +++ b/lib/widget/settings.rb @@ -3,11 +3,13 @@ class Widget::Settings < Widget::Base form_tag("#", {:id => 'query_form', :method => :post}) do content_tag :div, :id => "query_form_content" do - fieldsets = render_widget Widget::Settings::Fieldset, @query, { :type => "filter" } do + fieldsets = render_widget Widget::Settings::Fieldset, @query, + { :type => "filter", :help_text => :help_filters } do render_widget Widget::Filters, @query end - fieldsets += render_widget Widget::Settings::Fieldset, @query, { :type => "group_by" } do + fieldsets += render_widget Widget::Settings::Fieldset, @query, + { :type => "group_by", :help_text => :help_group_by } do render_widget Widget::GroupBys, @query end @@ -18,7 +20,6 @@ class Widget::Settings < Widget::Base render_widget(Widget::Controls::Clear, @query, :to => widgets) render_widget(Widget::Controls::Delete, @query, :to => widgets) end - fieldsets + controls end end From 48b9d9edecf2f3ee4e3cfd1bee268de7142e228e Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 18:48:24 +0200 Subject: [PATCH 22/52] removed hard-coded help texts and made them configurable --- lib/widget/settings.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/widget/settings.rb b/lib/widget/settings.rb index b10eabdf36..aa259f07ab 100644 --- a/lib/widget/settings.rb +++ b/lib/widget/settings.rb @@ -4,12 +4,12 @@ class Widget::Settings < Widget::Base content_tag :div, :id => "query_form_content" do fieldsets = render_widget Widget::Settings::Fieldset, @query, - { :type => "filter", :help_text => :help_filters } do + { :type => "filter", :help_text => self.filter_help } do render_widget Widget::Filters, @query end fieldsets += render_widget Widget::Settings::Fieldset, @query, - { :type => "group_by", :help_text => :help_group_by } do + { :type => "group_by", :help_text => self.group_by_help } do render_widget Widget::GroupBys, @query end @@ -24,4 +24,20 @@ class Widget::Settings < Widget::Base end end end + + def filter_help + if help_text.kind_of?(Array) + help_text[0] + else + nil + end + end + + def group_by_help + if help_text.kind_of?(Array) + help_text[1] + else + nil + end + end end From c5cd5934188c39dcbf052d6220b846116b34fbe2 Mon Sep 17 00:00:00 2001 From: Wieland Lindenthal Date: Wed, 20 Apr 2011 13:08:26 +0200 Subject: [PATCH 23/52] Giving the group-by areas a background in order to signal to which a select box belongs, cols or rows. --- assets/stylesheets/reporting.css | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index 5bf167752d..b3976c8fca 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -306,12 +306,14 @@ fieldset#filter-settings table td > label { } .drag_container { - padding: 7px 0; + padding: 0; height: 22px; + margin-bottom: 1em; + background-color: #EEE; } .drag_container select { - margin-right: 20px; + margin-right: 3px; float: right; } From 48d70e548cce69c8e3063dd6a138112945e56c28 Mon Sep 17 00:00:00 2001 From: Philipp Tessenow Date: Wed, 20 Apr 2011 16:54:16 +0200 Subject: [PATCH 24/52] change typo in comment --- lib/report/table.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/report/table.rb b/lib/report/table.rb index e4fc8470b3..271b945bee 100644 --- a/lib/report/table.rb +++ b/lib/report/table.rb @@ -35,7 +35,7 @@ class Report::Table ## # @param [Array] expected Fields expected - # @param [Array,Hash,Resul] given Fields/result to be tested + # @param [Array,Hash,Result] given Fields/result to be tested # @return [TrueClass,FalseClass] def satisfies?(type, expected, given) given = fields_from(given, type) if given.respond_to? :to_hash From 5cdc1e33520cc225f9c37c387c7c05077004e2f8 Mon Sep 17 00:00:00 2001 From: Philipp Tessenow Date: Wed, 20 Apr 2011 16:54:48 +0200 Subject: [PATCH 25/52] map value, but convert nils different now. So they can stay at the end of the table --- lib/report/query_utils.rb | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/report/query_utils.rb b/lib/report/query_utils.rb index ec18c7eceb..08e62597ef 100644 --- a/lib/report/query_utils.rb +++ b/lib/report/query_utils.rb @@ -167,10 +167,39 @@ module Report::QueryUtils "-- code specific for #{adapter_name}\n\t" << super(field) end + ## + # Converts value with a given behavior, but treats nil differently. + # Params + # - value: the value to convert + # - weight_of_nil (optional): How a nil should be treated. + # :infinit - makes a nil weight really heavy, which will make it stay + # at the very end when sorting + # :negative_infinit - opposite of :infinit, let's the nil stay at the very beginning + # any other object - nil's will be replaced by thyt object + # - block (optional) - defines how to convert values which are not nil + # if no block is given, values stay untouched + def convert_unless_nil(value, weight_of_nil = :infinit) + if value.nil? + if weight_of_nil == :infinit + 1.0/0 # Infinity, which is greater than any string or number + elsif weight_of_nil == :negative_infinit + -1.0/0 # negative Infinity, which is smaller than any string or number + else + weight_of_nil + end + else + if block_given? + yield value + else + value + end + end + end + def map_field(key, value) case key.to_s - when "singleton_value", /_id$/ then value.to_i - else value.to_s + when "singleton_value", /_id$/ then convert_unless_nil(value) {|v| v.to_i } + else convert_unless_nil(value) {|v| v.to_s } end end From 0c1d928dcb1b942f36b12e716da4b3b9799a6948 Mon Sep 17 00:00:00 2001 From: Philipp Tessenow Date: Wed, 20 Apr 2011 17:20:05 +0200 Subject: [PATCH 26/52] have better translations vor none --- config/locales/de.yml | 2 +- config/locales/en.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index d2d7664105..54ae818a9e 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -16,7 +16,7 @@ de: label_count: Anzahl label_sum: Summe - label_none: "(no value)" + label_none: "(Keine Angabe)" description_drill_down: Details anzeigen diff --git a/config/locales/en.yml b/config/locales/en.yml index a879c64de6..27dbbf983a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -16,7 +16,7 @@ en: label_count: Count label_sum: Sum - label_none: "(no value)" + label_none: "(no data)" description_drill_down: Show details From 3eab89f4808c682c758d9989a16210a3222d60cc Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Wed, 27 Apr 2011 10:31:31 +0200 Subject: [PATCH 27/52] fixed 'invalid arg' bug --- assets/javascripts/cordinc_tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/javascripts/cordinc_tooltip.js b/assets/javascripts/cordinc_tooltip.js index 51891ede30..c4c2ee260c 100644 --- a/assets/javascripts/cordinc_tooltip.js +++ b/assets/javascripts/cordinc_tooltip.js @@ -68,7 +68,7 @@ var Tooltip = Class.create({ this.clone = this.tooltip.cloneNode(true); parentId = this.options.DOM_location?$(this.options.DOM_location.parentId):show_at.parentNode; - successorId = this.options.DOM_location?$(this.options.DOM_location.successorId):show_at.target; + successorId = this.options.DOM_location?$(this.options.DOM_location.successorId):show_at; parentId.insertBefore(this.clone, successorId); this.clone.setStyle({ From f1c47a2babd8f8444113a8eaaaa8612ba2377a26 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Wed, 27 Apr 2011 11:00:44 +0200 Subject: [PATCH 28/52] [FIT #19060] Redirect to default report upon deleting an old one --- lib/report/controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/report/controller.rb b/lib/report/controller.rb index fc06739361..a693016214 100644 --- a/lib/report/controller.rb +++ b/lib/report/controller.rb @@ -65,7 +65,7 @@ module Report::Controller else raise ActiveRecord::RecordNotFound end - redirect_to :action => "index" + redirect_to :action => "index", :default => 1 end ## From 9c956977e6bc0896631207d842c83f91572e1bc9 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Fri, 1 Apr 2011 11:47:48 +0200 Subject: [PATCH 29/52] Added Help Widget and put one next to the filter selection for demonstration. --- assets/stylesheets/reporting.css | 24 ++++++++++++++++++++++++ config/locales/de.yml | 4 ++++ config/locales/en.yml | 2 ++ lib/widget/controls/help.rb | 11 +++++++++++ lib/widget/filters.rb | 6 ++++-- 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 lib/widget/controls/help.rb diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index b3976c8fca..bfd9207788 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -507,3 +507,27 @@ html>body #ajax-indicator { position: fixed; } padding-left: 26px; vertical-align: bottom; } + +a.help { + margin-left: 10px; +} + +a.help span { + display: none; + text-decoration: none; +} + +a.help:hover span { + display: block; + position: absolute; + margin-top: 3px; + margin-bottom: 3px; + padding: 3px; + width: 300px; + z-index: 9999; + color: #000000; + border: 1px dashed #000000; + background: #FFFFCC; + font: 12px Verdana, sans-serif; + text-align: left; +} diff --git a/config/locales/de.yml b/config/locales/de.yml index 54ae818a9e..24f2d2eac6 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -18,7 +18,11 @@ de: label_sum: Summe label_none: "(Keine Angabe)" + label_help: Hilfe + description_drill_down: Details anzeigen validation_failure_date: "ist kein gültiges Datum" validation_failure_integer: "ist keine ganze Zahl" + + help_filters: Über Filter:
Mit Hilfe von Filtern kann die Ergebnismenge reduziert werden. Beispielsweise möchte man vielleicht einen Bericht nur für ein bestimmtes Land erhalten ... diff --git a/config/locales/en.yml b/config/locales/en.yml index 27dbbf983a..a48dae7e0a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -18,6 +18,8 @@ en: label_sum: Sum label_none: "(no data)" + label_help: Help + description_drill_down: Show details validation_failure_date: "is not a valid date" diff --git a/lib/widget/controls/help.rb b/lib/widget/controls/help.rb new file mode 100644 index 0000000000..147a13333e --- /dev/null +++ b/lib/widget/controls/help.rb @@ -0,0 +1,11 @@ +## +# Usgae: render_widget Widget::Controls::Help, :text +# +# Where :text is a i18n key. +class Widget::Controls::Help < Widget::Base + def render + icon = tag :img, :src => '/images/help.png', :alt => '?' + span = content_tag_string :span, l(@query), {}, false + content_tag :a, icon + span, :href => "#", :class => "help" + end +end \ No newline at end of file diff --git a/lib/widget/filters.rb b/lib/widget/filters.rb index c924cdd107..4b40acd5a7 100644 --- a/lib/widget/filters.rb +++ b/lib/widget/filters.rb @@ -12,10 +12,12 @@ class Widget::Filters < Widget::Base end end select = content_tag :div, :id => "add_filter_block" do - select_tag 'add_filter_select', + add_filter = select_tag 'add_filter_select', options_for_select([["-- #{l(:label_filter_add)} --",'']] + selectables), :class => "select-small", :name => nil + help = render_widget Widget::Controls::Help, :help_filters + add_filter + help end content_tag(:div, table + select) end @@ -72,4 +74,4 @@ class Widget::Filters < Widget::Base end render_widget Filters::RemoveButton, f, :to => html end -end \ No newline at end of file +end From 195fdc2046e38d02ac99280f56631257baed288d Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 4 Apr 2011 12:07:59 +0200 Subject: [PATCH 30/52] cleaned up debris --- assets/stylesheets/reporting.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index bfd9207788..ac0c760bff 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -531,3 +531,5 @@ a.help:hover span { font: 12px Verdana, sans-serif; text-align: left; } + +} \ No newline at end of file From 33644dff5f265858160be78e85637342051563a7 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 4 Apr 2011 18:13:10 +0200 Subject: [PATCH 31/52] Integrated help widget rendering into Widget Base. Implemented custom rendering for Filters and GroupBy Widgets. --- assets/stylesheets/reporting.css | 8 ++++--- lib/widget/base.rb | 21 +++++++++++++++++++ lib/widget/controls/help.rb | 36 ++++++++++++++++++++++++++++---- lib/widget/filters.rb | 10 +++++++-- lib/widget/group_bys.rb | 9 +++++++- 5 files changed, 74 insertions(+), 10 deletions(-) diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index ac0c760bff..800dc0e6aa 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -512,6 +512,10 @@ a.help { margin-left: 10px; } +a.help div { + position: relative; +} + a.help span { display: none; text-decoration: none; @@ -526,10 +530,8 @@ a.help:hover span { width: 300px; z-index: 9999; color: #000000; - border: 1px dashed #000000; + border: 1px solid #000000; background: #FFFFCC; font: 12px Verdana, sans-serif; text-align: left; } - -} \ No newline at end of file diff --git a/lib/widget/base.rb b/lib/widget/base.rb index b44567b4d6..a58e92b050 100644 --- a/lib/widget/base.rb +++ b/lib/widget/base.rb @@ -17,4 +17,25 @@ class Widget::Base < Widget render(&block) end end + + ## + # An optional help text. If defined the Help Widget + # displaying the given text is going to be placed + # next to this Widget, if it supports that. + def help_text; end + + ## + # Appends the Help Widget with this Widget's help text + # if it is defined to the input. + # If the help text is not defined the input is returned. + def maybe_with_help(html, options = {}) + if help_text + help = render_widget Widget::Controls::Help, help_text do + options + end + html + help + else + html + end + end end diff --git a/lib/widget/controls/help.rb b/lib/widget/controls/help.rb index 147a13333e..b08a93f5a4 100644 --- a/lib/widget/controls/help.rb +++ b/lib/widget/controls/help.rb @@ -4,8 +4,36 @@ # Where :text is a i18n key. class Widget::Controls::Help < Widget::Base def render - icon = tag :img, :src => '/images/help.png', :alt => '?' - span = content_tag_string :span, l(@query), {}, false - content_tag :a, icon + span, :href => "#", :class => "help" + options = {:icon => {}, :tooltip => {}} + options.merge!(yield) if block_given? + icon = tag :img, :src => '/images/help.png' + span = content_tag_string :span, l(@query), options[:tooltip], false + hull = content_tag :div, span + icon_options = icon_config(options[:icon]) + content_tag :a, icon + hull, icon_options end -end \ No newline at end of file + + def icon_config(options) + add_class = lambda do |cl| + if cl + "help #{cl}" + else + "help" + end + end + options.mega_merge! :href => '#', :class => add_class + end +end + +class Hash + def mega_merge!(hash) + hash.each do |key, value| + if value.kind_of?(Proc) + self[key] = value.call(self[key]) + else + self[key] = value + end + end + self + end +end diff --git a/lib/widget/filters.rb b/lib/widget/filters.rb index 4b40acd5a7..829b646631 100644 --- a/lib/widget/filters.rb +++ b/lib/widget/filters.rb @@ -16,8 +16,14 @@ class Widget::Filters < Widget::Base options_for_select([["-- #{l(:label_filter_add)} --",'']] + selectables), :class => "select-small", :name => nil - help = render_widget Widget::Controls::Help, :help_filters - add_filter + help + maybe_with_help add_filter, { + :icon => { + :class => 'filter-icon' + }, + :tooltip => { + :class => 'filter-tip' + } + } end content_tag(:div, table + select) end diff --git a/lib/widget/group_bys.rb b/lib/widget/group_bys.rb index 5265204d6a..35ba298f10 100644 --- a/lib/widget/group_bys.rb +++ b/lib/widget/group_bys.rb @@ -46,7 +46,14 @@ class Widget::GroupBys < Widget::Base end.join.html_safe content end - out.html_safe + maybe_with_help out.html_safe, { + :icon => { + :class => 'group-by-icon' + }, + :tooltip => { + :class => 'group-by-tip' + } + } end end From df0a575e2202b7a6daf22b0c06d566a0af4f7c7d Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 4 Apr 2011 18:13:30 +0200 Subject: [PATCH 32/52] Removed UR specific translation. --- config/locales/de.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index 24f2d2eac6..cebf2a946f 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -24,5 +24,4 @@ de: validation_failure_date: "ist kein gültiges Datum" validation_failure_integer: "ist keine ganze Zahl" - - help_filters: Über Filter:
Mit Hilfe von Filtern kann die Ergebnismenge reduziert werden. Beispielsweise möchte man vielleicht einen Bericht nur für ein bestimmtes Land erhalten ... + From 3a86896c1bac9be6512f5b965684af373e6e36da Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 4 Apr 2011 18:58:50 +0200 Subject: [PATCH 33/52] changed help icon --- assets/images/icon_info_red.gif | Bin 0 -> 67 bytes lib/widget/controls/help.rb | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 assets/images/icon_info_red.gif diff --git a/assets/images/icon_info_red.gif b/assets/images/icon_info_red.gif new file mode 100644 index 0000000000000000000000000000000000000000..34de8c6b9824f786fcc7f571bfccb69c3248a11a GIT binary patch literal 67 zcmZ?wbhEHb {}, :tooltip => {}} options.merge!(yield) if block_given? - icon = tag :img, :src => '/images/help.png' + icon = tag :img, :src => '/images/icon_info_red.gif' span = content_tag_string :span, l(@query), options[:tooltip], false hull = content_tag :div, span icon_options = icon_config(options[:icon]) From edfb2673f7d438dedb1323d444f0ab6377fc7ac6 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 4 Apr 2011 18:59:17 +0200 Subject: [PATCH 34/52] only render a help icon next to one of the two group-by selections --- lib/widget/group_bys.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/widget/group_bys.rb b/lib/widget/group_bys.rb index 35ba298f10..1ae29b8afa 100644 --- a/lib/widget/group_bys.rb +++ b/lib/widget/group_bys.rb @@ -24,7 +24,7 @@ class Widget::GroupBys < Widget::Base end end - def render_group(type, initially_selected) + def render_group(type, initially_selected, show_help = false) initially_selected = initially_selected.map do |group_by| [group_by.class.underscore_name, l(group_by.class.label)] end @@ -46,20 +46,24 @@ class Widget::GroupBys < Widget::Base end.join.html_safe content end - maybe_with_help out.html_safe, { - :icon => { - :class => 'group-by-icon' - }, - :tooltip => { - :class => 'group-by-tip' + if show_help + maybe_with_help out.html_safe, { + :icon => { + :class => 'group-by-icon' + }, + :tooltip => { + :class => 'group-by-tip' + } } - } + else + out.html_safe + end end end def render content_tag :div, :id => 'group_by_area' do - out = render_group 'columns', @query.group_bys(:column) + out = render_group 'columns', @query.group_bys(:column), true out += render_group 'rows', @query.group_bys(:row) out.html_safe end From 2898fc3aa036deb4ca3fe5481c287a67c0b1eedb Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 5 Apr 2011 14:34:35 +0200 Subject: [PATCH 35/52] Mitigate 'info icon hover deformation' in Chrome & Safari a tiny bit. --- assets/stylesheets/reporting.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index 800dc0e6aa..bba5bfc3ac 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -521,6 +521,10 @@ a.help span { text-decoration: none; } +a.help div { + display: none; +} + a.help:hover span { display: block; position: absolute; From 6a0f39b397bf6b631fa403b57f2f84fcbf289d4c Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 5 Apr 2011 14:38:34 +0200 Subject: [PATCH 36/52] Make help text an instance variable and overridable in maybe_with_help. --- lib/widget/base.rb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/widget/base.rb b/lib/widget/base.rb index a58e92b050..2923cc86a0 100644 --- a/lib/widget/base.rb +++ b/lib/widget/base.rb @@ -11,26 +11,35 @@ class Widget::Base < Widget end def render_with_options(options = {}, &block) + help_text = options[:help_text] if canvas = options[:to] canvas << "\n" << render(&block) else render(&block) end end - + ## # An optional help text. If defined the Help Widget # displaying the given text is going to be placed # next to this Widget, if it supports that. - def help_text; end - + def help_text + @help_text + end + + def help_text=(text) + @help_text = text + end + ## # Appends the Help Widget with this Widget's help text # if it is defined to the input. # If the help text is not defined the input is returned. def maybe_with_help(html, options = {}) - if help_text - help = render_widget Widget::Controls::Help, help_text do + text = options[:text] + text ||= help_text unless options[:ignore_default] + if text + help = render_widget Widget::Controls::Help, text do options end html + help From c134acbedf9364c178e8b05a42483f705b6d7ed0 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 5 Apr 2011 15:13:41 +0200 Subject: [PATCH 37/52] Help texts for individual filters. --- lib/report/chainable.rb | 16 +++++++++++++++- lib/widget/filters.rb | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/report/chainable.rb b/lib/report/chainable.rb index 8bc4b5aa2b..38476e357a 100644 --- a/lib/report/chainable.rb +++ b/lib/report/chainable.rb @@ -309,7 +309,6 @@ class Report < ActiveRecord::Base value.to_s end - def self.mapping_for(field) @field_map ||= (engine::Filter.all + engine.GroupBy.all).inject(Hash.new {|h,k| h[k] = []}) do |hash,cbl| hash[cbl.field] << cbl.mapping @@ -317,5 +316,20 @@ class Report < ActiveRecord::Base @field_map[field] end + def help_text + self.class.help_text + end + + ## + # Sets a help text to be displayed for this kind of Chainable. + def self.help_text=(sym) + @help_text = sym + end + + def self.help_text(sym = nil) + @help_text = sym if sym + @help_text + end + end end diff --git a/lib/widget/filters.rb b/lib/widget/filters.rb index 829b646631..48cc5256aa 100644 --- a/lib/widget/filters.rb +++ b/lib/widget/filters.rb @@ -78,6 +78,20 @@ class Widget::Filters < Widget::Base render_widget Filters::MultiValues, f, :to => html end end + render_filter_help f, :to => html render_widget Filters::RemoveButton, f, :to => html end + + def render_filter_help(filter, options = {}) + html = content_tag :td, :width => "25px" do + if filter.help_text + render_widget Widget::Controls::Help, filter.help_text + end + end + if canvas = options[:to] + canvas << "\n" << html + else + html + end + end end From d9980d408ceb80c54ba8c2574e1e109627482c05 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 5 Apr 2011 18:46:04 +0200 Subject: [PATCH 38/52] Enabled help text for Clear Control. --- lib/widget/controls/clear.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/widget/controls/clear.rb b/lib/widget/controls/clear.rb index f460105a8d..c58570e7ab 100644 --- a/lib/widget/controls/clear.rb +++ b/lib/widget/controls/clear.rb @@ -1,5 +1,6 @@ class Widget::Controls::Clear < Widget::Base def render - link_to content_tag(:span, content_tag(:em, l(:"button_clear"), :class => "button-icon icon-clear")), '#', :id => 'query-link-clear', :class => 'button secondary' + html = link_to content_tag(:span, content_tag(:em, l(:"button_clear"), :class => "button-icon icon-clear")), '#', :id => 'query-link-clear', :class => 'button secondary' + maybe_with_help html end end From d2e2e146ee926fc5180b1a6039b423de8d6ce179 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Fri, 8 Apr 2011 10:09:08 +0200 Subject: [PATCH 39/52] Use cordinc_tooltip; made icon and diff customizable. --- assets/javascripts/cordinc_tooltip.js | 155 ++++++++++++++++++++++++++ assets/stylesheets/reporting.css | 25 +---- lib/widget/controls/help.rb | 23 +++- 3 files changed, 179 insertions(+), 24 deletions(-) create mode 100644 assets/javascripts/cordinc_tooltip.js diff --git a/assets/javascripts/cordinc_tooltip.js b/assets/javascripts/cordinc_tooltip.js new file mode 100644 index 0000000000..cb8e48ae44 --- /dev/null +++ b/assets/javascripts/cordinc_tooltip.js @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2009 Charles Cordingley (www.cordinc.com) + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * cordinc_tooltip.js, v1.0.2 - 27 August 2008 + * For help see www.cordinc.com/projects/tooltips.html + */ +var Tooltip = Class.create({ + initialize: function(target, tooltip) { + var options = Object.extend({ + start_effect: function(element) {}, + end_effect: function(element) {}, + zindex: 1000, + offset: {x:0, y:0}, + hook: {target:'topRight', tip:'bottomLeft'}, + trigger: false, + DOM_location: false, + className: false, + delay: {} + }, arguments[2] || {}); + + this.target = $(target); + this.tooltip = $(tooltip); + this.options = options; + this.event_target = this.options.trigger?$(this.options.trigger):this.target; + + if (this.options.className) { + this.tooltip.addClassName(this.options.className); + } + this.tooltip.hide(); + this.display=false; + + this.mouse_over = this.displayTooltip.bindAsEventListener(this); + this.mouse_out = this.removeTooltip.bindAsEventListener(this); + this.event_target.observe("mouseover", this.mouse_over); + this.event_target.observe("mouseout", this.mouse_out); + }, + + displayTooltip: function(event){ + event.stop(); + + if (this.display) {return;} + if (this.options.delay.start) { + var self = this; + this.timer_id = setTimeout(function(){self.timer_id = false; self.showTooltip(event);}, this.options.delay.start*1000); + } else { + this.showTooltip(event); + } + }, + + showTooltip: function(event) { + this.display=true; + position = this.positionTooltip(event); + + this.clone = this.tooltip.cloneNode(true); + parentId = this.options.DOM_location?$(this.options.DOM_location.parentId):this.target.parentNode; + successorId = this.options.DOM_location?$(this.options.DOM_location.successorId):this.target; + parentId.insertBefore(this.clone, successorId); + + this.clone.setStyle({ + position:'absolute', + top: position.top + "px", + left: position.left + "px", + display: "inline", + zIndex:this.options.zindex + }); + + if (this.options.start_effect) { + this.options.start_effect(this.clone); + } + }, + + positionTooltip: function(event) { + target_position = this.target.cumulativeOffset(); + + tooltip_dimensions = this.tooltip.getDimensions(); + target_dimensions = this.target.getDimensions(); + + this.positionModify(target_position, target_dimensions, this.options.hook.target, 1); + this.positionModify(target_position, tooltip_dimensions, this.options.hook.tip, -1); + + target_position.top += this.options.offset.y; + target_position.left += this.options.offset.x; + + return target_position; + }, + + positionModify: function(position, box, corner, neg) { + if (corner == 'topRight') { + position.left += box.width*neg; + } else if (corner == 'topLeft') { + } else if (corner == 'bottomLeft') { + position.top += box.height*neg; + } else if (corner == 'bottomRight') { + position.top += box.height*neg; + position.left += box.width*neg; + } else if (corner == 'topMid') { + position.left += (box.width/2)*neg; + } else if (corner == 'leftMid') { + position.top += (box.height/2)*neg; + } else if (corner == 'bottomMid') { + position.top += box.height*neg; + position.left += (box.width/2)*neg; + } else if (corner == 'rightMid') { + position.top += (box.height/2)*neg; + position.left += box.width*neg; + } + }, + + removeTooltip: function(event) { + if (this.timer_id) { + clearTimeout(this.timer_id); + this.timer_id = false; + return; + } + + if (this.options.end_effect) { + this.options.end_effect(this.clone); + } + + if (this.options.delay.end) { + var self = this; + setTimeout(function(){self.clearTooltip();}, this.options.delay.end*1000); + } else { + this.clearTooltip(); + } + }, + + clearTooltip: function() { + if (this.clone !== undefined && this.clone !== null) { + this.clone.remove(); + this.clone = null; + this.display=false; + } + }, + + destroy: function() { + this.event_target.stopObserving("mouseover", this.mouse_over); + this.event_target.stopObserving("mouseout", this.mouse_out); + this.clearTooltip(); + } +}) \ No newline at end of file diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index bba5bfc3ac..9ad8dd94a0 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -508,31 +508,18 @@ html>body #ajax-indicator { position: fixed; } vertical-align: bottom; } -a.help { - margin-left: 10px; +.help { + margin-left: 5px; + margin-right: 5px; } -a.help div { - position: relative; -} - -a.help span { - display: none; - text-decoration: none; -} - -a.help div { - display: none; -} - -a.help:hover span { - display: block; +.tooltip { position: absolute; margin-top: 3px; margin-bottom: 3px; padding: 3px; - width: 300px; - z-index: 9999; + width: 400px; + z-index: 256; color: #000000; border: 1px solid #000000; background: #FFFFCC; diff --git a/lib/widget/controls/help.rb b/lib/widget/controls/help.rb index 3f0e1e6293..62650239d5 100644 --- a/lib/widget/controls/help.rb +++ b/lib/widget/controls/help.rb @@ -4,13 +4,15 @@ # Where :text is a i18n key. class Widget::Controls::Help < Widget::Base def render + id = "tip:#{@query}" options = {:icon => {}, :tooltip => {}} options.merge!(yield) if block_given? - icon = tag :img, :src => '/images/icon_info_red.gif' - span = content_tag_string :span, l(@query), options[:tooltip], false - hull = content_tag :div, span - icon_options = icon_config(options[:icon]) - content_tag :a, icon + hull, icon_options + icon = tag :img, :src => '/images/icon_info_red.gif', :id => "target:#{@query}" + tip = content_tag_string :div, l(@query), tip_config(options[:tooltip]), false + script = content_tag_string :script, "new Tooltip('target:#{@query}', 'tip:#{@query}', {className: 'tooltip'});", + {:type => 'text/javascript'}, false + target = content_tag :a, icon + tip, icon_config(options[:icon]) + target + script end def icon_config(options) @@ -23,6 +25,17 @@ class Widget::Controls::Help < Widget::Base end options.mega_merge! :href => '#', :class => add_class end + + def tip_config(options) + add_class = lambda do |cl| + if cl + "#{cl} tooltip" + else + "tooltip" + end + end + options.mega_merge! :id => "tip:#{@query}", :class => add_class + end end class Hash From cf11aa99d94febc1d8189e55ce01cf63c44885ca Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Fri, 8 Apr 2011 12:27:04 +0200 Subject: [PATCH 40/52] Ensure tooltip visibility and size. Tooltip JS fix specifically for UR. --- assets/javascripts/cordinc_tooltip.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/cordinc_tooltip.js b/assets/javascripts/cordinc_tooltip.js index cb8e48ae44..8335c035ed 100644 --- a/assets/javascripts/cordinc_tooltip.js +++ b/assets/javascripts/cordinc_tooltip.js @@ -71,11 +71,14 @@ var Tooltip = Class.create({ parentId.insertBefore(this.clone, successorId); this.clone.setStyle({ - position:'absolute', + position: 'absolute', top: position.top + "px", left: position.left + "px", display: "inline", - zIndex:this.options.zindex + zIndex:this.options.zindex, + /* fix for ur dashboard */ + visibility: 'visible', + width: "400px" }); if (this.options.start_effect) { From 59b59ae6026afeae90fe223be38479c5fe426669 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Fri, 8 Apr 2011 12:27:22 +0200 Subject: [PATCH 41/52] Moved help/tooltip css into extra file. --- assets/stylesheets/help.css | 39 ++++++++++++++++++++++++++++++++ assets/stylesheets/reporting.css | 19 ---------------- 2 files changed, 39 insertions(+), 19 deletions(-) create mode 100644 assets/stylesheets/help.css diff --git a/assets/stylesheets/help.css b/assets/stylesheets/help.css new file mode 100644 index 0000000000..d8b800e38c --- /dev/null +++ b/assets/stylesheets/help.css @@ -0,0 +1,39 @@ +.help { + margin-left: 5px; + margin-right: 5px; +} + +.tooltip { + position: absolute; + margin-top: 3px; + margin-bottom: 3px; + padding: 3px; + width: 400px; + z-index: 256; + color: #000000; + border: 1px solid #000000; + background: #FFFFCC; + font: 12px Verdana, sans-serif; + text-align: left; + padding: -50px; + line-height: 16px; + font-size: 11px; +} + +.filter-icon { + +} + +.filter-tip { + +} + +.group-by-icon { + float: right; + margin-right: 5px; +} + +.group-by-tip { + margin-top: -300px; + margin-left: -475px; +} \ No newline at end of file diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index 9ad8dd94a0..b3976c8fca 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -507,22 +507,3 @@ html>body #ajax-indicator { position: fixed; } padding-left: 26px; vertical-align: bottom; } - -.help { - margin-left: 5px; - margin-right: 5px; -} - -.tooltip { - position: absolute; - margin-top: 3px; - margin-bottom: 3px; - padding: 3px; - width: 400px; - z-index: 256; - color: #000000; - border: 1px solid #000000; - background: #FFFFCC; - font: 12px Verdana, sans-serif; - text-align: left; -} From c1031abc1b108e83cae1ce3be4d866fc0c5571cf Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 17:45:58 +0200 Subject: [PATCH 42/52] New option to place tooltip somewhere else than next to the target. --- assets/javascripts/cordinc_tooltip.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/cordinc_tooltip.js b/assets/javascripts/cordinc_tooltip.js index 8335c035ed..51891ede30 100644 --- a/assets/javascripts/cordinc_tooltip.js +++ b/assets/javascripts/cordinc_tooltip.js @@ -31,8 +31,8 @@ var Tooltip = Class.create({ className: false, delay: {} }, arguments[2] || {}); - this.target = $(target); + this.show_at = (options.show_at_id !== undefined) ? $(options.show_at_id) : undefined this.tooltip = $(tooltip); this.options = options; this.event_target = this.options.trigger?$(this.options.trigger):this.target; @@ -62,12 +62,13 @@ var Tooltip = Class.create({ }, showTooltip: function(event) { + var show_at = (this.show_at !== undefined) ? this.show_at : this.target this.display=true; position = this.positionTooltip(event); this.clone = this.tooltip.cloneNode(true); - parentId = this.options.DOM_location?$(this.options.DOM_location.parentId):this.target.parentNode; - successorId = this.options.DOM_location?$(this.options.DOM_location.successorId):this.target; + parentId = this.options.DOM_location?$(this.options.DOM_location.parentId):show_at.parentNode; + successorId = this.options.DOM_location?$(this.options.DOM_location.successorId):show_at.target; parentId.insertBefore(this.clone, successorId); this.clone.setStyle({ From 7ad327f73bc09b4daaa2174a3ac324f965a99b87 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 17:47:21 +0200 Subject: [PATCH 43/52] Consider help text from render_with_options (bugfix). --- lib/widget/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widget/base.rb b/lib/widget/base.rb index 2923cc86a0..a96299e4f9 100644 --- a/lib/widget/base.rb +++ b/lib/widget/base.rb @@ -11,7 +11,7 @@ class Widget::Base < Widget end def render_with_options(options = {}, &block) - help_text = options[:help_text] + self.help_text = options[:help_text] if canvas = options[:to] canvas << "\n" << render(&block) else From 6e6f0acf84709595c19c5d70e53988c5892f17fa Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 17:48:51 +0200 Subject: [PATCH 44/52] Enable show_at_id for tooltips. --- lib/widget/controls/help.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/widget/controls/help.rb b/lib/widget/controls/help.rb index 62650239d5..0283e9bc49 100644 --- a/lib/widget/controls/help.rb +++ b/lib/widget/controls/help.rb @@ -7,9 +7,12 @@ class Widget::Controls::Help < Widget::Base id = "tip:#{@query}" options = {:icon => {}, :tooltip => {}} options.merge!(yield) if block_given? + sai = options[:show_at_id] ? ", show_at_id: '#{options[:show_at_id]}'" : "" + icon = tag :img, :src => '/images/icon_info_red.gif', :id => "target:#{@query}" tip = content_tag_string :div, l(@query), tip_config(options[:tooltip]), false - script = content_tag_string :script, "new Tooltip('target:#{@query}', 'tip:#{@query}', {className: 'tooltip'});", + script = content_tag :script, + "new Tooltip('target:#{@query}', 'tip:#{@query}', {className: 'tooltip'#{sai}});", {:type => 'text/javascript'}, false target = content_tag :a, icon + tip, icon_config(options[:icon]) target + script From 8820cde8406e1ca34aa0306e731e8777ad8e2c10 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 17:56:15 +0200 Subject: [PATCH 45/52] fixed indentation --- lib/widget/group_bys.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widget/group_bys.rb b/lib/widget/group_bys.rb index 1ae29b8afa..49cf7b84c7 100644 --- a/lib/widget/group_bys.rb +++ b/lib/widget/group_bys.rb @@ -50,7 +50,7 @@ class Widget::GroupBys < Widget::Base maybe_with_help out.html_safe, { :icon => { :class => 'group-by-icon' - }, + }, :tooltip => { :class => 'group-by-tip' } From 3d1ba705bf8c2b2de8687682e1f2e5aec2786809 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 17:56:36 +0200 Subject: [PATCH 46/52] enabled help for SaveAs button --- lib/widget/controls/save_as.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widget/controls/save_as.rb b/lib/widget/controls/save_as.rb index 5ae48ed33e..e89f4f72ed 100644 --- a/lib/widget/controls/save_as.rb +++ b/lib/widget/controls/save_as.rb @@ -10,7 +10,7 @@ class Widget::Controls::SaveAs < Widget::Base button = link_to content_tag(:span, content_tag(:em, link_name, :class => "button-icon icon-save-as")), "#", :class => "button secondary", :id => 'query-icon-save-as', :title => link_name - button + render_popup + maybe_with_help(button) + render_popup end def render_popup_form From f701f1ce7a59bc0e78ea182ae841034ac2689bf2 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 18:00:36 +0200 Subject: [PATCH 47/52] Enabled help for filter and group-by legends. --- assets/stylesheets/help.css | 16 ++++++++++++++++ lib/widget/settings/fieldset.rb | 8 +++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/assets/stylesheets/help.css b/assets/stylesheets/help.css index d8b800e38c..4330734532 100644 --- a/assets/stylesheets/help.css +++ b/assets/stylesheets/help.css @@ -36,4 +36,20 @@ .group-by-tip { margin-top: -300px; margin-left: -475px; +} + +.filter-legend-icon { + +} + +.filter-legend-tip { + margin-left: 10px; +} + +.group_by-legend-icon { + +} + +.group_by-legend-tip { + margin-left: 10px; } \ No newline at end of file diff --git a/lib/widget/settings/fieldset.rb b/lib/widget/settings/fieldset.rb index c4f71d2d22..82ea1f4ef6 100644 --- a/lib/widget/settings/fieldset.rb +++ b/lib/widget/settings/fieldset.rb @@ -7,8 +7,14 @@ class Widget::Settings::Fieldset < Widget::Base end def render + hash = self.hash content_tag :fieldset, :id => @id, :class => "collapsible collapsed" do - html = content_tag :legend, l(@label), :onclick => "toggleFieldset(this);" #FIXME: onclick + content = maybe_with_help l(@label), + :show_at_id => hash.to_s, + :icon => { :class => "#{@type}-legend-icon" }, + :tooltip => { :class => "#{@type}-legend-tip" } + html = content_tag :legend, content, + {:onclick => "toggleFieldset(this);", :id => hash.to_s}, false #FIXME: onclick html + yield end end From df635d46a6d6dd58cfeed5827ff9bc761a80d49b Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 18:01:00 +0200 Subject: [PATCH 48/52] Set help texts for filter and group-by legends. --- lib/widget/settings.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/widget/settings.rb b/lib/widget/settings.rb index f134cef9c2..b10eabdf36 100644 --- a/lib/widget/settings.rb +++ b/lib/widget/settings.rb @@ -3,11 +3,13 @@ class Widget::Settings < Widget::Base form_tag("#", {:id => 'query_form', :method => :post}) do content_tag :div, :id => "query_form_content" do - fieldsets = render_widget Widget::Settings::Fieldset, @query, { :type => "filter" } do + fieldsets = render_widget Widget::Settings::Fieldset, @query, + { :type => "filter", :help_text => :help_filters } do render_widget Widget::Filters, @query end - fieldsets += render_widget Widget::Settings::Fieldset, @query, { :type => "group_by" } do + fieldsets += render_widget Widget::Settings::Fieldset, @query, + { :type => "group_by", :help_text => :help_group_by } do render_widget Widget::GroupBys, @query end @@ -18,7 +20,6 @@ class Widget::Settings < Widget::Base render_widget(Widget::Controls::Clear, @query, :to => widgets) render_widget(Widget::Controls::Delete, @query, :to => widgets) end - fieldsets + controls end end From 01cab3618e3d82f04191de8439e0b0f1beee7072 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 19 Apr 2011 18:48:24 +0200 Subject: [PATCH 49/52] removed hard-coded help texts and made them configurable --- lib/widget/settings.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/widget/settings.rb b/lib/widget/settings.rb index b10eabdf36..aa259f07ab 100644 --- a/lib/widget/settings.rb +++ b/lib/widget/settings.rb @@ -4,12 +4,12 @@ class Widget::Settings < Widget::Base content_tag :div, :id => "query_form_content" do fieldsets = render_widget Widget::Settings::Fieldset, @query, - { :type => "filter", :help_text => :help_filters } do + { :type => "filter", :help_text => self.filter_help } do render_widget Widget::Filters, @query end fieldsets += render_widget Widget::Settings::Fieldset, @query, - { :type => "group_by", :help_text => :help_group_by } do + { :type => "group_by", :help_text => self.group_by_help } do render_widget Widget::GroupBys, @query end @@ -24,4 +24,20 @@ class Widget::Settings < Widget::Base end end end + + def filter_help + if help_text.kind_of?(Array) + help_text[0] + else + nil + end + end + + def group_by_help + if help_text.kind_of?(Array) + help_text[1] + else + nil + end + end end From 94b3d1199fc2a27d37009ce087c6cf7254e68e4f Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Wed, 27 Apr 2011 10:31:31 +0200 Subject: [PATCH 50/52] fixed 'invalid arg' bug --- assets/javascripts/cordinc_tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/javascripts/cordinc_tooltip.js b/assets/javascripts/cordinc_tooltip.js index 51891ede30..c4c2ee260c 100644 --- a/assets/javascripts/cordinc_tooltip.js +++ b/assets/javascripts/cordinc_tooltip.js @@ -68,7 +68,7 @@ var Tooltip = Class.create({ this.clone = this.tooltip.cloneNode(true); parentId = this.options.DOM_location?$(this.options.DOM_location.parentId):show_at.parentNode; - successorId = this.options.DOM_location?$(this.options.DOM_location.successorId):show_at.target; + successorId = this.options.DOM_location?$(this.options.DOM_location.successorId):show_at; parentId.insertBefore(this.clone, successorId); this.clone.setStyle({ From 268f51fc752969453a903503d48b2ee011a02026 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Wed, 27 Apr 2011 11:34:27 +0200 Subject: [PATCH 51/52] [FIT #19061] Hide SaveAs and Delete popup widgets per default. --- lib/widget/controls/delete.rb | 19 +++++++++++++------ lib/widget/controls/save_as.rb | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/widget/controls/delete.rb b/lib/widget/controls/delete.rb index b60d6ad07a..af14559987 100644 --- a/lib/widget/controls/delete.rb +++ b/lib/widget/controls/delete.rb @@ -1,11 +1,19 @@ class Widget::Controls::Delete < Widget::Base def render return "" if @query.new_record? - button = link_to content_tag(:span, content_tag(:em, l(:button_delete), :class => "button-icon icon-delete")), "#", - :class => 'button secondary', - :id => 'query-icon-delete', - :title => l(:button_delete) - popup = content_tag :div, :id => "delete_form", :class => "button_form" do + render_button + render_popup + end + + def render_button + link_to(content_tag(:span, content_tag(:em, l(:button_delete), :class => "button-icon icon-delete")), + "#", + :class => 'button secondary', + :id => 'query-icon-delete', + :title => l(:button_delete)) + end + + def render_popup + content_tag :div, :id => "delete_form", :class => "button_form", :style => "display:none" do question = content_tag :p, l(:label_really_delete_question) options = content_tag :p do delete_button = content_tag :span do @@ -19,6 +27,5 @@ class Widget::Controls::Delete < Widget::Base end question + options end - button + popup end end diff --git a/lib/widget/controls/save_as.rb b/lib/widget/controls/save_as.rb index 5ae48ed33e..f410f67378 100644 --- a/lib/widget/controls/save_as.rb +++ b/lib/widget/controls/save_as.rb @@ -39,7 +39,7 @@ class Widget::Controls::SaveAs < Widget::Base end def render_popup - content_tag :div, :id => 'save_as_form', :class => "button_form" do + content_tag :div, :id => 'save_as_form', :class => "button_form", :style => "display:none" do render_popup_form + render_popup_buttons end end From 2850f1bd725b3bca238df2f5435f60cb41c95013 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 27 Apr 2011 12:20:54 +0200 Subject: [PATCH 52/52] fix engine for filters/group_bys that are not being subclassed (like singleton value) --- lib/report.rb | 5 ++++- lib/report/query_utils.rb | 10 ++++++++-- lib/report/sql_statement.rb | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/report.rb b/lib/report.rb index fccb529116..0b02ff69cf 100644 --- a/lib/report.rb +++ b/lib/report.rb @@ -77,7 +77,10 @@ class Report < ActiveRecord::Base def chain(klass = nil, options = {}) build_new_chain unless @chain - @chain = klass.new @chain, options if klass + if klass + @chain = klass.new @chain, options + @chain.engine = self.class + end @chain = @chain.parent until @chain.top? @chain end diff --git a/lib/report/query_utils.rb b/lib/report/query_utils.rb index 08e62597ef..4b6d5116dd 100644 --- a/lib/report/query_utils.rb +++ b/lib/report/query_utils.rb @@ -32,8 +32,14 @@ module Report::QueryUtils # # @return [Class] subclass def engine - return self.class.engine unless is_a? Module - @engine ||= Object.const_get(name[/^[^:]+/] || :Report) + return @engine if @engine + if is_a? Module + @engine = Object.const_get(name[/^[^:]+/] || :Report) + elsif respond_to? :parent and parent.respond_to? :engine + parent.engine + else + self.class.engine + end end ## diff --git a/lib/report/sql_statement.rb b/lib/report/sql_statement.rb index 3c73f708a6..5062937c35 100644 --- a/lib/report/sql_statement.rb +++ b/lib/report/sql_statement.rb @@ -74,6 +74,7 @@ class Report::SqlStatement # FIXME I'm ugly @sql ||= begin sql = "\n-- BEGIN #{desc}\n" \ + "-- DB: #{ConnectionSwitcher.config_name}\n" \ "SELECT\n#{select.map { |e| "\t#{e}" }.join ",\n"}" \ "\nFROM\n\t#{from.gsub("\n", "\n\t")}" \ "\n\t#{joins.map { |e| e.gsub("\n", "\n\t") }.join "\n\t"}" \