brick 1.0.178 → 1.0.179

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: 888b7144102e5155a28f931b7b986a68a3eb781dee890990fae9f81ed8bf2e21
4
- data.tar.gz: c5fcc9dd02f6b45025d600e9a02a16011e93559568c63c24b4acde0f603a2540
3
+ metadata.gz: 54b14ce2c9b998599c3fd529f0a718a85365c49f7405a97e698155e2b9cf22be
4
+ data.tar.gz: e1337a86afb957dc8a5545090dc667534bbf792266e82f4654a55611b92b7e18
5
5
  SHA512:
6
- metadata.gz: f8f32f40106be993ee33bac87ef4dad4558e7bcbae61f6f61658671b825eba6312586f75fdc329c22a3a2898a2d38e568c70e05ca173e9824637226ce28aaee3
7
- data.tar.gz: e3e0fa0646201059751ecf8fdd30860d582aa3e746ceeb3c6cac276aa831dcefe6a9fc8de34f6e4a720fcd5503842192e8cd8f33ceed37cb6087000d342223ee
6
+ metadata.gz: c0bee060354c43c662e41e247957f896d7680af9b11cd4109e4ad32ef4b5b8bf907f64d2ed66d32bb59522addb540d1dc3a9e4812f2fdfc1dd6eb6a4da6e516a
7
+ data.tar.gz: a44dc906d317e74100463a1ffb18935e91ee7a818727131fa4813f5329cbc0db07f7995d08246d32052239d4a6bae15db8db4de51cfcdb0c3d250b08e341d4ee
@@ -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, uses_transaction: false) do |conn|
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}brick_orphans\">(Crosstab)</option>".html_safe if is_crosstab
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(location.href, options).then(success);
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\" class=\"mermaid\">
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
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 178
8
+ TINY = 179
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
data/lib/brick.rb CHANGED
@@ -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.178
4
+ version: 1.0.179
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-02 00:00:00.000000000 Z
11
+ date: 2023-10-07 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