glib-web 0.5.53 → 0.5.58

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/glib/json/libs.rb +6 -1
  3. data/app/controllers/glib/home_controller.rb +38 -0
  4. data/app/helpers/glib/json_ui/action_builder/panels.rb +14 -0
  5. data/app/helpers/glib/json_ui/action_builder/windows.rb +5 -0
  6. data/app/helpers/glib/json_ui/list_builders.rb +1 -0
  7. data/app/helpers/glib/json_ui/view_builder.rb +1 -0
  8. data/app/helpers/glib/json_ui/view_builder/fields.rb +14 -0
  9. data/app/helpers/glib/json_ui/view_builder/panels.rb +1 -0
  10. data/app/views/json_ui/garage/actions/_panels.json.jbuilder +18 -0
  11. data/app/views/json_ui/garage/actions/_timeouts.json.jbuilder +1 -1
  12. data/app/views/json_ui/garage/actions/index.json.jbuilder +2 -0
  13. data/app/views/json_ui/garage/forms/index.json.jbuilder +1 -2
  14. data/app/views/json_ui/garage/forms/new_rich_text.json.jbuilder +0 -0
  15. data/app/views/json_ui/garage/forms/pickers.json.jbuilder +64 -8
  16. data/app/views/json_ui/garage/forms/rich_text.json.jbuilder +32 -32
  17. data/app/views/json_ui/garage/forms/selects.json.jbuilder +70 -57
  18. data/app/views/json_ui/garage/forms/styled_boxes.json.jbuilder +21 -22
  19. data/app/views/json_ui/garage/forms/submission_flow.json.jbuilder +12 -12
  20. data/app/views/json_ui/garage/forms/submission_flow_post.json.jbuilder +6 -4
  21. data/app/views/json_ui/garage/forms/text_validation.json.jbuilder +10 -0
  22. data/app/views/json_ui/garage/home/blank.json.jbuilder +4 -5
  23. data/app/views/json_ui/garage/home/index.json.jbuilder +31 -27
  24. data/app/views/json_ui/garage/home/slow.json.jbuilder +5 -5
  25. data/app/views/json_ui/garage/lists/chat_ui.json.jbuilder +1 -0
  26. data/app/views/json_ui/garage/notifications/action_cable.json.jbuilder +2 -2
  27. data/app/views/json_ui/garage/pages/index.json.jbuilder +4 -0
  28. data/app/views/json_ui/garage/pages/lifecycle_hooks.json.jbuilder +13 -0
  29. data/app/views/json_ui/garage/pages/tab_bar.json.jbuilder +8 -4
  30. data/app/views/json_ui/garage/panels/vertical.json.jbuilder +5 -0
  31. data/app/views/json_ui/garage/tables/layout.json.jbuilder +5 -1
  32. metadata +4 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65a2bc305ef53f9a39b851abfa09c8e760b174c74c2a8fcf41a7d04c527ef0ee
4
- data.tar.gz: 5a75ed552c05fcf47468e8d91e630dd4567d5f5028656324ef36d5d0818bd8e3
3
+ metadata.gz: 0530acf902c8752058a734963723a16e5811befbe70266998c69a8f4aaa848d1
4
+ data.tar.gz: 78382d21966ea3f149afc4b8ce1dc31505909756011979351b50359f49877bc2
5
5
  SHA512:
6
- metadata.gz: 9ac891b106a5e45b949d523464c82152f24166bc61e274a0377108cee8a3784e97cda6b2627340d1c1fa7cb0187870a3526fd60e6e5d3da01443e24e50b60313
7
- data.tar.gz: 4e15c49028568df461f16c3de40b7c22bbfdc5e6ff2cfdd938f55e1e6263041a52f95620eef38126d7531c3ba3b10e31a1d7d2c7cb46a75d94be589d724fe9b2
6
+ metadata.gz: 8828097d8d8d4959888bbdd7634d8cbf676ddd31183b98fa16440535ace50cdde2a8f6230ca9eb0d22ef1fc8bf9e5358642b3a2652ab1b9014dcbcc3c78fca17
7
+ data.tar.gz: 8d2c328743536269527adac29527b00ec2cae739cdef6c9d1ac645c041e73aa56ab5d13aeec7ec72505f813b45d96d54d1351ffc78b3eee92e0c9355dd17be1e
@@ -62,13 +62,18 @@ module Glib::Json::Libs
62
62
 
63
63
  def glib_json_handle_500(exception)
64
64
  if json_ui_activated? && Rails.env.production?
65
- Rollbar.error(exception) if defined?(Rollbar)
65
+ Rollbar.error(exception, :use_exception_level_filters => true) if defined?(Rollbar)
66
66
  render file: Rails.root.join('public', '500.html'), status: :internal_server_error
67
67
  else
68
68
  raise exception
69
69
  end
70
70
  end
71
71
 
72
+ def glib_json_redirect_to(url)
73
+ render json: {
74
+ onResponse: { action: 'dialogs/close', onClose: { action: 'windows/open', url: url } }
75
+ }
76
+ end
72
77
 
73
78
  module ClassMethods
74
79
 
@@ -6,11 +6,49 @@ module Glib
6
6
  end
7
7
 
8
8
  def json_ui_garage
9
+ init_orders
10
+
9
11
  @path_prefix = 'json_ui/garage'
10
12
 
11
13
  # We can't use prepend_view_path because it affects the app, not the gem
12
14
  path = "#{@path_prefix}/#{params[:path] || 'home/index'}"
13
15
  render path
14
16
  end
17
+
18
+ def init_orders
19
+ @order_headings = {}
20
+ @orders = params[:orders] || []
21
+ @orders.each do |order|
22
+ prop_name, direction = order.split('-')
23
+ index_order(prop_name, direction)
24
+ end
25
+ end
26
+
27
+ def index_order(prop_name, direction)
28
+ # In a real app, apply ordering to the model. For example:
29
+ # @users = @users.order(prop_name => direction)
30
+
31
+ # Garage example
32
+ @order_headings[prop_name] = direction
33
+ end
34
+
35
+ def reversed_order(order)
36
+ order.to_sym == :asc ? :desc : :asc
37
+ end
38
+
39
+ def reversed_order_params(prop_name)
40
+ prop_value = :asc
41
+ remaining = @orders.reject do |o|
42
+ tuple = o.split('-')
43
+ if tuple.first == prop_name.to_s
44
+ prop_value = reversed_order(tuple.second)
45
+ true
46
+ end
47
+ end
48
+ # Sort the params to produce predictable URLs which are useful for SEO
49
+ (["#{prop_name}-#{prop_value}"] + remaining).sort
50
+ end
51
+
52
+ helper_method :reversed_order_params
15
53
  end
16
54
  end
@@ -0,0 +1,14 @@
1
+ class Glib::JsonUi::ActionBuilder
2
+ module Panels
3
+ class ScrollToBottom < Action
4
+ action :onScroll
5
+ bool :animate
6
+ end
7
+
8
+ class ScrollTo < Action
9
+ string :viewId
10
+ action :onScroll
11
+ bool :animate
12
+ end
13
+ end
14
+ end
@@ -22,5 +22,10 @@ class Glib::JsonUi::ActionBuilder
22
22
  string :url, cache: true
23
23
  action :onReload
24
24
  end
25
+
26
+ class CloseWithReload < Action
27
+ string :fallbackUrl
28
+ action :onReload
29
+ end
25
30
  end
26
31
  end
@@ -12,6 +12,7 @@ module Glib
12
12
  menu :editButtons
13
13
  menu :chips
14
14
  singleton_array :styleClass, :styleClasses
15
+ color :backgroundColor
15
16
 
16
17
  # def editButtons(block)
17
18
  # json.editButtons do
@@ -24,6 +24,7 @@ module Glib
24
24
  end
25
25
 
26
26
  class View < JsonUiElement
27
+ string :id
27
28
  length :width
28
29
  length :height
29
30
  color :backgroundColor
@@ -233,8 +233,22 @@ class Glib::JsonUi::ViewBuilder
233
233
  string :publicKey
234
234
  end
235
235
 
236
+ class StripeExternalAccount < AbstractField
237
+ string :publicKey
238
+ string :accountHolderName
239
+ string :accountHolderType
240
+ string :country
241
+ string :currency
242
+ end
243
+
236
244
  class CreditCard < AbstractField
237
245
  string :publicKey
238
246
  end
247
+
248
+ class Rating < AbstractField
249
+ bool :halfIncrements
250
+ string :color
251
+ int :size
252
+ end
239
253
  end
240
254
  end
@@ -202,6 +202,7 @@ class Glib::JsonUi::ViewBuilder
202
202
  views :childViews
203
203
  string :distribution
204
204
  string :align
205
+ action :onClick
205
206
  end
206
207
 
207
208
  class Horizontal < View
@@ -0,0 +1,18 @@
1
+
2
+ section.header padding: glib_json_padding_list, childViews: ->(header) do
3
+ header.h3 text: 'Panels'
4
+ end
5
+
6
+ section.rows builder: ->(template) do
7
+ template.thumbnail title: 'panels/scrollToBottom', onClick: ->(action) do
8
+ action.panels_scrollToBottom animate: true, onScroll: ->(subaction) do
9
+ subaction.dialogs_alert message: 'Bottom reached'
10
+ end
11
+ end
12
+
13
+ template.thumbnail title: 'panels/scrollTo', onClick: ->(action) do
14
+ action.panels_scrollTo viewId: 'scroll_anchor', animate: true, onScroll: ->(subaction) do
15
+ subaction.dialogs_alert message: 'Bottom reached'
16
+ end
17
+ end
18
+ end
@@ -1,6 +1,6 @@
1
1
 
2
2
  section.header padding: glib_json_padding_list, childViews: ->(header) do
3
- header.h3 text: 'Timeouts'
3
+ header.h3 text: 'Timeouts', id: 'scroll_anchor'
4
4
  end
5
5
 
6
6
  section.rows builder: ->(template) do
