effective_bootstrap 1.19.2 → 1.19.3

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: 30ed0755d71e2507d659e3b3c0a4fe94f5aa87cdd28b18b98e00ac355d18b317
4
- data.tar.gz: '0423308054e7ac0369dc1d980c02d108ad938990dc9e02fc0b036f2df1fa91bb'
3
+ metadata.gz: 300f02e7b6b2330abf3c481bc1f25fba946452a2645e8b8563de189260edcdfa
4
+ data.tar.gz: 54bf157e0565aeb433d5c8ba7bf192823f4bc6fcedeed665ff6533fa5addc935
5
5
  SHA512:
6
- metadata.gz: 4cd32bb7192b96ac9349d0451749bff769ff93b48772b2f0d1ba508091410bd276eccce7b884f5855fb5d8b5ecdc2c1b79c349433bdeb5a62a487f8c772549b2
7
- data.tar.gz: 1d0ec5d073cc37811ac8ee38e524bdf4311eacd1a745c3719db38453f16526757d865fb704a564fcf51e4660e337cd4ccc2c1c91eae487a88d4428b2f9df8062
6
+ metadata.gz: c4a22fed5a95d87fc8a83c49e612d065d1ce72b11149afe117cc08ddfce2e050904c5644a43ad513245c93bcfecbe4f5e8089db8c2f171c4e13de0583b35e8bb
7
+ data.tar.gz: cb7f2aa5c848d3dadbd6413d6a4232db808a272d2faf77671bd169b324387d00143826ac82a7bc744e1a8160abd5edc7e7370d6e8bb27593220607bbf036841b
@@ -16,6 +16,12 @@ $(document).on('click', '[data-effective-select-or-text]', function(event) {
16
16
  $visible_input = $visible.find('input,textarea,select').first()
17
17
  $hidden_input = $hidden.find('input,textarea,select').first()
18
18
 
19
+ if ($visible.find('select').length > 0) {
20
+ $obj.removeClass('select-enabled').addClass('text-enabled')
21
+ } else {
22
+ $obj.removeClass('text-enabled').addClass('select-enabled')
23
+ }
24
+
19
25
  required = $visible_input.prop('required') || $hidden_input.prop('required')
20
26
 
21
27
  $hidden_input.prop('required', required)
@@ -15,11 +15,19 @@ module Effective
15
15
  @name_text = options.delete(:name_text) || raise('Please include a text method name')
16
16
  @select_collection = options.delete(:collection) || raise('Please include a collection')
17
17
 
18
- @select_options = { placeholder: 'Please choose, or...', required: false }
19
- .merge(options[:select] || options.presence || {})
18
+ @shared_options = (options[:input_html] || {})
20
19
 
21
- @text_options = { placeholder: 'Enter freeform', required: false }
22
- .merge(options[:text] || options[:text_field] || options.presence || {})
20
+ @select_options = {
21
+ placeholder: '',
22
+ hint: "Can't find your #{(options[:name] || name).to_s.chomp('_id')}? <a class='effective-select-or-text-switch' title='Switch to enter freeform' data-effective-select-or-text='true' href='#'>Click here</a> to add one",
23
+ required: false,
24
+ }.merge(options[:select] || options.presence || {}).merge(@shared_options)
25
+
26
+ @text_options = {
27
+ placeholder: '',
28
+ hint: "Looking for an existing #{(options[:name] || name).to_s.chomp('_id')}? <a class='effective-select-or-text-switch' title='Switch to search for existing' data-effective-select-or-text='true' href='#'>Click here</a> to search",
29
+ required: false
30
+ }.merge(options[:text] || options[:text_field] || options.presence || {}).merge(@shared_options)
23
31
 
24
32
  @email_field = options.fetch(:email, name_text.to_s.include?('email'))
25
33
 
@@ -27,15 +35,16 @@ module Effective
27
35
  end
28
36
 
29
37
  def to_html(&block)
30
- content_tag(:div, class: 'effective-select-or-text') do
38
+ wrapper_class = ['effective-select-or-text', (select? ? 'select-enabled' : 'text-enabled'), options.dig(:wrapper, :class)].compact.join(' ')
39
+
40
+ content_tag(:div, (options[:wrapper] || {}).merge(class: wrapper_class)) do
31
41
  if select?
32
42
  @builder.send(email_field? ? :email_field : :text_field, name_text, text_options) +
33
43
  @builder.select(name, select_collection, select_options)
34
44
  else
35
45
  @builder.select(name, select_collection, select_options) +
36
46
  @builder.send(email_field? ? :email_field : :text_field, name_text, text_options)
37
- end +
38
- link_to(icon('rotate-ccw'), '#', class: 'effective-select-or-text-switch', title: 'Switch between choice and freeform', 'data-effective-select-or-text': true)
47
+ end
39
48
  end
40
49
  end
41
50
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '1.19.2'.freeze
2
+ VERSION = '1.19.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.2
4
+ version: 1.19.3
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: 2024-08-20 00:00:00.000000000 Z
11
+ date: 2024-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails