active_admin_simple_life 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: 4dbb9fd0eac672fd2b9f57ca4243839719b16c7c
4
- data.tar.gz: a6f3c276440b9b8a69294745b256d47d2b1b240a
3
+ metadata.gz: a252b16609862d3cd5c7273dc4e0fc1f7bcb235d
4
+ data.tar.gz: 7ffd5c633e72d7e56c1500e314345568d57d673a
5
5
  SHA512:
6
- metadata.gz: b737608ba11584d5e318e575b0e8c1655c2d1a850589b66e834e4a2a8c4ee552e524757f8005e9bd8909e0c76a0df921fc7cc9876fdd9c9bc5ab825e1dc46fb5
7
- data.tar.gz: 433b2308c7da1455bad83e00addb86a0e7b23e369ba1978c8f072015aeb2a91a42f4dd7a3ea09d86bc71b1fd2262e77a1aec21855c48c9b5a270dceaa8b5a358
6
+ metadata.gz: fd53081a69abbab520c2f0ef004df24c6e7e8208ea855b97606db2e7f22a8a1294d2553d6d1466ca5096986320f0e3f27a7f5250ab047396576d7b0f1b000881
7
+ data.tar.gz: 4f4e923c9f2b29509d20e7cdae768e94bc25390010f35d9eecf27945be190243f4075e16d3199c2c0ee274af037b3120ca5f4c734acd0eb9f1487eb277131688
data/README.md CHANGED
@@ -21,8 +21,8 @@ ActiveAdmin.setup do |config|
21
21
  # your settings
22
22
  ```
23
23
 
24
- I used 2 includes, be course `simple_menu_for` method must be in main namespace,
25
- so it is not a bug ;)
24
+ I had to include `simple_menu_for` method bacause it must be in the main
25
+ namespace, so it is not a bug ;)
26
26
 
27
27
  ###Usage
28
28
 
@@ -41,15 +41,16 @@ end
41
41
  ###Methods
42
42
 
43
43
  `simple_menu_for KlassName, [options]` which will make all dirty work, and just
44
- jive you simple menu, with only `main_fields` and `filters` in 1 line.
44
+ give you simple menu, with only `main_fields` and `filters` in 1 line.
45
45
  method takes options like:
46
- * `priority` = `ActiveAdmin` proxy menu `priority`
47
- * `parent` = `ActiveAdmin` proxy menu `parent`
48
- * `[permitted_params] = addition for strong params (by default provides only
46
+ * `:priority` = `ActiveAdmin` proxy menu `priority`
47
+ * `:parent` = `ActiveAdmin` proxy menu `parent`
48
+ * `:permitted_params` = addition for strong params (by default provides only
49
49
  `main_fields`)
50
+ * `:max_length` = max column length
50
51
 
51
52
  Parts of `simple_menu_for` may be used for other purposes with:
52
- * `index_for_main_fields klass`
53
+ * `index_for_main_fields klass, options`, where options is `:max_length`
53
54
  * `filter_for_main_fields klass`
54
55
  * `form_for_main_fields klass`
55
56
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveAdminSimpleLife
3
3
  module SimpleElements
4
- def index_for_main_fields(klass)
4
+ def index_for_main_fields(klass, options={})
5
+ max_length = options[:max_length]
5
6
  index download_links: false do
6
7
  selectable_column
7
8
  id_column
@@ -10,7 +11,7 @@ module ActiveAdminSimpleLife
10
11
  field_value = current.send(symbol.cut_id)
11
12
  case field_value
12
13
  when String
13
- truncate_field field_value
14
+ truncate_field field_value, max_length
14
15
  when ::ActiveSupport::TimeWithZone, Time, Date
15
16
  I18n.l field_value, format: :long
16
17
  when TrueClass
@@ -18,7 +19,7 @@ module ActiveAdminSimpleLife
18
19
  when FalseClass
19
20
  span_false
20
21
  else
21
- link_to truncate_field(field_value), send(fetch_path(field_value), field_value.id)
22
+ link_to truncate_field(field_value, max_length), send(fetch_path(field_value), field_value.id)
22
23
  end
23
24
  end
24
25
  end
@@ -60,9 +61,9 @@ module ActiveAdminSimpleLife
60
61
 
61
62
  private
62
63
 
63
- # TODO: move length to var
64
- def truncate_field(field)
65
- truncate(field.to_s, length: 50)
64
+ def truncate_field(field, max_length = 50)
65
+ length = max_length || 50
66
+ truncate(field.to_s, length: max_length)
66
67
  end
67
68
 
68
69
  def fetch_path(field)
@@ -27,7 +27,7 @@ module ActiveAdminSimpleLife
27
27
  end
28
28
  end if permitted_params
29
29
 
30
- index_for_main_fields klass
30
+ index_for_main_fields klass, options
31
31
  filter_for_main_fields klass
32
32
  form_for_main_fields klass
33
33
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveAdminSimpleLife
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_simple_life
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kvokka