effective_form_inputs 1.1.15 → 1.2.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
  SHA1:
3
- metadata.gz: 937725fe7bfe1c08ac559edcacdb52ea6ee2a37c
4
- data.tar.gz: 06bf13049aeec498038a5c306bbabc0b8f498bae
3
+ metadata.gz: 90f5076595ba940118763164668a2d02f0fcb5f9
4
+ data.tar.gz: b993340a53be0274d77d2bf36200bab4e477da78
5
5
  SHA512:
6
- metadata.gz: 5cde7d118be3449afde95fa63650d181963e88d2cc6e5bbead22773d609326b457716b231234761fb82aaf98d4376910560e3e1e29ceb1a26c5591084e423d50
7
- data.tar.gz: 4514ab3d6a80d8bb9d2a55d54bc62ad65ccc4c7d40e19a3e61e0e7c2d7c617b8d49fcb75f59a0990efa30f51992f02799859ecbf8c4311f9212e298ea886f43a
6
+ metadata.gz: f056ce1b75729929c346f35650f4e355a51ec48b5e1f51de0076d5bd6693e4fb08bec5719c9e8332c6983bcae5ce15ff874c717d1c7fcdfb7556442bd32ed31e
7
+ data.tar.gz: a0c6003793fb2c9d11aff6a91940a882ffa9bbe10c50c57416e3974f48a3713393984373c1fb365a560be0448e9bad9212a8edfb4f44b6bd2da345f47fb233c2
@@ -0,0 +1,121 @@
1
+ module EffectiveBootstrap3Helper
2
+
3
+ # An effective Bootstrap3 menu DSL
4
+ # Automatically puts in the 'active' class based on request path
5
+
6
+ # %ul.nav.navbar-nav.navbar-right
7
+ # = nav_link_to 'Sign In', new_user_session_path
8
+ # = nav_dropdown 'Settings' do
9
+ # = nav_link_to 'Account Settings', user_settings_path
10
+ # %li.divider
11
+ # = nav_link_to 'Sign In', new_user_session_path, method: :delete
12
+ def nav_link_to(label, path, opts = {})
13
+ content_tag(:li, class: ('active' if request.fullpath.include?(path))) do
14
+ link_to(label, path, opts)
15
+ end
16
+ end
17
+
18
+ def nav_dropdown(label, link_class: [], list_class: [], &block)
19
+ raise 'expected a block' unless block_given?
20
+
21
+ content_tag(:li, class: 'dropdown') do
22
+ content_tag(:a, class: 'dropdown-toggle', href: '#', 'data-toggle': 'dropdown', role: 'button', 'aria-haspopup': 'true', 'aria-expanded': 'false') do
23
+ label.html_safe + content_tag(:span, '', class: 'caret')
24
+ end + content_tag(:ul, class: 'dropdown-menu') { yield }
25
+ end
26
+ end
27
+
28
+ # An effective Bootstrap3 tabpanel DSL
29
+ # Inserts both the tablist and the tabpanel
30
+
31
+ # = tabs do
32
+ # = tab 'Imports' do
33
+ # %p Imports
34
+
35
+ # = tab 'Exports' do
36
+ # %p Exports
37
+
38
+ # If you pass active 'label' it will make that tab active. Otherwise first.
39
+ def tabs(active: nil, panel: {}, list: {}, content: {}, &block)
40
+ raise 'expected a block' unless block_given?
41
+
42
+ @_tab_mode = :panel
43
+ @_tab_active = (active || :first)
44
+
45
+ content_tag(:div, {role: 'tabpanel'}.merge(panel)) do
46
+ content_tag(:ul, {class: 'nav nav-tabs', role: 'tablist'}.merge(list)) { yield } # Yield to tab the first time
47
+ end + content_tag(:div, {class: 'tab-content'}.merge(content)) do
48
+ @_tab_mode = :content
49
+ @_tab_active = (active || :first)
50
+ yield # Yield tot ab the second time
51
+ end
52
+ end
53
+
54
+ def tab(label, controls = nil, &block)
55
+ controls ||= label.to_s.parameterize.gsub('_', '-')
56
+ controls = controls[1..-1] if controls[0] == '#'
57
+
58
+ active = (@_tab_active == :first || @_tab_active == label)
59
+
60
+ @_tab_active = nil if @_tab_active == :first
61
+
62
+ if @_tab_mode == :panel # Inserting the label into the tabpanel top
63
+ content_tag(:li, role: 'presentation', class: ('active' if active)) do
64
+ content_tag(:a, href: '#' + controls, 'aria-controls': controls, 'data-toggle': 'tab', role: 'tab') do
65
+ label
66
+ end
67
+ end
68
+ else # Inserting the content into the tab itself
69
+ content_tag(:div, id: controls, class: "tab-pane#{' active' if active}", role: 'tabpanel') do
70
+ yield
71
+ end
72
+ end
73
+ end
74
+
75
+ ### Icon Helpers for actions_column or elsewhere
76
+ def show_icon_to(path, options = {})
77
+ glyphicon_to('eye-open', path, {title: 'Show'}.merge(options))
78
+ end
79
+
80
+ def edit_icon_to(path, options = {})
81
+ glyphicon_to('edit', path, {title: 'Edit'}.merge(options))
82
+ end
83
+
84
+ def destroy_icon_to(path, options = {})
85
+ defaults = {title: 'Destroy', data: {method: :delete, confirm: 'Delete this item?'}}
86
+ glyphicon_to('trash', path, defaults.merge(options))
87
+ end
88
+
89
+ def settings_icon_to(path, options = {})
90
+ glyphicon_to('cog', path, {title: 'Settings'}.merge(options))
91
+ end
92
+
93
+ def ok_icon_to(path, options = {})
94
+ glyphicon_to('ok', path, {title: 'OK'}.merge(options))
95
+ end
96
+
97
+ def approve_icon_to(path, options = {})
98
+ glyphicon_to('ok', path, {title: 'Approve'}.merge(options))
99
+ end
100
+
101
+ def remove_icon_to(path, options = {})
102
+ glyphicon_to('remove', path, {title: 'Remove'}.merge(options))
103
+ end
104
+
105
+ def glyphicon_tag(icon, options = {})
106
+ if icon.to_s.start_with?('glyphicon-')
107
+ content_tag(:span, '', {class: "glyphicon #{icon}"}.merge(options))
108
+ else
109
+ content_tag(:span, '', {class: "glyphicon glyphicon-#{icon}"}.merge(options))
110
+ end
111
+ end
112
+
113
+ def glyphicon_to(icon, path, options = {})
114
+ content_tag(:a, options.merge(href: path)) do
115
+ glyphicon_tag(icon)
116
+ end
117
+ end
118
+ alias_method :bootstrap_icon_to, :glyphicon_to
119
+ alias_method :glyph_icon_to, :glyphicon_to
120
+
121
+ end
@@ -37,6 +37,7 @@ module Inputs
37
37
 
