glib-web 4.2.0 → 4.4.0

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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/glib/json/new_dynamic_text.rb +0 -0
  3. data/app/controllers/glib/glib_direct_uploads_controller.rb +1 -1
  4. data/app/controllers/glib/home_controller.rb +5 -0
  5. data/app/helpers/glib/app_feature_support_helper.rb +0 -0
  6. data/app/helpers/glib/dynamic_texts_helper.rb +0 -0
  7. data/app/helpers/glib/json_ui/abstract_builder.rb +1 -1
  8. data/app/helpers/glib/json_ui/action_builder/browsers.rb +12 -0
  9. data/app/helpers/glib/json_ui/action_builder/components.rb +7 -1
  10. data/app/helpers/glib/json_ui/action_builder/fields.rb +6 -0
  11. data/app/helpers/glib/json_ui/action_builder/logics.rb +30 -0
  12. data/app/helpers/glib/json_ui/action_builder/sheets.rb +0 -0
  13. data/app/helpers/glib/json_ui/action_builder/storage_items.rb +23 -0
  14. data/app/helpers/glib/json_ui/action_builder.rb +0 -18
  15. data/app/helpers/glib/json_ui/analytics_helper.rb +0 -0
  16. data/app/helpers/glib/json_ui/generic_builders.rb +0 -0
  17. data/app/helpers/glib/json_ui/menu_builder.rb +1 -1
  18. data/app/helpers/glib/json_ui/view_builder/charts.rb +3 -2
  19. data/app/helpers/glib/json_ui/view_builder/fields.rb +20 -22
  20. data/app/helpers/glib/json_ui/view_builder/panels.rb +26 -11
  21. data/app/helpers/glib/json_ui/view_builder.rb +20 -8
  22. data/app/models/glib/active_storage/attachment.rb +0 -0
  23. data/app/models/glib/active_storage/blob.rb +0 -0
  24. data/app/models/glib/dummy_job_application.rb +3 -2
  25. data/app/models/glib/dynamic_text_record.rb +0 -0
  26. data/app/models/glib/text.rb +0 -0
  27. data/app/validators/email_typo_validator.rb +0 -0
  28. data/app/validators/email_validator.rb +0 -0
  29. data/app/validators/url_validator.rb +0 -0
  30. data/app/views/json_ui/garage/_nav_menu.json.jbuilder +1 -1
  31. data/app/views/json_ui/garage/actions/dialogs_oauth_post.json.jbuilder +0 -0
  32. data/app/views/json_ui/garage/forms/dynamic_group.json.jbuilder +35 -13
  33. data/app/views/json_ui/garage/forms/dynamic_select_data.json.jbuilder +0 -0
  34. data/app/views/json_ui/garage/forms/file_upload.json.jbuilder +2 -2
  35. data/app/views/json_ui/garage/forms/generic_post.json.jbuilder +0 -0
  36. data/app/views/json_ui/garage/forms/selects.json.jbuilder +39 -5
  37. data/app/views/json_ui/garage/forms/show_hide.json.jbuilder +16 -5
  38. data/app/views/json_ui/garage/forms/submission_flow.json.jbuilder +0 -0
  39. data/app/views/json_ui/garage/forms/submission_flow_post.json.jbuilder +0 -0
  40. data/app/views/json_ui/garage/forms/submission_indicator.json.jbuilder +0 -0
  41. data/app/views/json_ui/garage/forms/submission_indicator_post.json.jbuilder +0 -0
  42. data/app/views/json_ui/garage/forms/submit_on_change.json.jbuilder +1 -1
  43. data/app/views/json_ui/garage/forms/text_validation.json.jbuilder +13 -8
  44. data/app/views/json_ui/garage/home/blank.json.jbuilder +0 -0
  45. data/app/views/json_ui/garage/home/slow.json.jbuilder +0 -0
  46. data/app/views/json_ui/garage/lists/autoload_all.json.jbuilder +0 -0
  47. data/app/views/json_ui/garage/lists/autoload_as_needed.json.jbuilder +0 -0
  48. data/app/views/json_ui/garage/lists/chat_ui.json.jbuilder +0 -0
  49. data/app/views/json_ui/garage/lists/fab.json.jbuilder +0 -0
  50. data/app/views/json_ui/garage/notifications/web_socket.json.jbuilder +0 -0
  51. data/app/views/json_ui/garage/pages/custom_style_class.json.jbuilder +0 -0
  52. data/app/views/json_ui/garage/pages/full_width.json.jbuilder +0 -0
  53. data/app/views/json_ui/garage/pages/full_width_height.json.jbuilder +0 -0
  54. data/app/views/json_ui/garage/pages/layout.json.jbuilder +0 -0
  55. data/app/views/json_ui/garage/pages/loading_indicator.json.jbuilder +0 -0
  56. data/app/views/json_ui/garage/pages/nested_scroll.json.jbuilder +0 -0
  57. data/app/views/json_ui/garage/pages/redirect_onload.json.jbuilder +0 -0
  58. data/app/views/json_ui/garage/panels/_styled.json.jbuilder +0 -0
  59. data/app/views/json_ui/garage/panels/card.json.jbuilder +0 -0
  60. data/app/views/json_ui/garage/panels/custom.json.jbuilder +0 -0
  61. data/app/views/json_ui/garage/panels/outlined.json.jbuilder +0 -0
  62. data/app/views/json_ui/garage/services/dynamic_text.json.jbuilder +0 -0
  63. data/app/views/json_ui/garage/services/image.json.jbuilder +0 -0
  64. data/app/views/json_ui/garage/services/index.json.jbuilder +0 -0
  65. data/app/views/json_ui/garage/tables/_autoload_section.json.jbuilder +0 -0
  66. data/app/views/json_ui/garage/tables/autoload_all.json.jbuilder +0 -0
  67. data/app/views/json_ui/garage/tables/autoload_as_needed.json.jbuilder +0 -0
  68. data/app/views/json_ui/garage/tables/export_import.json.jbuilder +0 -0
  69. data/app/views/json_ui/garage/tables/index.json.jbuilder +0 -0
  70. data/app/views/json_ui/garage/test_page/_header.json.jbuilder +14 -0
  71. data/app/views/json_ui/garage/test_page/auto_validate.json.jbuilder +77 -0
  72. data/app/views/json_ui/garage/test_page/dialog.json.jbuilder +38 -0
  73. data/app/views/json_ui/garage/test_page/dialog_open.json.jbuilder +14 -0
  74. data/app/views/json_ui/garage/test_page/form.json.jbuilder +111 -0
  75. data/app/views/json_ui/garage/test_page/form_dynamic.json.jbuilder +63 -0
  76. data/app/views/json_ui/garage/test_page/multiupload.json.jbuilder +65 -0
  77. data/app/views/json_ui/garage/views/calendar_data.json.jbuilder +0 -0
  78. data/app/views/json_ui/garage/views/map_data.json.jbuilder +0 -0
  79. data/app/views/json_ui/garage/views/multimedia.json.jbuilder +0 -0
  80. data/app/views/layouts/json_ui/no_custom.html.erb +0 -0
  81. data/lib/generators/glib/install_generator.rb +0 -0
  82. data/lib/generators/templates/20191017062519_create_texts.rb +0 -0
  83. data/lib/generators/templates/20191024063257_add_scope_to_texts.rb +0 -0
  84. data/lib/generators/templates/20191112095018_add_lang_to_texts.rb +0 -0
  85. data/lib/generators/templates/20191126071051_create_active_storage_tables.active_storage.rb +0 -0
  86. data/lib/generators/templates/database.yml +0 -0
  87. data/lib/generators/templates/dynamic_text.rb +0 -0
  88. data/lib/glib/dynamic_text/config.rb +0 -0
  89. data/lib/glib/dynamic_text.rb +0 -0
  90. data/lib/glib/json_crawler/action_crawler.rb +0 -0
  91. data/lib/glib/json_crawler/action_crawlers/action_http.rb +0 -0
  92. data/lib/glib/json_crawler/action_crawlers/dialogs_alert.rb +0 -0
  93. data/lib/glib/json_crawler/action_crawlers/menu.rb +0 -0
  94. data/lib/glib/json_crawler/action_crawlers/run_multiple.rb +0 -0
  95. data/lib/glib/json_crawler/action_crawlers/windows_open.rb +0 -0
  96. data/lib/glib/json_crawler/coverage.rb +0 -0
  97. data/lib/glib/mailer_tester.rb +1 -1
  98. data/lib/glib/value.rb +0 -0
  99. data/lib/glib/version.rb +0 -0
  100. metadata +12 -3
  101. data/app/views/json_ui/garage/test_page/index.json.jbuilder +0 -120
