forest_liana 5.3.0 → 5.3.1
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
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4ce31e8e9d92594427c53bfd5b2b6827218a225921fbeec7a371404fcbbf67bc
|
|
4
|
+
data.tar.gz: 4baa01b9c4583493f697123ec8517ad191ceeec5ee7923058f70fd33255a2026
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 423933e1177d38264ea7b351a66a86c8dd7d4d435c15fdd23f4399ae9cde8bf9604405dea94051038467b8853fa70e24e7d8e73cfb79ad124056c196f8b12ad0
|
|
7
|
+
data.tar.gz: f9b955b3a70e2a1a576d5be1635a9257b72c2938929dd6b21d009a9de8f705a24a0f194f19f829703d73d1d9e0d47117fd9d71da8e55c997613834521a136313
|
|
@@ -27,12 +27,19 @@ module ForestLiana
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def get_smart_action_load_ctx(fields)
|
|
30
|
-
fields = fields.reduce({})
|
|
30
|
+
fields = fields.reduce({}) do |p, c|
|
|
31
|
+
ForestLiana::WidgetsHelper.set_field_widget(c)
|
|
32
|
+
p.update(c[:field] => c.merge!(value: nil))
|
|
33
|
+
end
|
|
31
34
|
{:record => get_record, :fields => fields}
|
|
32
35
|
end
|
|
33
36
|
|
|
34
37
|
def get_smart_action_change_ctx(fields)
|
|
35
|
-
fields = fields.reduce({})
|
|
38
|
+
fields = fields.reduce({}) do |p, c|
|
|
39
|
+
field = c.permit!.to_h.symbolize_keys
|
|
40
|
+
ForestLiana::WidgetsHelper.set_field_widget(field)
|
|
41
|
+
p.update(c[:field] => field)
|
|
42
|
+
end
|
|
36
43
|
{:record => get_record, :fields => fields}
|
|
37
44
|
end
|
|
38
45
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require 'set'
|
|
2
|
+
|
|
3
|
+
module ForestLiana
|
|
4
|
+
module WidgetsHelper
|
|
5
|
+
|
|
6
|
+
@widget_edit_list = [
|
|
7
|
+
'address editor',
|
|
8
|
+
'belongsto typeahead',
|
|
9
|
+
'belongsto dropdown',
|
|
10
|
+
'boolean editor',
|
|
11
|
+
'checkboxes',
|
|
12
|
+
'color editor',
|
|
13
|
+
'date editor',
|
|
14
|
+
'dropdown',
|
|
15
|
+
'embedded document editor',
|
|
16
|
+
'file picker',
|
|
17
|
+
'json code editor',
|
|
18
|
+
'input array',
|
|
19
|
+
'multiple select',
|
|
20
|
+
'number input',
|
|
21
|
+
'point editor',
|
|
22
|
+
'price editor',
|
|
23
|
+
'radio button',
|
|
24
|
+
'rich text',
|
|
25
|
+
'text area editor',
|
|
26
|
+
'text editor',
|
|
27
|
+
'time input',
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
@v1_to_v2_edit_widgets_mapping = {
|
|
31
|
+
address: 'address editor',
|
|
32
|
+
'belongsto select': 'belongsto dropdown',
|
|
33
|
+
'color picker': 'color editor',
|
|
34
|
+
'date picker': 'date editor',
|
|
35
|
+
price: 'price editor',
|
|
36
|
+
'JSON editor': 'json code editor',
|
|
37
|
+
'rich text editor': 'rich text',
|
|
38
|
+
'text area': 'text area editor',
|
|
39
|
+
'text input': 'text editor',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
def self.set_field_widget(field)
|
|
43
|
+
|
|
44
|
+
if field[:widget]
|
|
45
|
+
if @v1_to_v2_edit_widgets_mapping[field[:widget].to_sym]
|
|
46
|
+
field[:widgetEdit] = {name: @v1_to_v2_edit_widgets_mapping[field[:widget].to_sym], parameters: {}}
|
|
47
|
+
elsif @widget_edit_list.include?(field[:widget])
|
|
48
|
+
field[:widgetEdit] = {name: field[:widget], parameters: {}}
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
if !field.key?(:widgetEdit)
|
|
53
|
+
field[:widgetEdit] = nil
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
field.delete(:widget)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
data/lib/forest_liana/version.rb
CHANGED
|
@@ -114,7 +114,10 @@ describe 'Requesting Actions routes', :type => :request do
|
|
|
114
114
|
it 'should respond 200' do
|
|
115
115
|
post '/forest/actions/my_action/hooks/change', JSON.dump(params), 'CONTENT_TYPE' => 'application/json'
|
|
116
116
|
expect(response.status).to eq(200)
|
|
117
|
-
|
|
117
|
+
expected = updated_foo.merge({:value => 'baz'})
|
|
118
|
+
expected[:widgetEdit] = nil
|
|
119
|
+
expected.delete(:widget)
|
|
120
|
+
expect(JSON.parse(response.body)).to eq({'fields' => [expected.stringify_keys]})
|
|
118
121
|
end
|
|
119
122
|
|
|
120
123
|
it 'should respond 500 with bad params' do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: forest_liana
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.3.
|
|
4
|
+
version: 5.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sandro Munda
|
|
@@ -214,6 +214,7 @@ files:
|
|
|
214
214
|
- app/helpers/forest_liana/is_same_data_structure_helper.rb
|
|
215
215
|
- app/helpers/forest_liana/query_helper.rb
|
|
216
216
|
- app/helpers/forest_liana/schema_helper.rb
|
|
217
|
+
- app/helpers/forest_liana/widgets_helper.rb
|
|
217
218
|
- app/models/forest_liana/model/action.rb
|
|
218
219
|
- app/models/forest_liana/model/collection.rb
|
|
219
220
|
- app/models/forest_liana/model/segment.rb
|