effective_bootstrap 0.9.17 → 0.9.22

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: 9c76bc463f1c4a4b5c248ac9072bdb2cc971da468cf13292519e80f64d3ec693
4
- data.tar.gz: 85349386858572224e4a1127d8afc3dbc98250751282f60e29678833eab0ee86
3
+ metadata.gz: dc2972eec59594f06ea675c943277a99d67ca6e1e75e30e10bcc7252c776a15d
4
+ data.tar.gz: 22debca767e9449ba70d890bd98d38e262641d39fcc6b7c53fd184f28a9d83ae
5
5
  SHA512:
6
- metadata.gz: 59b788edfb7934ad72a406d79ceab25c813c27343a4cefb0f871bc4fb026110a0646eae6df0fbc663d14168644f91b421a381b326705582c8dfb2f259f3e909d
7
- data.tar.gz: 6cc0cbc87baa14e033a480ce895be3c0570c78639a6891017e57cd9cf105027287c5b3ed83990f38024315d76a06f56cf734b7f87a01d4814fa8ff58b1a1b832
6
+ metadata.gz: f14eceace3be9ceead1d2fdec73c34959223e3a47684355da505d41165e4d68b3c24203c95d1b5009b58153725052f5c91398c6c6affd499ba3ca00ca35fd7df
7
+ data.tar.gz: 7a847310a0b44fae9ce81e7fb21f5cf89bfc43c2200bfafea61eddc6341adf32e1cb2b3d8e896d6add4c52a663b2d399e261b4e2a6b9d62897ffb17db1bc8802
@@ -4,6 +4,7 @@ this.EffectiveForm ||= new class
4
4
  remote_form_commit: '' # String containing the last params[:commit]
5
5
  remote_form_payload: '' # String containing html from server side render of this form
6
6
  remote_form_flash: '' # Array of Arrays
7
+ remote_form_redirect: '' # String containing the redirect path (optional)
7
8
 
8
9
  validate: (form) ->
9
10
  valid = form.checkValidity()
@@ -73,6 +74,15 @@ this.EffectiveForm ||= new class
73
74
  $target = $target.closest('form') unless $target.is('form')
74
75
  $form = ''
75
76
 
77
+ if @remote_form_redirect.length > 0
78
+ if window.Turbolinks
79
+ window.Turbolinks.visit(@remote_form_redirect)
80
+ else
81
+ window.location.href = @remote_form_redirect
82
+
83
+ @remote_form_redirect = ''
84
+ return
85
+
76
86
  if @remote_form_payload.length > 0
77
87
  $payload = $("<div>#{@remote_form_payload}</div>")
78
88
  $form = $payload.find("form[data-remote-index='#{$target.data('remote-index')}']")
@@ -160,7 +170,7 @@ this.EffectiveForm ||= new class
160
170
  # This displays the spinner here, and directs any flash messages before and after loadRemoteForm
161
171
  $(document).on 'click', '.form-actions a[data-remote],.form-actions button[type=submit]', (event) ->
162
172
  EffectiveForm.setCurrentSubmit($(@).parent())
163
- EffectiveForm.spin()
173
+ EffectiveForm.spin() unless $(@).attr('data-confirm')
164
174
 
165
175
  # This actually attached the handlers to a remote ajax form when it or an action inside it triggers a remote thing.
166
176
  $(document).on 'ajax:beforeSend', 'form[data-remote]', (event) ->
@@ -3,7 +3,7 @@ assignPositions = (target) ->
3
3
  return unless $hasMany.length > 0
4
4
 
5
5
  $fields = $hasMany.children('.has-many-fields:not(.marked-for-destruction)')
6
- positions = $fields.find("input[name$='[position]']").map(-> this.value).get()
6
+ positions = $fields.find("input[name$='[position]'][type=hidden]").map(-> this.value).get()
7
7
 
8
8
  if positions.length > 0
9
9
  index = Math.min.apply(Math, positions) || 0
@@ -35,7 +35,7 @@ $(document).on 'click', '[data-effective-form-has-many-add]', (event) ->
35
35
  return unless $hasMany.length > 0
36
36
 
37
37
  uid = (new Date).valueOf()
38
- template = $obj.data('effective-form-has-many-template').replace(/HASMANYINDEX/g, uid)
38
+ template = atob($obj.data('effective-form-has-many-template')).replace(/HASMANYINDEX/g, uid)
39
39
 
40
40
  $fields = $(template).hide().fadeIn('fast')
41
41
  EffectiveBootstrap.initialize($fields)
@@ -1,9 +1,9 @@
1
1
  # Prevent non-currency buttons from being pressed
2
- $(document).on 'click', 'button[data-effective-password]', (event) ->
2
+ $(document).on 'click', 'span[data-effective-password]', (event) ->
3
3
  $obj = $(event.currentTarget)
4
4
  $input = $obj.closest('.input-group')
5
5
 
6
6
  $input.find('input').attr('type', $obj.data('effective-password'))
7
- $input.find('button[data-effective-password]').toggle()
7
+ $input.find('span[data-effective-password]').toggle()
8
8
 
9
9
  false
@@ -411,7 +411,9 @@ module EffectiveBootstrapHelper
411
411
 