@@ -15,14 +15,48 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
15
15
  'melbourne' => 'Melbourne',
16
16
  'sydney' => 'Sydney',
17
17
  }
18
+
19
+ form.panels_responsive childViews: ->(column) do
20
+ form.fields_select \
21
+ name: 'user[city]',
22
+ width: 'matchParent',
23
+ label: 'City1',
24
+ placeholder: 'This is a placeholder',
25
+ options: languages.map { |k, v| { value: k, text: v } },
26
+ value: 'canberra',
27
+ onChange: ->(action) do
28
+ action.components_findClosest view: 'panels/responsive', onFind: ->(find) do
29
+ # This is to demonstrate that `components_set` can be a more flexible version
30
+ # of `components_replace`.
31
+ find.components_set dataBuilder: ->(set) do
32
+ # Don't update the childViews, just update the footer
33
+ set.panels_responsive accessory: ->(accessory) do
34
+ accessory.footer childViews: ->(footer) do
35
+ footer.label text: 'New footer'
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end, accessory: ->(accessory) do
42
+ accessory.footer childViews: ->(footer) do
43
+ footer.label text: 'Original footer'
44
+ end
45
+ end
46
+
47
+ form.spacer height: 6
48
+
18
49
  form.fields_select \
19
- name: 'user[city]',
50
+ name: 'user[cities][]',
20
51
  width: 'matchParent',
