kadmin 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ae7ab81f575c8f1b81ea683971e2d1c1eb674f71ee0f7434ac2295394763363
4
- data.tar.gz: 2e9dbf8da6871530fd4bb86a6c7213fdc4c2c6bdfabdf4fad71dff8f5095e27e
3
+ metadata.gz: f006debe357b9b00018578ed59b5f70abd7062c47aa69ec3fbfb488d6b74bc98
4
+ data.tar.gz: 8ccabc5103f421e655c5d38a3b4cb8fe8975a515d14d3849c4799ddffe329934
5
5
  SHA512:
6
- metadata.gz: 0ceaa06561d11a4a467af85d8e979b96c5f4378fda459f78d0a0bef941f94866c254a856c9c7341a2ad444288d2531c68d7cdd019bf2b6cddb644ea213a67f42
7
- data.tar.gz: 1938dc5c81a833f9dadb3780cc5d5d1ef1757a6a9b8fdd3eb70a02fdac9617d837d52e61a52792a5b5caa7cf28162bef60b961e593f36a967626c1d7b5dea09b
6
+ metadata.gz: 3f16f761cc7292f9206ed15cc3277b9ceda44a733f67fff832f5d06333f90d34af257e569856acb6d7b804092c2d7c55aaff05c209f946671fe1f4ff41a30c9a
7
+ data.tar.gz: cfa6a82c8999d89b3056a818a55977afd970f4a1e609041f1abbe28cbd86ae849b458408d9dc6b4260b4119458b3be330c4cc5168a32e5f786c3d4a6adfba4bf
@@ -44,33 +44,40 @@ module Kadmin
44
44
  end
45
45
 
46
46
  # Custom label generator using bootstrap i.e. * for mendatory feilds, help icon and popover for help
47
- # @param [String] label text for the view
48
- # @param [String] label_for is ID of the html element for which we are displaying label.
49
- # @param [Boolean] Display the red asteric to indicate mendatory field.
50
- # @param [Boolean] to decide weither we need to display the help iocn or not
51
- # @param [String] Title of the popover
52
- # @param [String] Body text of popover
53
- # @param [String] classname for the label.
54
- def create_custom_label(label, label_for = '', required = false, display_help = true, title = '', message = '', label_class = 'control-label')
55
- label = t(label)
47
+ # @param [String] key identifier for the help label / input field
48
+ # @param [Hash] options options for the help label
49
+ def create_custom_label(key, options = {})
50
+ defaults = {
51
+ label_for: "#{key}",
52
+ required: false,
53
+ display_help: true,
54
+ title: ".#{key}.title",
55
+ message: ".#{key}.message",
56
+ label_class: 'control-label',
57
+ data_placement: 'top'
58
+ }
59
+ options = defaults.merge(options)
60
+
61
+ label = t(".#{key}.label")
56
62
  label = label.html_safe
57
63
 
58
- require_html = required ? '<span class="required-field"><span>' : ''
64
+ require_html = options[:required] ? '<span class="required-field"><span>' : ''
59
65
  icon_html = "<i class='fa fa-question-circle' style='color:green'></i>"
60
66
 
61
67
  display_message = ''
62
- if display_help
63
- message = t(message)
68
+ if options[:display_help]
69
+ message = t(options[:message])
64
70
  message = message.gsub('"', '\"')
65
71
  message = message.gsub("'", "\'")
66
72
  html_message = message.html_safe
67
73
 
68
- title = t(title)
74
+ title = t(options[:title])
69
75
  title = title.html_safe
70
- display_message = "<span data-toggle='popover' title='#{title}' data-placement='top' data-trigger='hover' data-content='#{html_message}'>#{icon_html}</span>"
76
+
77
+ display_message = "<span data-toggle='popover' title='#{title}' data-placement='#{options[:data_placement]}' data-trigger='hover' data-content='#{html_message}'>#{icon_html}</span>"
71
78
  end
72
79
 
73
- return "<label for='#{label_for}' class='#{label_class}'' >#{require_html}#{label} #{display_message}</label>".html_safe
80
+ return "<label for='#{options[:label_for]}' class='#{options[:label_class]}'>#{require_html}#{label} #{display_message}</label>".html_safe
74
81
  end
75
82
  end
76
83
  end
@@ -1,3 +1,3 @@
1
1
  module Kadmin
2
- VERSION = '1.2.1'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kadmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Pepin-Perreault
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-11-29 00:00:00.000000000 Z
13
+ date: 2020-02-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails