remove unused help functionality

pull/6827/head
Jens Ulferts 8 years ago
parent 7044046a61
commit 35b2d43870
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 1
      config/locales/en.yml
  2. 1
      lib/assets/javascripts/reporting_engine/reporting_engine.js
  3. 76
      lib/assets/stylesheets/reporting_engine/help.css
  4. 3
      lib/assets/stylesheets/reporting_engine/reporting_engine.css
  5. 13
      lib/report/chainable.rb
  6. 40
      lib/widget/base.rb
  7. 1
      lib/widget/controls/clear.rb
  8. 1
      lib/widget/controls/save_as.rb
  9. 28
      lib/widget/filters.rb
  10. 10
      lib/widget/group_bys.rb
  11. 76
      lib/widget/help.rb
  12. 20
      lib/widget/settings.rb
  13. 2
      lib/widget/settings/fieldset.rb
  14. 159
      vendor/assets/javascripts/reporting_engine/cordinc_tooltip.js

@ -30,7 +30,6 @@ en:
label_greater: ">"
label_group_by: "Group by"
label_group_by_add: "Add Group-by Attribute"
label_help: "Help"
label_inactive: "«inactive»"
label_less: "<"
label_no: "No"

@ -21,7 +21,6 @@
//= require controls
//= require reporting_engine/reporting
//= require reporting_engine/sortable
//= require reporting_engine/cordinc_tooltip
//= require reporting_engine/reporting/filters
//= require reporting_engine/reporting/group_bys
//= require reporting_engine/reporting/restore_query

@ -1,76 +0,0 @@
/*-- copyright
ReportingEngine
Copyright (C) 2010 - 2014 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 3.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++*/
.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;
white-space: normal;
}
.filter-icon {
}
.filter-tip {
}
.group-by-icon {
float: right;
margin-right: 5px;
}
.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;
}

@ -19,6 +19,5 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++*/
/* *
*= require reporting_engine/help
*= require reporting_engine/reporting
*/
*/

@ -28,7 +28,7 @@ class Report < ActiveRecord::Base
# this attr. should point to a symbol useable for translations
inherited_attribute :applies_for, default: :label_cost_entry_attributes
def_delegators :'self.class', :table_joins, :table_name, :field, :display?, :help_text, :underscore_name
def_delegators :'self.class', :table_joins, :table_name, :field, :display?, :underscore_name
def self.accepts_property(*list)
engine.accepted_properties.push(*list.map(&:to_s))
@ -331,16 +331,5 @@ class Report < ActiveRecord::Base
end
@field_map[field]
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

@ -64,25 +64,12 @@ class Widget::Base < Widget
# Available options:
# :to => canvas - The canvas (streaming or otherwise) to render to. Has to respond to #write
def render_with_options(options = {}, &block)
@help_text = options[:help_text]
set_canvas(options.delete(:to)) if options.has_key? :to
@options = options
render_with_cache(options, &block)
@output
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
@help_text
end
def help_text=(text)
@help_text = text
end
def cache_key
@cache_key ||= Digest::SHA1::hexdigest begin
if subject.respond_to? :cache_key
@ -121,31 +108,4 @@ class Widget::Base < Widget
@cache_output = ''.html_safe
@output = canvas
end
##
# Appends the Help Widget with this Widget's help text.
# If no help-text was given and no default help-text is set,
# the given default html will be printed instead.
# Params:
# - html
# - options-hash
# - :fallback_html (string, default: '') - the html code to render if no help-text was found
# - :help_text (string) - the help text to render
# - :instant_write (bool, default: true) - wether to write
# the help-widget instantly to the output-buffer.
# If set to false you should care to save the rendered text.
def maybe_with_help(options = {})
options[:instant_write] = true if options[:instant_write].nil?
options[:fallback_html] ||= ''
output = ''.html_safe
if text = options[:help_text] || help_text
output += render_widget Widget::Help, text do
options
end
else
output += options[:fallback_html]
end
write output if options[:instant_write]
output.html_safe
end
end

@ -23,6 +23,5 @@ class Widget::Controls::Clear < Widget::Controls
'#',
id: 'query-link-clear',
class: 'button icon-context icon-undo')
maybe_with_help
end
end

@ -28,7 +28,6 @@ class Widget::Controls::SaveAs < Widget::Controls
end
button = link_to(link_name, '#', id: 'query-icon-save-as', class: "button icon-context #{icon}")
write(button + render_popup)
maybe_with_help
end
def cache_key

