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: 703a3fcf46aa777dda6ed22421da5a937027a19de733cc461da566d892bf207a
4
- data.tar.gz: c5c389c17b60a395a77d0d9d92a0171af83d5f94fb102017c3b01adbf10f7857
3
+ metadata.gz: e095e90e8a67093d377cd4ba64763adead3eaf7f100e7e27a3a6ab60c2851763
4
+ data.tar.gz: ee22043cb52eea432818add1114b5e08f8b91deb450845c480ee289794f72809
5
5
  SHA512:
6
- metadata.gz: 3f45524f227c1d73c64eea3f8660aee6e8054617c17f969ed85f3c131048678d8fc0988c24d5421b7a27b6a8787135a0957c8de1d5c7033e13fa92f25a504c6c
7
- data.tar.gz: a77b5396c95012b32f2a682c7bb40974f9e60e9f65fc8a0a890595f968a9114ba3c883c3f19f1352b1f84ef8c9ea97a07024887c1209c6e63043a57c5d5cdf19
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
  })
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveAdmin
4
4
  module DynamicFields
5
- VERSION = '0.4.2'
5
+ VERSION = '0.4.4'
6
6
  end
7
7
  end
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.2
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-24 00:00:00.000000000 Z
11
+ date: 2020-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin