activeadmin_dynamic_fields 0.4.2 → 0.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e095e90e8a67093d377cd4ba64763adead3eaf7f100e7e27a3a6ab60c2851763
|
4
|
+
data.tar.gz: ee22043cb52eea432818add1114b5e08f8b91deb450845c480ee289794f72809
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 116395a999d86f0f976a04cd7be8ba1ee994ce6bcb71c21d735e621ed037881aa24b73a57fa75e7be8062acfb6ea178e935da0e03b9d0c82f29ec8f73b7afff5
|
7
|
+
data.tar.gz: 6d7659ba3297a2f218829678bd24ea10a62703ed294822dc94ac5591671f92073d496e9d7432b6c7b80da25bd70238490e4285ef31e42c21e5a60d991c5a8448
|
data/README.md
CHANGED
@@ -31,6 +31,8 @@ Conditions:
|
|
31
31
|
+ **changed**: check if the value of an input is changed (dirty)
|
32
32
|
- **data-eq**: check if a field has a specific value (ex. `"data-eq": "42"`)
|
33
33
|
- **data-not**: check if a field has not a specific value
|
34
|
+
- **data-match**: check if a field match a regexp
|
35
|
+
- **data-mismatch**: check if a field doesn't match a regexp (ex. `"data-mismatch": "^\d+$"`)
|
34
36
|
- **data-function**: check the return value of a custom function (ex. `"data-function": "my_check"`)
|
35
37
|
|
36
38
|
Actions:
|
@@ -33,6 +33,8 @@
|
|
33
33
|
changed: _el => true,
|
34
34
|
checked: el => el.is(':checked'),
|
35
35
|
eq: (el, value) => el.val() == value,
|
36
|
+
match: (el, regexp) => regexp.test(el.val()),
|
37
|
+
mismatch: (el, regexp) => !regexp.test(el.val()),
|
36
38
|
not: (el, value) => el.val() != value,
|
37
39
|
not_blank: el => el.val().trim(),
|
38
40
|
not_checked: el => !el.is(':checked')
|
@@ -69,6 +71,12 @@
|
|
69
71
|
if (!this.condition && el.data('not')) {
|
70
72
|
[this.condition, this.condition_arg] = [CONDITIONS['not'], el.data('not')]
|
71
73
|
}
|
74
|
+
if (!this.condition && el.data('match')) {
|
75
|
+
[this.condition, this.condition_arg] = [CONDITIONS['match'], new RegExp(el.data('match'))]
|
76
|
+
}
|
77
|
+
if (!this.condition && el.data('mismatch')) {
|
78
|
+
[this.condition, this.condition_arg] = [CONDITIONS['mismatch'], new RegExp(el.data('mismatch'))]
|
79
|
+
}
|
72
80
|
this.custom_function = el.data('function')
|
73
81
|
if (!this.condition && this.custom_function) {
|
74
82
|
this.condition = window[this.custom_function]
|
@@ -164,7 +172,7 @@
|
|
164
172
|
// Init
|
165
173
|
$(document).ready(function () {
|
166
174
|
// Setup dynamic fields
|
167
|
-
const selectors = '.active_admin .input [data-if], .active_admin .input [data-eq], .active_admin .input [data-not], .active_admin .input [data-function]'
|
175
|
+
const selectors = '.active_admin .input [data-if], .active_admin .input [data-eq], .active_admin .input [data-not], .active_admin .input [data-match], .active_admin .input [data-mismatch], .active_admin .input [data-function]'
|
168
176
|
$(selectors).each(function () {
|
169
177
|
new Field($(this)).setup()
|
170
178
|
})
|
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.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|