412
412
  @_tab_active = nil if @_tab_active == :first
413
413
 
414
- if @_tab_mode == :tablist # Inserting the label into the tablist top
414
+ if @_tab_mode == :tablist_vertical
415
+ content_tag(:a, label, id: ('tab-' + controls), class: ['nav-link', ('active' if active)].compact.join(' '), href: '#' + controls, 'aria-controls': controls, 'aria-selected': active.to_s, 'data-toggle': 'tab', role: 'tab')
416
+ elsif @_tab_mode == :tablist # Inserting the label into the tablist top
415
417
  content_tag(:li, class: 'nav-item') do
416
418
  content_tag(:a, label, id: ('tab-' + controls), class: ['nav-link', ('active' if active)].compact.join(' '), href: '#' + controls, 'aria-controls': controls, 'aria-selected': active.to_s, 'data-toggle': 'tab', role: 'tab')
417
419
  end
@@ -423,6 +425,29 @@ module EffectiveBootstrapHelper
423
425
  end
424
426
  end
425
427
 
428
+ def vertical_tabs(active: nil, unique: false, list: {}, content: {}, &block)
429
+ raise 'expected a block' unless block_given?
430
+
431
+ @_tab_mode = :tablist_vertical
432
+ @_tab_active = (active || :first)
433
+ @_tab_unique = ''.object_id if unique
434
+
435
+ content_tag(:div, class: 'row border') do
436
+ content_tag(:div, class: 'col-3 border-right') do
437
+ content_tag(:div, {class: 'nav flex-column nav-pills my-2', role: 'tablist', 'aria-orientation': :vertical}.merge(list)) do
438
+ yield # Yield to tab the first time
439
+ end
440
+ end +
441
+ content_tag(:div, class: 'col-9') do
442
+ content_tag(:div, {class: 'tab-content my-2'}.merge(content)) do
443
+ @_tab_mode = :content
444
+ @_tab_active = (active || :first)
445
+ yield # Yield to tab the second time
446
+ end
447
+ end
448
+ end
449
+ end
450
+
426
451
  def merge_class_key(hash, value)
427
452
  return { :class => value } unless hash.kind_of?(Hash)
428
453
 
@@ -75,6 +75,8 @@ module Effective
75
75
 
76
76
  def build_table_attachment(attachment)
77
77
  url = (@template.url_for(attachment) rescue false)
78
+ url ||= (Rails.application.routes.url_helpers.rails_blob_path(attachment, only_path: true) rescue false)
79
+
78
80
  return unless url
79
81
 
80
82
  image_tag = content_tag(:img, '', class: '', src: url, alt: attachment.filename.to_s) if attachment.image?
@@ -98,6 +100,8 @@ module Effective
98
100
 
99
101
  def build_card_attachment(attachment)
100
102
  url = (@template.url_for(attachment) rescue false)
103
+ url ||= (Rails.application.routes.url_helpers.rails_blob_path(attachment, only_path: true) rescue false)
104
+
101
105
  return unless url
102
106
 
103
107
  content_tag(:div, class: 'col') do
@@ -150,7 +150,7 @@ module Effective
150
150
  html.gsub!("#{name}_attributes][#{index}]", "#{name}_attributes][HASMANYINDEX]")
151
151
  html.gsub!("#{name}_attributes_#{index}_", "#{name}_attributes_HASMANYINDEX_")
152
152
 
153
- html.html_safe
153
+ Base64.encode64(html)
154
154
  end
155
155
 
156
156
  def link_to_add(block)
@@ -11,12 +11,12 @@ module Effective
11
11
  end
12
12
 
13
13
  def eyes
14
- content_tag(:button, icon('eye'),
14
+ content_tag(:span, icon('eye'),
15
15
  class: 'btn input-group-text',
16
16
  title: 'Show password',
17
17
  'data-effective-password': 'text'
18
18
  ) +
19
- content_tag(:button, icon('eye-off'),
19
+ content_tag(:span, icon('eye-off'),
20
20
  class: 'btn input-group-text',
21
21
  title: 'Hide password',
22
22
  style: 'display: none;',
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.9.17'.freeze
2
+ VERSION = '0.9.22'.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: 0.9.17
4
+ version: 0.9.22
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: 2021-03-09 00:00:00.000000000 Z
11
+ date: 2021-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -615,7 +615,6 @@ files:
615
615
  - app/helpers/effective_editor_helper.rb
616
616
  - app/helpers/effective_form_builder_helper.rb
617
617
  - app/helpers/effective_icons_helper.rb
618
- - app/models/effective/access_denied.rb
619
618
  - app/models/effective/form_builder.rb
620
619
  - app/models/effective/form_input.rb
621
620
  - app/models/effective/form_inputs/check_box.rb
@@ -1,17 +0,0 @@
1
- unless defined?(Effective::AccessDenied)
2
- module Effective
3
- class AccessDenied < StandardError
4
- attr_reader :action, :subject
5
-
6
- def initialize(message = nil, action = nil, subject = nil)
7
- @message = message
8
- @action = action
9
- @subject = subject
10
- end
11
-
12
- def to_s
13
- @message || I18n.t(:'unauthorized.default', :default => 'Access Denied')
14
- end
15
- end
16
- end
17
- end