active_dry_form 1.0.0 → 1.1.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
  SHA256:
3
- metadata.gz: a1bc39aacc5e7a40501a20eeadc515470220ba16439fa8c92c31bdf85f330103
4
- data.tar.gz: 14f34c96e37c815f85c2adfee658e2fcf5801c92d8a17574f8f620ff90ab3159
3
+ metadata.gz: 0134c8126c7ce5ea25422550c9ed232b668ce2d0e3b892bbc1535340bf2bcfe5
4
+ data.tar.gz: a1a90179815dec9d0964d6aa03612565afc1cafe157cb29eebeba225fcf0996d
5
5
  SHA512:
6
- metadata.gz: 295333f32cd4a66a5e8dc30953af57b527370abbb808d7f668bafd13ee1f256976245f4ba1db7bf8288caa5ba5f92ddaab6f32d085f285bfe1d7599652cd67c3
7
- data.tar.gz: 96e147d7df5450147c17722c8867cdd7836108f91c274f1b6e660857c2742c52942fc9de10744cdde5fc9da8ba3a2817f4ae03242d00f91b5a5644672af000ad
6
+ metadata.gz: eb484a9edbfb4fe0f215717dbd4cab04b41ec6eaf33334c663ac588df393bdae26d13cd7d7c973d25e3c193a5f21871314142122679c91b44c3fee7765cd5af7
7
+ data.tar.gz: f845993ba3a0cc7c0756b610634cae6a1c6b3fb0e4cee3f45d985ffc045cbe10460637b198fdcbd35cdbc1f1ff71df105edddc55ac3aaaca18f832223a40b15e
data/Gemfile.lock CHANGED
@@ -27,7 +27,7 @@ GIT
27
27
  PATH
28
28
  remote: .
29
29
  specs:
30
- active_dry_form (0.1.0)
30
+ active_dry_form (1.0.0)
31
31
  actionpack
32
32
  activerecord
33
33
  dry-configurable
@@ -3,8 +3,6 @@
3
3
  module ActiveDryForm
4
4
  class Builder < ActionView::Helpers::FormBuilder
5
5
 
6
- include ActionView::Helpers::TagHelper
7
- include ActionView::Context
8
6
  include Dry::Core::Constants
9
7
 
10
8
  def input(field, options = {})
@@ -56,16 +54,16 @@ module ActiveDryForm
56
54
  def show_base_errors
57
55
  return if @object.base_errors.empty?
58
56
 
59
- tag.div class: ActiveDryForm.config.css_classes.base_error do
60
- tag.ul do
57
+ @template.content_tag(:div, class: ActiveDryForm.config.css_classes.base_error) do
58
+ @template.content_tag(:ul) do
61
59
  # внутри ошибки может быть html
62
- @object.base_errors.map { tag.li _1.html_safe }.join.html_safe
60
+ @object.base_errors.map { @template.content_tag(:li, _1.html_safe) }.join.html_safe
63
61
  end
64
62
  end
65
63
  end
66
64
 
67
65
  def show_error(field)
68
- ActiveDryForm::Input.new(self, __method__, field, {}).error_text
66
+ ActiveDryForm::Input.new(self, nil, field, {}).error_text
69
67
  end
70
68
 
71
69
  def button(value = nil, options = {}, &block)
@@ -7,9 +7,7 @@ module ActiveDryForm
7
7
  options[:builder] = ActiveDryForm::Builder
8
8
  options[:html] = html_options(options)
9
9
 
10
- # Array.wrap because Hash === name, it breaks polymorphic_path
11
- # TODO: refactor to options[:url]
12
- form_for(Array.wrap(name), options) do |f|
10
+ form_for(name, options) do |f|
13
11
  concat f.show_base_errors
14
12
  instance_exec(f, &block)
15
13
  end
@@ -5,6 +5,9 @@ module ActiveDryForm
5
5
 
6
6
  def initialize(builder, builder_method, field, options)
7
7
  @builder = builder
8
+ @form_object = builder.object
9
+ @template = builder.instance_variable_get(:@template)
10
+
8
11
  @builder_method = builder_method
9
12
  @field = field
10
13
 
@@ -25,7 +28,7 @@ module ActiveDryForm
25
28
  end
26
29
 
27
30
  def wrap_tag(input, label_last: nil)
28
- @builder.tag.div class: css_classes do
31
+ @template.tag(:div, class: css_classes) do
29
32
  [
30
33
  label_last ? input : label,
31
34
  label_last ? label : input,
@@ -42,23 +45,23 @@ module ActiveDryForm
42
45
  def hint_text
43
46
  return unless @hint_text
44
47
 
45
- @builder.tag.small @hint_text, class: ActiveDryForm.config.css_classes.hint
48
+ @template.content_tag(:small, @hint_text, class: ActiveDryForm.config.css_classes.hint)
46
49
  end
47
50
 
48
51
  def error_text
49
52
  return unless error?(@field)
50
53
 
51
54
  obj_error_text =
52
- case e = @builder.object.errors[@field]
55
+ case e = @form_object.errors[@field]
53
56
  when Hash then e.values
54
57
  else e
55
58
  end
56
59
 
57
- @builder.tag.div obj_error_text.join('<br />').html_safe, class: ActiveDryForm.config.css_classes.error
60
+ @template.content_tag(:div, obj_error_text.join('<br />').html_safe, class: ActiveDryForm.config.css_classes.error)
58
61
  end
59
62
 
60
63
  def error?(field)
61
- @builder.object.errors.key?(field)
64
+ @form_object.errors.key?(field)
62
65
  end
63
66
 
64
67
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveDryForm
4
4
 
5
- VERSION = '1.0.0'
5
+ VERSION = '1.1.0'
6
6
 
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_dry_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ermolaev Andrey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-28 00:00:00.000000000 Z
11
+ date: 2024-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -112,6 +112,9 @@ homepage: https://github.com/corp-gp/active_dry_form
112
112
  licenses:
113
113
  - MIT
114
114
  metadata:
115
+ allowed_push_host: https://rubygems.org
116
+ homepage_uri: https://github.com/corp-gp/active_dry_form
117
+ source_code_uri: https://github.com/corp-gp/active_dry_form
115
118
  rubygems_mfa_required: 'true'
116
119
  post_install_message:
117
120
  rdoc_options: []