glib-web 3.20.5 → 3.21.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09a9fcb392c01c3befef1f951014fe4934bafea422cb1d5a7f13d2eed5f3e5db'
4
- data.tar.gz: 21c5e44448d4eaa6b51ff67dfdf8d20234e83cdbfc8f2bfd571c58ee5cbf98cb
3
+ metadata.gz: 6a1d6390dceb59db91cdb5fea9a123375d9442af6941b74770881736a6f25de0
4
+ data.tar.gz: 46bfd89ea540dfd8fc125c5c486595fad64d5a40fc55de365b66bf1fb8dbccce
5
5
  SHA512:
6
- metadata.gz: 4420d70795aa12b42bb493cec14553c150740b48864bf7c90a92c4012139109c301721b61d31bba3333ddc85dab39a8a45cac82a0ce0d4b40e285b9e2554319f
7
- data.tar.gz: bae84a5f666c73f04151cbc47e685335914bcfd527392350f31ba90b1450f18f09d3fd2aca1dc92ae7a9ff1c883e99b31a7403d15f437448f584d22c7927accb
6
+ metadata.gz: 4e3536a448117c3c53b26899cc02457dff0326386d187fd1f538d1169f677a2d231a1b3238ace6d53cca7ebbe0effd4b0319c59ec4477f90ec691a571a4c62ea
7
+ data.tar.gz: 32ecff8bb25917bd35605764f4e34c8d52f17e5d89be17738aa5c5230bac8fec4bab40d69c32e470473ad1425338197e0c201b6026985443f6ed4d14a383d4b9
@@ -68,6 +68,11 @@ module Glib::Json::Libs
68
68
  redirect_to url
69
69
  end
70
70
  format.json do
71
+ if __json_ui_rendering?
72
+ redirect_to url
73
+ return
74
+ end
75
+
71
76
  json_ui_redirect_to url
72
77
  end
73
78
  end
@@ -91,6 +96,10 @@ module Glib::Json::Libs
91
96
 
92
97
  REDIRECT_BACK_KEY = :glib_return_to_url
93
98
 
99
+ def json_ui_save_return_url(url = nil)
100
+ session[REDIRECT_BACK_KEY] = url || url_for(params.to_unsafe_h.merge(format: nil))
101
+ end
102
+
94
103
  def glib_handle_401(sign_in_url)
95
104
  if !glib_json_dialog_mode? && request.get?
96
105
  session[REDIRECT_BACK_KEY] = url_for(params.to_unsafe_h.merge(format: nil))
@@ -172,10 +181,29 @@ module Glib::Json::Libs
172
181
  }
173
182
  end
174
183
 
175
- def glib_json_handle_500(exception)
176
- if json_ui_activated? && Rails.env.production?
177
- Rollbar.error(exception, :use_exception_level_filters => true) if defined?(Rollbar)
178
- render file: Rails.root.join('public', '500.html'), status: :internal_server_error
184
+ def glib_json_handle_500(exception, preview_mode)
185
+ if json_ui_activated?
186
+ if Rails.env.production? || preview_mode
187
+ if defined?(Rollbar) && !preview_mode
188
+ Rollbar.error(exception, :use_exception_level_filters => true)
189
+ end
190
+
191
+ render file: Rails.root.join('public', '500.html'), status: :internal_server_error
192
+ else
193
+ raise exception
194
+ end
195
+ else
196
+ raise exception
197
+ end
198
+ end
199
+
200
+ def glib_json_handle_404(exception, preview_mode)
201
+ if json_ui_activated?
202
+ if Rails.env.production? || preview_mode
203
+ render file: Rails.root.join('public', '404.html'), status: :not_found
204
+ else
205
+ raise exception
206
+ end
179
207
  else
180
208
  raise exception
181
209
  end
@@ -262,18 +290,16 @@ module Glib::Json::Libs
262
290
 
263
291
  # Call this before other rescues. Later rescue_from statements will take precedence, so more specific
264
292
  # rescues have to be declared later.
265
- def json_libs_rescue_500
293
+ def json_libs_rescue_500(preview_mode: false)
266
294
  rescue_from StandardError do |exception|
267
- glib_json_handle_500(exception)
295
+ glib_json_handle_500(exception, preview_mode)
268
296
  end
269
297
  end
270
298
 
271
- def json_libs_rescue_404
272
- # Removed because it doesn't seem to offer anything extra
273
- # rescue_from ActiveRecord::RecordNotFound do |exception|
274
- # glib_json_handle_404
275
- # end
299
+ def json_libs_rescue_404(preview_mode: false)
300
+ rescue_from ActiveRecord::RecordNotFound do |exception|
301
+ glib_json_handle_404(exception, preview_mode)
302
+ end
276
303
  end
277
-
278
304
  end
279
305
  end
@@ -5,6 +5,10 @@ class Glib::JsonUi::ActionBuilder
5
5
  action :onFocus
6
6
  end
7
7
 
8
+ class Blur < Action
9
+ action :onBlur
10
+ end
11
+
8
12
  class Reset < Action
9
13
  string :targetId
10
14
  action :onReset
@@ -101,6 +101,7 @@ class Glib::JsonUi::ViewBuilder
101
101
  string :rightText
102
102
  action :onTypeStart
103
103
  action :onTypeEnd
104
+ action :onClick
104
105
  end
105
106
 
106
107
  class Number < Text
@@ -82,7 +82,8 @@ page.form \
82
82
  form.h2 text: 'Country'
83
83
  form.spacer height: 6
84
84
  region_field = { name: 'user[city]', label: 'City' }
85
- form.fields_country name: 'user[country]', width: 'matchParent', label: 'Country', region: region_field
85
+ form.fields_country name: 'user[country]', width: 'matchParent', label: 'Country', region: nil
86
+ form.fields_country name: 'user[country_with_region]', width: 'matchParent', label: 'Country with region', region: region_field
86
87
 
87
88
  form.spacer height: 20
88
89
  form.h2 text: 'Map'
@@ -72,6 +72,14 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
72
72
  end
73
73
  accessory.footer padding: { x: 16, y: 10 }, childViews: ->(footer) do
74
74
  footer.label text: 'Footer'
75
+ footer.spacer height: 14
76
+ footer.label text: 'Click me', onClick: ->(action) do
77
+ action.components_findClosest view: 'fields/select', onFind: ->(subaction) do
78
+ subaction.components_set data: { value: 'pt' }, onSet: ->(subsubaction) do
79
+ subsubaction.fields_blur
80
+ end
81
+ end
82
+ end
75
83
  end
76
84
  end
77
85
 
@@ -16,4 +16,8 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
16
16
  scroll.spacer height: 20
17
17
  scroll.h2 text: 'Icon with badge'
18
18
  scroll.icon name: 'home', badge: { text: '22', backgroundColor: '#00ff00' }
19
+
20
+ scroll.spacer height: 20
21
+ scroll.h2 text: 'Icon with styleClasses'
22
+ scroll.icon name: 'home', styleClasses: ['small']
19
23
  end
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: 3.20.5
4
+ version: 3.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''