active_admin_simple_life 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 059f403f8012aa9bd4e592258b2b1c6995a7f90c
4
- data.tar.gz: f32438e38df93cc3af33bb9ce3a1d0ea297a970f
3
+ metadata.gz: 8aa03c963023e3ef843224bd4c01c00b27095286
4
+ data.tar.gz: 705d2e272f174060334480d0e8c3db76ec694c3a
5
5
  SHA512:
6
- metadata.gz: f5484452ccff07d5ef7cfb6bfd78f27dfbbd6d7a50ee6f8a0a03e5a727fdb42a2a7568e1837c7d2daf42326c5b911563f0107158f146a2597a9103618393e3c0
7
- data.tar.gz: 85d6fc4452715f18a68c10d9d28482383efdb6dcc4a81dd8d8e4511fe1874ce14d11e37d9766f51c44faa35d4b31bb3d8450812536c50152bc87eb5c2446f5df
6
+ metadata.gz: 03fee0bce76777e94cce5095c8ed444a2f27e887ef2bf07e73cc2d3e5c049590f4b9feb1402abf8825f87bdc1e0fd13ff5154254b2be59a53f63817eae39ac49
7
+ data.tar.gz: 8784c225abc94ab76f5210824d503cb212ecebb996b0facc030b25ac2ad39fe2a65a67032c339e6ab3aafda0b6d536a673d86471a5cde4fa9dfada9c9bfd8960
data/README.md CHANGED
@@ -41,11 +41,14 @@ Parts of `simple_menu_for` may be used for other purposes with:
41
41
  1. `:max_length` - max length of field. Integer
42
42
  2. `:add` - extra fields, which will be added in index. Symbol or Array
43
43
  3. `:position` - extra fields starting position (from 0)
44
- * `filter_for_main_fields klass`
44
+ * `filter_for_main_fields klass, options`
45
+ 1. `:options` - accept Hash of options for 1 column, like `products: { hint: 'click for select'}`
45
46
  * `form_for_main_fields klass`
46
47
 
47
48
  Other feature is simple menu with 1 single nested klass. For it I made
48
- * `nested_form_for_main_fields klass, nested_klass`
49
+ * `nested_form_for_main_fields klass, nested_klass, options`
50
+ 1. `:options` - accept Hash of options for 1 column ot nested column. Nested column example
51
+ `products: {comments: { label: 'Words'} }`
49
52
 
50
53
  ###Goodies
51
54
 
@@ -48,16 +48,17 @@ module ActiveAdminSimpleLife
48
48
  end
49
49
  end
50
50
 
51
- def form_for_main_fields(klass, &block)
51
+ def form_for_main_fields(klass, options={}, &block)
52
52
  form do |f|
53
53
  f.semantic_errors(*f.object.errors.keys)
54
54
  f.inputs do
55
55
  klass.main_fields.each do |ff|
56
56
  ff_cut_id = ExtensionedSymbol.new(ff).cut_id
57
+ current_options = options[ff] || options[ff_cut_id] || {}
57
58
  if ff == ff_cut_id
58
59
  f.input ff_cut_id
59
60
  else
60
- f.input ff_cut_id, as: :select, member_label: :to_s
61
+ f.input ff_cut_id, {as: :select, member_label: :to_s}.merge(current_options)
61
62
  end
62
63
  end
63
64
  f.instance_eval(&block) if block_given?
@@ -67,13 +68,14 @@ module ActiveAdminSimpleLife
67
68
  end
68
69
 
69
70
  # simple nested set for 2 classes with defined main_fields
70
- def nested_form_for_main_fields(klass, nested_klass)
71
- form_for_main_fields(klass) do |form_field|
71
+ def nested_form_for_main_fields(klass, nested_klass, options={})
72
+ form_for_main_fields(klass,options) do |form_field|
72
73
  nested_table_name = nested_klass.to_s.underscore.pluralize.to_sym
73
74
  main_model_name = klass.to_s.underscore.to_sym
74
75
  form_field.has_many nested_table_name, allow_destroy: true do |form|
75
76
  nested_klass.main_fields.map { |f| ExtensionedSymbol.new(f).cut_id }.each do |nested_field|
76
- form.input(nested_field) unless nested_field == main_model_name
77
+ current_options = options.fetch(nested_table_name){{}}.fetch(nested_field){{}}
78
+ form.input(nested_field, current_options) unless nested_field == main_model_name
77
79
  end
78
80
  end
79
81
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveAdminSimpleLife
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_simple_life
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kvokka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-23 00:00:00.000000000 Z
11
+ date: 2016-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails