web47core 3.2.3.26 → 3.2.3.28
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 +4 -4
- data/app/helpers/core_data_grid_helper.rb +59 -0
- data/app/helpers/core_menu_helper.rb +1 -1
- data/lib/web47core/boolean_flux_capacitor.rb +81 -0
- data/lib/web47core/version.rb +1 -1
- data/lib/web47core.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0ae4e8d149eb528b642a281d596ce1d74a3be183c5c4f96973d18fe5feceea51
|
|
4
|
+
data.tar.gz: b903d5e5875c61111150ead42469abb2ceaf12667d42125949eaf284e5c29661
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab104e17e0c0780a4b8ae5d3359dfde29d5433e9e705105a5babdd515cddb059af97d9d5e8557288d42236e2945c6b15685d5739d60be5f39f56201bdb9098ee
|
|
7
|
+
data.tar.gz: c8eeee3b4cc1a18a43f3076ed0601c7258481ef4a5b8316f88b12230b5ffb0e53573f7cc321ae6334ec4613b279e9572354f3ab0f24bf196008820da50ddae53
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module CoreDataGridHelper
|
|
2
|
+
def data_grid_tag(model, fields: [], except: [])
|
|
3
|
+
fields = model.class.allowed_param_names(except) + model.class::STANDARD_FIELDS if fields.blank?
|
|
4
|
+
|
|
5
|
+
content_tag(:div, class: 'datagrid') do
|
|
6
|
+
fields.sort.each do |field|
|
|
7
|
+
next if %w[_id _type].include?(field)
|
|
8
|
+
next unless model.respond_to?(field)
|
|
9
|
+
next if model.send(field).blank?
|
|
10
|
+
|
|
11
|
+
concat(data_grid_item(field, data_grid_field_value(model, field)))
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def data_grid_item(title, content)
|
|
18
|
+
content_tag(:div, class: 'datagrid-item') do
|
|
19
|
+
concat(content_tag(:div, class: 'datagrid-title') { title })
|
|
20
|
+
concat(content_tag(:div, class: 'datagrid-content') { content })
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def data_grid_url(title, url)
|
|
25
|
+
url = content_tag(:a, href: url) { url }
|
|
26
|
+
data_grid_item(title, url)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def data_grid_mask(title, secret_content)
|
|
30
|
+
data_grid_item(title, mask_value(secret_content))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def data_grid_field_value(model, field_name)
|
|
34
|
+
value = model.respond_to?(field_name) ? model.send(field_name) : nil
|
|
35
|
+
case value
|
|
36
|
+
when BSON::ObjectId
|
|
37
|
+
if field_name.eql?('_id')
|
|
38
|
+
value.to_s
|
|
39
|
+
else
|
|
40
|
+
related_model = fetch_related_model(model, field_name.chomp('_id'))
|
|
41
|
+
related_model.present? ? related_model.name : 'N/A'
|
|
42
|
+
end
|
|
43
|
+
when FalseClass
|
|
44
|
+
'No'
|
|
45
|
+
when TrueClass
|
|
46
|
+
'Yes'
|
|
47
|
+
when Mongoid::Boolean
|
|
48
|
+
value ? 'Yes' : 'No'
|
|
49
|
+
when Date, DateTime, Time
|
|
50
|
+
current_user.local_time(value, :medium)
|
|
51
|
+
when Integer, Array
|
|
52
|
+
value.to_s
|
|
53
|
+
when String
|
|
54
|
+
value
|
|
55
|
+
else
|
|
56
|
+
'N/S'
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -34,7 +34,7 @@ module CoreMenuHelper
|
|
|
34
34
|
def menu_link(name, action_path, classes: [], badge_count: 0, icon_name: '')
|
|
35
35
|
classes << 'menu-link'
|
|
36
36
|
content_tag(:a, href: action_path, class: classes.join(' ')) do
|
|
37
|
-
concat(
|
|
37
|
+
concat(svg_icon(icon_name)) if icon_name.present?
|
|
38
38
|
concat(menu_name(name))
|
|
39
39
|
concat(menu_count_badge(name, badge_count)) if badge_count.positive?
|
|
40
40
|
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Convert the thingy listed below to a true/false value
|
|
3
|
+
#
|
|
4
|
+
# BooleanFluxCapacitor
|
|
5
|
+
#
|
|
6
|
+
# Provides a common `to_bool` method for core Ruby types, similar in spirit
|
|
7
|
+
# to `to_s` or `to_i`.
|
|
8
|
+
#
|
|
9
|
+
# The goal is to produce TOTAL boolean coercion:
|
|
10
|
+
# - Always returns `true` or `false`
|
|
11
|
+
# - Never raises
|
|
12
|
+
# - Never returns `nil`
|
|
13
|
+
#
|
|
14
|
+
# Conversion rules are explicit and deterministic.
|
|
15
|
+
#
|
|
16
|
+
module BooleanFluxCapacitor
|
|
17
|
+
# Truthy string values (case-insensitive, whitespace ignored)
|
|
18
|
+
TRUTHY = /\A(true|on|yes|y|1)\z/i
|
|
19
|
+
|
|
20
|
+
# Convert the receiver into a Boolean value.
|
|
21
|
+
#
|
|
22
|
+
# This method is intended for configuration, environment variables,
|
|
23
|
+
# and user-supplied input where values may arrive as different types.
|
|
24
|
+
#
|
|
25
|
+
# Conversion rules:
|
|
26
|
+
#
|
|
27
|
+
# * `true` → `true`
|
|
28
|
+
# * `false` → `false`
|
|
29
|
+
# * `nil` → `false`
|
|
30
|
+
#
|
|
31
|
+
# * Numeric values:
|
|
32
|
+
# * `0` → `false`
|
|
33
|
+
# * non-zero → `true`
|
|
34
|
+
#
|
|
35
|
+
# * String values:
|
|
36
|
+
# * Case-insensitive match of:
|
|
37
|
+
# "true", "on", "yes", "y", "1" → `true`
|
|
38
|
+
# * All other strings → `false`
|
|
39
|
+
#
|
|
40
|
+
# * All other object types:
|
|
41
|
+
# * Converted using `to_s` and evaluated using the same string rules
|
|
42
|
+
#
|
|
43
|
+
# Notes:
|
|
44
|
+
# * This method does NOT affect Ruby's native truthiness.
|
|
45
|
+
# * It exists solely for explicit boolean coercion.
|
|
46
|
+
#
|
|
47
|
+
# Examples:
|
|
48
|
+
#
|
|
49
|
+
# true.to_bool # => true
|
|
50
|
+
# false.to_bool # => false
|
|
51
|
+
# nil.to_bool # => false
|
|
52
|
+
#
|
|
53
|
+
# 0.to_bool # => false
|
|
54
|
+
# 42.to_bool # => true
|
|
55
|
+
#
|
|
56
|
+
# "true".to_bool # => true
|
|
57
|
+
# " YES ".to_bool # => true
|
|
58
|
+
# "false".to_bool # => false
|
|
59
|
+
# "anything else".to_bool # => false
|
|
60
|
+
#
|
|
61
|
+
def to_bool
|
|
62
|
+
case self
|
|
63
|
+
when true
|
|
64
|
+
true
|
|
65
|
+
when false, nil
|
|
66
|
+
false
|
|
67
|
+
when Numeric
|
|
68
|
+
!zero?
|
|
69
|
+
else
|
|
70
|
+
to_s.strip.match?(TRUTHY)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Extend core classes with `to_bool`
|
|
76
|
+
NilClass.include(BooleanFluxCapacitor)
|
|
77
|
+
TrueClass.include(BooleanFluxCapacitor)
|
|
78
|
+
FalseClass.include(BooleanFluxCapacitor)
|
|
79
|
+
Numeric.include(BooleanFluxCapacitor)
|
|
80
|
+
String.include(BooleanFluxCapacitor)
|
|
81
|
+
|
data/lib/web47core/version.rb
CHANGED
data/lib/web47core.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: web47core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.2.3.
|
|
4
|
+
version: 3.2.3.28
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Schroeder
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-12-
|
|
11
|
+
date: 2025-12-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|
|
@@ -536,6 +536,7 @@ files:
|
|
|
536
536
|
- app/helpers/core_avatar_helper.rb
|
|
537
537
|
- app/helpers/core_breadcrumb_helper.rb
|
|
538
538
|
- app/helpers/core_card_nav_items_helper.rb
|
|
539
|
+
- app/helpers/core_data_grid_helper.rb
|
|
539
540
|
- app/helpers/core_dropdown_helper.rb
|
|
540
541
|
- app/helpers/core_flash_toast_helper.rb
|
|
541
542
|
- app/helpers/core_floating_action_button_helper.rb
|
|
@@ -6628,6 +6629,7 @@ files:
|
|
|
6628
6629
|
- lib/templates/slack/failed_delayed_job.liquid
|
|
6629
6630
|
- lib/update_icons.rb
|
|
6630
6631
|
- lib/web47core.rb
|
|
6632
|
+
- lib/web47core/boolean_flux_capacitor.rb
|
|
6631
6633
|
- lib/web47core/config.rb
|
|
6632
6634
|
- lib/web47core/engine.rb
|
|
6633
6635
|
- lib/web47core/version.rb
|