abyme 0.6.3 → 0.6.4

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: e71aaa0391ddf79198fbd0e3076b7899ecd8a72abbfac41429d416f3a671dccc
4
- data.tar.gz: 382947241368e89f93142bb5b0c9b34f1af8323f5d8689fd54d2dd4a7907385e
3
+ metadata.gz: aa7e981607f8bab371a8cef7529510076e0095db0b3c1908ba045e21df10a476
4
+ data.tar.gz: f25822329ba46b8418e4d0507291b590a3ce3e9b1f2ff2a7b25ff78821fbb0dd
5
5
  SHA512:
6
- metadata.gz: 34cc3af27975485027977aa98f51419924ec4d42f3f72a0a03c559eaed18bb2a2e5734efc9345ed10631740f7860b63691e42da159c84e89e27711505ce19a6c
7
- data.tar.gz: e9588871ddce9c79d34d77511a9f56f29a280177a5dc9f9fe056cc7540ce2e28d3b0a64d6ceb5735811cd910e9cf1692e4a5ff81a87eaec8d0a0c4d466ff216d
6
+ metadata.gz: 77ea88778c1373472d1c8af396e235e6d51331ffabab8b613763a0fabb89ced08d76d0741af52254774d80011a2a77786520fd52f4385de8e212b5f3858884f4
7
+ data.tar.gz: 999cadbcf32145e4f1968815779d1828f04a272c1923135a5a049b40e676889755349c19b377f1b97913301b15ffce2650e9f4641442b4037d4851a1ba73b353
data/.DS_Store CHANGED
Binary file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abyme (0.6.3)
4
+ abyme (0.6.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -100,11 +100,9 @@ GEM
100
100
  marcel (1.0.1)
101
101
  method_source (1.0.0)
102
102
  mini_mime (1.1.0)
103
- mini_portile2 (2.5.3)
104
103
  minitest (5.14.4)
105
104
  nio4r (2.5.7)
106
- nokogiri (1.11.7)
107
- mini_portile2 (~> 2.5.0)
105
+ nokogiri (1.11.7-x86_64-darwin)
108
106
  racc (~> 1.4)
109
107
  pry (0.13.1)
110
108
  coderay (~> 1.1)
@@ -211,7 +209,7 @@ GEM
211
209
  zeitwerk (2.4.2)
212
210
 
213
211
  PLATFORMS
214
- ruby
212
+ x86_64-darwin-19
215
213
 
216
214
  DEPENDENCIES
217
215
  abyme!
data/abyme.gemspec CHANGED
@@ -26,6 +26,9 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ["lib"]
28
28
 
29
+ # SimpleForm dependency is only required for test purposes and optional behaviour
30
+ spec.add_development_dependency 'simple_form'
31
+
29
32
  spec.add_development_dependency "bundler", "~> 2.0"
30
33
  spec.add_development_dependency "rake", "~> 13.0"
31
34
  # Tests
@@ -42,7 +45,6 @@ Gem::Specification.new do |spec|
42
45
  spec.add_development_dependency 'pry-byebug'
43
46
  spec.add_development_dependency 'byebug'
44
47
  spec.add_development_dependency 'web-console'
45
- spec.add_development_dependency 'simple_form'
46
48
 
47
49
  spec.add_development_dependency 'puma'
48
50
  spec.add_development_dependency 'simplecov'
data/lib/abyme/version.rb CHANGED
@@ -3,7 +3,7 @@ module Abyme
3
3
  module VERSION
4
4
  MAJOR = 0
5
5
  MINOR = 6
6
- PATCH = 3
6
+ PATCH = 4
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH].join(".")
9
9
  end
@@ -113,7 +113,7 @@ module Abyme
113
113
 
114
114
  content_tag(:div, build_attributes(wrapper_default, options[:wrapper_html])) do
115
115
  content_tag(:template, class: "abyme--#{association.to_s.singularize}_template", data: {abyme_target: "template"}) do
116
- form.fields_for association, association.to_s.classify.constantize.new, child_index: "NEW_RECORD" do |f|
116
+ fields_for_builder form, association, association.to_s.classify.constantize.new, child_index: "NEW_RECORD" do |f|
117
117
  content_tag(:div, build_attributes(fields_default, basic_fields_markup(options[:fields_html], association))) do
118
118
  # Here, if a block is passed, we're passing the association fields to it, rather than the form itself
119
119
  # block_given? ? yield(f) : render(options[:partial] || "abyme/#{association.to_s.singularize}_fields", f: f)
