supercharts-bullet_train 0.1.4 → 0.1.5
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/controllers/account/scaffolding/completely_concrete/{charts/tangible_things_controller.rb → tangible_things/tangible_things_chart_controller.rb} +6 -4
- data/app/views/account/scaffolding/completely_concrete/{charts/tangible_things → tangible_things/tangible_things_chart}/_breadcrumbs.html.erb +0 -0
- data/app/views/account/scaffolding/completely_concrete/{charts/tangible_things/index.html.erb → tangible_things/tangible_things_chart/show.html.erb} +2 -2
- data/lib/bullet_train/supercharts/version.rb +1 -1
- data/lib/scaffolding/supercharts_chart_transformer.rb +21 -47
- data/lib/scaffolding/supercharts_transformer.rb +11 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45c0bd86dbe047792cab708063e2c7e6184ea4c17631c505c4eff8b3631bd80c
|
4
|
+
data.tar.gz: d4613278a0aca3aa0930984e91b1081342dbd9aaa7967214114e824dabbd2e38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1076e3c5d9eb36bb6c15e270a765a64391f9744ca1740e3629b94461e5a8809eee6c8c04a1d75c91a53c306b311664b535af4c79c0f2d5161f154856494164ee
|
7
|
+
data.tar.gz: 6b334f93446421ca5be46ae2dae2c574534d2433968df7fcd796fbfe4e87ec88488fc0c1d11ce3f30c825e993afe9c536adb889c3b1d1a86e306a13c807c6d1b
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'csv'
|
2
2
|
|
3
|
-
class Account::Scaffolding::CompletelyConcrete::
|
4
|
-
account_load_and_authorize_resource :tangible_thing, through: :absolutely_abstract_creative_concept, through_association: :completely_concrete_tangible_things
|
3
|
+
class Account::Scaffolding::CompletelyConcrete::TangibleThings::TangibleThingsChartController < Account::ApplicationController
|
4
|
+
account_load_and_authorize_resource :tangible_thing, through: :absolutely_abstract_creative_concept, through_association: :completely_concrete_tangible_things, collection_actions: [:show]
|
5
5
|
|
6
|
-
# GET /account/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/
|
7
|
-
def
|
6
|
+
# GET /account/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things/chart
|
7
|
+
def show
|
8
|
+
@tangible_things = @absolutely_abstract_creative_concept.completely_concrete_tangible_things
|
9
|
+
|
8
10
|
@timespan = params[:timespan]
|
9
11
|
case @timespan
|
10
12
|
when "ytd"
|
File without changes
|
@@ -23,8 +23,8 @@
|
|
23
23
|
>
|
24
24
|
<div class="flex items-center justify-center">
|
25
25
|
<div class="inline-flex space-x-1" role="group">
|
26
|
-
<%= render "shared/supercharts/filter_button", path: polymorphic_path([:account, @absolutely_abstract_creative_concept, :
|
27
|
-
<%= render "shared/supercharts/filter_button", path: polymorphic_path([:account, @absolutely_abstract_creative_concept, :
|
26
|
+
<%= render "shared/supercharts/filter_button", path: polymorphic_path([:account, @absolutely_abstract_creative_concept, :tangible_things, :chart], timespan: "1m"), label: "1m", first: true %>
|
27
|
+
<%= render "shared/supercharts/filter_button", path: polymorphic_path([:account, @absolutely_abstract_creative_concept, :tangible_things, :chart], timespan: "ytd"), label: "ytd", last: true %>
|
28
28
|
</div>
|
29
29
|
</div>
|
30
30
|
<template data-supercharts--filters-target="data">
|
@@ -6,8 +6,8 @@ class Scaffolding::SuperchartsChartTransformer < Scaffolding::SuperchartsTransfo
|
|
6
6
|
|
7
7
|
# copy files over and do the appropriate string replace.
|
8
8
|
files = [
|
9
|
-
"./app/controllers/account/scaffolding/completely_concrete/
|
10
|
-
"./app/views/account/scaffolding/completely_concrete/
|
9
|
+
"./app/controllers/account/scaffolding/completely_concrete/tangible_things/tangible_things_chart_controller.rb",
|
10
|
+
"./app/views/account/scaffolding/completely_concrete/tangible_things/tangible_things_chart",
|
11
11
|
"./app/views/shared/supercharts",
|
12
12
|
].compact
|
13
13
|
|
@@ -23,7 +23,7 @@ class Scaffolding::SuperchartsChartTransformer < Scaffolding::SuperchartsTransfo
|
|
23
23
|
unless cli_options["skip-parent"] || parent == "None"
|
24
24
|
lines_to_add = <<~RUBY
|
25
25
|
<div class="mt-4">
|
26
|
-
<%= turbo_frame_tag :charts_tangible_things, src: polymorphic_path([:account, @creative_concept, :
|
26
|
+
<%= turbo_frame_tag :charts_tangible_things, src: polymorphic_path([:account, @creative_concept, :tangible_things, :chart], timespan: "1m") do %>
|
27
27
|
<% end %>
|
28
28
|
</div>
|
29
29
|
RUBY
|
@@ -36,50 +36,27 @@ class Scaffolding::SuperchartsChartTransformer < Scaffolding::SuperchartsTransfo
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# apply routes.
|
39
|
-
|
40
|
-
|
39
|
+
# TODO this is a hack and should be in its own RouteFileManipulator class
|
40
|
+
lines = File.read("config/routes.rb").lines.map(&:chomp)
|
41
|
+
account_namespace_found = false
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
lines.each_with_index do |line, index|
|
44
|
+
if line.match?("namespace :account do")
|
45
|
+
account_namespace_found = true
|
46
|
+
elsif account_namespace_found && line.match?(transform_string("resources :tangible_things"))
|
47
|
+
chart_resource_lines = transform_string("collection do\nresource :chart, only: :show, module: :tangible_things, as: :tangible_things_chart, controller: :tangible_things_chart\nend")
|
48
|
+
if line.match? /do$/
|
49
|
+
lines[index] = "#{line}\n#{chart_resource_lines}\n"
|
45
50
|
else
|
46
|
-
"
|
51
|
+
lines[index] = "#{line} do\n#{chart_resource_lines}\nend"
|
47
52
|
end
|
48
|
-
routes_manipulator = Scaffolding::SuperchartsRoutesFileManipulator.new(routes_path, child, parent, cli_options)
|
49
|
-
rescue Errno::ENOENT => _
|
50
|
-
puts "Creating '#{routes_path}'.".green
|
51
|
-
|
52
|
-
unless File.directory?("config/routes")
|
53
|
-
FileUtils.mkdir_p("config/routes")
|
54
|
-
end
|
55
|
-
|
56
|
-
File.write(routes_path, <<~RUBY)
|
57
|
-
collection_actions = [:index, :new, :create]
|
58
|
-
|
59
|
-
# 🚅 Don't remove this block, it will break Super Scaffolding.
|
60
|
-
begin do
|
61
|
-
namespace :#{routes_namespace} do
|
62
|
-
shallow do
|
63
|
-
resources :teams do
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
RUBY
|
69
|
-
|
70
|
-
retry
|
71
53
|
end
|
72
|
-
|
73
|
-
begin
|
74
|
-
routes_manipulator.apply([routes_namespace], prepend_namespace_to_child: "charts")
|
75
|
-
rescue StandardError => e
|
76
|
-
p e
|
77
|
-
add_additional_step :yellow, "We weren't able to automatically add your `#{routes_namespace}` routes for you. In theory this should be very rare, so if you could reach out on Slack, you could probably provide context that will help us fix whatever the problem was. In the meantime, to add the routes manually, we've got a guide at https://blog.bullettrain.co/nested-namespaced-rails-routing-examples/ ."
|
78
|
-
end
|
79
|
-
|
80
|
-
Scaffolding::FileManipulator.write("config/routes.rb", routes_manipulator.lines)
|
81
54
|
end
|
82
55
|
|
56
|
+
File.write("config/routes.rb", lines.join("\n"))
|
57
|
+
|
58
|
+
puts `standardrb --fix ./config/routes.rb`
|
59
|
+
|
83
60
|
restart_server unless ENV["CI"].present?
|
84
61
|
end
|
85
62
|
|
@@ -89,8 +66,7 @@ class Scaffolding::SuperchartsChartTransformer < Scaffolding::SuperchartsTransfo
|
|
89
66
|
|
90
67
|
def transform_string(string)
|
91
68
|
[
|
92
|
-
"Scaffolding::CompletelyConcrete::
|
93
|
-
"scaffolding/completely_concrete/charts/tangible_things",
|
69
|
+
"Scaffolding::CompletelyConcrete::TangibleThings::TangibleThingsChart",
|
94
70
|
].each do |needle|
|
95
71
|
# TODO There might be more to do here?
|
96
72
|
# What method is this calling?
|
@@ -103,10 +79,8 @@ class Scaffolding::SuperchartsChartTransformer < Scaffolding::SuperchartsTransfo
|
|
103
79
|
|
104
80
|
def replacement_for(string)
|
105
81
|
case string
|
106
|
-
when "Scaffolding::CompletelyConcrete::
|
107
|
-
"
|
108
|
-
when "scaffolding/completely_concrete/charts/tangible_things"
|
109
|
-
"charts/" + child.underscore.pluralize
|
82
|
+
when "Scaffolding::CompletelyConcrete::TangibleThings::TangibleThingsChart"
|
83
|
+
child.pluralize + "::" + child.pluralize + "Chart"
|
110
84
|
else
|
111
85
|
"🛑"
|
112
86
|
end
|
@@ -4,5 +4,16 @@ class Scaffolding::SuperchartsTransformer < Scaffolding::Transformer
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def scaffold_supercharts
|
7
|
+
begin
|
8
|
+
# Update the routes to add the namespace and base resource
|
9
|
+
routes_manipulator = Scaffolding::RoutesFileManipulator.new("config/routes.rb", transform_string("Scaffolding::CompletelyConcrete::TangibleThings"), transform_string("Scaffolding::AbsolutelyAbstract::CreativeConcept"))
|
10
|
+
routes_manipulator.apply(["account"])
|
11
|
+
Scaffolding::FileManipulator.write("config/routes.rb", routes_manipulator.lines)
|
12
|
+
rescue BulletTrain::SuperScaffolding::CannotFindParentResourceException => exception
|
13
|
+
# TODO It would be great if we could automatically generate whatever the structure of the route needs to be and
|
14
|
+
# tell them where to try and inject it. Obviously we can't calculate the line number, otherwise the robots would
|
15
|
+
# have already inserted the routes, but at least we can try to do some of the complicated work for them.
|
16
|
+
add_additional_step :red, "We were not able to generate the routes for your Action Model automatically because: \"#{exception.message}\" You'll need to add them manually, which admittedly can be complicated. See https://blog.bullettrain.co/nested-namespaced-rails-routing-examples/ for guidance. 🙇🏻♂️"
|
17
|
+
end
|
7
18
|
end
|
8
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: supercharts-bullet_train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pascal Laliberté
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -44,14 +44,14 @@ files:
|
|
44
44
|
- app/assets/javascripts/supercharts-bullet-train.modern.mjs.map
|
45
45
|
- app/assets/javascripts/supercharts-bullet-train.umd.js
|
46
46
|
- app/assets/javascripts/supercharts-bullet-train.umd.js.map
|
47
|
-
- app/controllers/account/scaffolding/completely_concrete/
|
47
|
+
- app/controllers/account/scaffolding/completely_concrete/tangible_things/tangible_things_chart_controller.rb
|
48
48
|
- app/javascript/controllers/index.js
|
49
49
|
- app/javascript/controllers/superchart_controller.js
|
50
50
|
- app/javascript/controllers/supercharts/filterable_controller.js
|
51
51
|
- app/javascript/controllers/supercharts/filters_controller.js
|
52
52
|
- app/javascript/index.js
|
53
|
-
- app/views/account/scaffolding/completely_concrete/
|
54
|
-
- app/views/account/scaffolding/completely_concrete/
|
53
|
+
- app/views/account/scaffolding/completely_concrete/tangible_things/tangible_things_chart/_breadcrumbs.html.erb
|
54
|
+
- app/views/account/scaffolding/completely_concrete/tangible_things/tangible_things_chart/show.html.erb
|
55
55
|
- app/views/shared/supercharts/_filter_button.html.erb
|
56
56
|
- config/routes.rb
|
57
57
|
- lib/bullet_train/supercharts.rb
|