glib-web 4.35.5 → 4.36.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: bd64c82e1baa6874b8791fdc0a330916a9463e92145a5e7c8ac3a6b64ef271dd
4
- data.tar.gz: 85ea472517490fd0d2fc572531869964240111df12d2e93b9fc35a569ece071d
3
+ metadata.gz: 94b3768dec74f3a05c32ffd19612d151afce3829643e070f173899d02627e72f
4
+ data.tar.gz: e7f8124643269e1634a979683210b93a7ca613fd1cf975a0ff20419a3f08f9f2
5
5
  SHA512:
6
- metadata.gz: 4cfd05eee3620fc4177e75f7e5f43904e1560084979aad3bc522beb837afc45e86b47f766feb2ada4b69d4f20a14b236907f04e4072968316d7b2b99100fdebe
7
- data.tar.gz: 1afe10ae33a3688b85be1cd1f966ff8bd01d60eaca51fb3602d4d1c8d52b6276701371f455758d488248c1ea344c8e019e6c2b61878dcd5ea88be52725c15dd2
6
+ metadata.gz: 91cf7697395548ce7d8ee306269688c1166ed9e9d1ca0778a5d2d2dfd72d26dab277a3d22069a1d4ef31727511816854bd12de8ef984629069b4413f295095c5
7
+ data.tar.gz: 4b655db49df2bfba84b0c524d02e41fdaadcacfb687418f7d3651c24712c9c7a55ed1b5bf4a1951b3107264a5db09b348b892293efaee7212c06d05b9b36408e
@@ -68,10 +68,10 @@ module Glib::Json::Libs
68
68
 
69
69
  # As much as possible, try retaining the front fragment by matching the back, because
70
70
  # the front could be either a `?` or `&`
71
- url = url.sub(/format=json\&/, '')
71
+ url = url.sub(/format=json\&/, '');
72
72
 
73
73
  # If no match, then we replace the front fragment
74
- url.sub(/[\&\?]format=json/, '')
74
+ url.sub(/[\&\?]format=json/, '');
75
75
  end
76
76
 
77
77
  def glib_redirect_to(url, return_to_previous: false, status: :ok)
@@ -87,13 +87,6 @@ module Glib::Json::Libs
87
87
  return
88
88
  end
89
89
 
90
- # Inside a dialog, it's easier to simply use HTTP redirect, as opposed to trying to
91
- # get the dialog to perform manual redirection.
92
- if glib_json_dialog_mode?
93
- redirect_to url
94
- return
95
- end
96
-
97
90
  json_ui_redirect_to url, status: status
98
91
  end
99
92
  end
@@ -159,14 +152,14 @@ module Glib::Json::Libs
159
152
  end
160
153
 
161
154
  render json: if glib_json_dialog_mode?
162
- { onLoad: __glib_error_dialog('Access denied', "Make sure you're logged in with the correct account.") }
163
- else
164
- {
165
- onResponse: {
166
- action: 'windows/open', url: user_default_url
167
- }
168
- }
169
- end, status: Rails.env.test? ? :forbidden : :ok
155
+ { onLoad: __glib_error_dialog('Access denied', "Make sure you're logged in with the correct account.") }
156
+ else
157
+ {
158
+ onResponse: {
159
+ action: 'windows/open', url: user_default_url
160
+ }
161
+ }
162
+ end, status: Rails.env.test? ? :forbidden : :ok
170
163
  end
171
164
  format.csv do
172
165
  if Rails.env.test?
@@ -236,7 +229,7 @@ module Glib::Json::Libs
236
229
  if json_ui_activated?
237
230
  if Rails.env.production? || preview_mode
238
231
  if defined?(Rollbar) && !preview_mode
239
- Rollbar.error(exception, use_exception_level_filters: true)
232
+ Rollbar.error(exception, :use_exception_level_filters => true)
240
233
  end
241
234
 
242
235
  render file: Rails.root.join('public', '500.html'), status: :internal_server_error
@@ -268,7 +261,7 @@ module Glib::Json::Libs
268
261
  if glib_json_dialog_mode?
269
262
  # Only do this in dialog mode because this seems to add to the rendering time
270
263
  # (i.e. longer flicker time), presumably due to the use of things like `nextTick()`.
271
- on_response = { action: 'dialogs/close', onClose: on_response }
264
+ on_response = { action: 'dialogs/close', onClose: on_load }
272
265
  end
273
266
 
274
267
  # Use onResponse because it is harder to guarantee that `onLoad` executes in Vuejs because it relies
@@ -0,0 +1,22 @@
1
+ class MutuallyExclusiveWithValidator < ActiveModel::EachValidator
2
+ include ActiveSupport::Inflector
3
+
4
+ def validate_each(record, attribute, _value)
5
+ other_attribute = options[:with]
6
+
7
+ validate_mutual_exclusivity(record, attribute, other_attribute)
8
+ validate_mutual_exclusivity(record, other_attribute, attribute)
9
+ end
10
+
11
+ private
12
+ def validate_mutual_exclusivity(record, attribute, other_attribute)
13
+ attribute_value = record.send(attribute)
14
+ other_attribute_value = record.send(other_attribute)
15
+
16
+ if attribute_value.present? && other_attribute_value.present?
17
+ record.errors.add(attribute, :present, **options)
18
+ elsif attribute_value.nil? && other_attribute_value.nil?
19
+ record.errors.add(attribute, :blank, **options)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ class PresenceOnlyIfValidator < ActiveModel::EachValidator
2
+ include ActiveSupport::Inflector
3
+
4
+ def validate_each(record, attribute, _value)
5
+ condition = options[:with]
6
+
7
+ if condition.is_a?(Symbol)
8
+ evaluate_condition(record, attribute, ->(record) { record.send(condition) })
9
+ elsif condition.respond_to?(:call)
10
+ evaluate_condition(record, attribute, condition)
11
+ else
12
+ raise 'Invalid option'
13
+ end
14
+ end
15
+
16
+ private
17
+ def evaluate_condition(record, attribute, condition)
18
+ if condition.call(record) && record.send(attribute).nil?
19
+ record.errors.add(attribute, :blank, **options)
20
+ end
21
+ end
22
+ 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: 4.35.5
4
+ version: 4.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -217,6 +217,8 @@ files:
217
217
  - app/policies/glib/application_policy.rb
218
218
  - app/validators/email_typo_validator.rb
219
219
  - app/validators/email_validator.rb
220
+ - app/validators/mutually_exclusive_with_validator.rb
221
+ - app/validators/presence_only_if_validator.rb
220
222
  - app/validators/url_validator.rb
221
223
  - app/views/json_ui/garage/_nav_menu.json.jbuilder
222
224
  - app/views/json_ui/garage/actions/_commands.json.jbuilder