brick 1.0.153 → 1.0.154
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 647f34b463dc92515c7eb04331726a808b5ea69dd2bbd6ef99c9d6c769868565
|
4
|
+
data.tar.gz: 22ae7fa65845e65a7848f5cfff0fbb52a864b0161783c3f7d28cfb82ba1f88e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84034f48010bd159804a19cb865a9cad04ba5efe89bb1e807a7031393d9a64a33d9ca9802f991565f4d73753df087d200099052dde59e4127c6b94370456ec09
|
7
|
+
data.tar.gz: 57b3cca20e566ef0d4ac72a45f24b025feea45421417b23cbe7cb683877ac228463f5f348f931a6024b9cdf750dde6aa6c49293e1ae1a596a70a0d8f3c128d6c
|
data/lib/brick/config.rb
CHANGED
@@ -230,6 +230,14 @@ module Brick
|
|
230
230
|
@mutex.synchronize { @json_columns = cols }
|
231
231
|
end
|
232
232
|
|
233
|
+
def sidescroll
|
234
|
+
@mutex.synchronize { @sidescroll ||= {} }
|
235
|
+
end
|
236
|
+
|
237
|
+
def sidescroll=(scroll)
|
238
|
+
@mutex.synchronize { @sidescroll = scroll }
|
239
|
+
end
|
240
|
+
|
233
241
|
def model_descrips
|
234
242
|
@mutex.synchronize { @model_descrips ||= {} }
|
235
243
|
end
|
@@ -864,6 +864,10 @@ tr th {
|
|
864
864
|
color: #fff;
|
865
865
|
text-align: left;
|
866
866
|
}
|
867
|
+
.col-sticky {
|
868
|
+
position: sticky;
|
869
|
+
left: 0;
|
870
|
+
}
|
867
871
|
#headerTop tr th {
|
868
872
|
position: relative;
|
869
873
|
}
|
@@ -902,6 +906,10 @@ tr td.highlight {
|
|
902
906
|
background-color: #B0B0FF;
|
903
907
|
}
|
904
908
|
|
909
|
+
table tr .col-sticky {
|
910
|
+
background-color: #28B898;
|
911
|
+
}
|
912
|
+
|
905
913
|
.show-field {
|
906
914
|
background-color: #004998;
|
907
915
|
}
|
@@ -916,6 +924,12 @@ table.shadow > tbody > tr {
|
|
916
924
|
table tbody tr:nth-of-type(even) {
|
917
925
|
background-color: #f3f3f3;
|
918
926
|
}
|
927
|
+
table tbody tr:nth-of-type(even) .col-sticky {
|
928
|
+
background-color: #fff;
|
929
|
+
}
|
930
|
+
table tbody tr:nth-of-type(odd) .col-sticky {
|
931
|
+
background-color: #f3f3f3;
|
932
|
+
}
|
919
933
|
|
920
934
|
table.shadow > tbody > tr:last-of-type {
|
921
935
|
border-bottom: 2px solid #009879;
|
@@ -1080,18 +1094,30 @@ function setHeaderSizes() {
|
|
1080
1094
|
// %%% Grab the TRs from headerTop, clear it out, do this stuff, add them back
|
1081
1095
|
headerTop.innerHTML = \"\"; // %%% Would love to not have to clear it out like this every time! (Currently doing this to support resize events.)
|
1082
1096
|
var isEmpty = headerTop.childElementCount === 0;
|
1097
|
+
var numFixed = parseInt(grid.getAttribute(\"x-num-frozen\")) || 0;
|
1098
|
+
var fixedColLefts = [0];
|
1099
|
+
|
1083
1100
|
// Set up proper sizings of sticky column header
|
1084
1101
|
var node;
|
1085
1102
|
for (var j = 0; j < #{table_name}HtColumns.length; ++j) {
|
1086
1103
|
var row = #{table_name}HtColumns[j];
|
1087
1104
|
var tr = isEmpty ? document.createElement(\"TR\") : headerTop.childNodes[j];
|
1088
1105
|
tr.innerHTML = row.innerHTML.trim();
|
1106
|
+
var curLeft = 0.0;
|
1089
1107
|
// Match up widths from the original column headers
|
1090
1108
|
for (var i = 0; i < row.childNodes.length; ++i) {
|
1091
1109
|
node = row.childNodes[i];
|
1092
1110
|
if (node.nodeType === 1) {
|
1093
1111
|
var th = tr.childNodes[i];
|
1094
1112
|
th.style.minWidth = th.style.maxWidth = getComputedStyle(node).width;
|
1113
|
+
// Add \"left: __px\" style to the fixed-width column THs
|
1114
|
+
if (i <= numFixed) {
|
1115
|
+
th.style.position = \"sticky\";
|
1116
|
+
th.style.backgroundColor = \"#008061\";
|
1117
|
+
th.style.zIndex = \"1\";
|
1118
|
+
th.style.left = curLeft + \"px\";
|
1119
|
+
fixedColLefts.push(curLeft += node.clientWidth);
|
1120
|
+
}
|
1095
1121
|
if (#{pk&.present? ? 'i > 0' : 'true'}) {
|
1096
1122
|
// Add <span> at the end
|
1097
1123
|
var span = document.createElement(\"SPAN\");
|
@@ -1108,6 +1134,12 @@ function setHeaderSizes() {
|
|
1108
1134
|
headerCols = tr.childNodes;
|
1109
1135
|
if (isEmpty) headerTop.appendChild(tr);
|
1110
1136
|
}
|
1137
|
+
// Add \"left: __px\" style to all fixed-width column TDs
|
1138
|
+
[...grid.children[1].children].forEach(function (row) {
|
1139
|
+
for (var j = 1; j <= numFixed; ++j) {
|
1140
|
+
row.children[j].style.left = fixedColLefts[j] + 'px';
|
1141
|
+
}
|
1142
|
+
});
|
1111
1143
|
grid.style.marginTop = \"-\" + getComputedStyle(headerTop).height;
|
1112
1144
|
// console.log(\"end\");
|
1113
1145
|
}
|
@@ -24,8 +24,11 @@ module Brick::Rails::FormTags
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
nfc = Brick.config.sidescroll.fetch(relation.table_name, nil)&.fetch(:num_frozen_columns, nil) ||
|
28
|
+
Brick.config.sidescroll.fetch(:num_frozen_columns, nil) ||
|
29
|
+
0
|
27
30
|
out = "<table id=\"headerTop\"></table>
|
28
|
-
<table id=\"#{relation.table_name.split('.').last}\" class=\"shadow\">
|
31
|
+
<table id=\"#{relation.table_name.split('.').last}\" class=\"shadow\"#{ " x-num-frozen=\"#{nfc}\"" if nfc.positive? }>
|
29
32
|
<thead><tr>"
|
30
33
|
pk = (klass = relation.klass).primary_key || []
|
31
34
|
pk = [pk] unless pk.is_a?(Array)
|
@@ -95,12 +98,13 @@ module Brick::Rails::FormTags
|
|
95
98
|
# (After restarting the server it worked fine again.)
|
96
99
|
relation.each do |obj|
|
97
100
|
out << "<tr>\n"
|
98
|
-
out << "<td>#{link_to('⇛', send("#{klass._brick_index(:singular)}_path".to_sym,
|
101
|
+
out << "<td class=\"col-sticky\">#{link_to('⇛', send("#{klass._brick_index(:singular)}_path".to_sym,
|
99
102
|
pk.map { |pk_part| obj.send(pk_part.to_sym) }), { class: 'big-arrow' })}</td>\n" if pk.present?
|
100
|
-
sequence.
|
103
|
+
sequence.each_with_index do |col_name, idx|
|
101
104
|
val = obj.attributes[col_name]
|
102
105
|
bt = bts[col_name]
|
103
106
|
out << '<td'
|
107
|
+
(classes ||= []) << 'col-sticky' if idx < nfc
|
104
108
|
(classes ||= []) << 'dimmed' unless cols.key?(col_name) || (cust_col = cust_cols[col_name]) ||
|
105
109
|
(col_name.is_a?(Symbol) && bts.key?(col_name)) # HOT
|
106
110
|
(classes ||= []) << 'right' if val.is_a?(Numeric) && !bt
|
data/lib/brick/version_number.rb
CHANGED
data/lib/brick.rb
CHANGED
@@ -501,6 +501,11 @@ module Brick
|
|
501
501
|
Brick.config.json_columns = cols
|
502
502
|
end
|
503
503
|
|
504
|
+
# @api public
|
505
|
+
def sidescroll=(scroll)
|
506
|
+
Brick.config.sidescroll = scroll
|
507
|
+
end
|
508
|
+
|
504
509
|
# DSL templates for individual models to provide prettier descriptions of objects
|
505
510
|
# @api public
|
506
511
|
def model_descrips=(descrips)
|
@@ -35,7 +35,7 @@ module Brick
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
possible_additional_references = relations.each_with_object(Hash.new { |h, k| h[k] = [] }) do |relation, s|
|
38
|
-
this_tnp = tnps&.keys
|
38
|
+
this_tnp = tnps&.keys&.find { |tnp| relation.first.start_with?(tnp) }
|
39
39
|
model_filename = "app/models/#{ActiveSupport::Inflector.singularize(relation.first)}.rb"
|
40
40
|
relation.last[:cols].each do |col, type|
|
41
41
|
col_down = col.downcase
|
@@ -244,6 +244,14 @@ if ActiveRecord::Base.respond_to?(:brick_select) && !::Brick.initializer_loaded
|
|
244
244
|
# Brick.column_sequence = { 'users' => { include: ['email', 'profile.firstname', 'profile.lastname'] },
|
245
245
|
# 'profile' => { exclude: ['birthdate'] } }
|
246
246
|
|
247
|
+
# # When rendering the grid on index pages, a default number of columns to keep as \"sticky\" so that they remain
|
248
|
+
# # at the left of the grid while scrolling. By default this is 0 extra columns -- only the link to that
|
249
|
+
# # object's show / edit page is sticky. And this would add one extra column in the mix:
|
250
|
+
# Brick.sidescroll = { num_frozen_columns: 1 }
|
251
|
+
# # As well if you would like to customise this for specific resources, that is possible:
|
252
|
+
# Brick.sidescroll = { num_frozen_columns: 0,
|
253
|
+
# 'products' => { num_frozen_columns: 2 } }
|
254
|
+
|
247
255
|
# # EXTRA FOREIGN KEYS AND OTHER HAS_MANY SETTINGS
|
248
256
|
|
249
257
|
# # Additional table references which are used to create has_many / belongs_to associations inside auto-created
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.154
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lorin Thwaits
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|