glib-web 4.39.0 → 4.39.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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/glib/auth/policy.rb +13 -0
  3. data/app/views/json_ui/garage/actions/_dialogs.json.jbuilder +2 -2
  4. data/app/views/json_ui/garage/forms/dynamic_group.json.jbuilder +2 -2
  5. data/app/views/json_ui/garage/forms/file_upload_new.json.jbuilder +1 -1
  6. data/app/views/json_ui/garage/forms/partial_update.json.jbuilder +12 -12
  7. data/app/views/json_ui/garage/forms/selects.json.jbuilder +1 -1
  8. data/app/views/json_ui/garage/forms/show_hide.json.jbuilder +62 -7
  9. data/app/views/json_ui/garage/lists/edit_mode.json.jbuilder +4 -4
  10. data/app/views/json_ui/garage/pages/custom_style_class.json.jbuilder +1 -1
  11. data/app/views/json_ui/garage/pages/nav_buttons.json.jbuilder +31 -13
  12. data/app/views/json_ui/garage/panels/_styled.json.jbuilder +8 -8
  13. data/app/views/json_ui/garage/panels/hover.json.jbuilder +2 -2
  14. data/app/views/json_ui/garage/panels/timeline.json.jbuilder +5 -5
  15. data/app/views/json_ui/garage/panels/ul.json.jbuilder +1 -1
  16. data/app/views/json_ui/garage/tables/bulk_edit.json.jbuilder +1 -1
  17. data/app/views/json_ui/garage/test_page/file_upload_new.json.jbuilder +1 -1
  18. data/app/views/json_ui/garage/test_page/form.json.jbuilder +6 -6
  19. data/app/views/json_ui/garage/test_page/form_dynamic.json.jbuilder +2 -2
  20. data/app/views/json_ui/garage/test_page/logics_set.json.jbuilder +94 -0
  21. data/app/views/json_ui/garage/views/components_replace.json.jbuilder +13 -13
  22. data/app/views/json_ui/garage/views/components_set.json.jbuilder +6 -6
  23. data/app/views/json_ui/garage/views/fields_focus.json.jbuilder +22 -22
  24. data/lib/glib/json_crawler/router.rb +45 -24
  25. data/lib/glib/rubocop/cops/json_ui/base_nested_parameter.rb +145 -0
  26. data/lib/glib/rubocop/cops/json_ui/nested_action_parameter.rb +55 -0
  27. data/lib/glib/rubocop/cops/json_ui/nested_block_parameter.rb +51 -0
  28. data/lib/glib/rubocop/cops/multiline_method_call_style.rb +74 -5
  29. data/lib/glib/rubocop.rb +3 -0
  30. data/lib/glib/test/parallel_coverage.rb +38 -0
  31. data/lib/glib/test_helpers.rb +12 -0
  32. data/lib/glib-web.rb +1 -0
  33. metadata +6 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04bdbf508e9bae2d875e880a1ccff951cacb80d7eae24a543e82a816d9eaff4f
4
- data.tar.gz: 3f209d236fafbb17c2a40a5cf570bfd5166be900059abbf71b0b652260e035ec
3
+ metadata.gz: acbdde8fcc5033a60d976bf56fc3222d3ab1e7e9a138c65c326e3e16912ed729
4
+ data.tar.gz: 0b4ab5237c244659ddd40351b3b480fcb76a04e103aa1660e8c63f246d72333b
5
5
  SHA512:
6
- metadata.gz: 480b89089e395f1b123bab2e0b161d485406eb537c215fab96c464e8be22bd7e42a44d7ef460cf37d32396642dcf37eb46afe7625bae126e19cae89d3870f1bc
7
- data.tar.gz: 3ad20d4a121a87e14b496ad5e179b4f7db2be6812a7bc086086e000ec12c52558b6768192300cdcd273a676824beed495d5db8a4fa97854aff76957310f6fee3
6
+ metadata.gz: 5b68ef7f7342522130b45f15b5216d07ae9df74d2267b5590ae3a7ed049d97419b4e599ba6db66bc5ba2f21d41a58afe653a547216194b331a28b2996d376287
7
+ data.tar.gz: 6d6d29eb399863ca102ad6658f39f78f5b69bd7c6353b14be961270de7f5ecf07b6906899e3e8bc2630f1d744e09929efe4ac2a3910a78c4a2b7ec6feb7ec110
@@ -9,6 +9,14 @@ module Glib::Auth
9
9
  include Overrides
