active_admin_simple_life 0.0.2 → 0.0.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a252b16609862d3cd5c7273dc4e0fc1f7bcb235d
|
4
|
+
data.tar.gz: 7ffd5c633e72d7e56c1500e314345568d57d673a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
44
|
+
give you simple menu, with only `main_fields` and `filters` in 1 line.
|
45
45
|
method takes options like:
|
46
|
-
*
|
47
|
-
*
|
48
|
-
* `
|
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
|
-
|
64
|
-
|
65
|
-
truncate(field.to_s, length:
|
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)
|