@@ -6,6 +6,8 @@ render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
6
6
  page.list sections: [
7
7
  ->(section) do
8
8
  render "#{@path_prefix}/actions/reload", section: section
9
+ end, ->(section) do
10
+ render "#{@path_prefix}/actions/panels", section: section
9
11
  end, ->(section) do
10
12
  render "#{@path_prefix}/actions/dialogs", section: section
11
13
  end, ->(section) do
@@ -16,7 +16,7 @@ page.list sections: [
16
16
  template.thumbnail title: "Submission Flow (timestamp: #{DateTime.current.to_i})", onClick: ->(action) do
17
17
  action.windows_open url: json_ui_garage_url(path: 'forms/submission_flow')
18
18
  end
19
- template.thumbnail title: "Submission Indicator", onClick: ->(action) do
19
+ template.thumbnail title: 'Submission Indicator', onClick: ->(action) do
20
20
  action.windows_open url: json_ui_garage_url(path: 'forms/submission_indicator')
21
21
  end
22
22
  template.thumbnail title: 'GET Request', onClick: ->(action) do
@@ -59,7 +59,6 @@ page.list sections: [
59
59
  template.thumbnail title: 'Floating Submit', onClick: ->(action) do
60
60
  action.windows_open url: json_ui_garage_url(path: 'forms/floating_submit')
61
61
  end
62
-
63
62
  end
64
63
  end, ->(section) do
65
64
  section.header padding: glib_json_padding_list, childViews: ->(header) do
@@ -3,7 +3,12 @@ json.title 'Forms'
3
3
  page = json_ui_page json
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
6
+ page.form \
7
+ url: json_ui_garage_url(path: 'forms/generic_post'),
8
+ method: 'post',
9
+ padding: glib_json_padding_body,
10
+ childViews: ->(form) do
11
+
7
12
  form.h2 text: 'Radio Group'
8
13
  form.spacer height: 6
9
14
  form.h4 text: 'Gender'
@@ -15,15 +20,40 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
15
20
 
16
21
  form.spacer height: 20
17
22
  form.h2 text: 'Single Checkbox'
18
- form.fields_check name: 'user[age_range]', value: '16+', checkValue: '16+', uncheckValue: '0-16', label: 'I am over 16 (has default value)'
19
- form.fields_check name: 'user[employer]', checkValue: 1, label: 'I am an employer (no default value)'
20
- form.fields_check name: 'user[enabled]', checkValue: true, label: 'Enable', styleClass: 'switch', value: 'true'
23
+ form.fields_check \
24
+ name: 'user[age_range]',
25
+ value: '16+',
26
+ checkValue: '16+',
27
+ uncheckValue: '0-16',
28
+ label: 'I am over 16 (has default value)'
29
+ form.fields_check \
30
+ name: 'user[employer]',
31
+ checkValue: 1,
32
+ label: 'I am an employer (no default value)'
33
+ form.fields_check \
34
+ name: 'user[enabled]',
35
+ checkValue: true,
36
+ label: 'Enable',
37
+ styleClass: 'switch',
38
+ value: 'true'
21
39
 
22
40
  form.spacer height: 20
23
41
  form.h2 text: 'Date/Time'
24
42
  form.spacer height: 6
25
- form.fields_date name: 'user[date]', width: 'matchParent', label: 'Date', min: '2010-01-01', max: '2012-01-01', value: '2010-02-01'
26
- form.fields_datetime name: 'user[date_time]', width: 'matchParent', label: 'Date Time', min: '2018-06-09T00:00', max: '2018-06-17T00:00', value: '2018-06-15T19:30'
43
+ form.fields_date \
44
+ name: 'user[date]',
45
+ width: 'matchParent',
46
+ label: 'Date',
47
+ min: '2010-01-01',
48
+ max: '2012-01-01',
49
+ value: '2010-02-01'
50
+ form.fields_datetime \
51
+ name: 'user[date_time]',
52
+ width: 'matchParent',
53
+ label: 'Date Time',
54
+ min: '2018-06-09T00:00',
55
+ max: '2018-06-17T00:00',
56
+ value: '2018-06-15T19:30'
27
57
 
28
58
  form.spacer height: 20
29
59
  form.h2 text: 'Country'
@@ -34,13 +64,39 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
34
64
  form.spacer height: 20
35
65
  form.h2 text: 'Map'
36
66
  form.spacer height: 6
37
- form.fields_location name: 'user[address]', width: 'matchParent', label: 'Type an address', value: 'Sydney Harbour Bridge',
67
+ form.fields_location \
68
+ name: 'user[address]',
69
+ width: 'matchParent',
70
+ label: 'Type an address',
71
+ value: 'Sydney Harbour Bridge',
38
72
  autocompleteOptions: { componentRestrictions: { country: 'au' }, types: ['(cities)'] },
39
73
  latitudeField: { view: 'fields/text', name: 'user[latitude]', label: 'Lat', value: -33.8523063, readOnly: true },
40
74
  longitudeField: { view: 'fields/text', name: 'user[longitude]', label: 'Long', value: 151.21078710000006, readOnly: true },
41
75
  zoomField: { view: 'fields/text', name: 'user[zoom]', label: 'Zoom' }
42
76
 
43
77
  form.spacer height: 20
44
- form.fields_submit text: 'Submit'
78
+ form.h2 text: 'Rating'
79
+ form.spacer height: 6
80
+ form.fields_rating \
81
+ name: 'user[rating_summary1]',
82
+ value: 1,
83
+ color: 'primary'
84
+ form.fields_rating \
85
+ name: 'user[rating_summary2]',
86
+ value: 1.5,
87
+ halfIncrements: true,
88
+ color: 'secondary'
89
+ form.fields_rating \
90
+ name: 'user[rating_summary3]',
91
+ value: 2,
92
+ color: 'ternary',
93
+ size: 35
94
+ form.fields_rating \
95
+ name: 'user[rating_summary4]',
96
+ value: 3,
97
+ readOnly: true,
98
+ size: 40
45
99
 
100
+ form.spacer height: 20
101
+ form.fields_submit text: 'Submit'
46
102
  end
@@ -1,40 +1,40 @@
1
1
  json.title 'Forms'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page
5
-
6
- page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: { top: 12, left: 20, right: 20, bottom: 12 }, childViews: ->(form) do
7
- form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
8
-
9
- # images = [
10
- # {
11
- # value: "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4",
12
- # fileUrl: "https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100"
13
- # }
14
- # ]
15
- # form.fields_richText name: 'user[bio]', width: 'matchParent', label: 'Content', images: images, value: '<p>Test {{image1}}</p>'
16
-
17
- json.child! do
18
- json.view 'fields/richText-v1'
19
- json.width 'matchParent'
20
- json.label 'Content'
21
- json.name 'user[bio]'
22
- json.value '<p>Test {{image1}}</p>'
23
-
24
- json.images do
25
- json.child! do
26
- json.value "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4"
27
- # json.fileTitle "hita i hanom hg.jpg"
28
- json.fileUrl "https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100"
29
- end
30
- end
3
+ page = json_ui_page json
4
+
5
+ render "#{@path_prefix}/nav_menu", json: json, page: page
6
+
7
+ page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: { top: 12, left: 20, right: 20, bottom: 12 }, childViews: ->(form) do
8
+ form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
9
+
10
+ # images = [
11
+ # {
12
+ # value: "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4",
13
+ # fileUrl: "https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100"
14
+ # }
15
+ # ]
16
+ # form.fields_richText name: 'user[bio]', width: 'matchParent', label: 'Content', images: images, value: '<p>Test {{image1}}</p>'
31
17
 
32
- json.imageUploader do
33
- json.accepts(fileType: "image/*", maxFileSize: 5000)
34
- json.directUploadUrl rails_direct_uploads_url
18
+ json.child! do
19
+ json.view 'fields/richText-v1'
20
+ json.width 'matchParent'
21
+ json.label 'Content'
22
+ json.name 'user[bio]'
23
+ json.value '<p>Test {{image1}}</p>'
24
+
25
+ json.images do
26
+ json.child! do
27
+ json.value "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4"
28
+ # json.fileTitle "hita i hanom hg.jpg"
29
+ json.fileUrl "https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100"
35
30
  end
36
31
  end
37
32
 
38
- form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
33
+ json.imageUploader do
34
+ json.accepts(fileType: "image/*", maxFileSize: 5000)
35
+ json.directUploadUrl rails_direct_uploads_url
36
+ end
39
37
  end
38
+
39
+ form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
40
40
  end
@@ -1,70 +1,83 @@
1
1
  json.title 'Forms'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page
3
+ page = json_ui_page json
5
4
 
6
- page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
5
+ render "#{@path_prefix}/nav_menu", json: json, page: page
7
6
 
8
- form.spacer height: 20
9
- form.h2 text: 'Basic select fields'
10
- form.spacer height: 6
11
- languages = {
12
- 'brisbane' => 'Brisbane',
13
- 'canberra' => 'Canberra',
14
- 'melbourne' => 'Melbourne',
15
- 'sydney' => 'Sydney',
16
- }
17
- form.fields_select name: 'user[city]', width: 'matchParent', label: 'Primary Language', options: languages.map { |k, v| { value: k, text: v } }, value: 'canberra'
18
- form.fields_select name: 'user[cities][]', width: 'matchParent', label: 'Preferred Languages', options: languages.map { |k, v| { value: k, text: v } }, value: ['melbourne', 'sydney'], multiple: true
7
+ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
8
+
9
+ form.spacer height: 20
10
+ form.h2 text: 'Basic select fields'
11
+ form.spacer height: 6
12
+ languages = {
13
+ 'brisbane' => 'Brisbane',
14
+ 'canberra' => 'Canberra',
15
+ 'melbourne' => 'Melbourne',
16
+ 'sydney' => 'Sydney',
17
+ }
18
+ form.fields_select name: 'user[city]', width: 'matchParent', label: 'Primary Language', options: languages.map { |k, v| { value: k, text: v } }, value: 'canberra'
19
+ form.fields_select name: 'user[cities][]', width: 'matchParent', label: 'Preferred Languages', options: languages.map { |k, v| { value: k, text: v } }, value: ['melbourne', 'sydney'], multiple: true
19
20
 
20
- form.spacer height: 20
21
- form.h2 text: 'Select fields with grouping'
22
- form.spacer height: 6
23
- form.label text: 'Applicable to select fields with many options'
24
- form.spacer height: 6
21
+ form.spacer height: 20
22
+ form.h2 text: 'Select fields with grouping'
23
+ form.spacer height: 6
24
+ form.label text: 'Applicable to select fields with many options'
25
+ form.spacer height: 6
25
26
 
26
- languages = {
27
- "East Asia" => {
28
- "zh" => "Chinese",
29
- "ja" => "Japanese",
30
- "ko" => "Korean",
31
- },
32
- "Middle East" => {
33
- "ar" => 'Arabic',
34
- "hi" => "Hindi",
35
- },
36
- "Europe" => {
37
- "nl" => "Dutch",
38
- "en" => "English",
39
- "fr" => "French",
40
- "de" => "German",
41
- "it" => "Italian",
42
- "pt" => "Portuguese",
43
- "es" => "Spanish",
44
- },
45
- "Eastern Europe" => {
46
- "ru" => "Russian",
47
- }
27
+ languages = {
28
+ "East Asia" => {
29
+ "zh" => "Chinese",
30
+ "ja" => "Japanese",
31
+ "ko" => "Korean",
32
+ },
33
+ "Middle East" => {
34
+ "ar" => 'Arabic',
35
+ "hi" => "Hindi",
36
+ },
37
+ "Europe" => {
38
+ "nl" => "Dutch",
39
+ "en" => "English",
40
+ "fr" => "French",
41
+ "de" => "German",
42
+ "it" => "Italian",
43
+ "pt" => "Portuguese",
44
+ "es" => "Spanish",
45
+ },
46
+ "Eastern Europe" => {
47
+ "ru" => "Russian",
48
48
  }
49
- options = []
50
- languages.each do |group, sub|
51
- options << { type: 'label', text: group }
52
- options.concat(sub.map { |k, v| { value: k, text: v } })
53
- options << { type: 'divider' }
54
- end
49
+ }
50
+ options = []
51
+ languages.each do |group, sub|
52
+ options << { type: 'label', text: group }
53
+ options.concat(sub.map { |k, v| { value: k, text: v } })
54
+ options << { type: 'divider' }
55
+ end
55
56
 
56
- form.fields_select name: 'user[language]', width: 'matchParent', label: 'Primary Language', options: options, value: 'nl'
57
- form.fields_select name: 'user[languages][]', width: 'matchParent', label: 'Primary Language', options: options, value: ['ja', 'de'], multiple: true
57
+ form.fields_select name: 'user[language]', width: 'matchParent', label: 'Primary Language', options: options, value: 'nl'
58
+ form.fields_select name: 'user[languages][]', width: 'matchParent', label: 'Primary Language', options: options, value: ['ja', 'de'], multiple: true
58
59
 
59
- form.spacer height: 20
60
- form.h2 text: 'Autocomplete (select with manual entry)'
61
- form.spacer height: 6
62
- skills = ['Singing', 'Dancing', 'Fighting']
63
- form.fields_autocomplete name: 'user[skill]', width: 'matchParent', label: 'Skill', options: skills, value: 'Singing'
64
- form.fields_autocomplete name: 'user[skills][]', width: 'matchParent', label: 'Skills', options: skills, value: ['Dancing', 'Fencing'], multiple: true
60
+ form.spacer height: 20
61
+ form.h2 text: 'Select fields with empty values'
62
+ form.spacer height: 6
63
+ form.label text: 'It is not recommended to use nil because when the value gets submitted, it is not distinguishable from an empty string.'
64
+ form.spacer height: 6
65
+ languages = {
66
+ nil => 'Nil',
67
+ '' => 'Unspecified',
68
+ 'specified' => 'Specified',
69
+ }
70
+ form.fields_select name: 'user[empty_default]', width: 'matchParent', label: 'Unspecified Default', options: languages.map { |k, v| { value: k, text: v } }, value: ''
71
+ form.fields_select name: 'user[nil_default]', width: 'matchParent', label: 'Nil Default', options: languages.map { |k, v| { value: k, text: v } }
72
+ form.fields_select name: 'user[mixed_default][]', width: 'matchParent', label: 'Mixed Default', options: languages.map { |k, v| { value: k, text: v } }, value: ['', 'specified', nil], multiple: true
65
73
 
66
- form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
74
+ form.spacer height: 20
75
+ form.h2 text: 'Autocomplete (select with manual entry)'
76
+ form.spacer height: 6
77
+ skills = ['Singing', 'Dancing', 'Fighting']
78
+ form.fields_autocomplete name: 'user[skill]', width: 'matchParent', label: 'Skill', options: skills, value: 'Singing'
79
+ form.fields_autocomplete name: 'user[skills][]', width: 'matchParent', label: 'Skills', options: skills, value: ['Dancing', 'Fencing'], multiple: true
67
80
 
68
- end
81
+ form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
69
82
 
70
83
  end
@@ -1,36 +1,35 @@
1
1
  json.title 'Forms'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page
3
+ page = json_ui_page json
5
4
 
6
- page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
7
- form.fields_text name: 'user[name]', width: 'matchParent', label: 'Search', placeholder: 'Enter a keyword', styleClasses: ['outlined', 'rounded']
5
+ render "#{@path_prefix}/nav_menu", json: json, page: page
8
6
 
9
- form.spacer height: 14
10
- form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password', placeholder: 'Type your password', styleClass: 'outlined'
7
+ page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
8
+ form.fields_text name: 'user[name]', width: 'matchParent', label: 'Search', placeholder: 'Enter a keyword', styleClasses: ['outlined', 'rounded']
11
9
 
12
- form.spacer height: 14
13
- form.fields_textarea name: 'user[bio]', width: 'matchParent', label: 'Bio', placeholder: 'Enter your bio', styleClasses: ['outlined']
10
+ form.spacer height: 14
11
+ form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password', placeholder: 'Type your password', styleClass: 'outlined'
14
12
 
15
- # form.spacer height: 14
16
- # form.fields_stripeToken name: 'user[stripe_token_outlined]', width: 'matchParent', publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx', styleClass: 'outlined'
13
+ form.spacer height: 14
14
+ form.fields_textarea name: 'user[bio]', width: 'matchParent', label: 'Bio', placeholder: 'Enter your bio', styleClasses: ['outlined']
17
15
 
18
- # form.spacer height: 14
19
- # form.fields_stripeToken name: 'user[stripe_token_individual]', width: 'matchParent', publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx', styleClass: 'individual'
16
+ # form.spacer height: 14
17
+ # form.fields_stripeToken name: 'user[stripe_token_outlined]', width: 'matchParent', publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx', styleClass: 'outlined'
20
18
 
21
- form.spacer height: 14
22
- form.fields_creditCard name: 'user[stripe_token_outlined]', width: 'matchParent', publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx', styleClass: 'outlined'
19
+ # form.spacer height: 14
20
+ # form.fields_stripeToken name: 'user[stripe_token_individual]', width: 'matchParent', publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx', styleClass: 'individual'
23
21
 
24
- form.spacer height: 14
25
- form.fields_creditCard name: 'user[stripe_token_individual]', width: 'matchParent', publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx', styleClass: 'individual'
22
+ form.spacer height: 14
23
+ form.fields_creditCard name: 'user[stripe_token_outlined]', width: 'matchParent', publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx', styleClass: 'outlined'
26
24
 
27
- form.spacer height: 14
28
- form.panels_split width: 'matchParent', content: ->(split) do
29
- split.right childViews: ->(right) do
30
- right.fields_submit text: 'Submit'
31
- end
32
- end
25
+ form.spacer height: 14
26
+ form.fields_creditCard name: 'user[stripe_token_individual]', width: 'matchParent', publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx', styleClass: 'individual'
33
27
 
28
+ form.spacer height: 14
29
+ form.panels_split width: 'matchParent', content: ->(split) do
30
+ split.right childViews: ->(right) do
31
+ right.fields_submit text: 'Submit'
32
+ end
34
33
  end
35
34
 
36
35
  end
@@ -1,17 +1,17 @@
1
1
  json.title 'Forms'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page
3
+ page = json_ui_page json
5
4
 
6
- page.form url: json_ui_garage_url(path: 'forms/submission_flow_post'), method: 'post', padding: { top: 12, left: 20, right: 20, bottom: 12 }, childViews: ->(form) do
7
- form.fields_radioGroup name: 'user[flow]', childViews: ->(group) do
8
- group.h3 text: 'Flow'
9
- group.spacer height: 6
10
- group.fields_radio value: 'close_reload', label: 'close+reload - useful for form submission in mobile apps'
11
- group.fields_radio value: 'open', label: 'open - useful for form submission in web app'
12
- group.fields_radio value: 'close_alert', label: 'close+alert - useful for non-model form (e.g. contact us) in both mobile/web'
13
- group.fields_radio value: 'alert_close', label: 'alert+close - useful for non-model form (e.g. contact us) in both mobile/web'
14
- end
15
- form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
5
+ render "#{@path_prefix}/nav_menu", json: json, page: page
6
+
7
+ page.form url: json_ui_garage_url(path: 'forms/submission_flow_post'), method: 'post', padding: { top: 12, left: 20, right: 20, bottom: 12 }, childViews: ->(form) do
8
+ form.fields_radioGroup name: 'user[flow]', childViews: ->(group) do
9
+ group.h3 text: 'Flow'
10
+ group.spacer height: 6
11
+ group.fields_radio value: 'open', label: 'open - useful for form create'
12
+ group.fields_radio value: 'close_with_reload', label: 'closeWithReload - useful for form update'
13
+ group.fields_radio value: 'close_alert', label: 'close+alert - useful for non-model form (e.g. contact us)'
14
+ group.fields_radio value: 'alert_close', label: 'alert+close - useful for non-model form (e.g. contact us)'
16
15
  end
16
+ form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
17
17
  end
@@ -5,10 +5,12 @@ json_ui_response json do |action|
5
5
  action.dialogs_alert message: 'Please enter all required information'
6
6
  else
7
7
  case flow
8
- when 'close_reload'
9
- action.windows_close onClose: ->(action) do
10
- action.windows_reload
11
- end
8
+ when 'close_with_reload'
9
+ # action.windows_close onClose: ->(action) do
10
+ # action.windows_reload
11
+ # end
12
+
13
+ action.windows_closeWithReload fallbackUrl: json_ui_garage_url(path: 'forms/index')
12
14
  when 'close_alert'
13
15
  action.windows_close onClose: ->(action) do
14
16
  action.dialogs_alert message: 'Thanks for the submission!'
@@ -54,6 +54,16 @@ page.form \
54
54
  width: 'matchParent',
55
55
  publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx'
56
56
 
57
+ form.spacer height: 20
58
+ form.fields_stripeExternalAccount \
59
+ name: 'user[stripe_external_account]',
60
+ width: 'matchParent',
61
+ publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx',
62
+ accountHolderName: 'John Doe',
63
+ accountHolderType: 'individual',
64
+ country: 'AU',
65
+ currency: 'AUD'
66
+
57
67
  form.spacer height: 30
58
68
  form.fields_submit text: 'Submit'
59
69
  end
@@ -2,10 +2,9 @@ sleep 0.5
2
2
 
3
3
  json.title 'Menu'
4
4
 
5
- json_ui_page json do |page|
6
- render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: false
5
+ page = json_ui_page json
6
+ render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: false
7
7
 
8
- page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
9
- scroll.label text: 'Blank page'
10
- end
8
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
9
+ scroll.label text: 'Blank page'
11
10
  end
@@ -1,32 +1,36 @@
1
1
  json.title 'Menu'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
5
-
6
- page.list firstSection: ->(section) do
7
- section.rows builder: ->(template) do
8
- template.thumbnail title: 'Pages', onClick: ->(action) do
9
- action.windows_open url: json_ui_garage_url(path: 'pages/index')
10
- end
11
- template.thumbnail title: 'Lists', onClick: ->(action) do
12
- action.windows_open url: json_ui_garage_url(path: 'lists/index')
13
- end
14
- template.thumbnail title: 'Forms', onClick: ->(action) do
15
- action.windows_open url: json_ui_garage_url(path: 'forms/index')
16
- end
17
- template.thumbnail title: 'Panels', onClick: ->(action) do
18
- action.windows_open url: json_ui_garage_url(path: 'panels/index')
19
- end
20
- template.thumbnail title: 'Views', onClick: ->(action) do
21
- action.windows_open url: json_ui_garage_url(path: 'views/index')
22
- end
23
- template.thumbnail title: 'Actions', onClick: ->(action) do
24
- action.windows_open url: json_ui_garage_url(path: 'actions/index')
25
- end
26
- template.thumbnail title: 'Tables (Web Only)', onClick: ->(action) do
27
- action.windows_open url: json_ui_garage_url(path: 'tables/index')
28
- end
29
- end
3
+ page = json_ui_page json
4
+
5
+ render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
30
6
 
7
+ page.list firstSection: ->(section) do
8
+ section.rows builder: ->(template) do
9
+ template.thumbnail title: 'Pages', onClick: ->(action) do
10
+ action.windows_open url: json_ui_garage_url(path: 'pages/index')
11
+ end
12
+ template.thumbnail title: 'Panels', onClick: ->(action) do
13
+ action.windows_open url: json_ui_garage_url(path: 'panels/index')
14
+ end
15
+ template.thumbnail title: 'Lists', onClick: ->(action) do
16
+ action.windows_open url: json_ui_garage_url(path: 'lists/index')
17
+ end
18
+ template.thumbnail title: 'Forms', onClick: ->(action) do
19
+ action.windows_open url: json_ui_garage_url(path: 'forms/index')
20
+ end
21
+ template.thumbnail title: 'Views', onClick: ->(action) do
22
+ action.windows_open url: json_ui_garage_url(path: 'views/index')
23
+ end
24
+ template.thumbnail title: 'Actions', onClick: ->(action) do
25
+ action.windows_open url: json_ui_garage_url(path: 'actions/index')
26
+ end
27
+ template.thumbnail title: 'Tables (Web Only)', onClick: ->(action) do
28
+ action.windows_open url: json_ui_garage_url(path: 'tables/index')
29
+ end
30
+ # Disabled to prevent errors in crawler tests due to external dependencies
31
+ # template.thumbnail title: 'Services', onClick: ->(action) do
32
+ # action.windows_open url: json_ui_garage_url(path: 'services/index')
33
+ # end
31
34
  end
35
+
32
36
  end
@@ -2,10 +2,10 @@ sleep 2.0
2
2
 
3
3
  json.title 'Menu'
4
4
 
5
- json_ui_page json do |page|
6
- render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: false
5
+ page = json_ui_page json
7
6
 
8
- page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
9
- scroll.label text: 'Blank page'
10
- end
7
+ render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: false
8
+
9
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
10
+ scroll.label text: 'Blank page'
11
11
  end
@@ -3,6 +3,7 @@ json.title 'Lists'
3
3
  liked = params[:liked] == 'true'
4
4
 
5
5
  page = json_ui_page json
6
+
6
7
  render "#{@path_prefix}/nav_menu", json: json, page: page
7
8
 
8
9
  json.phoenixSocket({
@@ -43,7 +43,7 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
43
43
  scroll.panels_split width: 'matchParent', content: ->(content) do
44
44
  content.left childViews: ->(left) do
45
45
  left.fields_textarea \
46
- width: 'matchParent',
46
+ width: 440,
47
47
  label: "Messages from #{first_user.full_name}",
48
48
  onTypeStart: lambda { |action|
49
49
  action.cables_push \
@@ -69,7 +69,7 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
69
69
  end
70
70
  content.right childViews: ->(right) do
71
71
  right.fields_textarea \
72
- width: 'matchParent',
72
+ width: 440,
73
73
  label: "Messages from #{second_user.full_name}",
74
74
  onTypeStart: lambda { |action|
75
75
  action.cables_push \
@@ -25,6 +25,10 @@ json_ui_page json do |page|
25
25
  template.thumbnail title: 'Loading Indicator', onClick: ->(action) do
26
26
  action.windows_open url: json_ui_garage_url(path: 'pages/loading_indicator')
27
27
  end
28
+
29
+ template.thumbnail title: 'Lifecycle Hooks', onClick: ->(action) do
30
+ action.windows_open url: json_ui_garage_url(path: 'pages/lifecycle_hooks')
31
+ end
28
32
  end
29
33
  end,
30
34
  ->(section) do
@@ -0,0 +1,13 @@
1
+ json.title 'Pages'
2
+
3
+ page = json_ui_page json
4
+
5
+ render "#{@path_prefix}/nav_menu", json: json, page: page
6
+
7
+ page.on load: ->(action) do
8
+ action.dialogs_alert message: 'This is an onLoad action'
9
+ end
10
+
11
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
12
+ scroll.label text: 'A dialog should appear automatically.'
13
+ end
@@ -2,12 +2,16 @@ json.title 'Pages'
2
2
 
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
-
5
+
6
6
  page.header childViews: ->(header) do
7
7
  header.tabBar width: 'matchParent', backgroundColor: '#ffca05', color: '#7f561b', buttons: ->(menu) do
8
-
9
- ['FIRST', 'SECOND', 'THIRD'].each_with_index do |text, index|
10
- menu.button text: text, disabled: params[:tab].to_i == index, onClick: ->(action) do
8
+
9
+ {
10
+ 'FIRST' => 'home',
11
+ 'SECOND' => 'schedule',
12
+ 'THIRD' => 'analytics'
13
+ }.each_with_index do |(text, icon), index|
14
+ menu.button icon: icon, text: text, disabled: params[:tab].to_i == index, onClick: ->(action) do
11
15
  action.windows_reload url: json_ui_garage_url(path: 'pages/tab_bar', tab: index)
12
16
  end
13
17
  end
@@ -46,5 +46,10 @@ json_ui_page json do |page|
46
46
  panel.button text: '3'
47
47
  end
48
48
 
49
+ scroll.label text: "\n"
50
+ scroll.h1 text: 'Click action'
51
+ scroll.panels_vertical width: 100, height: 100, backgroundColor: '#b3bac2', onClick: ->(action) do
52
+ action.dialogs_alert message: 'Perform action'
53
+ end
49
54
  end
50
55
  end
@@ -18,7 +18,11 @@ page.table sections: [
18
18
  ->(section) do
19
19
  section.header cellViews: ->(header) do
20
20
  column_indexes.each do |i|
21
- header.label text: "Heading#{i}"
21
+ order_key = "heading#{i}"
22
+ order = @order_headings[order_key]
23
+ header.label text: "Heading#{i} (#{order})", onClick: ->(action) do
24
+ action.windows_reload url: json_ui_garage_url(path: 'tables/layout', orders: reversed_order_params(order_key))
25
+ end
22
26
  end
23
27
  end
24
28
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.53
4
+ version: 0.5.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -92,6 +92,7 @@ files:
92
92
  - app/helpers/glib/json_ui/action_builder.rb
93
93
  - app/helpers/glib/json_ui/action_builder/dialogs.rb
94
94
  - app/helpers/glib/json_ui/action_builder/http.rb
95
+ - app/helpers/glib/json_ui/action_builder/panels.rb
95
96
  - app/helpers/glib/json_ui/action_builder/sheets.rb
96
97
  - app/helpers/glib/json_ui/action_builder/snackbars.rb
97
98
  - app/helpers/glib/json_ui/action_builder/windows.rb
@@ -123,6 +124,7 @@ files:
123
124
  - app/views/json_ui/garage/_nav_menu.json.jbuilder
124
125
  - app/views/json_ui/garage/actions/_dialogs.json.jbuilder
125
126
  - app/views/json_ui/garage/actions/_http.json.jbuilder
127
+ - app/views/json_ui/garage/actions/_panels.json.jbuilder
126
128
  - app/views/json_ui/garage/actions/_reload.json.jbuilder
127
129
  - app/views/json_ui/garage/actions/_sheets.json.jbuilder
128
130
  - app/views/json_ui/garage/actions/_snackbars.json.jbuilder
@@ -175,6 +177,7 @@ files:
175
177
  - app/views/json_ui/garage/pages/full_width_height.json.jbuilder
176
178
  - app/views/json_ui/garage/pages/index.json.jbuilder
177
179
  - app/views/json_ui/garage/pages/layout.json.jbuilder
180
+ - app/views/json_ui/garage/pages/lifecycle_hooks.json.jbuilder
178
181
  - app/views/json_ui/garage/pages/loading_indicator.json.jbuilder
179
182
  - app/views/json_ui/garage/pages/nav_buttons.json.jbuilder
180
183
  - app/views/json_ui/garage/pages/nested_scroll.json.jbuilder