activeadmin_dynamic_fields 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -4
- data/lib/activeadmin/dynamic_fields/version.rb +1 -1
- metadata +2 -156
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04dad08d3de4d4cfd25de86ec9a07e3010e081afc8481b513e85103026863869
|
4
|
+
data.tar.gz: 193871cc16015051ae231a3894c6dbf3fa71f043156fcfac7162bc830380e92c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed3de892e2f3e225bfc875c37906dfca703c1769413c631f20caf8a1fcded149c9560cf523c50f3e56ff60cca02622061c5fe8185a09d8bd081963d3674ee9ed
|
7
|
+
data.tar.gz: 70e75c688f0b2c8448e23f747752202288c89abf9ab7b4c5b11a1c4de1d92c3c18ff1e029e2e7728f5333bf76c2cc4ad54c0ca5b76402b33e698a83e448b410a
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
# ActiveAdmin Dynamic Fields [![Gem Version](https://badge.fury.io/rb/activeadmin_dynamic_fields.svg)](https://badge.fury.io/rb/activeadmin_dynamic_fields) [![
|
1
|
+
# ActiveAdmin Dynamic Fields [![Gem Version](https://badge.fury.io/rb/activeadmin_dynamic_fields.svg)](https://badge.fury.io/rb/activeadmin_dynamic_fields) [![Gem downloads](https://badgen.net/rubygems/dt/activeadmin_dynamic_fields)](https://rubygems.org/gems/activeadmin_dynamic_fields) [![Specs](https://github.com/blocknotes/activeadmin_dynamic_fields/actions/workflows/specs.yml/badge.svg)](https://github.com/blocknotes/activeadmin_dynamic_fields/actions/workflows/specs.yml)
|
2
2
|
|
3
3
|
An Active Admin plugin to add dynamic behaviors to some fields.
|
4
4
|
|
5
5
|
Features:
|
6
|
+
|
6
7
|
- set conditional checks on fields
|
7
8
|
- trigger actions on target elements
|
8
9
|
- inline field editing
|
@@ -10,19 +11,39 @@ Features:
|
|
10
11
|
|
11
12
|
The easiest way to show how this plugin works is looking the examples [below](#examples).
|
12
13
|
|
14
|
+
Please :star: if you like it.
|
15
|
+
|
13
16
|
## Install
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
|
18
|
+
First, add the gem to your ActiveAdmin project: `gem 'activeadmin_dynamic_fields'` (and execute `bundle`)
|
19
|
+
|
20
|
+
If you installed Active Admin **without Webpacker** support:
|
21
|
+
- add at the end of your ActiveAdmin javascripts (_app/assets/javascripts/active_admin.js_):
|
17
22
|
|
18
23
|
```js
|
19
24
|
//= require activeadmin/dynamic_fields
|
20
25
|
```
|
21
26
|
|
27
|
+
Otherwise **with Webpacker**:
|
28
|
+
|
29
|
+
- Execute in your project root:
|
30
|
+
|
31
|
+
```sh
|
32
|
+
yarn add blocknotes/activeadmin_dynamic_fields
|
33
|
+
```
|
34
|
+
|
35
|
+
- Add to your *app/javascript/packs/active_admin.js*:
|
36
|
+
|
37
|
+
```js
|
38
|
+
require('activeadmin_dynamic_fields')
|
39
|
+
```
|
40
|
+
|
22
41
|
## Options
|
42
|
+
|
23
43
|
Options are passed to fields using *input_html* parameter as *data* attributes.
|
24
44
|
|
25
45
|
Conditions:
|
46
|
+
|
26
47
|
- **data-if**: check a condition, values:
|
27
48
|
+ **checked**: check if a checkbox is checked (ex. `"data-if": "checked"`)
|
28
49
|
+ **not_checked**: check if a checkbox is not checked
|
@@ -36,6 +57,7 @@ Conditions:
|
|
36
57
|
- **data-function**: check the return value of a custom function (ex. `"data-function": "my_check"`)
|
37
58
|
|
38
59
|
Actions:
|
60
|
+
|
39
61
|
- **data-then**: action to trigger (alias **data-action**), values:
|
40
62
|
+ **hide**: hides elements (ex. `"data-then": "hide", "data-target": ".errors"`)
|
41
63
|
+ **slide**: hides elements (using sliding)
|
@@ -49,6 +71,7 @@ Actions:
|
|
49
71
|
- **data-args**: arguments passed to the callback function
|
50
72
|
|
51
73
|
Targets:
|
74
|
+
|
52
75
|
- **data-target**: target css selector (from parent fieldset, look for the closest match)
|
53
76
|
- **data-gtarget**: target css selector globally
|
54
77
|
|
@@ -57,6 +80,7 @@ A check condition or a custom check function are required. A trigger action is r
|
|
57
80
|
## Examples
|
58
81
|
|
59
82
|
### Dynamic fields examples
|
83
|
+
|
60
84
|
- A checkbox that hides other fields if is checked (ex. model *Article*):
|
61
85
|
|
62
86
|
```rb
|
@@ -128,6 +152,7 @@ function on_change_category(el) {
|
|
128
152
|
```
|
129
153
|
|
130
154
|
### Inline editing examples
|
155
|
+
|
131
156
|
- Prepare a custom member action to save data, an *update* helper function is available (third parameter is optional, allow to filter using strong parameters):
|
132
157
|
|
133
158
|
```rb
|
@@ -165,6 +190,7 @@ end
|
|
165
190
|
```
|
166
191
|
|
167
192
|
### Dialog example
|
193
|
+
|
168
194
|
Example with 2 models: *Author* and *Article*
|
169
195
|
|
170
196
|
Prepare the content dialog - in Active Admin Author config:
|
@@ -208,13 +234,16 @@ end
|
|
208
234
|
The link url is loaded via AJAX before opening the dialog.
|
209
235
|
|
210
236
|
## Do you like it? Star it!
|
237
|
+
|
211
238
|
If you use this component just star it. A developer is more motivated to improve a project when there is some interest. My other [Active Admin components](https://github.com/blocknotes?utf8=✓&tab=repositories&q=activeadmin&type=source).
|
212
239
|
|
213
240
|
Or consider offering me a coffee, it's a small thing but it is greatly appreciated: [about me](https://www.blocknot.es/about-me).
|
214
241
|
|
215
242
|
## Contributors
|
243
|
+
|
216
244
|
- [Mattia Roccoberton](http://blocknot.es): author
|
217
245
|
- The good guys that opened issues and pull requests from time to time
|
218
246
|
|
219
247
|
## License
|
248
|
+
|
220
249
|
The gem is available as open-source under the terms of the [MIT](LICENSE.txt).
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_dynamic_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
@@ -24,160 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activestorage
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '6.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '6.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: capybara
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.33'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.33'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.13'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.13'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: puma
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '4.3'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '4.3'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec_junit_formatter
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0.4'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0.4'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rspec-rails
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '4.0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '4.0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rubocop
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0.90'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0.90'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: sassc
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '2.4'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '2.4'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: selenium-webdriver
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '3.142'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '3.142'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: sprockets-rails
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '3.2'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '3.2'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: sqlite3
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '1.4'
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - "~>"
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '1.4'
|
181
27
|
description: An Active Admin plugin to add dynamic behaviors to fields
|
182
28
|
email: mat@blocknot.es
|
183
29
|
executables: []
|