10
10
  extend ClassMethods
11
11
 
12
+ class_attribute :glib_permission_test_callback
13
+
14
+ # Controllers can override this callback to implement additional permission check logics
15
+ # that are implemented outside of policies, which would have been skipped by the permission test.
16
+ glib_on_permission_test do
17
+ # Do nothing by default
18
+ end
19
+
12
20
  # TODO: Ultimately we want to uncomment this line, but:
13
21
  # - Need to be able to set aside some time to run rspec tests to ensure nothing gets broken
14
22
  # - Need to find a solution where we can reuse a single public policy
@@ -104,6 +112,7 @@ module Glib::Auth
104
112
  permission_test = params[:__glib_permission_test].present?
105
113
 
106
114
  if permission_test
115
+ instance_exec(&self.class.glib_permission_test_callback)
107
116
  render status: 200, json: { status: 'ok' }
108
117
  end
109
118
  end
@@ -112,6 +121,10 @@ module Glib::Auth
112
121
  end
113
122
 
114
123
  module ClassMethods
124
+ def glib_on_permission_test(&block)
125
+ self.glib_permission_test_callback = block
126
+ end
127
+
115
128
  # rubocop:disable Style/ClassVars
116
129
  def glib_auth_init
117
130
  @@__glib_auth_init = true
@@ -5,8 +5,8 @@ end
5
5
 
6
6
  section.rows builder: ->(template) do
7
7
  template.thumbnail title: 'dialogs/alert', onClick: ->(action) do
8
- action.dialogs_alert message: 'This is an alert dialog', onClose: ->(action) do
9
- action.snackbars_alert message: 'Closed'
8
+ action.dialogs_alert message: 'This is an alert dialog', onClose: ->(subaction) do
9
+ subaction.snackbars_alert message: 'Closed'
10
10
  end
11
11
  end
12
12
 
@@ -37,7 +37,7 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
37
37
  template.fields_text width: 'matchParent', name: 'question', label: 'Question', placeholder: 'Question'
38
38
  template.fields_richText width: 'matchParent', name: 'description', label: 'Desc', placeholder: 'Desc'
39
39
 
40
- form.panels_responsive id: 'responsive_{{entryIndex}}', childViews: ->(column) do
40
+ template.panels_responsive id: 'responsive_{{entryIndex}}', childViews: ->(column) do
41
41
  column.panels_split width: 'matchParent', content: ->(split) do
42
42
  split.center childViews: ->(center) do
43
43
  center.fields_dynamicSelect \
@@ -51,7 +51,7 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
51
51
  end
52
52
 
53
53
  options = [:rating, :yes_no, :choices, :unspecified]
54
- template.fields_select \
54
+ column.fields_select \
55
55
  width: 'matchParent',
56
56
  name: 'type',
57
57
  label: 'Answer Type',
@@ -58,7 +58,7 @@ page.form \
58
58
  form.h2 text: 'Field Upload', styleClass: 'pb-4'
59
59
  form.label text: 'placeholder image', styleClass: 'pb-1'
60
60
  form.panels_flow styleClass: 'align-center', xs: { gap: { all: 4 } }, childViews: ->(flow) do