21
- label: 'City1',
22
- placeholder: 'This is a placeholder',
52
+ label: 'Cities',
23
53
  options: languages.map { |k, v| { value: k, text: v } },
24
- value: 'canberra'
25
- form.fields_select name: 'user[cities][]', width: 'matchParent', label: 'Cities', options: languages.map { |k, v| { value: k, text: v } }, value: ['melbourne', 'sydney'], multiple: true
54
+ value: ['melbourne', 'sydney'],
55
+ multiple: true,
56
+ onChange: ->(action) do
57
+ # TODO: Fix needed. When closing this dialog, the dirty prompt appears.
58
+ action.dialogs_alert message: 'Options selected'
59
+ end
26
60
 
27
61
  form.spacer height: 20
28
62
  form.h2 text: 'Select fields with grouping'
@@ -349,12 +349,14 @@ page.form \
349
349
  form.spacer height: 20
350
350
  options = [
351
351
  { text: 'Option 1', value: 'option1' },
352
- { text: 'Option 2', value: 'option2' }
352
+ { text: 'Option 2', value: 'option2' },
353
+ { text: 'Option 3', value: 'option3' }
353
354
  ]
354
355
  form.fields_select name: 'user[loadif7]', width: 'matchParent', label: 'Select "show"', options: options, value: '', onChangeAndLoad: ->(action) do
355
356
  action.runMultiple childActions: ->(saction) do
356
357
  saction.logics_set targetId: 'panel7a', conditionalData: { displayed: { "==": [{ "var": 'user[loadif7]' }, 'option1'] } }
357
358
  saction.logics_set targetId: 'panel7b', conditionalData: { displayed: { "==": [{ "var": 'user[loadif7]' }, 'option2'] } }
359
+ saction.logics_set targetId: 'panel7c', conditionalData: { displayed: { "==": [{ "var": 'user[loadif7]' }, 'option3'] } }
358
360
  end
359
361
  end
360
362
 
@@ -363,8 +365,8 @@ page.form \
363
365
  styleClass: 'border-2',
364
366
  width: 'matchParent',
