brick 1.0.172 → 1.0.173
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brick/extensions.rb +15 -8
- data/lib/brick/frameworks/rails/engine.rb +39 -132
- data/lib/brick/frameworks/rails/form_builder.rb +1 -2
- data/lib/brick/frameworks/rails/form_tags.rb +196 -31
- data/lib/brick/version_number.rb +1 -1
- data/lib/brick.rb +14 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a26fe42450ca6c08c82b70f7d60c51a256b3171e626f961806564336413c645
|
4
|
+
data.tar.gz: d02880197677be70fef8b9f4897210202a31610660245953cd5f6acf03cfee49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51bd9281080d4d77b61b309c9dfe1fc160ac7377591ec06cbe1127edadcd2a608ed09f96787979bdcb02c30a331232e413f0e5b9e2993ddb5000f026f3ce4249
|
7
|
+
data.tar.gz: 4a28c71ca04c1d2036e07415c363ff7b6d72fa843c0233ec01f9ec1ab074f01cb1e48919c7cfe91ad9c9a1592c8c473ab09fa4b4cbf49a8e50fbce36e5e6417c
|
data/lib/brick/extensions.rb
CHANGED
@@ -1885,7 +1885,7 @@ class Object
|
|
1885
1885
|
cspd.select! { |val| val == "'self'" }
|
1886
1886
|
cspd << style_value
|
1887
1887
|
else
|
1888
|
-
cspd << "'sha256-
|
1888
|
+
cspd << "'sha256-Q8t+pETkz0RtyV4XprwdP+uEkVaFyMnx1mXif0wDoxw='"
|
1889
1889
|
end
|
1890
1890
|
cspd << 'https://cdn.jsdelivr.net'
|
1891
1891
|
end
|
@@ -2278,10 +2278,15 @@ class Object
|
|
2278
2278
|
else
|
2279
2279
|
@_lookup_context.instance_variable_set("@#{singular_table_name}".to_sym,
|
2280
2280
|
(created_obj = model.send(:create, send(params_name_sym))))
|
2281
|
-
# %%% Surface any errors to the user in a flash message
|
2282
2281
|
@_lookup_context.instance_variable_set(:@_brick_model, model)
|
2283
|
-
|
2284
|
-
|
2282
|
+
if created_obj.errors.empty?
|
2283
|
+
index
|
2284
|
+
render :index
|
2285
|
+
else # Surface errors to the user in a flash message
|
2286
|
+
flash.alert = (created_obj.errors.errors.map { |err| "<b>#{err.attribute}</b> #{err.message}" }.join(', '))
|
2287
|
+
new
|
2288
|
+
render :new
|
2289
|
+
end
|
2285
2290
|
end
|
2286
2291
|
end
|
2287
2292
|
|
@@ -2350,6 +2355,9 @@ class Object
|
|
2350
2355
|
upd_hash[model.inheritance_column] = nil
|
2351
2356
|
end
|
2352
2357
|
obj.send(:update, upd_hash || upd_params)
|
2358
|
+
if obj.errors.any? # Surface errors to the user in a flash message
|
2359
|
+
flash.alert = (obj.errors.errors.map { |err| "<b>#{err.attribute}</b> #{err.message}" }.join(', '))
|
2360
|
+
end
|
2353
2361
|
end
|
2354
2362
|
|
2355
2363
|
code << " def destroy\n"
|
@@ -2660,10 +2668,9 @@ end.class_exec do
|
|
2660
2668
|
s[row.first] = { dt: row.last } unless ['information_schema', 'pg_catalog', 'pg_toast', 'heroku_ext',
|
2661
2669
|
'INFORMATION_SCHEMA', 'sys'].include?(row.first)
|
2662
2670
|
end
|
2663
|
-
|
2664
|
-
|
2665
|
-
|
2666
|
-
if (possible_schema = possible_schemas.find { |ps| ::Brick.db_schemas.key?(ps) })
|
2671
|
+
possible_schema, possible_schemas, multitenancy = ::Brick.get_possible_schemas
|
2672
|
+
if possible_schemas
|
2673
|
+
if possible_schema
|
2667
2674
|
::Brick.default_schema = ::Brick.apartment_default_tenant
|
2668
2675
|
schema = possible_schema
|
2669
2676
|
orig_schema = ActiveRecord::Base.execute_sql('SELECT current_schemas(true)').first['current_schemas'][1..-2].split(',')
|
@@ -6,7 +6,7 @@ module Brick
|
|
6
6
|
def display_value(col_type, val, lat_lng = nil)
|
7
7
|
is_mssql_geography = nil
|
8
8
|
# Some binary thing that really looks like a Microsoft-encoded WGS84 point? (With the first two bytes, E6 10, indicating an EPSG code of 4326)
|
9
|
-
if col_type == :binary && val &&
|
9
|
+
if col_type == :binary && val && ::Brick.is_geography?(val)
|
10
10
|
col_type = 'geography'
|
11
11
|
is_mssql_geography = true
|
12
12
|
end
|
@@ -19,7 +19,7 @@ module Brick
|
|
19
19
|
|
20
20
|
if @is_mysql || (is_mssql_geography ||=
|
21
21
|
(@is_mssql ||
|
22
|
-
(val &&
|
22
|
+
(val && ::Brick.is_geography?(val))
|
23
23
|
)
|
24
24
|
)
|
25
25
|
# MySQL's \"Internal Geometry Format\" and MSSQL's Geography are like WKB, but with an initial 4 bytes that indicates the SRID.
|
@@ -335,14 +335,10 @@ function linkSchemas() {
|
|
335
335
|
def eager_load(entity)
|
336
336
|
_brick_eager_load(entity)
|
337
337
|
if entity == :resources
|
338
|
-
|
339
|
-
if
|
340
|
-
|
341
|
-
|
342
|
-
if (possible_schema = possible_schemas.find { |ps| ::Brick.db_schemas.key?(ps) })
|
343
|
-
orig_tenant = Apartment::Tenant.current
|
344
|
-
Apartment::Tenant.switch!(possible_schema)
|
345
|
-
end
|
338
|
+
possible_schema, _x1, _x2 = ::Brick.get_possible_schemas
|
339
|
+
if possible_schema
|
340
|
+
orig_tenant = Apartment::Tenant.current
|
341
|
+
Apartment::Tenant.switch!(possible_schema)
|
346
342
|
end
|
347
343
|
existing = Avo::BaseResource.descendants.each_with_object({}) do |r, s|
|
348
344
|
s[r.name[0..-9]] = nil if r.name.end_with?('Resource')
|
@@ -803,15 +799,26 @@ window.addEventListener(\"popstate\", linkSchemas);
|
|
803
799
|
position: sticky;
|
804
800
|
display: inline-block;
|
805
801
|
left: 0;
|
802
|
+
z-index: 2;
|
806
803
|
}
|
807
804
|
|
808
805
|
.flashNotice {
|
809
806
|
color: green;
|
810
807
|
}
|
808
|
+
.flashAlert {
|
809
|
+
color: red;
|
810
|
+
}
|
811
811
|
|
812
812
|
h1, h3 {
|
813
813
|
margin-bottom: 0;
|
814
814
|
}
|
815
|
+
#rowCount {
|
816
|
+
display: table-cell;
|
817
|
+
height: 32px;
|
818
|
+
vertical-align: middle;
|
819
|
+
font-size: 0.9em;
|
820
|
+
font-family: sans-serif;
|
821
|
+
}
|
815
822
|
#imgErd {
|
816
823
|
display: table-cell;
|
817
824
|
background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAE0AAABNCAMAAADU1xmCAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAARxaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA2LjAuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICAgICAgICAgICB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIKICAgICAgICAgICAgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiCiAgICAgICAgICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyI+CiAgICAgICAgIDx0aWZmOllSZXNvbHV0aW9uPjcyPC90aWZmOllSZXNvbHV0aW9uPgogICAgICAgICA8dGlmZjpYUmVzb2x1dGlvbj43MjwvdGlmZjpYUmVzb2x1dGlvbj4KICAgICAgICAgPHRpZmY6T3JpZW50YXRpb24+MTwvdGlmZjpPcmllbnRhdGlvbj4KICAgICAgICAgPHhtcE1NOkRlcml2ZWR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MvLy9LS0oxETk2U3tLS0tXV1cPDw+Xl5amDftbX19na2uLj4+jo6dzd3OXl511dXd/g31paWlZXV9TU1HBwcOvr687OzdDQ0u/u7fTx79PSzcrJx6KiooWFhujn5NvW05WUk7S1t3R1d7y9vcLCv37J68vMzVJTVOLY1gMiSpmamnt7e7K6zHq+43LQ9Vyez+Pf3LGyscXGybzD1sXDw46v02vI8I+Pj7vEtNvIx7q4ubnZ54a3it3f5s+8vGS/6L6trK+6qICs1H+33cXc6KiuwAOr48fN20ee0Fao0lyz4W6s1qyrrKKlt3XdkoqnyyFoqzuTy6ixosuVeobA4YHNl8TOv3/Ck9bc4I3P7Uqq3tDIxz2FwzN/vF+VxdDe59mIfU+OxJmovxl+wX7S9WjbhovW9jihyKGalIq31uNyY36exJCatJONhTm36nKj0B2q4Mqxsae2zc/U3tvf1cqKa7zAyJS4npqyyTh2tUhMT1drj5ixtN98cEfC8U2Y5vf39355cSN0s4mDfKaomlrG8b2cmcFvaGx/m2CeZge68HG64YCNntSgoVHUdJzKnIHIh6c+BalVVaPM5qrG2CZZkyaHH3WRtYrdn5nH2rxoP22+gN1VQTyxW1aXl0iO2GaxtFuzaCCAQyXSWDOKlDZwkxIINVZPP52Io3uldtIoC1uGVxmzRP6PHn8AAADVdFJOUwAmEf6t/v4EAQVR/oT+Hl4U/v1bR/7+Kf7+a/76Q4Y2Wf1b4j71sXm0y2hF/bBwbtXN/fyGl8Sxiu382Preqfzia9iIkdP51/Povnineu+9n6H7ov5ksLfYy/7////////+/////////////////////v/////////////////////////////////////////////////////////////////////////////+/////////////////////////////////////////////////////r5xM8kAAA0qSURBVFjDpZh3WFNnG8YDMZOiLEFEsVhn1Vq1Vq1abWv3br+dc5IQsklCSEiIyAoJyAhb9h4ishVQcCAIOLC4UBFxr7bu0X6dX6/vec8JikIptecPVrh+576f5z3vez+HQmGyKBSK28eT4SsL/fiXLiaFwmD/E5NzPmU7wG8s5l/DOXy8+vhxLg8TcN5/yw0JZPwV2GoJH+fj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|
@@ -1037,21 +1044,8 @@ callbacks = {} %>"
|
|
1037
1044
|
poly_cols = #{poly_cols.inspect} %>"
|
1038
1045
|
end
|
1039
1046
|
|
1040
|
-
addNewLink = if !@_brick_model&.is_view?
|
1041
|
-
"<% if respond_to?(:#{new_path_name = "new_#{path_obj_name}_path"}) %>
|
1042
|
-
var addNew = document.createElement(\"A\");
|
1043
|
-
addNew.id = \"addNew\";
|
1044
|
-
addNew.href = \"<%= send(:#{new_path_name}) %>\";
|
1045
|
-
addNew.title = \"New #{obj_name}\";
|
1046
|
-
addNew.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"#fff\" d=\"M24 10h-10v-10h-4v10h-10v4h10v10h4v-10h10z\"/></svg>';
|
1047
|
-
document.getElementById(\"headerButtonBox\").append(addNew);
|
1048
|
-
<% end %>"
|
1049
|
-
end
|
1050
|
-
|
1051
1047
|
# %%% When doing schema select, if we're on a new page go to index
|
1052
1048
|
script = "<script>
|
1053
|
-
var #{table_name}HtColumns;
|
1054
|
-
|
1055
1049
|
// Add \"Are you sure?\" behaviour to any data-confirm buttons out there
|
1056
1050
|
document.querySelectorAll(\"input[type=submit][data-confirm]\").forEach(function (btn) {
|
1057
1051
|
btn.addEventListener(\"click\", function (evt) {
|
@@ -1062,108 +1056,11 @@ document.querySelectorAll(\"input[type=submit][data-confirm]\").forEach(function
|
|
1062
1056
|
});
|
1063
1057
|
});
|
1064
1058
|
|
1059
|
+
<%= @_brick_javascripts&.fetch(:grid_scripts, nil)&.html_safe
|
1060
|
+
%>
|
1065
1061
|
#{JS_CHANGEOUT}#{
|
1066
1062
|
"\nbrickTestSchema = \"#{::Brick.test_schema}\";" if ::Brick.test_schema
|
1067
1063
|
}
|
1068
|
-
// Snag first TR for sticky header
|
1069
|
-
var grid = document.getElementById(\"#{table_name}\");
|
1070
|
-
#{table_name}HtColumns = grid && [grid.getElementsByTagName(\"TR\")[0]];
|
1071
|
-
var headerTop = document.getElementById(\"headerTop\");
|
1072
|
-
var headerCols;
|
1073
|
-
if (grid) {
|
1074
|
-
// COLUMN HEADER AND TABLE CELL HIGHLIGHTING
|
1075
|
-
var gridHighHeader = null,
|
1076
|
-
gridHighCell = null;
|
1077
|
-
grid.addEventListener(\"mouseenter\", gridMove);
|
1078
|
-
grid.addEventListener(\"mousemove\", gridMove);
|
1079
|
-
grid.addEventListener(\"mouseleave\", function (evt) {
|
1080
|
-
if (gridHighCell) gridHighCell.classList.remove(\"highlight\");
|
1081
|
-
gridHighCell = null;
|
1082
|
-
if (gridHighHeader) gridHighHeader.classList.remove(\"highlight\");
|
1083
|
-
gridHighHeader = null;
|
1084
|
-
});
|
1085
|
-
function gridMove(evt) {
|
1086
|
-
var lastHighCell = gridHighCell;
|
1087
|
-
gridHighCell = document.elementFromPoint(evt.x, evt.y);
|
1088
|
-
while (gridHighCell && gridHighCell.tagName !== \"TD\" && gridHighCell.tagName !== \"TH\")
|
1089
|
-
gridHighCell = gridHighCell.parentElement;
|
1090
|
-
if (gridHighCell) {
|
1091
|
-
if (lastHighCell !== gridHighCell) {
|
1092
|
-
gridHighCell.classList.add(\"highlight\");
|
1093
|
-
if (lastHighCell) lastHighCell.classList.remove(\"highlight\");
|
1094
|
-
}
|
1095
|
-
var lastHighHeader = gridHighHeader;
|
1096
|
-
if ((gridHighHeader = headerCols[gridHighCell.cellIndex]) && lastHighHeader !== gridHighHeader) {
|
1097
|
-
if (gridHighHeader) gridHighHeader.classList.add(\"highlight\");
|
1098
|
-
if (lastHighHeader) lastHighHeader.classList.remove(\"highlight\");
|
1099
|
-
}
|
1100
|
-
}
|
1101
|
-
}
|
1102
|
-
// // LESS TOUCHY NAVIGATION BACK OR FORWARD IN HISTORY WHEN USING MOUSE WHEEL
|
1103
|
-
// grid.addEventListener(\"wheel\", function (evt) {
|
1104
|
-
// grid.scrollLeft += evt.deltaX;
|
1105
|
-
// document.body.scrollTop += (evt.deltaY * 0.6);
|
1106
|
-
// evt.preventDefault();
|
1107
|
-
// return false;
|
1108
|
-
// });
|
1109
|
-
}
|
1110
|
-
function setHeaderSizes() {
|
1111
|
-
if (grid.clientWidth > window.outerWidth)
|
1112
|
-
document.getElementById(\"titleBox\").style.width = grid.clientWidth;
|
1113
|
-
// console.log(\"start\");
|
1114
|
-
// See if the headerTop is already populated
|
1115
|
-
// %%% Grab the TRs from headerTop, clear it out, do this stuff, add them back
|
1116
|
-
headerTop.innerHTML = \"\"; // %%% Would love to not have to clear it out like this every time! (Currently doing this to support resize events.)
|
1117
|
-
var isEmpty = headerTop.childElementCount === 0;
|
1118
|
-
var numFixed = parseInt(grid.getAttribute(\"x-num-frozen\")) || 0;
|
1119
|
-
var fixedColLefts = [0];
|
1120
|
-
|
1121
|
-
// Set up proper sizings of sticky column header
|
1122
|
-
var node;
|
1123
|
-
for (var j = 0; j < #{table_name}HtColumns.length; ++j) {
|
1124
|
-
var row = #{table_name}HtColumns[j];
|
1125
|
-
var tr = isEmpty ? document.createElement(\"TR\") : headerTop.childNodes[j];
|
1126
|
-
tr.innerHTML = row.innerHTML.trim();
|
1127
|
-
var curLeft = 0.0;
|
1128
|
-
// Match up widths from the original column headers
|
1129
|
-
for (var i = 0; i < row.childNodes.length; ++i) {
|
1130
|
-
node = row.childNodes[i];
|
1131
|
-
if (node.nodeType === 1) {
|
1132
|
-
var th = tr.childNodes[i];
|
1133
|
-
th.style.minWidth = th.style.maxWidth = getComputedStyle(node).width;
|
1134
|
-
// Add \"left: __px\" style to the fixed-width column THs
|
1135
|
-
if (i <= numFixed) {
|
1136
|
-
th.style.position = \"sticky\";
|
1137
|
-
th.style.backgroundColor = \"#008061\";
|
1138
|
-
th.style.zIndex = \"1\";
|
1139
|
-
th.style.left = curLeft + \"px\";
|
1140
|
-
fixedColLefts.push(curLeft += node.clientWidth);
|
1141
|
-
}
|
1142
|
-
if (#{pk&.present? ? 'i > 0' : 'true'}) {
|
1143
|
-
// Add <span> at the end
|
1144
|
-
var span = document.createElement(\"SPAN\");
|
1145
|
-
span.className = \"exclude\";
|
1146
|
-
span.innerHTML = \"X\";
|
1147
|
-
span.addEventListener(\"click\", function (e) {
|
1148
|
-
e.stopPropagation();
|
1149
|
-
doFetch(\"POST\", {_brick_exclude: this.parentElement.getAttribute(\"x-order\")});
|
1150
|
-
});
|
1151
|
-
th.appendChild(span);
|
1152
|
-
}
|
1153
|
-
}
|
1154
|
-
}
|
1155
|
-
headerCols = tr.childNodes;
|
1156
|
-
if (isEmpty) headerTop.appendChild(tr);
|
1157
|
-
}
|
1158
|
-
// Add \"left: __px\" style to all fixed-width column TDs
|
1159
|
-
[...grid.children[1].children].forEach(function (row) {
|
1160
|
-
for (var j = 1; j <= numFixed; ++j) {
|
1161
|
-
row.children[j].style.left = fixedColLefts[j] + 'px';
|
1162
|
-
}
|
1163
|
-
});
|
1164
|
-
grid.style.marginTop = \"-\" + getComputedStyle(headerTop).height;
|
1165
|
-
// console.log(\"end\");
|
1166
|
-
}
|
1167
1064
|
function doFetch(method, payload, success) {
|
1168
1065
|
payload.authenticity_token = <%= session[:_csrf_token].inspect.html_safe %>;
|
1169
1066
|
if (!success) {
|
@@ -1176,13 +1073,7 @@ function doFetch(method, payload, success) {
|
|
1176
1073
|
if (payload) options.body = JSON.stringify(payload);
|
1177
1074
|
return fetch(location.href, options).then(success);
|
1178
1075
|
}
|
1179
|
-
|
1180
|
-
setHeaderSizes();
|
1181
|
-
window.addEventListener('resize', function(event) {
|
1182
|
-
setHeaderSizes();
|
1183
|
-
}, true);#{
|
1184
|
-
addNewLink}
|
1185
|
-
}
|
1076
|
+
|
1186
1077
|
// Cause descriptive text to use the same font as the resource
|
1187
1078
|
var brickFontFamily = document.getElementById(\"resourceName\").computedStyleMap().get(\"font-family\");
|
1188
1079
|
if (window.brickFontFamily) {
|
@@ -1402,7 +1293,14 @@ erDiagram
|
|
1402
1293
|
</head>
|
1403
1294
|
<body>
|
1404
1295
|
<div id=\"titleBox\"><div id=\"titleSticky\">
|
1405
|
-
|
1296
|
+
<% if request.respond_to?(:flash)
|
1297
|
+
if (alert)
|
1298
|
+
%><p class=\"flashAlert\"><%= alert.html_safe %></p><%
|
1299
|
+
end
|
1300
|
+
if (notice)
|
1301
|
+
%><p class=\"flashNotice\"><%= notice.html_safe %></p><%
|
1302
|
+
end
|
1303
|
+
end %>#{"
|
1406
1304
|
#{schema_options}" if schema_options}
|
1407
1305
|
<select id=\"tbl\">#{table_options}</select>
|
1408
1306
|
<table id=\"resourceName\"><tr>
|
@@ -1620,7 +1518,14 @@ end
|
|
1620
1518
|
c23.141-70.188,89.141-120.906,167.063-120.906c97.25,0,176,78.813,176,176C511.828,227.078,404.391,119.641,271.844,119.641z\" />
|
1621
1519
|
</svg>
|
1622
1520
|
|
1623
|
-
|
1521
|
+
<% if request.respond_to?(:flash)
|
1522
|
+
if (alert)
|
1523
|
+
%><p class=\"flashAlert\"><%= alert.html_safe %></p><%
|
1524
|
+
end
|
1525
|
+
if (notice)
|
1526
|
+
%><p class=\"flashNotice\"><%= notice.html_safe %></p><%
|
1527
|
+
end
|
1528
|
+
end %>#{"
|
1624
1529
|
#{schema_options}" if schema_options}
|
1625
1530
|
<select id=\"tbl\">#{table_options}</select>
|
1626
1531
|
<table id=\"resourceName\"><td><h1><%= page_title %></h1></td>
|
@@ -1694,12 +1599,14 @@ end
|
|
1694
1599
|
end
|
1695
1600
|
s << "<table id=\"#{hm_name}\" class=\"shadow\">
|
1696
1601
|
<tr><th>#{hm[1]}#{' poly' if hm[0].options[:as]} #{hm[3]}
|
1602
|
+
<% if respond_to?(:new_#{partial_new_path_name = hm.first.klass._brick_index(:singular)}_path) %>
|
1697
1603
|
<span class = \"add-hm-related\"><%=
|
1698
1604
|
pk_val = (obj_pk = model.primary_key).is_a?(String) ? obj.send(obj_pk) : obj_pk.map { |pk_part| obj.send(pk_part) }
|
1699
1605
|
pk_val_arr = [pk_val] unless pk_val.is_a?(Array)
|
1700
1606
|
link_to('<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"#fff\" d=\"M24 10h-10v-10h-4v10h-10v4h10v10h4v-10h10z\"/></svg>'.html_safe,
|
1701
|
-
new_#{
|
1607
|
+
new_#{partial_new_path_name}_path(predicates))
|
1702
1608
|
%></span>
|
1609
|
+
<% end %>
|
1703
1610
|
</th></tr>
|
1704
1611
|
<% if (assoc = @#{obj_name}.class.reflect_on_association(:#{hm_name})).macro == :has_one &&
|
1705
1612
|
assoc.options&.fetch(:through, nil).nil?
|
@@ -91,8 +91,7 @@ module Brick::Rails::FormBuilder
|
|
91
91
|
when :binary
|
92
92
|
is_revert = false
|
93
93
|
if val
|
94
|
-
|
95
|
-
out << if val.length < 31 && (val.length - 6) % 8 == 0 && val[0..5].bytes == [230, 16, 0, 0, 1, 12]
|
94
|
+
out << if ::Brick.is_geography?(val)
|
96
95
|
::Brick::Rails.display_value('geography', val)
|
97
96
|
else
|
98
97
|
::Brick::Rails.display_binary(val)
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Brick::Rails::FormTags
|
2
2
|
# Our super speedy grid
|
3
3
|
def brick_grid(relation = nil, bt_descrip = nil, sequence = nil, inclusions = nil, exclusions = nil,
|
4
|
-
cols = {}, poly_cols = nil, bts = {}, hms_keys = [], hms_cols = {}
|
4
|
+
cols = {}, poly_cols = nil, bts = {}, hms_keys = [], hms_cols = {},
|
5
|
+
show_header: nil, show_row_count: nil, show_erd_button: nil, show_new_button: nil, show_avo_button: nil, show_aa_button: nil)
|
5
6
|
# When a relation is not provided, first see if one exists which matches the controller name
|
6
7
|
unless (relation ||= instance_variable_get("@#{controller_name}".to_sym))
|
7
8
|
# Failing that, dig through the instance variables with hopes to find something that is an ActiveRecord::Relation
|
@@ -27,44 +28,57 @@ module Brick::Rails::FormTags
|
|
27
28
|
nfc = Brick.config.sidescroll.fetch(relation.table_name, nil)&.fetch(:num_frozen_columns, nil) ||
|
28
29
|
Brick.config.sidescroll.fetch(:num_frozen_columns, nil) ||
|
29
30
|
0
|
31
|
+
|
32
|
+
# HTML for brick_grid
|
30
33
|
out = +"<div id=\"headerTopContainer\"><table id=\"headerTop\"></table>
|
31
|
-
<div id=\"headerTopAddNew\">
|
32
|
-
<div id=\"headerButtonBox\">
|
33
|
-
<div id=\"imgErd\" title=\"Show ERD\"></div>
|
34
34
|
"
|
35
35
|
klass = relation.klass
|
36
|
-
|
37
|
-
out << "
|
36
|
+
unless show_header == false
|
37
|
+
out << " <div id=\"headerTopAddNew\">
|
38
|
+
<div id=\"headerButtonBox\">
|
39
|
+
"
|
40
|
+
unless show_row_count == false
|
41
|
+
out << " <div id=\"rowCount\"></div>
|
42
|
+
"
|
43
|
+
end
|
44
|
+
unless show_erd_button == false
|
45
|
+
out << " <div id=\"imgErd\" title=\"Show ERD\"></div>
|
46
|
+
"
|
47
|
+
end
|
48
|
+
if show_avo_button != false && Object.const_defined?('Avo') && ::Avo.respond_to?(:railtie_namespace) && klass.name.exclude?('::')
|
49
|
+
out << "
|
38
50
|
<td>#{link_to_brick(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
51
|
+
::Brick::Rails::AVO_SVG,
|
52
|
+
{ index_proc: Proc.new do |_avo_model, relation|
|
53
|
+
path_helper = "resources_#{relation.fetch(:auto_prefixed_schema, nil)}#{klass.model_name.route_key}_path".to_sym
|
54
|
+
::Avo.railtie_routes_url_helpers.send(path_helper) if ::Avo.railtie_routes_url_helpers.respond_to?(path_helper)
|
55
|
+
end,
|
56
|
+
title: "#{klass.name} in Avo" }
|
45
57
|
)}</td>
|
46
58
|
"
|
47
|
-
|
59
|
+
end
|
48
60
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
61
|
+
if show_aa_button != false && Object.const_defined?('ActiveAdmin')
|
62
|
+
ActiveAdmin.application.namespaces.names.each do |ns|
|
63
|
+
out << "
|
64
|
+
<td>#{link_to_brick(
|
65
|
+
::Brick::Rails::AA_PNG,
|
66
|
+
{ index_proc: Proc.new do |aa_model, relation|
|
67
|
+
path_helper = "#{ns}_#{relation.fetch(:auto_prefixed_schema, nil)}#{rk = aa_model.model_name.route_key}_path".to_sym
|
68
|
+
send(path_helper) if respond_to?(path_helper)
|
69
|
+
end,
|
70
|
+
title: "#{klass.name} in ActiveAdmin" }
|
59
71
|
)}</td>
|
60
72
|
"
|
73
|
+
end
|
61
74
|
end
|
62
|
-
end
|
63
|
-
|
64
75
|
out << " </div>
|
65
76
|
</div>
|
66
|
-
|
67
|
-
|
77
|
+
"
|
78
|
+
end
|
79
|
+
|
80
|
+
out << "</div>
|
81
|
+
<table id=\"#{table_name = relation.table_name.split('.').last}\" class=\"shadow\"#{ " x-num-frozen=\"#{nfc}\"" if nfc.positive? }>
|
68
82
|
<thead><tr>"
|
69
83
|
pk = klass.primary_key || []
|
70
84
|
pk = [pk] unless pk.is_a?(Array)
|
@@ -137,6 +151,7 @@ module Brick::Rails::FormTags
|
|
137
151
|
# ActiveRecord::StatementTimeout in Warehouse::ColdRoomTemperatures_Archive#index
|
138
152
|
# TinyTds::Error: Adaptive Server connection timed out
|
139
153
|
# (After restarting the server it worked fine again.)
|
154
|
+
rowCount = 0
|
140
155
|
relation.each do |obj|
|
141
156
|
out << "<tr>\n"
|
142
157
|
out << "<td class=\"col-sticky\">#{link_to('⇛', send("#{klass._brick_index(:singular)}_path".to_sym,
|
@@ -152,16 +167,16 @@ module Brick::Rails::FormTags
|
|
152
167
|
out << " class=\"#{classes.join(' ')}\"" if classes&.present?
|
153
168
|
out << '>'
|
154
169
|
if (bt || composite_bt_names[col_name])
|
155
|
-
if bt[2] # Polymorphic?
|
156
|
-
if (poly_id = obj.send(
|
170
|
+
if bt[2] && obj.respond_to?(poly_id_col = "#{bt.first}_id") # Polymorphic?
|
171
|
+
if (poly_id = obj.send(poly_id_col))
|
157
172
|
bt_class = obj.send(klass.brick_foreign_type(bt.first))
|
158
173
|
base_class_underscored = (::Brick.existing_stis[bt_class] || bt_class).constantize.base_class._brick_index(:singular)
|
159
174
|
out << link_to("#{bt_class} ##{poly_id}", send("#{base_class_underscored}_path".to_sym, poly_id))
|
160
175
|
end
|
161
176
|
else # BT or HOT
|
162
177
|
bt_class = bt[1].first.first
|
163
|
-
if bt_descrip
|
164
|
-
descrips =
|
178
|
+
if bt_descrip && (this_bt_descrip = bt_descrip[bt.first])
|
179
|
+
descrips = this_bt_descrip[bt_class]
|
165
180
|
bt_id_col = if descrips.nil?
|
166
181
|
puts "Caught it in the act for obj / #{col_name}!"
|
167
182
|
elsif descrips.length == 1
|
@@ -237,10 +252,160 @@ module Brick::Rails::FormTags
|
|
237
252
|
out << '</td>'
|
238
253
|
end
|
239
254
|
out << '</tr>'
|
255
|
+
rowCount += 1
|
240
256
|
end
|
241
257
|
out << " </tbody>
|
242
258
|
</table>
|
259
|
+
<script>
|
260
|
+
var rowCount = document.getElementById(\"rowCount\");
|
261
|
+
if (rowCount) rowCount.innerHTML = \"#{pluralize(rowCount, "row")} \";
|
262
|
+
</script>
|
263
|
+
"
|
264
|
+
|
265
|
+
# Javascript for brick_grid
|
266
|
+
(@_brick_javascripts ||= {})[:grid_scripts] = "
|
267
|
+
var #{table_name}HtColumns;
|
268
|
+
|
269
|
+
// Snag first TR for sticky header
|
270
|
+
var grid = document.getElementById(\"#{table_name}\");
|
271
|
+
#{table_name}HtColumns = grid && [grid.getElementsByTagName(\"TR\")[0]];
|
272
|
+
var headerTop = document.getElementById(\"headerTop\");
|
273
|
+
var headerCols;
|
274
|
+
if (grid) {
|
275
|
+
// COLUMN HEADER AND TABLE CELL HIGHLIGHTING
|
276
|
+
var gridHighHeader = null,
|
277
|
+
gridHighCell = null;
|
278
|
+
grid.addEventListener(\"mouseenter\", gridMove);
|
279
|
+
grid.addEventListener(\"mousemove\", gridMove);
|
280
|
+
grid.addEventListener(\"mouseleave\", function (evt) {
|
281
|
+
if (gridHighCell) gridHighCell.classList.remove(\"highlight\");
|
282
|
+
gridHighCell = null;
|
283
|
+
if (gridHighHeader) gridHighHeader.classList.remove(\"highlight\");
|
284
|
+
gridHighHeader = null;
|
285
|
+
});
|
286
|
+
function gridMove(evt) {
|
287
|
+
var lastHighCell = gridHighCell;
|
288
|
+
gridHighCell = document.elementFromPoint(evt.x, evt.y);
|
289
|
+
while (gridHighCell && gridHighCell.tagName !== \"TD\" && gridHighCell.tagName !== \"TH\")
|
290
|
+
gridHighCell = gridHighCell.parentElement;
|
291
|
+
if (gridHighCell) {
|
292
|
+
if (lastHighCell !== gridHighCell) {
|
293
|
+
gridHighCell.classList.add(\"highlight\");
|
294
|
+
if (lastHighCell) lastHighCell.classList.remove(\"highlight\");
|
295
|
+
}
|
296
|
+
var lastHighHeader = gridHighHeader;
|
297
|
+
if ((gridHighHeader = headerCols[gridHighCell.cellIndex]) && lastHighHeader !== gridHighHeader) {
|
298
|
+
if (gridHighHeader) gridHighHeader.classList.add(\"highlight\");
|
299
|
+
if (lastHighHeader) lastHighHeader.classList.remove(\"highlight\");
|
300
|
+
}
|
301
|
+
}
|
302
|
+
}
|
303
|
+
// // LESS TOUCHY NAVIGATION BACK OR FORWARD IN HISTORY WHEN USING MOUSE WHEEL
|
304
|
+
// grid.addEventListener(\"wheel\", function (evt) {
|
305
|
+
// grid.scrollLeft += evt.deltaX;
|
306
|
+
// document.body.scrollTop += (evt.deltaY * 0.6);
|
307
|
+
// evt.preventDefault();
|
308
|
+
// return false;
|
309
|
+
// });
|
310
|
+
}
|
311
|
+
function setHeaderSizes() {
|
312
|
+
if (grid.clientWidth > window.outerWidth)
|
313
|
+
document.getElementById(\"titleBox\").style.width = grid.clientWidth;
|
314
|
+
// console.log(\"start\");
|
315
|
+
// See if the headerTop is already populated
|
316
|
+
// %%% Grab the TRs from headerTop, clear it out, do this stuff, add them back
|
317
|
+
headerTop.innerHTML = \"\"; // %%% Would love to not have to clear it out like this every time! (Currently doing this to support resize events.)
|
318
|
+
var isEmpty = headerTop.childElementCount === 0;
|
319
|
+
var numFixed = parseInt(grid.getAttribute(\"x-num-frozen\")) || 0;
|
320
|
+
var fixedColLefts = [0];
|
321
|
+
|
322
|
+
// Set up proper sizings of sticky column header
|
323
|
+
var node;
|
324
|
+
for (var j = 0; j < #{table_name}HtColumns.length; ++j) {
|
325
|
+
var row = #{table_name}HtColumns[j];
|
326
|
+
var tr = isEmpty ? document.createElement(\"TR\") : headerTop.childNodes[j];
|
327
|
+
tr.innerHTML = row.innerHTML.trim();
|
328
|
+
var curLeft = 0.0;
|
329
|
+
// Match up widths from the original column headers
|
330
|
+
for (var i = 0; i < row.childNodes.length; ++i) {
|
331
|
+
node = row.childNodes[i];
|
332
|
+
if (node.nodeType === 1) {
|
333
|
+
var th = tr.childNodes[i];
|
334
|
+
th.style.minWidth = th.style.maxWidth = getComputedStyle(node).width;
|
335
|
+
// Add \"left: __px\" style to the fixed-width column THs
|
336
|
+
if (i <= numFixed) {
|
337
|
+
th.style.position = \"sticky\";
|
338
|
+
th.style.backgroundColor = \"#008061\";
|
339
|
+
th.style.zIndex = \"1\";
|
340
|
+
th.style.left = curLeft + \"px\";
|
341
|
+
fixedColLefts.push(curLeft += node.clientWidth);
|
342
|
+
}
|
343
|
+
if (#{pk&.present? ? 'i > 0' : 'true'}) {
|
344
|
+
// Add <span> at the end
|
345
|
+
var span = document.createElement(\"SPAN\");
|
346
|
+
span.className = \"exclude\";
|
347
|
+
span.innerHTML = \"X\";
|
348
|
+
span.addEventListener(\"click\", function (e) {
|
349
|
+
e.stopPropagation();
|
350
|
+
doFetch(\"POST\", {_brick_exclude: this.parentElement.getAttribute(\"x-order\")});
|
351
|
+
});
|
352
|
+
th.appendChild(span);
|
353
|
+
}
|
354
|
+
}
|
355
|
+
}
|
356
|
+
headerCols = tr.childNodes;
|
357
|
+
if (isEmpty) headerTop.appendChild(tr);
|
358
|
+
}
|
359
|
+
// Add \"left: __px\" style to all fixed-width column TDs
|
360
|
+
[...grid.children[1].children].forEach(function (row) {
|
361
|
+
for (var j = 1; j <= numFixed; ++j) {
|
362
|
+
row.children[j].style.left = fixedColLefts[j] + 'px';
|
363
|
+
}
|
364
|
+
});
|
365
|
+
grid.style.marginTop = \"-\" + getComputedStyle(headerTop).height;
|
366
|
+
// console.log(\"end\");
|
367
|
+
}
|
368
|
+
|
369
|
+
if (headerTop) {
|
370
|
+
onImagesLoaded(function() {
|
371
|
+
setHeaderSizes();
|
372
|
+
});
|
373
|
+
window.addEventListener(\"resize\", function(event) {
|
374
|
+
setHeaderSizes();
|
375
|
+
}, true);#{
|
376
|
+
if !klass.is_view? && respond_to?(new_path_name = "new_#{klass._brick_index(:singular)}_path")
|
377
|
+
"
|
378
|
+
var headerButtonBox = document.getElementById(\"headerButtonBox\");
|
379
|
+
if (headerButtonBox) {
|
380
|
+
var addNew = document.createElement(\"A\");
|
381
|
+
addNew.id = \"addNew\";
|
382
|
+
addNew.href = \"#{send(new_path_name)}\";
|
383
|
+
addNew.title = \"New #{table_name.singularize}\";
|
384
|
+
addNew.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"#fff\" d=\"M24 10h-10v-10h-4v10h-10v4h10v10h4v-10h10z\"/></svg>';
|
385
|
+
headerButtonBox.append(addNew);
|
386
|
+
}
|
243
387
|
"
|
388
|
+
end}
|
389
|
+
}
|
390
|
+
|
391
|
+
function onImagesLoaded(event) {
|
392
|
+
var images = document.getElementsByTagName(\"IMG\");
|
393
|
+
var numLoaded = images.length;
|
394
|
+
for (var i = 0; i < images.length; ++i) {
|
395
|
+
if (images[i].complete)
|
396
|
+
--numLoaded;
|
397
|
+
else {
|
398
|
+
images[i].addEventListener(\"load\", function() {
|
399
|
+
if (--numLoaded <= 0)
|
400
|
+
event();
|
401
|
+
});
|
402
|
+
}
|
403
|
+
}
|
404
|
+
if (numLoaded <= 0)
|
405
|
+
event();
|
406
|
+
}
|
407
|
+
"
|
408
|
+
|
244
409
|
out.html_safe
|
245
410
|
end # brick_grid
|
246
411
|
|
data/lib/brick/version_number.rb
CHANGED
data/lib/brick.rb
CHANGED
@@ -111,6 +111,15 @@ module Brick
|
|
111
111
|
:is_oracle, :is_eager_loading, :auto_models, :initializer_loaded
|
112
112
|
::Brick.auto_models = []
|
113
113
|
|
114
|
+
def get_possible_schemas
|
115
|
+
if (possible_schemas = (multitenancy = ::Brick.config.schema_behavior&.[](:multitenant)) &&
|
116
|
+
multitenancy&.[](:schema_to_analyse))
|
117
|
+
possible_schemas = [possible_schemas] unless possible_schemas.is_a?(Array)
|
118
|
+
possible_schema = possible_schemas.find { |ps| ::Brick.db_schemas.key?(ps) }
|
119
|
+
end
|
120
|
+
[possible_schema, possible_schemas, multitenancy]
|
121
|
+
end
|
122
|
+
|
114
123
|
def set_db_schema(params = nil)
|
115
124
|
# If Apartment::Tenant.current is not still the default (usually 'public') then an elevator has brought us into
|
116
125
|
# a different tenant. If so then don't allow schema navigation.
|
@@ -297,6 +306,10 @@ module Brick
|
|
297
306
|
true
|
298
307
|
end
|
299
308
|
|
309
|
+
def is_geography?(val)
|
310
|
+
val.length < 31 && (val.length - 6) % 8 == 0 && val[0..5].bytes == [230, 16, 0, 0, 1, 12]
|
311
|
+
end
|
312
|
+
|
300
313
|
# @api public
|
301
314
|
def mode=(setting)
|
302
315
|
Brick.config.mode = setting
|
@@ -894,7 +907,7 @@ In config/initializers/brick.rb appropriate entries would look something like:
|
|
894
907
|
else
|
895
908
|
table_class_length = class_name.length if class_name.length > table_class_length
|
896
909
|
tables
|
897
|
-
end << [class_name, aps,
|
910
|
+
end << [class_name, aps, k.tr('.', '/')]
|
898
911
|
end
|
899
912
|
|
900
913
|
options = {}
|
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.173
|
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-09-
|
11
|
+
date: 2023-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|