glib-web 4.35.3 → 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: 139b8bb1e77c9778bb396d3ed8da72c74051d9cae9cacbae23dd713357ad9586
4
- data.tar.gz: 200ab9fae64c136049b7eb288898216ede1c261dba047e1f386166daa0ab0309
3
+ metadata.gz: 94b3768dec74f3a05c32ffd19612d151afce3829643e070f173899d02627e72f
4
+ data.tar.gz: e7f8124643269e1634a979683210b93a7ca613fd1cf975a0ff20419a3f08f9f2
5
5
  SHA512:
6
- metadata.gz: a5761de4b8433b8aec45ac23f3890cc66f1052426d133e37e40d25e3bb10109ef6ac13ee607554b3db7d7b0695086f7823e86f7cb432ea377317b83d35d26375
7
- data.tar.gz: d308d941d36c01460174449bc7375cbae1c767dd9797b56f4c008e86985605b890bb292c678d69a93e8a34e63e914921984d0fddde80d6eaa270cb6ae5275ae4
6
+ metadata.gz: 91cf7697395548ce7d8ee306269688c1166ed9e9d1ca0778a5d2d2dfd72d26dab277a3d22069a1d4ef31727511816854bd12de8ef984629069b4413f295095c5
7
+ data.tar.gz: 4b655db49df2bfba84b0c524d02e41fdaadcacfb687418f7d3651c24712c9c7a55ed1b5bf4a1951b3107264a5db09b348b892293efaee7212c06d05b9b36408e
@@ -7,7 +7,7 @@ module Glib
7
7
  button: I18n.t('glib.accepts.max_file_size_error.button', default: nil) || 'Dismiss'
8
8
  }
9
9
  default_max_length_error = {
10
- body: I18n.t('glib.accepts.max_file_length_error.body', default: nil) || 'Files exceed the maximum limit per upload',
10
+ body: I18n.t('glib.accepts.max_file_length_error.body', default: nil) || 'Files exceed the maximum limit',
11
11
  button: I18n.t('glib.accepts.max_file_length_error.button', default: nil) || 'Dismiss'
12
12
  }
13
13
 
@@ -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
@@ -46,7 +46,15 @@ page.form options.merge(childViews: ->(form) do
46
46
  name: 'user[multi][]',
47
47
  id: 'upload_1',
48
48
  width: 360,
49
- accepts: { fileType: 'image', maxFileSize: 10 },
49
+ accepts: {
50
+ fileType: 'image',
51
+ maxFileSize: 10,
52
+ maxFileLength: 2,
53
+ maxFileLengthErrorText: {
54
+ body: 'try with a smaller number of files',
55
+ button: 'OK'
56
+ }
57
+ },
50
58
  directUploadUrl: glib_direct_uploads_url,
51
59
  uploadTitle: 'Files uploaded:',
52
60
  storagePrefix: 'glib',
@@ -70,7 +78,10 @@ page.form options.merge(childViews: ->(form) do
70
78
  name: 'user[multi2][]',
71
79
  id: 'upload_2',
72
80
  width: 360,
73
- accepts: { fileType: 'image', maxFileSize: 5000 },
81
+ accepts: {
82
+ fileType: 'image',
83
+ maxFileSize: 5000
84
+ },
74
85
  directUploadUrl: glib_direct_uploads_url,
75
86
  uploadTitle: 'Files uploaded:',
76
87
  onFinishUpload: ->(action) { action.forms_submit }
@@ -89,7 +100,7 @@ page.form options.merge(childViews: ->(form) do
89
100
  form.fields_multiUpload \
90
101
  name: 'user[multi3][]',
91
102
  width: 360,
92
- accepts: { fileType: 'image', maxFileSize: 100 },
103
+ accepts: { fileType: 'image', maxFileSize: 100, maxFileLength: 2 },
93
104
  uploadTitle: 'Files uploaded:',
94
105
  onFinishUpload: ->(action) { action.forms_submit }
95
106
 
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.3
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