365
367
  padding: { top: 8, right: 8, bottom: 8, left: 8 },
366
- childViews: ->(res) do
367
- res.fields_text name: 'user[loadif_target9]', width: 'matchParent', value: 'Value 7a'
368
+ childViews: ->(vertical) do
369
+ vertical.fields_text name: 'user[0][loadif_target9]', width: 'matchParent', value: 'Value 7a'
368
370
  end
369
371
 
370
372
  form.panels_vertical \
@@ -372,8 +374,17 @@ page.form \
372
374
  styleClass: 'border-2',
373
375
  width: 'matchParent',
374
376
  padding: { top: 8, right: 8, bottom: 8, left: 8 },
375
- childViews: ->(res) do
376
- res.fields_text name: 'user[loadif_target9]', width: 'matchParent', value: 'Value 7b'
377
+ childViews: ->(vertical) do
378
+ vertical.fields_text name: 'user[1][loadif_target9]', width: 'matchParent', value: 'Value 7b'
379
+ end
380
+
381
+ form.panels_vertical \
382
+ id: 'panel7c',
383
+ styleClass: 'border-2',
384
+ width: 'matchParent',
385
+ padding: { top: 8, right: 8, bottom: 8, left: 8 },
386
+ childViews: ->(vertical) do
387
+ vertical.fields_text id: 'target_panel_3', name: 'user[2][loadif_target9]', width: 'matchParent', value: 'Value 7c'
377
388
  end
378
389
 
379
390
  form.spacer height: 20
@@ -107,7 +107,7 @@ page.scroll childViews: ->(scroll) do
107
107
  end
108
108
 
109
109
  form.spacer height: 20
110
- rules = { fileType: 'image', maxFileSize: 5000, fileTypeErrorText: 'Invalid!', maxFileSizeErrorText: 'Too big!' }
110
+ rules = { fileType: 'image', maxFileSize: 5000, maxFileSizeErrorText: 'Too big!' }
111
111
  form.fields_file \
112
112
  name: 'user[photo][]',
113
113
  width: 'matchParent',
@@ -15,29 +15,32 @@ page.form \
15
15
  name: 'user[name]',
16
16
  width: 'matchParent',
17
17
  label: 'Name'
18
-
18
+ form.spacer height: 8
19
19
 
20
20
  form.fields_email \
21
21
  name: 'user[email]',
22
22
  width: 'matchParent',
23
23
  label: 'Email'
24
+ form.spacer height: 8
24
25
 
25
26
  form.fields_url \
26
27
  name: 'user[url]',
27
28
  width: 'matchParent',
28
29
  label: 'URL'
30
+ form.spacer height: 8
29
31
 
30
32
  form.fields_number \
31
33
  prop: :age,
32
34
  name: 'user[age]',
33
35
  width: 'matchParent',
34
36
  label: 'Age'
35
-
37
+ form.spacer height: 8
36
38
 
37
39
  form.fields_phone \
38
40
  name: 'user[phone1]',
39
41
  width: 'matchParent',
40
42
  label: 'Phone field'
43
+ form.spacer height: 8
41
44
 
42
45
  form.fields_phone \
43
46
  name: 'user[phone2]',
@@ -45,6 +48,7 @@ page.form \
45
48
  label: 'Phone field with Australia as the default country',
46
49
  disableAutoDetect: true, # Disable country auto detect by user IP
47
50
  defaultCountry: 'AU' # ISO Country code, see: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
51
+ form.spacer height: 8
48
52
 
49
53
  form.fields_password \
50
54
  name: 'user[password]',
@@ -52,6 +56,7 @@ page.form \
52
56
  label: 'Password',
53
57
  hint: 'Should contain at least 6 characters',
54
58
  leftIcon: 'lock'
59
+ form.spacer height: 8
55
60
 
56
61
  form.fields_textarea \
57
62
  prop: :words,
@@ -59,6 +64,7 @@ page.form \
59
64
  width: 'matchParent',
60
65
  label: 'Textarea with maxLength',
61
66
  maxLength: 1000
67
+ form.spacer height: 8
62
68
 
63
69
 
