brick 1.0.178 → 1.0.180
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/lib/brick/extensions.rb +12 -2
- data/lib/brick/frameworks/rails/engine.rb +43 -5
- data/lib/brick/version_number.rb +1 -1
- data/lib/brick.rb +11 -2
- data/lib/generators/brick/install_generator.rb +1 -0
- data/lib/generators/brick/migrations_generator.rb +1 -0
- data/lib/generators/brick/models_generator.rb +1 -0
- data/lib/generators/brick/seeds_generator.rb +1 -0
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5cc0c73d63cbebcbad81388f8ae444c72dafa57a38c1f2a95b3b7f5bd4a621a
|
4
|
+
data.tar.gz: 8670884c20ac46ee01d28c97fabe97694a2f3862761228e16c0422790a937cc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62d010ea2765fe14369e18db8b123426f5ace62025b053b453656870223073b75f95add727e5cb2073f78d0f58a88cb293904bcbee08726b0ba09947c16f3709
|
7
|
+
data.tar.gz: 25dbb2878198256df74cc36934bb7fcaab24a3dfd0b9cac55de8d04e2fcfce8ff0158458cd2d76004e354020addd6b38de5001ab79bebecb9f8afaa1f3e5133f
|
data/lib/brick/extensions.rb
CHANGED
@@ -1189,7 +1189,7 @@ if Object.const_defined?('ActionView')
|
|
1189
1189
|
# not let Brick have any fun. So just call this right before any wildcard routes, and
|
1190
1190
|
# you'll be in business!
|
1191
1191
|
def mount_brick_routes
|
1192
|
-
add_brick_routes
|
1192
|
+
add_brick_routes if !::Brick.routes_done && respond_to?(:add_brick_routes)
|
1193
1193
|
end
|
1194
1194
|
end
|
1195
1195
|
end
|
@@ -1911,6 +1911,16 @@ class Object
|
|
1911
1911
|
instance_variable_set(:@resources, ::Brick.get_status_of_resources)
|
1912
1912
|
add_csp_hash
|
1913
1913
|
end
|
1914
|
+
self.define_method :schema_create do
|
1915
|
+
if (base_class = (model = params['modelName']&.constantize).base_class) &&
|
1916
|
+
base_class.column_names.exclude?(col_name = params['colName'])
|
1917
|
+
ActiveRecord::Base.connection.add_column(base_class.table_name.to_sym, col_name, (col_type = params['colType']).to_sym)
|
1918
|
+
base_class.reset_column_information
|
1919
|
+
::Brick.relations[base_class.table_name]&.fetch(:cols, nil)&.[]=(col_name, [col_type, nil, false, false])
|
1920
|
+
# instance_variable_set(:@schema, ::Brick.find_schema(::Brick.set_db_schema(params).first))
|
1921
|
+
add_csp_hash
|
1922
|
+
end
|
1923
|
+
end
|
1914
1924
|
self.define_method :orphans do
|
1915
1925
|
instance_variable_set(:@orphans, ::Brick.find_orphans(::Brick.set_db_schema(params).first))
|
1916
1926
|
add_csp_hash
|
@@ -2581,7 +2591,7 @@ end.class_exec do
|
|
2581
2591
|
if arca::AbstractAdapter.private_instance_methods.include?(:with_raw_connection)
|
2582
2592
|
db_statements.define_method(:begin_db_transaction) do
|
2583
2593
|
log("begin immediate transaction", "TRANSACTION") do
|
2584
|
-
with_raw_connection(allow_retry: true,
|
2594
|
+
with_raw_connection(allow_retry: true, materialize_transactions: false) do |conn|
|
2585
2595
|
conn.transaction(:immediate)
|
2586
2596
|
end
|
2587
2597
|
end
|
@@ -793,7 +793,7 @@ window.addEventListener(\"popstate\", linkSchemas);
|
|
793
793
|
end.html_safe
|
794
794
|
table_options << "<option value=\"#{prefix}brick_status\">(Status)</option>".html_safe if ::Brick.config.add_status
|
795
795
|
table_options << "<option value=\"#{prefix}brick_orphans\">(Orphans)</option>".html_safe if is_orphans
|
796
|
-
table_options << "<option value=\"#{prefix}
|
796
|
+
table_options << "<option value=\"#{prefix}brick_crosstab\">(Crosstab)</option>".html_safe if is_crosstab
|
797
797
|
css = +"<style>
|
798
798
|
#titleSticky {
|
799
799
|
position: sticky;
|
@@ -1063,6 +1063,8 @@ document.querySelectorAll(\"input[type=submit][data-confirm]\").forEach(function
|
|
1063
1063
|
}
|
1064
1064
|
function doFetch(method, payload, success) {
|
1065
1065
|
payload.authenticity_token = <%= session[:_csrf_token].inspect.html_safe %>;
|
1066
|
+
var action = payload._brick_action || location.href;
|
1067
|
+
delete payload._brick_action;
|
1066
1068
|
if (!success) {
|
1067
1069
|
success = function (p) {p.text().then(function (response) {
|
1068
1070
|
var result = JSON.parse(response).result;
|
@@ -1071,7 +1073,7 @@ function doFetch(method, payload, success) {
|
|
1071
1073
|
}
|
1072
1074
|
var options = {method: method, headers: {\"Content-Type\": \"application/json\"}};
|
1073
1075
|
if (payload) options.body = JSON.stringify(payload);
|
1074
|
-
return fetch(
|
1076
|
+
return fetch(action, options).then(success);
|
1075
1077
|
}
|
1076
1078
|
|
1077
1079
|
// Cause descriptive text to use the same font as the resource
|
@@ -1088,7 +1090,8 @@ if (window.brickFontFamily) {
|
|
1088
1090
|
end %>"
|
1089
1091
|
|
1090
1092
|
erd_markup = if @_brick_model
|
1091
|
-
"<div id=\"mermaidErd\"
|
1093
|
+
"<div id=\"mermaidErd\">
|
1094
|
+
<div id=\"mermaidDiagram\" class=\"mermaid\">
|
1092
1095
|
erDiagram
|
1093
1096
|
<% def sidelinks(shown_classes, klass)
|
1094
1097
|
links = []
|
@@ -1168,6 +1171,40 @@ erDiagram
|
|
1168
1171
|
# callback < %= cb_k % > erdClick
|
1169
1172
|
@_brick_monetized_attributes = model.respond_to?(:monetized_attributes) ? model.monetized_attributes.values : {}
|
1170
1173
|
%>
|
1174
|
+
</div>#{
|
1175
|
+
add_column = nil
|
1176
|
+
# Make into a server control with a javascript snippet
|
1177
|
+
# Have post back go to a common "brick_schema" endpoint, this one for add_column
|
1178
|
+
"
|
1179
|
+
<table style=\"position: relative; z-index: 2; border: 2px solid blue;\"><tr>
|
1180
|
+
<td rowspan=\"2\">Add<br>Column</td>
|
1181
|
+
<td style=\"padding-bottom: 0px\">Type</td><td style=\"padding-bottom: 0px\">Name</td>
|
1182
|
+
<td rowspan=\"2\"><input type=\"button\" id=\"btnAddCol\" value=\"+\"></td>
|
1183
|
+
</tr><tr><td style=\"padding-top: 0px\">
|
1184
|
+
<select id=\"ddlColType\">
|
1185
|
+
<option value=\"string\">String</option>
|
1186
|
+
<option value=\"text\">Text</option>
|
1187
|
+
<option value=\"integer\">Integer</option>
|
1188
|
+
<option value=\"bool\">Boolean</option>
|
1189
|
+
</select></td>
|
1190
|
+
<td style=\"padding-top: 0px\"><input id=\"txtColName\"></td>
|
1191
|
+
</tr></table>
|
1192
|
+
<script>
|
1193
|
+
var btnAddCol = document.getElementById(\"btnAddCol\");
|
1194
|
+
btnAddCol.addEventListener(\"click\", function () {
|
1195
|
+
var txtColName = document.getElementById(\"txtColName\");
|
1196
|
+
var ddlColType = document.getElementById(\"ddlColType\");
|
1197
|
+
doFetch(\"POST\", {modelName: \"#{@_brick_model.name}\",
|
1198
|
+
colName: txtColName.value, colType: ddlColType.value,
|
1199
|
+
_brick_action: \"/#{prefix}brick_schema\"},
|
1200
|
+
function () { // If it returns successfully, do a page refresh
|
1201
|
+
location.href = location.href;
|
1202
|
+
}
|
1203
|
+
);
|
1204
|
+
});
|
1205
|
+
</script>
|
1206
|
+
" unless add_column == false}
|
1207
|
+
|
1171
1208
|
</div>
|
1172
1209
|
"
|
1173
1210
|
end
|
@@ -1766,7 +1803,7 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
|
|
1766
1803
|
gErd.addEventListener(\"click\",
|
1767
1804
|
function (evt) {
|
1768
1805
|
location.href = changeout(changeout(
|
1769
|
-
changeout(location.href,
|
1806
|
+
changeout(location.href, \"_brick_order\", null), // Remove any ordering
|
1770
1807
|
-1, cbs[this.id].replace(/^[\/]+/, \"\")), \"_brick_erd\", \"1\");
|
1771
1808
|
}
|
1772
1809
|
);
|
@@ -1774,6 +1811,7 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
|
|
1774
1811
|
}}
|
1775
1812
|
});
|
1776
1813
|
mermaid.contentLoaded();
|
1814
|
+
window.history.replaceState({}, \"\", changeout(location.href, \"_brick_erd\", \"1\"));
|
1777
1815
|
// Add <span> at the end
|
1778
1816
|
var span = document.createElement(\"SPAN\");
|
1779
1817
|
span.className = \"exclude\";
|
@@ -1782,7 +1820,7 @@ flatpickr(\".timepicker\", {enableTime: true, noCalendar: true});
|
|
1782
1820
|
e.stopPropagation();
|
1783
1821
|
imgErd.style.display = \"table-cell\";
|
1784
1822
|
mermaidErd.style.display = \"none\";
|
1785
|
-
window.history.
|
1823
|
+
window.history.replaceState({}, \"\", changeout(location.href, \"_brick_erd\", null));
|
1786
1824
|
});
|
1787
1825
|
mermaidErd.appendChild(span);
|
1788
1826
|
}
|
data/lib/brick/version_number.rb
CHANGED
data/lib/brick.rb
CHANGED
@@ -910,7 +910,7 @@ In config/initializers/brick.rb appropriate entries would look something like:
|
|
910
910
|
|
911
911
|
object_name = k.split('.').last # Take off any first schema part
|
912
912
|
|
913
|
-
full_schema_prefix = if (aps = v.fetch(:auto_prefixed_schema, nil))
|
913
|
+
full_schema_prefix = if (full_aps = aps = v.fetch(:auto_prefixed_schema, nil))
|
914
914
|
aps = aps[0..-2] if aps[-1] == '_'
|
915
915
|
(schema_prefix&.dup || +'') << "#{aps}."
|
916
916
|
else
|
@@ -925,7 +925,7 @@ In config/initializers/brick.rb appropriate entries would look something like:
|
|
925
925
|
else
|
926
926
|
table_class_length = class_name.length if class_name.length > table_class_length
|
927
927
|
tables
|
928
|
-
end << [class_name, aps, k.tr('.', '/')]
|
928
|
+
end << [class_name, aps, k.tr('.', '/')[full_aps&.length || 0 .. -1]]
|
929
929
|
end
|
930
930
|
|
931
931
|
options = {}
|
@@ -1089,6 +1089,15 @@ In config/initializers/brick.rb appropriate entries would look something like:
|
|
1089
1089
|
get("/#{controller_prefix}brick_status", to: 'brick_gem#status', as: status_as.to_s)
|
1090
1090
|
end
|
1091
1091
|
|
1092
|
+
# ::Brick.config.add_schema &&
|
1093
|
+
if (schema_as = "#{controller_prefix.tr('/', '_')}brick_schema".to_sym)
|
1094
|
+
(
|
1095
|
+
!(schema_route = instance_variable_get(:@set).named_routes.find { |route| route.first == schema_as }&.last) ||
|
1096
|
+
!schema_route.ast.to_s.include?("/#{controller_prefix}brick_schema/")
|
1097
|
+
)
|
1098
|
+
post("/#{controller_prefix}brick_schema", to: 'brick_gem#schema_create', as: schema_as.to_s)
|
1099
|
+
end
|
1100
|
+
|
1092
1101
|
if ::Brick.config.add_orphans && (orphans_as = "#{controller_prefix.tr('/', '_')}brick_orphans".to_sym)
|
1093
1102
|
(
|
1094
1103
|
!(orphans_route = instance_variable_get(:@set).named_routes.find { |route| route.first == orphans_as }&.last) ||
|
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.180
|
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-10-
|
11
|
+
date: 2023-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -164,20 +164,6 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 1.42.0
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: rswag-ui
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
181
167
|
- !ruby/object:Gem::Dependency
|
182
168
|
name: mysql2
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|