forest_liana 5.3.0 → 5.3.1

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: e035848d2e7346973187338d78579301dcf062b2b6192ba383cd1f50dcccf584
4
- data.tar.gz: 5f8a3ecdea7a8f4643922c27626397bfa3d497c14302f77f377153a22f064b0f
3
+ metadata.gz: 4ce31e8e9d92594427c53bfd5b2b6827218a225921fbeec7a371404fcbbf67bc
4
+ data.tar.gz: 4baa01b9c4583493f697123ec8517ad191ceeec5ee7923058f70fd33255a2026
5
5
  SHA512:
6
- metadata.gz: a30b760625155ae65acf9c8d6941e1e8ddd408b98cd377fdd6f6385c943ceef74e72cf3318d1373f966f8eda48dd9c35c4198bdaeecba2c9c6ffd52f2285e465
7
- data.tar.gz: 52b468bfea30b0c115c318ab60eefd2caf382c94df171ea53ec0e203d6869d823f0deb23b20f66939f2560a8611d55b2c6b64f1dcb0b5ffb3d461de3471db8a5
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({}) {|p, c| p.update(c[:field] => c.merge!(value: nil))}
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({}) {|p, c| p.update(c[:field] => c.permit!.to_h)}
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
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "5.3.0"
2
+ VERSION = "5.3.1"
3
3
  end
@@ -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
- expect(JSON.parse(response.body)).to eq({'fields' => [updated_foo.merge({:value => 'baz'}).stringify_keys]})
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.0
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