bullet_train-fields 1.6.30 → 1.6.31

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 767a655557d3e78e7c8e124a77bcfef0bb744d0929da32b70b7c0c0a9a698f9f
4
- data.tar.gz: 4011e18b5c31fb11bec985ddbcb1a25ae569b7bf909dfb768a3e5f9aa17b4a53
3
+ metadata.gz: dce4e35906108db130d2c67047de53ad1c3b522226573c1b0b5a58794173d755
4
+ data.tar.gz: 5f1fd1ed5cac7fe9d1c9fb6eb73cd076f3e2c0fca2a4cb38c564f81a82232787
5
5
  SHA512:
6
- metadata.gz: 600a15fce43d66f13ac0ab147b76a791da7ba3dc3112a4f6c868c9eb7dd22cdd478d3ea842c96b9f204f3a00b2748190e8c03e217a9c9cbc00bd38e1c6c9712e
7
- data.tar.gz: 291caf0dfa8ceeb6e0761229fa9d0b114cb9f653dfaf3f6971b98fdabfd6a4f4e0781bc9e466fa9d436df0b5ec840cc6253118d7d0513c839723507f2a31f4df
6
+ metadata.gz: 16348cfa7e0354237f70ea88f29d66b051acdda4837fc9be0ff7aed0f77e80f2cee328f0a510554737a1b4dcb92526de91aecd2208cfefe5f7ec2f8613f949db
7
+ data.tar.gz: 0fb73b4b94abf6642ce5e598a97819d5b7c236b804e898dfab6a460bb90fb467a626b6633aa2d7388f3433b9db25aa440dd727f536642a067a1b49a11d309f89
@@ -0,0 +1,70 @@
1
+ module Account::DatesHelper
2
+ def display_date(timestamp, custom_date_format = nil, format: :default, date_format: nil)
3
+ return nil unless timestamp
4
+ format = date_format if date_format
5
+
6
+ if format && format == :default
7
+ # e.g. October 11, 2018
8
+ if custom_date_format
9
+ local_time(timestamp).strftime(custom_date_format)
10
+ elsif local_time(timestamp).year == local_time(Time.now).year
11
+ local_time(timestamp).strftime("%B %-d")
12
+ else
13
+ local_time(timestamp).strftime("%B %-d, %Y")
14
+ end
15
+ else
16
+ localize(local_time(timestamp).to_date, format: format)
17
+ end
18
+ end
19
+
20
+ def display_time(timestamp, custom_time_format = nil, format: :default, time_format: nil)
21
+ return nil unless timestamp
22
+ format = time_format if time_format
23
+
24
+ if format && format == :default
25
+ # e.g. 4:22 PM
26
+ local_time(timestamp).strftime(custom_time_format || "%l:%M %p")
27
+ else
28
+ localize(local_time(timestamp).to_time, format: format)
29
+ end
30
+ end
31
+
32
+ def display_date_and_time(timestamp, custom_date_format = nil, custom_time_format = nil, format: :default, date_format: nil, time_format: nil)
33
+ return nil unless timestamp
34
+ format = "#{date_format} #{time_format}" if date_format && time_format
35
+
36
+ if format && format == :default
37
+ # e.g. Today at 4:22 PM
38
+ # e.g. Yesterday at 2:12 PM
39
+ # e.g. April 24 at 7:39 AM
40
+ # today?
41
+ if local_time(timestamp).to_date == local_time(Time.now).to_date
42
+ "Today at #{display_time(timestamp, custom_time_format)}"
43
+ # yesterday?
44
+ elsif (local_time(timestamp).to_date) == (local_time(Time.now).to_date - 1.day)
45
+ "Yesterday at #{display_time(timestamp, custom_time_format)}"
46
+ else
47
+ "#{display_date(timestamp, custom_date_format)} at #{display_time(timestamp, custom_time_format)}"
48
+ end
49
+ else
50
+ localize(local_time(timestamp).to_datetime, format: format)
51
+ end
52
+ end
53
+
54
+ def local_time(timestamp)
55
+ timestamp&.in_time_zone(current_user.time_zone)
56
+ end
57
+
58
+ def am_pm?
59
+ !"#{I18n.t("time.am", fallback: false, default: "")}#{I18n.t("time.pm", fallback: false, default: "")}".empty?
60
+ end
61
+
62
+ def time_zone_name_to_id
63
+ ActiveSupport::TimeZone.all.map { |tz| {tz.name.to_s => tz.tzinfo.name} }.reduce({}, :merge)
64
+ end
65
+
66
+ def current_time_zone
67
+ current_time_zone_name = current_user&.time_zone || current_user&.current_team&.time_zone || "UTC"
68
+ ActiveSupport::TimeZone.find_tzinfo(current_time_zone_name).name
69
+ end
70
+ end
@@ -0,0 +1,65 @@
1
+ module Account::FormsHelper
2
+ PRESENCE_VALIDATORS = [ActiveRecord::Validations::PresenceValidator, ActiveModel::Validations::PresenceValidator]
3
+
4
+ def presence_validated?(object, attribute)
5
+ validators = object.class.validators
6
+ validators.select! do |validator|
7
+ PRESENCE_VALIDATORS.include?(validator.class) && validator.attributes.include?(attribute)
8
+ end
9
+ validators.any?
10
+ end
11
+
12
+ def flush_content_for(name)
13
+ content_for name, flush: true do
14
+ ""
15
+ end
16
+ end
17
+
18
+ def options_with_labels(options, namespace)
19
+ hash = {}
20
+ options.each do |option|
21
+ hash[option] = t([namespace, option].join("."))
22
+ end
23
+ hash
24
+ end
25
+
26
+ def if_present(string)
27
+ string.present? ? string : nil
28
+ end
29
+
30
+ def model_key(form)
31
+ form.object.class.name.pluralize.underscore
32
+ end
33
+
34
+ def labels_for(form, method)
35
+ keys = [:placeholder, :label, :help, :options_help]
36
+ path = [model_key(form), (current_fields_namespace || :fields), method].compact
37
+ Struct.new(*keys).new(*keys.map { |key| t((path + [key]).join("."), default: "").presence })
38
+ end
39
+
40
+ def options_for(form, method)
41
+ # e.g. "scaffolding/completely_concrete/tangible_things.fields.text_area_value.options"
42
+ path = [model_key(form), (current_fields_namespace || :fields), method, :options]
43
+ options = t(path.compact.join("."))
44
+ return options unless options.is_a?(Hash)
45
+ options.stringify_keys
46
+ end
47
+
48
+ def legacy_label_for(form, method)
49
+ # e.g. 'scaffolding/things.labels.name'
50
+ key = "#{model_key(form)}.labels.#{method}"
51
+ # e.g. 'scaffolding/things.labels.name' or 'scaffolding.things.labels.name' or nil
52
+ t(key, default: "").presence || t(key.tr("/", "."), default: "").presence
53
+ end
54
+
55
+ def within_fields_namespace(namespace)
56
+ @fields_namespaces ||= []
57
+ @fields_namespaces << namespace
58
+ yield
59
+ @fields_namespaces.pop
60
+ end
61
+
62
+ def current_fields_namespace
63
+ @fields_namespaces&.last
64
+ end
65
+ end
@@ -0,0 +1,17 @@
1
+ module AttributesHelper
2
+ def current_attributes_object
3
+ @_current_attribute_settings&.dig(:object)
4
+ end
5
+
6
+ def current_attributes_strategy
7
+ @_current_attribute_settings&.dig(:strategy)
8
+ end
9
+
10
+ def with_attribute_settings(object: current_attributes_object, strategy: current_attributes_strategy)
11
+ old_attribute_settings = @_current_attribute_settings
12
+ @_current_attribute_settings = {object: object, strategy: strategy}
13
+ yield
14
+ ensure
15
+ @_current_attribute_settings = old_attribute_settings
16
+ end
17
+ end
@@ -16,13 +16,8 @@ export default class extends Controller {
16
16
  initPluginInstance() {
17
17
  let options = {
18
18
  hiddenInput: this.fieldTarget.dataset.method,
19
- customContainer: "w-full"
20
- }
21
-
22
- // TODO: add instructions on how to copy this asset into the application's assets path and write the meta tag into the head (via the engine?)
23
- const utilsScriptPath = metaContent("intl_tel_input_utils_path")
24
- if (utilsScriptPath) {
25
- options['utilsScript'] = utilsScriptPath
19
+ customContainer: "w-full",
20
+ utilsScript: metaContent("intl_tel_input_utils_path") || `https://cdn.jsdelivr.net/npm/intl-tel-input@${window.intlTelInputGlobals.version}/build/js/utils.js`
26
21
  }
27
22
 
28
23
  this.plugin = intlTelInput(this.fieldTarget, options);
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Fields
3
- VERSION = "1.6.30"
3
+ VERSION = "1.6.31"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.30
4
+ version: 1.6.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-07 00:00:00.000000000 Z
11
+ date: 2024-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard
@@ -99,6 +99,9 @@ files:
99
99
  - app/controllers/concerns/fields/date_support.rb
100
100
  - app/controllers/concerns/fields/options_support.rb
101
101
  - app/controllers/concerns/fields/super_select_support.rb
102
+ - app/helpers/account/dates_helper.rb
103
+ - app/helpers/account/forms_helper.rb
104
+ - app/helpers/attributes_helper.rb
102
105
  - app/helpers/dependent_fields_frame_helper.rb
103
106
  - app/helpers/fields/address_field_helper.rb
104
107
  - app/helpers/fields/cloudinary_image_helper.rb