61
- form.fields_upload properties.merge(
61
+ flow.fields_upload properties.merge(
62
62
  name: 'user[file_placeholderView]',
63
63
  id: 'pv1',
64
64
  placeholderView: { type: 'image', url: image&.url, width: 144, height: 144 }
@@ -5,13 +5,13 @@ render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
6
  page.scroll childViews: ->(scroll) do
7
7
  scroll.panels_vertical padding: glib_json_padding_body, childViews: ->(vertical) do
8
- scroll.h2 text: 'Partial update'
9
- scroll.spacer height: 8
10
- scroll.label text: 'The content below will be updated. This is a more efficient alternative to windows_reload.'
11
- scroll.spacer height: 8
12
- scroll.label text: 'The updated content should be committed to the page history as the user navigates back and forward.'
13
- scroll.spacer height: 18
14
- scroll.panels_vertical id: 'greeting', childViews: ->(inner) do
8
+ vertical.h2 text: 'Partial update'
9
+ vertical.spacer height: 8
10
+ vertical.label text: 'The content below will be updated. This is a more efficient alternative to windows_reload.'
11
+ vertical.spacer height: 8
12
+ vertical.label text: 'The updated content should be committed to the page history as the user navigates back and forward.'
13
+ vertical.spacer height: 18
14
+ vertical.panels_vertical id: 'greeting', childViews: ->(inner) do
15
15
  inner.fields_hidden name: 'name', value: '<uninitialized>'
16
16
  inner.label text: 'Hello'
17
17
  end
@@ -21,11 +21,11 @@ page.scroll childViews: ->(scroll) do
21
21
  scroll.hr width: 'matchParent'
22
22
 
23
23
  scroll.panels_form url: json_ui_garage_url(path: 'forms/partial_update_response'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
24
- scroll.h2 text: 'Update via POST request'
25
- scroll.spacer height: 8
26
- scroll.fields_text name: 'name', width: 'matchParent', label: 'Name', value: 'Jane'
27
- scroll.spacer height: 8
28
- scroll.fields_submit text: 'Submit'
24
+ form.h2 text: 'Update via POST request'
25
+ form.spacer height: 8
26
+ form.fields_text name: 'name', width: 'matchParent', label: 'Name', value: 'Jane'
27
+ form.spacer height: 8
28
+ form.fields_submit text: 'Submit'
29
29
  end
30
30
 
31
31
  scroll.spacer height: 18
@@ -20,7 +20,7 @@ page.form id: 'form', url: json_ui_garage_url(path: 'forms/generic_post'), metho
20
20
  options = languages.map do |k, v|
21
21
  { value: k, text: v }
22
22
  end
23
- form.fields_select \
23
+ column.fields_select \
24
24
  name: 'user[city]',
25
25
  width: 'matchParent',
26
26
  clearable: true,
@@ -153,6 +153,61 @@ page.form \
153
153
  form.label id: 'radiolabel1', text: 'Yes'
154
154
  form.label id: 'radiolabel2', text: 'No'
155
155
 
156
+ form.spacer height: 20
157
+
158
+ form.fields_radioGroup name: 'user[radio10]', value: 'no', childViews: ->(group) do
159
+ group.panels_horizontal childViews: ->(horizontal) do
160
+ horizontal.fields_radio label: 'Hourly rate', value: 'hourly_rate'
161
+ horizontal.spacer width: 20
162
+ horizontal.fields_radio label: 'Fixed amount', value: 'fixed_amount'
163
+ end
164
+ end, onChangeAndLoad: ->(action) do
165
+ action.runMultiple childActions: ->(multiple) do
166
+ multiple.logics_set \
167
+ targetId: 'pricing_hourly_rate_field',
168
+ conditionalData: {
169
+ displayed: {
170
+ "==": [
171
+ { "var": 'user[radio10]' },
172
+ 'hourly_rate'
173
+ ]
174
+ }
175
+ }
176
+
177
+ multiple.logics_set \
178
+ targetId: 'pricing_fixed_amount_field',
179
+ conditionalData: {
180
+ displayed: {
181
+ "==": [
182
+ { "var": 'user[radio10]' },
183
+ 'fixed_amount'
184
+ ]
185
+ }
186
+ }
187
+ end
188
+ end
189
+
190
+ form.fields_number \
191
+ id: 'pricing_hourly_rate_field',
192
+ name: 'user[pricing_hourly_rate]',
193
+ width: 160,
194
+ styleClass: 'outlined',
195
+ leftIcon: 'attach_money',
196
+ rightText: '.00'
197
+
198
+ form.panels_horizontal \
199
+ id: 'pricing_fixed_amount_field', \
200
+ width: 'matchParent', \
201
+ align: 'middle', \
202
+ childViews: ->(horizontal) do
203
+ horizontal.fields_number \
204
+ name: 'user[pricing_fixed_amount]',
205
+ width: 160,
206
+ styleClass: 'outlined',
207
+ leftIcon: 'attach_money',
208
+ rightText: '.00'
209
+ end
210
+
156
211
  form.spacer height: 20
157
212
  form.h1 text: 'Radio Group'
158
213
  form.fields_radioGroup \
@@ -372,19 +427,19 @@ page.form \
372
427
  id: 'panel1',
373
428
  width: 'matchParent',
374
429
  childViews: ->(res) do
375
- form.fields_text name: 'user[loadif_target2]', width: 'matchParent', value: 'Value 1'
376
- form.spacer height: 4
377
- form.fields_textarea name: 'user[loadif_target3]', width: 'matchParent', value: 'Value 2'
378
- form.spacer height: 4
430
+ res.fields_text name: 'user[loadif_target2]', width: 'matchParent', value: 'Value 1'
431
+ res.spacer height: 4
432
+ res.fields_textarea name: 'user[loadif_target3]', width: 'matchParent', value: 'Value 2'
433
+ res.spacer height: 4
379
434
  end
380
435
 
381
436
  form.panels_responsive \
382
437
  id: 'panel2',
383
438
  width: 'matchParent',
384
439
  childViews: ->(res) do
385
- form.fields_richText name: 'user[loadIf_target4]', width: 'matchParent', value: 'Value 3'
386
- form.spacer height: 4
387
- form.fields_radioGroup name: 'user[loadIf_target5]', width: 'matchParent', value: 'choice_1', childViews: ->(group) do
440
+ res.fields_richText name: 'user[loadIf_target4]', width: 'matchParent', value: 'Value 3'
441
+ res.spacer height: 4
442
+ res.fields_radioGroup name: 'user[loadIf_target5]', width: 'matchParent', value: 'choice_1', childViews: ->(group) do
388
443
  group.fields_radio label: 'Choice 1', value: 'choice_1'
389
444
  group.fields_radio label: 'Choice 2', value: 'choice_2'
390
445
  group.fields_radio label: 'Choice 3', value: 'choice_3'
@@ -33,18 +33,18 @@ page.form \
33
33
  header.panels_horizontal childViews: ->(horizontal) do
34
34
  horizontal.fields_check name: 'user[check_all]', label: 'All', checkValue: true
35
35
 
36
- header.spacer width: 20
36
+ horizontal.spacer width: 20
37
37
  # header.fields_text width: 'matchParent', styleClass: 'outlined', name: 'user[new_name]', label: 'Item name'
38
38
  statuses = [:pending, :active]
39
- header.fields_select \
39
+ horizontal.fields_select \
40
40
  styleClass: 'outlined',
41
41
  name: 'user[status]',
42
42
  width: 'matchParent',
43
43
  label: 'Status',
44
44
  options: statuses.map { |status| { value: status, text: status.to_s.humanize } }
45
45
 
46
- header.spacer width: 20
47
- header.fields_submit text: 'Update'
46
+ horizontal.spacer width: 20
47
+ horizontal.fields_submit text: 'Update'
48
48
  end
49
49
  end
50
50
  section.rows builder: ->(row) do
@@ -26,7 +26,7 @@ end
26
26
  page.body padding: glib_json_padding_body, childViews: ->(scroll) do
27
27
  scroll.panels_vertical width: 'matchParent', styleClass: 'card', padding: glib_json_padding_body, childViews: ->(vertical) do
28
28
  (1..100).each do |index|
29
- scroll.label text: 'Content'
29
+ vertical.label text: 'Content'
30
30
  end
31
31
  end
32
32
  end
@@ -4,18 +4,36 @@ page = json_ui_page json
4
4
 
5
5
  render "#{@path_prefix}/nav_menu", json: json, page: page
6
6
 
7
- page.navBar backgroundColor: '#a8c4e3', color: '#ffffff', showTitle: true, rightButtons: ->(menu) do
8
- menu.button icon: 'search', text: 'Search', onClick: ->(action) do
9
- action.dialogs_alert message: 'Perform some action'
7
+ page.navBar(
8
+ backgroundColor: '#a8c4e3',
9
+ color: '#ffffff',
10
+ showTitle: true,
11
+ rightButtons: ->(menu) do
12
+ menu.button(
13
+ icon: 'search',
14
+ text: 'Search',
15
+ onClick: ->(action) do
16
+ action.dialogs_alert message: 'Perform some action'
17
+ end
18
+ )
19
+ menu.button(
20
+ icon: { name: 'star', badge: { text: '1', backgroundColor: '#ff0000' } },
21
+ onClick: ->(action) do
22
+ action.dialogs_alert message: 'Perform some action'
23
+ end
24
+ )
25
+ menu.button(
26
+ icon: { name: 'map', badge: '2' },
27
+ onClick: ->(action) do
28
+ action.dialogs_alert message: 'Perform some action'
29
+ end
30
+ )
10
31
  end
11
- menu.button icon: { name: 'star', badge: { text: '1', backgroundColor: '#ff0000' } }, onClick: ->(action) do
12
- action.dialogs_alert message: 'Perform some action'
13
- end
14
- menu.button icon: { name: 'map', badge: '2' }, onClick: ->(action) do
15
- action.dialogs_alert message: 'Perform some action'
16
- end
17
- end
32
+ )
18
33
 
19
- page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
20
- scroll.label text: 'See the right menu buttons on the nav bar'
21
- end
34
+ page.scroll(
35
+ padding: glib_json_padding_body,
36
+ childViews: ->(scroll) do
37
+ scroll.label text: 'See the right menu buttons on the nav bar'
38
+ end
39
+ )
@@ -54,23 +54,23 @@ page.scroll backgroundColor: '#fafafa', padding: { top: 10, right: 10, bottom: 1
54
54
  scroll.panels_responsive width: 'matchParent', childViews: ->(horizontal) do
55
55
  gap = { top: 12, left: 10, right: 10, bottom: 12 }
56
56
  horizontal.panels_column lg: { cols: 4 }, padding: gap, childViews: ->(column) do
57
- column.panels_vertical styleClasses: styleClasses, width: 'matchParent', padding: glib_json_padding_body, childViews: ->(column) do
58
- column.button text: '1'
57
+ column.panels_vertical styleClasses: styleClasses, width: 'matchParent', padding: glib_json_padding_body, childViews: ->(subcolumn) do
58
+ subcolumn.button text: '1'
59
59
  end
60
60
  end
61
61
  horizontal.panels_column lg: { cols: 4 }, padding: gap, childViews: ->(column) do
62
- column.panels_vertical styleClasses: styleClasses, width: 'matchParent', padding: glib_json_padding_body, childViews: ->(column) do
63
- column.button text: '2'
62
+ column.panels_vertical styleClasses: styleClasses, width: 'matchParent', padding: glib_json_padding_body, childViews: ->(subcolumn) do
63
+ subcolumn.button text: '2'
64
64
  end
65
65
  end
66
66
  horizontal.panels_column lg: { cols: 4 }, padding: gap, childViews: ->(column) do
67
- column.panels_vertical styleClasses: styleClasses, width: 'matchParent', padding: glib_json_padding_body, childViews: ->(column) do
68
- column.button text: '3'
67
+ column.panels_vertical styleClasses: styleClasses, width: 'matchParent', padding: glib_json_padding_body, childViews: ->(subcolumn) do
68
+ subcolumn.button text: '3'
69
69
  end
70
70
  end
71
71
  horizontal.panels_column lg: { cols: 4 }, padding: gap, childViews: ->(column) do
72
- column.panels_vertical styleClasses: styleClasses, width: 'matchParent', padding: glib_json_padding_body, childViews: ->(column) do
73
- column.button text: '4'
72
+ column.panels_vertical styleClasses: styleClasses, width: 'matchParent', padding: glib_json_padding_body, childViews: ->(subcolumn) do
73
+ subcolumn.button text: '4'
74
74
  end
75
75
  end
76
76
  end
@@ -23,8 +23,8 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
23
23
  9.times do |i|
24
24
  scroll.panels_column lg: { cols: 4 }, padding: { top: 18, right: 14, bottom: 18, left: 14 }, childViews: ->(column) do
25
25
  column.panels_responsive styleClasses: ['card'], padding: { top: 48, right: 24, bottom: 48, left: 24 }, childViews: ->(responsive) do
26
- column.h2 text: "Item #{i}"
27
- column.p text: "Hover view with #{i} sentence(s)"
26
+ responsive.h2 text: "Item #{i}"
27
+ responsive.p text: "Hover view with #{i} sentence(s)"
28
28
  end, hoverViews: ->(hover) do
29
29
  render 'json_ui/garage/panels/hover_views_content', hover: hover, i: i
30
30
  end, onClick: ->(action) do
@@ -46,31 +46,31 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
46
46
  timeline.panels_vertical childViews: ->(vertical) do
47
47
  vertical.h4 text: 'Order submitted'
48
48
  vertical.spacer height: 2
49
- timeline.label text: '15 minutes ago'
49
+ vertical.label text: '15 minutes ago'
50
50
  end
51
51
 
52
52
  timeline.panels_vertical childViews: ->(vertical) do
53
53
  vertical.h4 text: 'Finding you a driver'
54
54
  vertical.spacer height: 2
55
- timeline.label text: '15 minutes ago'
55
+ vertical.label text: '15 minutes ago'
56
56
  end
57
57
 
58
58
  timeline.panels_vertical childViews: ->(vertical) do
59
59
  vertical.h4 text: 'Driver found'
60
60
  vertical.spacer height: 2
61
- timeline.label text: '12 minutes ago'
61
+ vertical.label text: '12 minutes ago'
62
62
  end
63
63
 
64
64
  timeline.panels_vertical childViews: ->(vertical) do
65
65
  vertical.h4 text: 'On the way'
66
66
  vertical.spacer height: 2
67
- timeline.label text: 'Duration: 11 minutes'
67
+ vertical.label text: 'Duration: 11 minutes'
68
68
  end
69
69
 
70
70
  timeline.panels_vertical childViews: ->(vertical) do
71
71
  vertical.h4 text: 'Arrived'
72
72
  vertical.spacer height: 2
73
- timeline.label text: '1 minute ago'
73
+ vertical.label text: '1 minute ago'
74
74
  end
75
75
  end
76
76
 
@@ -31,7 +31,7 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
31
31
  vertical.spacer height: 6
32
32
  vertical.p text: 'The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.'
33
33
  vertical.spacer height: 6
34
- ul.panels_ul childViews: ->(inner_ul) do
34
+ vertical.panels_ul childViews: ->(inner_ul) do
35
35
  inner_ul.label text: 'Sub item 1'
36
36
  inner_ul.label text: 'Sub item 2'
37
37
  end
@@ -61,7 +61,7 @@ page.scroll childViews: ->(scroll) do
61
61
  displayed: false
62
62
  end
63
63
 
64
- scroll.panels_bulkEdit2 \
64
+ wres.panels_bulkEdit2 \
65
65
  id: 'import_table',
66
66
  width: 'matchParent',
67
67
  paramNameForRowId: 'row_id',
@@ -67,7 +67,7 @@ page.form(
67
67
  styleClass: 'align-center',
68
68
  xs: { gap: { all: 4 } },
69
69
  childViews: ->(flow) do
70
- form.fields_upload(
70
+ flow.fields_upload(
71
71
  properties.merge(
72
72
  name: 'user[file_placeholderView]',
73
73
  id: 'pv1',
@@ -89,17 +89,17 @@ page.body childViews: ->(body) do
89
89
  form.fields_select clearable: true, multiple: true, width: 'matchParent', name: 'user[select][]', id: 'select', options: options, value: ['option1', 'option2'], validation: validation
90
90
  form.hr width: 'matchParent'
91
91
  form.panels_flow innerPadding: { bottom: 0 }, width: 'matchParent', id: 'select1', childViews: ->(flow) do
92
- form.fields_select clearable: true, width: 'matchParent', name: 'user[select1]', options: options_with_icon, value: 'option1'
93
- form.hr width: 'matchParent'
92
+ flow.fields_select clearable: true, width: 'matchParent', name: 'user[select1]', options: options_with_icon, value: 'option1'
93
+ flow.hr width: 'matchParent'
94
94
  end
95
95
  form.panels_horizontal id: 'select2', width: 'matchParent', childViews: ->(hori) do
96
- form.fields_select clearable: true, width: 'matchParent', name: 'user[select2]', options: options_with_image, value: 'option2'
97
- form.hr width: 'matchParent'
96
+ hori.fields_select clearable: true, width: 'matchParent', name: 'user[select2]', options: options_with_image, value: 'option2'
97
+ hori.hr width: 'matchParent'
98
98
  end
99
99
  form.panels_split id: 'select3', width: 'matchParent', content: ->(split) do
100
100
  split.left childViews: ->(right) do
101
- form.fields_select clearable: true, width: 'matchParent', name: 'user[select3]', options: options, value: 'option3'
102
- form.hr width: 'matchParent'
101
+ right.fields_select clearable: true, width: 'matchParent', name: 'user[select3]', options: options, value: 'option3'
102
+ right.hr width: 'matchParent'
103
103
  end
104
104
  end
105
105
  form.fields_chipGroup width: 'matchParent', name: 'user[chip_group]', id: 'chip_group', options: options, value: ['option2'], validation: validation
@@ -36,9 +36,9 @@ page.body childViews: ->(body) do
36
36
  template.fields_hidden name: 'error_message'
37
37
  template.fields_text width: 'matchParent', name: 'question', label: 'Question', placeholder: 'Question', styleClass: 'question'
38
38
 
39
- form.panels_responsive id: 'responsive_{{entryIndex}}', childViews: ->(column) do
39
+ template.panels_responsive id: 'responsive_{{entryIndex}}', childViews: ->(column) do
40
40
  options = [:rating, :yes_no, :choices, :unspecified]
41
- template.fields_select \
41
+ column.fields_select \
42
42
  width: 'matchParent',
43
43
  name: 'type',
44
44
  label: 'Answer Type',
@@ -0,0 +1,94 @@
1
+ json.title 'Test Page (Logics Set)'
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: 'Logics Set - Icon Badge'
10
+ res.spacer height: 8
11
+
12
+ res.panels_flow innerPadding: { bottom: 0 }, width: 'matchParent', childViews: ->(flow) do
13
+ flow.button text: 'Set badge to "5"', onClick: ->(action) do
14
+ action.logics_set targetId: 'test_icon', conditionalData: {
15
+ 'badge.text': '5',
16
+ 'badge.backgroundColor': 'primary'
17
+ }
18
+ end
19
+
20
+ flow.spacer width: 8
21
+
22
+ flow.button text: 'Set badge to "99"', onClick: ->(action) do
23
+ action.logics_set targetId: 'test_icon', conditionalData: {
24
+ 'badge.text': '99',
25
+ 'badge.backgroundColor': 'warning'
26
+ }
27
+ end
28
+
29
+ flow.spacer width: 8
30
+
31
+ flow.button text: 'Clear badge', onClick: ->(action) do
32
+ action.logics_set targetId: 'test_icon', data: {
33
+ badge: nil
34
+ }
35
+ end
36
+ end
37
+
38
+ res.spacer height: 16
39
+ res.hr width: 'matchParent'
40
+ res.spacer height: 16
41
+
42
+ res.icon \
43
+ id: 'test_icon',
44
+ name: 'notifications',
45
+ badge: { text: '1', backgroundColor: 'error' }
46
+
47
+ res.spacer height: 24
48
+ res.h2 text: 'Button with Icon Badge'
49
+ res.spacer height: 8
50
+
51
+ res.panels_flow innerPadding: { bottom: 0 }, width: 'matchParent', childViews: ->(flow) do
52
+ flow.button text: 'Set button badge to "3"', onClick: ->(action) do
53
+ action.logics_set targetId: 'test_button', conditionalData: {
54
+ 'icon.badge.text': '3',
55
+ 'icon.badge.backgroundColor': 'success'
56
+ }
57
+ end
58
+
59
+ flow.spacer width: 8
60
+
61
+ flow.button text: 'Set button badge to "10"', onClick: ->(action) do
62
+ action.logics_set targetId: 'test_button', conditionalData: {
63
+ 'icon.badge.text': '10',
64
+ 'icon.badge.backgroundColor': 'error'
65
+ }
66
+ end
67
+
68
+ flow.spacer width: 8
69
+
70
+ flow.button text: 'Clear button badge', onClick: ->(action) do
71
+ action.logics_set targetId: 'test_button', data: {
72
+ 'icon.badge': nil
73
+ }
74
+ end
75
+ end
76
+
77
+ res.spacer height: 16
78
+ res.hr width: 'matchParent'
79
+ res.spacer height: 16
80
+
81
+ res.button \
82
+ id: 'test_button',
83
+ text: 'Notifications',
84
+ icon: {
85
+ name: 'notifications',
86
+ badge: { text: '5', backgroundColor: 'warning' }
87
+ },
88
+ onClick: ->(action) do
89
+ action.snackbars_alert message: 'Button clicked!'
90
+ end
91
+
92
+ res.spacer height: 16
93
+ end
94
+ end
@@ -24,9 +24,9 @@ small_image_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSGQpSWj
24
24
  page.body padding: glib_json_padding_body, childViews: ->(body) do
25
25
  body.panels_responsive width: 'matchParent', childViews: ->(res) do
26
26
  res.panels_column lg: { cols: 3 }, childViews: ->(col) do
27
- res.h3 text: 'Props changes'
28
- res.spacer height: 8
29
- res.panels_flow innerPadding: { top: 4, right: 4, bottom: 4, left: 4 }, childViews: ->(hori) do
27
+ col.h3 text: 'Props changes'
28
+ col.spacer height: 8
29
+ col.panels_flow innerPadding: { top: 4, right: 4, bottom: 4, left: 4 }, childViews: ->(hori) do
30
30
  hori.button text: 'change bgcolor', onClick: ->(action) do
31
31
  action.runMultiple childActions: ->(saction) do
32
32
  comp_ids.each do |id, method|
@@ -70,10 +70,10 @@ page.body padding: glib_json_padding_body, childViews: ->(body) do
70
70
  end
71
71
  end
72
72
  end
73
- res.spacer height: 16
74
- res.h3 text: 'Childviews changes'
75
- res.spacer height: 8
76
- res.panels_flow innerPadding: { top: 4, right: 4, bottom: 4, left: 4 }, childViews: ->(hori) do
73
+ col.spacer height: 16
74
+ col.h3 text: 'Childviews changes'
75
+ col.spacer height: 8
76
+ col.panels_flow innerPadding: { top: 4, right: 4, bottom: 4, left: 4 }, childViews: ->(hori) do
77
77
  hori.button text: 'Add child to panel', onClick: ->(action) do
78
78
  action.runMultiple childActions: ->(saction) do
79
79
  panels_ids.each do |id, method|
@@ -104,7 +104,7 @@ page.body padding: glib_json_padding_body, childViews: ->(body) do
104
104
  end
105
105
  end
106
106
  end
107
- res.spacer height: 16
107
+ col.spacer height: 16
108
108
  end
109
109
 
110
110
  res.panels_column lg: { cols: 9 }, childViews: ->(col) do
@@ -142,12 +142,12 @@ page.body padding: glib_json_padding_body, childViews: ->(body) do
142
142
  url: json_ui_garage_url(path: 'forms/generic_post'),
143
143
  method: 'post',
144
144
  childViews: ->(form) do
145
- col.fields_text id: 'inp-text', name: 'user[full_name]', width: 300, label: 'Full name', placeholder: 'Full name'
146
- col.spacer height: 4
145
+ form.fields_text id: 'inp-text', name: 'user[full_name]', width: 300, label: 'Full name', placeholder: 'Full name'
146
+ form.spacer height: 4
147
147
 
148
- col.fields_select id: 'inp-select', options: cities, width: 300, name: 'user[city]'
149
- col.spacer height: 4
150
- col.fields_submit text: 'Submit'
148
+ form.fields_select id: 'inp-select', options: cities, width: 300, name: 'user[city]'
149
+ form.spacer height: 4
150
+ form.fields_submit text: 'Submit'
151
151
  end
152
152
  col.spacer height: 8
153
153
  col.icon id: 'icon', name: 'pending', size: 32, styleClasses: ['warning']
@@ -19,14 +19,14 @@ page.body padding: glib_json_padding_body, childViews: ->(body) do
19
19
  url: json_ui_garage_url(path: 'forms/generic_post'),
20
20
  method: 'post',
21
21
  childViews: ->(form) do
22
- res.fields_text id: 'ftext', name: 'user[full_name]', value: 'John Doe', label: 'Full name', placeholder: 'Full name', width: 300
23
- res.spacer height: 8
24
- res.panels_horizontal childViews: ->(hori) do
25
- res.button text: 'set', onClick: ->(action) do
22
+ form.fields_text id: 'ftext', name: 'user[full_name]', value: 'John Doe', label: 'Full name', placeholder: 'Full name', width: 300
23
+ form.spacer height: 8
24
+ form.panels_horizontal childViews: ->(hori) do
25
+ hori.button text: 'set', onClick: ->(action) do
26
26
  action.components_set targetId: 'ftext', data: { name: 'user[city]', value: 'Taipei', label: 'City', placeholder: 'City' }
27
27
  end
28
- res.spacer width: 4
29
- res.fields_submit text: 'submit'
28
+ hori.spacer width: 4
29
+ hori.fields_submit text: 'submit'
30
30
  end
31
31
  end
32
32