@ -29,15 +29,10 @@ class Widget::Filters < Widget::Base
class: 'hidden-for-sighted'
add_filter_value = content_tag :div, class: 'advanced-filters--add-filter-value' do
value = select_tag 'add_filter_select',
options_for_select([['', '']] + selectables),
class: 'advanced-filters--select',
name: nil
value += maybe_with_help icon: { class: 'filter-icon' },
tooltip: { class: 'filter-tip' },
instant_write: false # help associated with this kind of Widget
value
select_tag 'add_filter_select',
options_for_select([['', '']] + selectables),
class: 'advanced-filters--select',
name: nil
end
(add_filter_label + add_filter_value).html_safe
@ -99,21 +94,6 @@ class Widget::Filters < Widget::Base
render_widget MultiValues, f, to: html, lazy: true
end
end
render_filter_help f, to: html
render_widget RemoveButton, f, to: html
end
# #Renders help for a filter (chainable)
def render_filter_help(filter, options = {})
html = content_tag :td, width: '25px' do
if filter.help_text # help associated with the chainable this Widget represents
render_widget Widget::Controls::Help, filter.help_text
end
end
if canvas = options[:to]
canvas << "\n" << html
else
html
end
end
end

@ -27,7 +27,7 @@ class Widget::GroupBys < Widget::Base
end.join.html_safe
end
def render_group(type, initially_selected, show_help = false)
def render_group(type, initially_selected)
initially_selected = initially_selected.map do |group_by|
[group_by.class.underscore_name, h(group_by.class.label)]
end
@ -68,12 +68,6 @@ class Widget::GroupBys < Widget::Base
content
end
if show_help
label += maybe_with_help icon: { class: 'group-by-icon' },
tooltip: { class: 'group-by-tip' },
instant_write: false
end
label
end
@ -86,7 +80,7 @@ class Widget::GroupBys < Widget::Base
def render
write(content_tag(:div, id: 'group-by--area') do
out = render_group 'columns', @subject.group_bys(:column), true
out = render_group 'columns', @subject.group_bys(:column)
out += render_group 'rows', @subject.group_bys(:row)
out.html_safe
end)

@ -1,76 +0,0 @@
#-- copyright
# ReportingEngine
#
# Copyright (C) 2010 - 2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#++
##
# Usage: render_widget Widget::Help, :text
#
# Where :text is a i18n key.
class Widget::Help < Widget::Base
dont_cache!
def render
id = "tip:#{@subject}"
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: image_path('reporting_engine/icon_info_red.gif'), id: "target:#{@subject}", alt: ''
tip = content_tag_string :span, l(@subject), tip_config(options[:tooltip]), false
script = content_tag :script,
"new Tooltip('target:#{@subject}', 'tip:#{@subject}', {className: 'tooltip'#{sai}});",
{ type: 'text/javascript' }, false
target = content_tag :a, icon + tip, icon_config(options[:icon])
write(target + script)
end
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
def tip_config(options)
add_class = lambda do |cl|
if cl
"#{cl} tooltip"
else
'tooltip'
end
end
options.mega_merge! id: "tip:#{@subject}", class: add_class
end
end
class Hash
def mega_merge!(hash)
hash.each do |key, value|
if value.is_a?(Proc)
self[key] = value.call(self[key])
else
self[key] = value
end
end
self
end
end

@ -24,14 +24,14 @@ class Widget::Settings < Widget::Base
def render_filter_settings
render_widget Widget::Settings::Fieldset, @subject,
type: 'filters', help_text: filter_help do
type: 'filters' do
render_widget Widget::Filters, @subject
end
end
def render_group_by_settings
render_widget Widget::Settings::Fieldset, @subject,
type: 'group_by', help_text: group_by_help do
type: 'group_by' do
render_widget Widget::GroupBys, @subject
end
end
@ -67,20 +67,4 @@ class Widget::Settings < Widget::Base
end
end)
end
def filter_help
if help_text.is_a?(Array)
help_text[0]
else
nil
end
end
def group_by_help
if help_text.is_a?(Array)
help_text[1]
else
nil
end
end
end

@ -39,7 +39,7 @@ class Widget::Settings::Fieldset < Widget::Base
onclick: 'toggleFieldset(this);',
class: 'form--fieldset-legend',
id: hash.to_s) do # FIXME: onclick
content_tag(:a, href: 'javascript:') do (l(@label) + maybe_with_help(instant_write: false)).html_safe end
content_tag(:a, href: 'javascript:') do l(@label) end
end
html + yield
end)

@ -1,159 +0,0 @@
/*
* 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.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;
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) {
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):show_at.parentNode;
successorId = this.options.DOM_location?$(this.options.DOM_location.successorId):show_at;
parentId.insertBefore(this.clone, successorId);
this.clone.setStyle({
position: 'absolute',
top: position.top + "px",
left: position.left + "px",
display: "inline",
zIndex:this.options.zindex,
/* fix for ur dashboard */
visibility: 'visible',
width: "400px"
});
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();
}
})
Loading…
Cancel
Save