effective_bootstrap 0.3.13 → 0.3.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/effective_bootstrap/form.js.coffee +1 -2
- data/app/helpers/effective_form_builder_helper.rb +3 -2
- data/app/models/effective/form_builder.rb +5 -0
- data/app/models/effective/form_inputs/reset.rb +22 -0
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fe27ec0f7e80f2eb443ef732080279c0bda7b59
|
4
|
+
data.tar.gz: 66a908a12cc17816782cdabdee51a64145702356
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72bcff10833ff251624f1d29efbc786ec4cf31890e146e14c390c3a47cebfcc17a788618c56edd3823f5b4ba717722b5fd5a2a5309749336c02745df29096c4b
|
7
|
+
data.tar.gz: c341f4ce42b5d3e89bf40081768fb2e239e6e6c406287b1402402d92434f695534c4fb4225daf22e76e7e1d6fc97dfaa93ce61630c525451123ed6e74c72e4e2
|
@@ -91,6 +91,7 @@ this.EffectiveForm ||= new class
|
|
91
91
|
else
|
92
92
|
@flash($form, 'success', '', true)
|
93
93
|
|
94
|
+
$form.trigger(if $form.hasClass('with-errors') then 'effective-form:error' else 'effective-form:success')
|
94
95
|
$form.trigger('effective-form:complete')
|
95
96
|
true
|
96
97
|
|
@@ -98,10 +99,8 @@ this.EffectiveForm ||= new class
|
|
98
99
|
return unless @current_submit.length > 0
|
99
100
|
|
100
101
|
if status == 'danger' || status == 'error'
|
101
|
-
$form.trigger('effective-form:error', message)
|
102
102
|
@current_submit.find('.eb-icon-x').show().delay(1000).fadeOut('slow', -> $form.trigger('effective-form:error-animation-done', message))
|
103
103
|
else
|
104
|
-
$form.trigger('effective-form:success', message)
|
105
104
|
@current_submit.find('.eb-icon-check').show().delay(1000).fadeOut('slow', -> $form.trigger('effective-form:success-animation-done', message))
|
106
105
|
|
107
106
|
if message? && !(status == 'success' && skip_success)
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module EffectiveFormBuilderHelper
|
2
2
|
def effective_form_with(**options, &block)
|
3
|
-
options[:class] = [options[:class], 'needs-validation', ('form-inline' if options[:layout] == :inline)].compact.join(' ')
|
4
|
-
options[:html] = (options[:html] || {}).merge(novalidate: true, onsubmit: 'return EffectiveForm.validate(this);')
|
5
3
|
|
6
4
|
# Compute the default ID
|
7
5
|
subject = Array(options[:scope] || options[:model]).last
|
@@ -15,6 +13,9 @@ module EffectiveFormBuilderHelper
|
|
15
13
|
"new_#{class_name}"
|
16
14
|
end
|
17
15
|
|
16
|
+
options[:class] = [options[:class], 'needs-validation', ('form-inline' if options[:layout] == :inline), ('with-errors' if subject.respond_to?(:errors) && subject.errors.present?)].compact.join(' ')
|
17
|
+
options[:html] = (options[:html] || {}).merge(novalidate: true, onsubmit: 'return EffectiveForm.validate(this);')
|
18
|
+
|
18
19
|
remote_index = options.except(:model).hash.abs
|
19
20
|
|
20
21
|
if options.delete(:remote) == true
|
@@ -130,6 +130,11 @@ module Effective
|
|
130
130
|
Effective::FormInputs::Radios.new(name, options, builder: self).to_html
|
131
131
|
end
|
132
132
|
|
133
|
+
def reset(name = 'Reset', options = {})
|
134
|
+
(options = name; name = 'Reset') if name.kind_of?(Hash)
|
135
|
+
Effective::FormInputs::Reset.new(name, options, builder: self).to_html
|
136
|
+
end
|
137
|
+
|
133
138
|
def text_area(name, options = {})
|
134
139
|
Effective::FormInputs::TextArea.new(name, options, builder: self).to_html { super(name, options) }
|
135
140
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Effective
|
2
|
+
module FormInputs
|
3
|
+
class Reset < Effective::FormInput
|
4
|
+
|
5
|
+
def to_html(&block)
|
6
|
+
content_tag(:button, options[:input]) do
|
7
|
+
icon_name.present? ? (icon(icon_name) + name) : name
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def input_html_options
|
12
|
+
{ class: 'btn btn-primary', type: 'reset' }
|
13
|
+
end
|
14
|
+
|
15
|
+
def icon_name
|
16
|
+
return @icon unless @icon.nil?
|
17
|
+
@icon = options[:input].delete(:icon) || ''.html_safe
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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.3.
|
4
|
+
version: 0.3.14
|
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: 2019-02-
|
11
|
+
date: 2019-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -454,6 +454,7 @@ files:
|
|
454
454
|
- app/models/effective/form_inputs/price_field.rb
|
455
455
|
- app/models/effective/form_inputs/radios.rb
|
456
456
|
- app/models/effective/form_inputs/remote_link_to.rb
|
457
|
+
- app/models/effective/form_inputs/reset.rb
|
457
458
|
- app/models/effective/form_inputs/save.rb
|
458
459
|
- app/models/effective/form_inputs/select.rb
|
459
460
|
- app/models/effective/form_inputs/select_or_text.rb
|