-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(smart-actions): transform legacy widgets in hooks
- Loading branch information
1 parent
5db679f
commit 297bf88
Showing
2 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'set' | ||
|
||
module ForestLiana | ||
module WidgetsHelper | ||
|
||
widget_edit_list = [ | ||
'address editor', | ||
'belongsto typeahead', | ||
'belongsto dropdown', | ||
'boolean editor', | ||
'checkboxes', | ||
'color editor', | ||
'date editor', | ||
'dropdown', | ||
'embedded document editor', | ||
'file picker', | ||
'json code editor', | ||
'input array', | ||
'multiple select', | ||
'number input', | ||
'point editor', | ||
'price editor', | ||
'radio button', | ||
'rich text', | ||
'text area editor', | ||
'text editor', | ||
'time input', | ||
] | ||
|
||
v1_to_v2_edit_widgets_mapping = { | ||
address: 'address editor', | ||
'belongsto select': 'belongsto dropdown', | ||
'color picker': 'color editor', | ||
'date picker': 'date editor', | ||
price: 'price editor', | ||
'JSON editor': 'json code editor', | ||
'rich text editor': 'rich text', | ||
'text area': 'text area editor', | ||
'text input': 'text editor', | ||
} | ||
|
||
def set_field_widget(field) | ||
field[:widgetEdit] = nil | ||
if field[:widget] && !field[:widgetEdit] | ||
if v1_to_v2_edit_widgets_mapping[field[:widget]] | ||
field[:widgetEdit] = {name: v1_to_v2_edit_widgets_mapping[field[:widget]], parameters: {}} | ||
elsif widget_edit_list.include?(field[:widget]) | ||
field[:widgetEdit] = {name: field[:widget], parameters: {}} | ||
end | ||
end | ||
|
||
field.delete(:widget) | ||
end | ||
end | ||
end |