38
38
  if options[:item_wrapper_tag]
39
39
  active = (builder.object.send(options[:value_method]).to_s == value.to_s)
40
+ #active ||= (builder.object.send(options[:value_method]).to_s == Array(value).first.to_s)
40
41
 
41
42
  content_tag(options[:item_wrapper_tag], item,
42
43
  class: [
@@ -79,7 +80,7 @@ module Inputs
79
80
  end
80
81
 
81
82
  def value
82
- options[:checked] || super
83
+ Array(options[:checked] || super).first
83
84
  end
84
85
 
85
86
  def options
@@ -4,7 +4,7 @@ module Inputs
4
4
  delegate :content_tag, :text_field_tag, :to => :@template
5
5
 
6
6
  def default_input_js
7
- {format: 'HH:mm', showClear: true}
7
+ { format: 'HH:mm', showClear: true, useCurrent: 'hour' }
8
8
  end
9
9
 
10
10
  def default_input_html
@@ -17,10 +17,17 @@ module EffectiveFormInputs
17
17
  Rails.application.config.to_prepare do
18
18
  ActiveSupport.on_load :action_controller do
19
19
  helper EffectiveFormInputsHelper
20
+ helper EffectiveBootstrap3Helper
20
21
  end
21
22
  end
22
23
  end
23
24
 
24
-
25
+ initializer 'effective_form_inputs.check_for_effective_bootstrap' do |app|
26
+ Rails.application.config.to_prepare do
27
+ if defined?(EffectiveBootstrap)
28
+ raise 'effective_form_inputs and effective_bootstrap cannot be run alongside eachother. Sorry.'
29
+ end
30
+ end
31
+ end
25
32
  end
26
33
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveFormInputs
2
- VERSION = '1.1.15'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_form_inputs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.15
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-24 00:00:00.000000000 Z
11
+ date: 2018-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -87,6 +87,7 @@ files:
87
87
  - app/assets/stylesheets/effective_select/overrides.scss
88
88
  - app/assets/stylesheets/effective_select/select2.css
89
89
  - app/assets/stylesheets/effective_time_picker/input.scss
90
+ - app/helpers/effective_bootstrap3_helper.rb
90
91
  - app/helpers/effective_form_inputs_helper.rb
91
92
  - app/models/effective/form_builder_inputs.rb
92
93
  - app/models/effective/form_input.rb
@@ -142,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
143
  version: '0'
143
144
  requirements: []
144
145
  rubyforge_project:
145
- rubygems_version: 2.5.2
146
+ rubygems_version: 2.4.5.1
146
147
  signing_key:
147
148
  specification_version: 4
148
149
  summary: Collection of Form Inputs