64
70
  options = ['programmer', 'devops', 'designer', 'ceo', 'office_boy'].map { |v| { text: v.humanize, value: v } }
@@ -68,11 +74,10 @@ page.form \
68
74
  width: 'matchParent',
69
75
  label: 'Position',
70
76
  options: options
77
+ form.spacer height: 8
71
78
 
72
79
 
73
- form.spacer height: 10
74
80
  form.h4 text: 'Gender'
75
- form.spacer height: 4
76
81
  form.fields_radioGroup \
77
82
  name: 'user[gender]',
78
83
  validation: { required: { message: 'Required' } },
@@ -82,9 +87,9 @@ page.form \
82
87
  group.fields_radio value: 'F', label: 'Female'
83
88
  end
84
89
 
85
- form.spacer height: 10
90
+ form.spacer height: 8
91
+
86
92
  form.h4 text: 'Skills'
87
- form.spacer height: 4
88
93
  form.fields_checkGroup \
89
94
  name: 'user[skills][]',
90
95
  uncheckValue: 1,
@@ -95,10 +100,10 @@ page.form \
95
100
  group.fields_check checkValue: 4, label: 'Mobile Development'
96
101
  end
97
102
 
98
- form.spacer height: 10
103
+ form.spacer height: 8
99
104
  form.fields_check prop: :accept, label: 'Accept terms & condition', name: 'user[accept]'
100
105
 
101
- form.spacer height: 30
106
+ form.spacer height: 8
102
107
  form.fields_submit text: 'Submit'
103
108
  form.fields_submit text: 'Submit (disable if form invalid)', disableIfFormInvalid: true
