effective_bootstrap 0.6.15 → 0.6.16

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: baff32b0e2fd189ebfed2965601b5b28f310d06bc81ffcfa21cb4408800535e0
4
- data.tar.gz: ea6ad9d1451a5841b2867083693a4a081a84aaea8ca7ff5f882652eca2a7cb0c
3
+ metadata.gz: ee127d9cd5bf9286c39d6956f815d55187024a996e90752fc44a022401adc6b6
4
+ data.tar.gz: 3e93f1f0f9caa77a5aeca17550597d80e250471c390924aebcb255b074e1e9d1
5
5
  SHA512:
6
- metadata.gz: d9171c65eb5ef481eb38f6d93edaff9e1762495825c6c8049aa848b86fc5fa3abb55507c2a262bbca05a77dbbd946e924c68d095f0e6ff2052ace5e7149b11ea
7
- data.tar.gz: 8220337bd6dba1c249595984c3b594b456e1cb0ce4e3a577aa455f1af2666771b292ac640bc094472df454ff6c04f50ad915daa024c6cb9de38377c77017b9de
6
+ metadata.gz: dfcb11403fdacfe1aaf2cb7c4b6b0eb7dfa5963a1ea31c06131cb5e32d1ef93cceab0a83794e357833fe0b9bc18dcb36ea9bdfbcffa17cdccfa150dc0b42fdfe
7
+ data.tar.gz: 8953ebb9de05d0bc59e20962752706055ac8a00f86fb8e4f43989fa8a601d878b9d4ab0aaeb38c20f24801d5106453247ac7b7740755eaa55047069303d03cb2
data/README.md CHANGED
@@ -231,6 +231,8 @@ The default is `layout: :vertical`.
231
231
 
232
232
  All standard form fields have been implemented as per [Rails 5.1 FormHelper](http://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/FormHelper.html)
233
233
 
234
+ When working as a `remote: true` form, you can also pass `flash_success: true|false` and `flash_error: true|false` to control the flash behaviour. By default, the errors will be displayed, and the success will be hidden.
235
+
234
236
  ### Options
235
237
 
236
238
  There are three sets of options hashes that you can pass into any form input:
@@ -101,7 +101,7 @@ this.EffectiveForm ||= new class
101
101
  flash_status = @remote_form_flash[0][0]
102
102
  flash_message = @remote_form_flash[0][1]
103
103
 
104
- @flash($form, flash_status, flash_message, true)
104
+ @flash($form, flash_status, flash_message)
105
105
 
106
106
  # Fire off form events
107
107
  was_error = ($form.hasClass('with-errors') || flash_status == 'danger' || flash_status == 'error')
@@ -118,7 +118,7 @@ this.EffectiveForm ||= new class
118
118
  @current_submit = ''
119
119
  true
120
120
 
121
- flash: ($form, status, message, skip_success = false) ->
121
+ flash: ($form, status, message) ->
122
122
  return unless @current_submit.length > 0
123
123
 
124
124
  if status == 'danger' || status == 'error'
@@ -126,7 +126,7 @@ this.EffectiveForm ||= new class
126
126
  else
127
127
  @current_submit.find('.eb-icon-check').show().delay(1000).fadeOut('slow', -> $form.trigger('effective-form:success-animation-done', @remote_form_commit, message))
128
128
 
129
- if message? && !(status == 'success' && skip_success)
129
+ if (message || '').length > 0
130
130
  @current_submit.prepend(@buildFlash(status, message))
131
131
 
132
132
  clearFlash: -> @current_submit.find('.alert').remove() if @current_submit.length > 0
@@ -12,6 +12,14 @@
12
12
  }
13
13
  }
14
14
 
15
+ form[data-remote="true"]:not(.show-flash-success) {
16
+ .effective-form-flash.alert-success { display: none; }
17
+ }
18
+
19
+ form[data-remote="true"].hide-flash-danger {
20
+ .effective-form-flash.alert-danger { display: none; }
21
+ }
22
+
15
23
  .form-actions-inline.justify-content-end {
16
24
  margin-left: 0.5em;
17
25
 
@@ -13,13 +13,6 @@ module EffectiveFormBuilderHelper
13
13
  "new_#{class_name}"
14
14
  end
15
15
 
16
- options[:class] = [
17
- options[:class],
18
- 'needs-validation',
19
- ('form-inline' if options[:layout] == :inline),
20
- ('with-errors' if subject.respond_to?(:errors) && subject.errors.present?)
21
- ].compact.join(' ')
22
-
23
16
  options[:html] = (options[:html] || {}).merge(novalidate: true, onsubmit: 'return EffectiveForm.validate(this);')
24
17
 
25
18
  remote_index = options.except(:model).hash.abs
@@ -31,6 +24,15 @@ module EffectiveFormBuilderHelper
31
24
  options[:local] = false
32
25
  end
33
26
 
27
+ options[:class] = [
28
+ options[:class],
29
+ 'needs-validation',
30
+ ('form-inline' if options[:layout] == :inline),
31
+ ('with-errors' if subject.respond_to?(:errors) && subject.errors.present?),
32
+ ('show-flash-success' if options[:remote] && options[:flash_success]),
33
+ ('hide-flash-danger' if options[:remote] && options.key?(:flash_error) && !options[:flash_error])
34
+ ].compact.join(' ')
35
+
34
36
  if options.delete(:remote) == true
35
37
  @_effective_remote_index ||= {}
36
38
  remote_index = remote_index + 1 if @_effective_remote_index[remote_index]
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.6.15'.freeze
2
+ VERSION = '0.6.16'.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.6.15
4
+ version: 0.6.16
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: 2020-02-20 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails