visual_condition_builder 0.1.4 → 0.1.5
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: f00908014554adb5fe961fe91dde9275426a7d26
|
4
|
+
data.tar.gz: 345aa2b4c9dd11192ef2201fe51208bfde123d5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32822cb58d0c9f2086796758f1353baccdb820a518797560cf65547f365d9bbc7d084e9ad99c8b6ef35a9386b35829f31a56b812daac223a44cb4002f75fdf4f
|
7
|
+
data.tar.gz: 984153d0e0d5b0fda9e66eb13c9f819b4212042392ea588ac74e42e8469667aecb12bdb2c29667aec7cf8667844c912d9f465804e95ba25dc5ffaa232d2d2e78
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ The condition builder information is based on a dictionary, so you need to creat
|
|
51
51
|
|
52
52
|
To generate the dictionary structure run:
|
53
53
|
```sh
|
54
|
-
$ rails g
|
54
|
+
$ rails g visual_condition_builder:dictionary example
|
55
55
|
```
|
56
56
|
Will be created a file `app/condition_dictionaries/example_dictionary.rb`:
|
57
57
|
|
@@ -279,7 +279,7 @@ Mas você pode fazer a geração da lista de campos manualmente através do mét
|
|
279
279
|
|
280
280
|
How create condition builder in you view:
|
281
281
|
```haml
|
282
|
-
= form_tag
|
282
|
+
= form_tag my_controller_path, method: :get do
|
283
283
|
-# condition builder don't create input field with values, create it:
|
284
284
|
= hidden_field_tag('my_conditions', @example_conditions.to_json)
|
285
285
|
-# DropDown with fields
|
@@ -3,13 +3,14 @@ module VisualConditionBuilder
|
|
3
3
|
|
4
4
|
def build_conditions(dictionary, *args)
|
5
5
|
dictionary_name = get_dictionary_name(dictionary)
|
6
|
+
dictionary_klass = get_dictionary_klass(dictionary)
|
6
7
|
container_name = "#{dictionary_name}_condition_container"
|
7
8
|
|
8
9
|
hArgs = (args ||= []).reduce(Hash.new, :merge)
|
9
10
|
hArgs = normalize_placeholder_label(hArgs)
|
10
11
|
|
11
12
|
builder_options = {
|
12
|
-
dictionary:
|
13
|
+
dictionary: dictionary_klass.dictionary(get_dictionary_context(dictionary), self.request)
|
13
14
|
}.deep_merge(hArgs)
|
14
15
|
|
15
16
|
capture do
|
@@ -25,6 +26,7 @@ txtjs
|
|
25
26
|
|
26
27
|
def conditions_fields(dictionary)
|
27
28
|
dictionary_name = get_dictionary_name(dictionary)
|
29
|
+
dictionary_klass = get_dictionary_klass(dictionary)
|
28
30
|
container_name = "#{dictionary_name}_condition_container"
|
29
31
|
capture do
|
30
32
|
content_tag(:div, class: 'dropdown add-condition', data: {target: "##{container_name}"}) do
|
@@ -33,7 +35,7 @@ txtjs
|
|
33
35
|
concat(content_tag(:span, nil, class:'caret'))
|
34
36
|
end)
|
35
37
|
concat(content_tag(:ul, class: 'dropdown-menu add-condition-menu') do
|
36
|
-
create_conditions_fields_item(
|
38
|
+
create_conditions_fields_item(dictionary_klass.fields(get_dictionary_context(dictionary)))
|
37
39
|
end)
|
38
40
|
end
|
39
41
|
end
|
@@ -58,6 +60,9 @@ txtjs
|
|
58
60
|
def get_dictionary_name(dictionary)
|
59
61
|
"#{dictionary.is_a?(Hash) ? dictionary.keys.first : dictionary}_#{get_dictionary_context(dictionary)}"
|
60
62
|
end
|
63
|
+
def get_dictionary_klass(dictionary)
|
64
|
+
"#{dictionary.is_a?(Hash) ? dictionary.keys.first : dictionary}_dictionary".classify.constantize
|
65
|
+
end
|
61
66
|
|
62
67
|
def normalize_placeholder_label(args)
|
63
68
|
args[:placeholder] ||= {}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visual_condition_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Porto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A great and easy visual condition builder to your rails project
|
14
14
|
email:
|