@@ -182,7 +182,7 @@ module Abyme
182
182
  end
183
183
 
184
184
  content_tag(:div, options[:wrapper_html]) do
185
- form.fields_for(association, records) do |f|
185
+ fields_for_builder(form, association, records) do |f|
186
186
  content_tag(:div, build_attributes(fields_default, basic_fields_markup(options[:fields_html], association))) do
187
187
  block_given? ? yield(f) : render_association_partial(association, f, options[:partial])
188
188
  end
@@ -213,6 +213,19 @@ module Abyme
213
213
 
214
214
  private
215
215
 
216
+ # FORM BUILDER SELECTION
217
+
218
+ # If form builder inherits from SimpleForm, we should use its fields_for helper to keep the wrapper options
219
+ # :nocov:
220
+ def fields_for_builder(form, association, records, options = {}, &block)
221
+ if defined?(SimpleForm) && form.instance_of?(SimpleForm::FormBuilder)
222
+ form.simple_fields_for(association, records, options, &block)
223
+ else
224
+ form.fields_for(association, records, options, &block)
225
+ end
226
+ end
227
+ # :nocov:
228
+
216
229
  # CREATE_BUTTON
217
230
 
218
231
  # this helper is call by either add_associated_record or remove_associated_record
@@ -8,6 +8,7 @@ module Abyme
8
8
  argument :association, type: :string, required: true, banner: "association association"
9
9
  argument :attributes, type: :array, default: [], banner: "field field"
10
10
 
11
+ # :nocov:
11
12
  def create_partial_file
12
13
  create_file partial_file_path
13
14
  if defined?(SimpleForm)
@@ -16,6 +17,7 @@ module Abyme
16
17
  insert_fields
17
18
  end
18
19
  end
20
+ # :nocov:
19
21
 
20
22
  private
21
23
 
@@ -23,6 +25,7 @@ module Abyme
23
25
  Rails.root.join("app", "views", "abyme", "_#{association.downcase.singularize}_fields.html.erb")
24
26
  end
25
27
 
28
+ # :nocov:
26
29
  def insert_fields(builder = nil)
27
30
  return unless File.exist? partial_file_path
28
31
  if builder == :simple_form
@@ -31,6 +34,7 @@ module Abyme
31
34
  insert_into_file(partial_file_path, "<%# Insert #{association.downcase} fields below %>\n" << default_keys)
32
35
  end
33
36
  end
37
+ # :nocov:
34
38
 
35
39
  def simple_form_fields
36
40
  inputs = if attributes.include?("all_attributes")
@@ -0,0 +1,15 @@
1
+ <%# frozen_string_literal: true %>
2
+ <%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
3
+ <%%= f.error_notification %>
4
+ <%%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
5
+
6
+ <div class="form-inputs">
7
+ <%- attributes.each do |attribute| -%>
8
+ <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
9
+ <%- end -%>
10
+ </div>
11
+
12
+ <div class="form-actions">
13
+ <%%= f.button :submit %>
14
+ </div>
15
+ <%% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abyme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain Sanson
@@ -9,8 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-06-24 00:00:00.000000000 Z
12
+ date: 2021-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: simple_form
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: bundler
16
30
  requirement: !ruby/object:Gem::Requirement
@@ -193,20 +207,6 @@ dependencies:
193
207
  - - ">="
194
208
  - !ruby/object:Gem::Version
195
209
  version: '0'
196
- - !ruby/object:Gem::Dependency
197
- name: simple_form
198
- requirement: !ruby/object:Gem::Requirement
199
- requirements:
200
- - - ">="
201
- - !ruby/object:Gem::Version
202
- version: '0'
203
- type: :development
204
- prerelease: false
205
- version_requirements: !ruby/object:Gem::Requirement
206
- requirements:
207
- - - ">="
208
- - !ruby/object:Gem::Version
209
- version: '0'
210
210
  - !ruby/object:Gem::Dependency
211
211
  name: puma
212
212
  requirement: !ruby/object:Gem::Requirement
@@ -300,6 +300,7 @@ files:
300
300
  - lib/generators/abyme/stimulus/stimulus_generator.rb
301
301
  - lib/generators/abyme/view/USAGE
302
302
  - lib/generators/abyme/view/view_generator.rb
303
+ - lib/templates/erb/scaffold/_form.html.erb
303
304
  - node_modules/.yarn-integrity
304
305
  - package-lock.json
305
306
  - package.json