vidl-toolbox 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -267,7 +267,7 @@ module Toolbox
267
267
 
268
268
  csv_string = FasterCSV.generate do |csv|
269
269
  # Title
270
- csv << field_renderers.map { |fr| fr.label }
270
+ csv << field_renderers.map { |fr| fr.label(false, false) }
271
271
  options[:collection].each do |rec|
272
272
  csv << field_renderers.map { |fr| fr.render_value(rec, false) }
273
273
  end
@@ -29,8 +29,14 @@ module Toolbox
29
29
  # Renders the label of the widget.
30
30
  # If show_model is set to a model name, the model name of this widget
31
31
  # will be added in parenthesis if it differs to the value in show_model.
32
- def label(show_model = nil)
33
- @widget_config.label ? @view.send(:h, @widget_config.label) : translate_field(show_model) unless @widget_config.suppress_label
32
+ def label(show_model = nil, html = true)
33
+ unless @widget_config.suppress_label
34
+ if @widget_config.label
35
+ html ? @view.send(:h, @widget_config.label) : @widget_config.label
36
+ else
37
+ translate_field(show_model, html)
38
+ end
39
+ end
34
40
  end
35
41
 
36
42
  # Translates a column name of a model using gettext
@@ -38,7 +44,7 @@ module Toolbox
38
44
  # and appended to the column name. Ensure, that the model name is also translated
39
45
  # (gettext does not extract this automatically).
40
46
  #
41
- def translate_field(show_model = nil)
47
+ def translate_field(show_model = nil, html = true)
42
48
  col_name = @widget_config.name.to_s
43
49
  model_name = @widget_config.model_name.classify
44
50
  a = col_name.split('.')
@@ -49,7 +55,8 @@ module Toolbox
49
55
 
50
56
  text = @view.send(:s_, model_name + '|' + col_name.humanize)
51
57
  text += ' (' + @view.send(:s_, model_name) + ')' if show_model && model_name != show_model
52
- @view.send(:h, text)
58
+
59
+ html ? @view.send(:h, text) : text
53
60
  end
54
61
 
55
62
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Toolbox
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vidl-toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Nyffenegger