104
109
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ navs = ['form', 'dialog', 'form_dynamic', 'auto_validate', 'multiupload']
2
+
3
+ view.panels_flow innerPadding: { bottom: 0 }, styleClass: 'align-right', width: 'matchParent', childViews: ->(res) do
4
+ navs.each_with_index do |nav, index|
5
+ if index < navs.size && index != 0
6
+ res.spacer width: 4
7
+ res.label text: '|'
8
+ res.spacer width: 4
9
+ end
10
+ res.label text: nav, onClick: ->(action) do
11
+ action.windows_open url: json_ui_garage_url(path: "test_page/#{nav}")
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,77 @@
1
+ json.title 'Test Page (Form)'
2
+
3
+ page = json_ui_page json
4
+
5
+ page.body childViews: ->(body) do
6
+ render 'json_ui/garage/test_page/header', view: body
7
+
8
+ model = Glib::DummyJobApplication.new(
9
+ name: 'John Deo',
10
+ accept: '0',
11
+ words: '',
12
+ age: 17,
13
+ position: 'ceo',
14
+ pet_you_have: 'crocodile'
15
+ )
16
+
17
+ body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
18
+ res.h2 text: 'Job Application'
19
+ res.spacer height: 8
20
+ res.panels_form \
21
+ url: json_ui_garage_url(path: 'forms/generic_post'),
22
+ method: 'post',
23
+ model: model,
24
+ autoValidate: true,
25
+ childViews: ->(form) do
26
+ form.fields_text prop: :name, label: 'name', name: 'user[name]', width: 'matchParent'
27
+ form.spacer height: 4
28
+
29
+ form.fields_text label: 'say hello', name: 'user[say]', width: 'matchParent', validation: { format: { regex: 'hello', message: 'Say hello!' } }, value: 'sup'
30
+ form.spacer height: 4
31
+
32
+ form.fields_number prop: :age, label: 'age', name: 'user[age]', width: 'matchParent'
33
+ form.spacer height: 4
34
+
35
+ form.fields_number \
36
+ name: 'user[height]',
37
+ label: 'height',
38
+ width: 'matchParent',
39
+ validation: { numericality: { greater_than_or_equal_to: 155, less_than_or_equal_to: 190, message: { greater_than_or_equal_to: 'Too short', less_than_or_equal_to: 'Too long' } } },
40
+ value: 150
41
+ form.spacer height: 4
42
+
43
+ form.fields_textarea prop: :words, label: 'words', name: 'user[words]', width: 'matchParent'
44
+ form.spacer height: 4
45
+
46
+ form.fields_textarea label: 'Tell me story', name: 'user[story]', width: 'matchParent', validation: { length: { minimum: 1, message: { too_short: { one: 'Min %{count} word', other: 'Min %{count} words' } } } }
47
+ form.spacer height: 4
48
+
49
+ options = ['programmer', 'devops', 'designer', 'ceo', 'office_boy'].map { |v| { text: v.humanize, value: v } }
50
+ form.fields_select prop: :position, label: 'postion', name: 'user[position]', width: 'matchParent', options: options
51
+ form.spacer height: 4
52
+
53
+ options2 = ['crocodile', 'cat', 'dog', 'bird', 'shark'].map { |v| { text: v.humanize, value: v } }
54
+ form.fields_select prop: :pet_you_have, label: 'Pet you have', name: 'user[pet_you_have]', width: 'matchParent', options: options2
55
+ form.spacer height: 4
56
+
57
+ form.label text: 'Decision'
58
+ options3 = ['choose me', 'dont choose me', 'whatever']
59
+ form.fields_radioGroup value: 'dont choose me', validation: { exclusion: { in: ['dont choose me'], message: 'dont choose me' } }, childViews: ->(radio) do
60
+ options3.each do |option|
61
+ radio.fields_radio label: option, value: option
62
+ end
63
+ end
64
+ form.spacer height: 4
65
+
66
+ form.fields_check prop: :accept, label: 'accept', name: 'user[accept]', width: 'matchParent', checkValue: '1'
67
+ form.spacer height: 4
68
+
69
+ form.spacer height: 4
70
+ form.fields_submit text: 'submit'
71
+ form.spacer height: 2
72
+ form.fields_submit text: 'submit (if form valid)', disableIfFormInvalid: true
73
+ end
74
+
75
+ res.spacer height: 16
76
+ end
77
+ end
@@ -0,0 +1,38 @@
1
+
2
+
3
+ json.title 'Test Page (Form)'
4
+
5
+ page = json_ui_page json
6
+
7
+ page.body childViews: ->(body) do
8
+ render 'json_ui/garage/test_page/header', view: body
9
+
10
+ body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
11
+ res.h2 text: 'Dialog'
12
+ res.spacer height: 8
13
+ res.button text: 'Dialog updateExisting', onClick: ->(action) do
14
+ action.runMultiple childActions: ->(saction) do
15
+ saction.dialogs_show content: ->(dialog) do
16
+ dialog.body padding: glib_json_padding_body, childViews: ->(sbody) do
17
+ sbody.h1 text: 'Hello world'
18
+ sbody.button text: 'change dialog content', onClick: ->(ssaction) do
19
+ ssaction.dialogs_show updateExisting: true, disableCloseButton: true, content: ->(sdialog) do
20
+ sdialog.body padding: glib_json_padding_body, childViews: ->(ssbody) do
21
+ ssbody.h1 text: 'Hello world (updated)'
22
+ ssbody.spacer height: 8
23
+ ssbody.button text: 'close', onClick: ->(xaction) do
24
+ xaction.dialogs_close
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ res.spacer height: 4
34
+ res.button text: 'Dialog open', onClick: ->(action) do
35
+ action.dialogs_open url: json_ui_garage_url(path: 'test_page/dialog_open')
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ page = json_ui_page json
2
+
3
+ page.body padding: glib_json_padding_body, childViews: ->(body) do
4
+ body.panels_responsive width: 'matchParent', childViews: ->(res) do
5
+ res.h2 text: 'Title'
6
+ res.spacer height: 16
7
+ res.button text: 'open', onClick: ->(action) do
8
+ action.dialogs_open url: json_ui_garage_url(path: 'test_page/dialog_open')
9
+ end
10
+ res.button text: 'close', onClick: ->(action) do
11
+ action.dialogs_close
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,111 @@
1
+ json.title 'Test Page (Form)'
2
+
3
+ page = json_ui_page json
4
+
5
+ page.body childViews: ->(body) do
6
+ render 'json_ui/garage/test_page/header', view: body
7
+
8
+ body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
9
+ res.h2 text: 'Form'
10
+ res.spacer height: 8
11
+ res.panels_form \
12
+ url: json_ui_garage_url(path: 'forms/generic_post'),
13
+ method: 'post',
14
+ childViews: ->(form) do
15
+ form.panels_flow innerPadding: { bottom: 0 }, width: 'matchParent', childViews: ->(hori) do
16
+ hori.button text: 'components/set', onClick: ->(action) do
17
+ action.runMultiple childActions: ->(saction) do
18
+ saction.components_set targetId: 'textarea', data: { value: 'The quick brown fox jumps over the lazy dog' }
19
+ new_options = [{ text: 'Option99', value: 'option99' }]
20
+ ['select', 'chip_group'].each do |id|
21
+ saction.components_set targetId: id, data: { options: new_options, value: ['option99'] }
22
+ end
23
+ end
24
+ end
25
+ hori.spacer width: 4
26
+ hori.button text: 'logics/set', onClick: ->(action) do
27
+ action.logics_set targetId: 'date', conditionalData: { value: { "+": [{ "var": ['user[date]'] }, 60 * 60 * 24 * 3] } }
28
+ end
29
+ hori.spacer width: 4
30
+ hori.button text: 'components/replace', onClick: ->(action) do
31
+ action.runMultiple childActions: ->(saction) do
32
+ saction.components_replace targetId: 'radio_group', newView: ->(view) do
33
+ view.fields_radioGroup value: '', childViews: ->(sview) do
34
+ sview.fields_radio label: 'Option99', value: 'option99'
35
+ end
36
+ end
37
+
38
+ saction.components_replace targetId: 'check_group', newView: ->(view) do
39
+ view.fields_checkGroup value: '', childViews: ->(sview) do
40
+ sview.fields_check label: 'Option99', value: nil, checkValue: 'option99'
41
+ end
42
+ end
43
+ end
44
+ end
45
+ hori.spacer width: 4
46
+ hori.button text: 'hide select', onClick: ->(action) do
47
+ action.components_set targetId: 'select', data: { displayed: false }
48
+ end
49
+ hori.spacer height: 4
50
+ hori.button text: 'hide jack', onClick: ->(action) do
51
+ action.runMultiple childActions: ->(saction) do
52
+ saction.components_set targetId: 'ver', data: { displayed: true }
53
+ saction.components_set targetId: 'ver1', data: { displayed: false }
54
+ end
55
+ end
56
+ hori.spacer height: 4
57
+ hori.button text: 'show jack', onClick: ->(action) do
58
+ action.runMultiple childActions: ->(saction) do
59
+ saction.components_set targetId: 'ver', data: { displayed: false }
60
+ saction.components_set targetId: 'ver1', data: { displayed: true }
61
+ end
62
+ end
63
+ end
64
+
65
+ form.spacer height: 8
66
+ form.hr width: 'matchParent'
67
+ form.spacer height: 8
68
+
69
+ validation = { required: { message: 'Required' } }
70
+ options = ['option1', 'option2', 'option3', 'option4'].map { |option| { 'text'=> option.humanize, 'value' => option } }
71
+
72
+ form.fields_date width: 'matchParent', name: 'user[date]', id: 'date', value: Date.new(2024, 7, 24), validation: validation
73
+ form.hr width: 'matchParent'
74
+ form.fields_select multiple: true, width: 'matchParent', name: 'user[select][]', id: 'select', options: options, value: ['option1', 'option2'], validation: validation
75
+ form.hr width: 'matchParent'
76
+ form.fields_chipGroup width: 'matchParent', name: 'user[chip_group]', id: 'chip_group', options: options, value: ['option2'], validation: validation
77
+ form.hr width: 'matchParent'
78
+ form.fields_radioGroup width: 'matchParent', name: 'user[radio_group]', id: 'radio_group', value: 'option3', validation: validation, childViews: ->(radio) do
79
+ options.each do |option|
80
+ radio.fields_radio label: option['text'], value: option['value']
81
+ end
82
+ end
83
+ form.hr width: 'matchParent'
84
+ check_group_value = ['option3', 'option1']
85
+ form.fields_checkGroup width: 'matchParent', name: 'user[check_group]', id: 'check_group', value: check_group_value, validation: validation, childViews: ->(radio) do
86
+ options.each do |option|
87
+ radio.fields_check label: option['text'], checkValue: option['value']
88
+ end
89
+ end
90
+ form.hr width: 'matchParent'
91
+ form.panels_vertical width: 'matchParent', id: 'ver', childViews: ->(ver) do
92
+ form.fields_text width: 'matchParent', name: 'user[text]', id: 'text', value: 'John Doe', validation: validation.merge(format: { regex: /Doe\z/, message: 'Must end with Doe' })
93
+ end
94
+ form.panels_vertical width: 'matchParent', id: 'ver1', displayed: false, childViews: ->(ver) do
95
+ form.fields_text width: 'matchParent', name: 'user[text]', value: 'Jack Doe', validation: validation.merge(format: { regex: /Doe\z/, message: 'Must end with Doe' })
96
+ end
97
+
98
+ form.hr width: 'matchParent'
99
+
100
+ form.fields_textarea width: 'matchParent', name: 'user[textarea]', id: 'textarea', value: 'Lorem ipsum et dumet bla bla bla...'
101
+
102
+ form.hr width: 'matchParent'
103
+ form.fields_submit text: 'submit'
104
+ form.spacer height: 2
105
+ form.fields_submit text: 'submit (if form valid)', disableIfFormInvalid: true
106
+ end
107
+
108
+
109
+ res.spacer height: 16
110
+ end
111
+ end
@@ -0,0 +1,63 @@
1
+ json.title 'Test Page (Form)'
2
+
3
+ page = json_ui_page json
4
+
5
+ page.body childViews: ->(body) do
6
+ render 'json_ui/garage/test_page/header', view: body
7
+
8
+ body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
9
+ res.h2 text: 'Form'
10
+ res.spacer height: 8
11
+ res.panels_form \
12
+ url: json_ui_garage_url(path: 'forms/generic_post'),
13
+ method: 'post',
14
+ childViews: ->(form) do
15
+
16
+ properties = [
17
+ [
18
+ { name: 'question', value: 'Punctuality' },
19
+ { name: 'type', value: 'rating' },
20
+ ],
21
+ [
22
+ { name: 'question', value: 'Quality of work' },
23
+ { name: 'type', value: 'rating' },
24
+ { name: 'enabled', value: '1' },
25
+ ],
26
+ [
27
+ { name: 'question', value: 'Satisfied?' },
28
+ { name: 'type', value: 'yes_no' },
29
+ ]
30
+ ]
31
+ validation = { required: { message: 'Required' } }
32
+ form.fields_dynamicGroup width: 'matchParent', name: 'user[evaluation]', groupFieldProperties: properties, titlePrefix: 'Entry', content: ->(group) do
33
+ group.template padding: { left: 32 }, childViews: ->(template) do
34
+ template.spacer height: 10
35
+ template.fields_text width: 'matchParent', name: 'question', label: 'Question', placeholder: 'Question', validation: validation
36
+
37
+ options = [ :rating, :yes_no ]
38
+ template.fields_select \
39
+ width: 'matchParent',
40
+ name: 'type',
41
+ label: 'Answer Type',
42
+ placeholder: 'Answer Type',
43
+ options: options.map { |o| { text: o.to_s.humanize, value: o } },
44
+ validation: validation
45
+
46
+ template.fields_check \
47
+ width: 'matchParent',
48
+ name: 'enabled',
49
+ label: 'Enable',
50
+ checkValue: '1',
51
+ showIf: { "==": [{ "var": 'user[evaluation][{{index}}][type]' }, 'rating'] }
52
+
53
+ template.spacer height: 14
54
+ end
55
+ end
56
+ form.fields_submit text: 'submit'
57
+ form.spacer height: 2
58
+ form.fields_submit text: 'submit (if form valid)', disableIfFormInvalid: true
59
+ end
60
+
61
+ res.spacer height: 16
62
+ end
63
+ end