supercharts-bullet_train 1.1.0 β 1.2.0
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/views/account/scaffolding/completely_concrete/tangible_things/tangible_things_chart/show.html.erb +6 -24
- data/app/views/shared/supercharts/_filter_button.html.erb +8 -1
- data/lib/bullet_train/supercharts/engine.rb +2 -2
- data/lib/bullet_train/supercharts/scaffolders/chart_scaffolder.rb +2 -2
- data/lib/bullet_train/supercharts/version.rb +1 -1
- data/lib/scaffolding/app/controllers/account/scaffolding/completely_concrete/tangible_things/tangible_things_chart_controller.rb +11 -24
- data/lib/scaffolding/supercharts_chart_transformer.rb +72 -20
- data/lib/scaffolding/supercharts_routes_file_manipulator.rb +21 -23
- data/lib/scaffolding/supercharts_transformer.rb +11 -13
- 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: 9f028c4e4c0144a3cc864dc7dfbfe3b04fe80462c1e602325e4520746a1c7e85
|
4
|
+
data.tar.gz: e1871658b39073aed06174cca8dc9528939b89a6cd6560259d9bfddd80f993d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4eaf6186a0186806bfaa6f616305bf00f8140a9543fb355237b2d37c0954abf4fc9a10ad6d1f9cb3175bbd4a532813afe3a784ff3625a03945d5d8c4104f707
|
7
|
+
data.tar.gz: 53d1ef43b3227b868443a9bb5c845d23caaa6432d0b955959f8fe44d9a6260a5eb8d265f69ac7b82d8ceeb12c6d60a87dde9d72cade2bb803062a2832ca051df
|
@@ -24,13 +24,7 @@
|
|
24
24
|
<div class="relative">
|
25
25
|
<div data-supercharts--describable-target="overallDescription">
|
26
26
|
<h2 class="text-xs uppercase dark:text-white/50">
|
27
|
-
|
28
|
-
Tangible Things last 7 days
|
29
|
-
<% elsif @timespan == "1m" %>
|
30
|
-
Tangible Things last month
|
31
|
-
<% elsif @timespan == "ytd" %>
|
32
|
-
Tangible Things since start of year
|
33
|
-
<% end %>
|
27
|
+
<%= t(['tangible_things.chart.description', @timespan].join('.')) %>
|
34
28
|
</h2>
|
35
29
|
<p class="font-semibold dark:text-white mt-2" style="font-size: 1.8rem;">
|
36
30
|
<%= @total %>
|
@@ -40,13 +34,7 @@
|
|
40
34
|
<template data-supercharts--describable-target="contextualDescriptionTemplate">
|
41
35
|
<p class="font-semibold dark:text-white mb-1" style="font-size: 1.6rem;">%value%</p>
|
42
36
|
<p class="text-xs uppercase dark:text-white/50">
|
43
|
-
|
44
|
-
Tangible Things on <span class="whitespace-nowrap">%label%</span>
|
45
|
-
<% elsif @period == :week %>
|
46
|
-
Tangible Things in <span class="whitespace-nowrap">%label%</span>
|
47
|
-
<% elsif @period == :month %>
|
48
|
-
Tangible Things in <span class="whitespace-nowrap">%label%</span>
|
49
|
-
<% end %>
|
37
|
+
<%= t(['tangible_things.chart.contextual_description', @timespan].join('.')).html_safe %>
|
50
38
|
</p>
|
51
39
|
</template>
|
52
40
|
</div>
|
@@ -56,9 +44,9 @@
|
|
56
44
|
>
|
57
45
|
<div class="flex items-center justify-center">
|
58
46
|
<div class="inline-flex space-x-1" role="group">
|
59
|
-
<%= render "shared/supercharts/filter_button", path: polymorphic_path([:account, @absolutely_abstract_creative_concept, :tangible_things, :chart], timespan: "1w"),
|
60
|
-
<%= render "shared/supercharts/filter_button", path: polymorphic_path([:account, @absolutely_abstract_creative_concept, :tangible_things, :chart], timespan: "1m")
|
61
|
-
<%= render "shared/supercharts/filter_button", path: polymorphic_path([:account, @absolutely_abstract_creative_concept, :tangible_things, :chart], timespan: "ytd"),
|
47
|
+
<%= render "shared/supercharts/filter_button", label: t("tangible_things.chart.filters.1w.abbr"), alt: t("tangible_things.chart.filters.1w.label"), path: polymorphic_path([:account, @absolutely_abstract_creative_concept, :tangible_things, :chart], timespan: "1w"), first: true %>
|
48
|
+
<%= render "shared/supercharts/filter_button", label: t("tangible_things.chart.filters.1m.abbr"), alt: t("tangible_things.chart.filters.1m.label"), path: polymorphic_path([:account, @absolutely_abstract_creative_concept, :tangible_things, :chart], timespan: "1m") %>
|
49
|
+
<%= render "shared/supercharts/filter_button", label: t("tangible_things.chart.filters.ytd.abbr"), alt: t("tangible_things.chart.filters.ytd.label"), path: polymorphic_path([:account, @absolutely_abstract_creative_concept, :tangible_things, :chart], timespan: "ytd"), last: true %>
|
62
50
|
</div>
|
63
51
|
</div>
|
64
52
|
<template data-supercharts--filters-target="data">
|
@@ -77,13 +65,7 @@
|
|
77
65
|
data-action="update-chart->superchart#updateChart"
|
78
66
|
>
|
79
67
|
<canvas data-superchart-target="chartjsCanvas" style="height: var(--chart-height)">
|
80
|
-
|
81
|
-
Chart of Tangible Things last 7 days
|
82
|
-
<% elsif @timespan == "1m" %>
|
83
|
-
Chart of Tangible Things last month
|
84
|
-
<% elsif @timespan == "ytd" %>
|
85
|
-
Chart of Tangible Things since start of year
|
86
|
-
<% end %>
|
68
|
+
<%= t(['tangible_things.chart.alt_description', @timespan].join('.')) %>
|
87
69
|
</canvas>
|
88
70
|
<template data-superchart-target="csvData" data-supercharts--filterable-target="chartSourceData"></template>
|
89
71
|
<template data-superchart-target="chartjsOptions"></template>
|
@@ -2,8 +2,15 @@
|
|
2
2
|
first ||= false
|
3
3
|
last ||= false
|
4
4
|
label ||= "link"
|
5
|
+
alt ||= nil
|
5
6
|
path ||= ""
|
6
7
|
button_classes = "px-5 py-1.5 dark:text-white font-small text-xs leading-tight uppercase hover:bg-blue-800/50 hover:text-white focus:bg-blue-700 focus:outline-none focus:ring-0 active:bg-blue-800 transition duration-150 ease-in-out rounded-lg"
|
8
|
+
options = {
|
9
|
+
class: [button_classes, "bg-gray-400 dark:bg-blue-800 text-white hover:bg-blue-400 dark:hover:bg-blue-800/100": current_page?(path)]
|
10
|
+
}
|
11
|
+
unless alt.nil?
|
12
|
+
options[:title] = alt.upcase_first
|
13
|
+
end
|
7
14
|
%>
|
8
15
|
|
9
|
-
<%= link_to label, path,
|
16
|
+
<%= link_to label, path, options %>
|
@@ -3,9 +3,9 @@ module BulletTrain
|
|
3
3
|
class Engine < ::Rails::Engine
|
4
4
|
initializer "bullet_train.super_scaffolding.templates.register_template_path" do |app|
|
5
5
|
# Register the base path of this package with the Super Scaffolding engine.
|
6
|
-
BulletTrain::SuperScaffolding.template_paths << File.expand_path(
|
6
|
+
BulletTrain::SuperScaffolding.template_paths << File.expand_path("../../../..", __FILE__)
|
7
7
|
BulletTrain::SuperScaffolding.scaffolders.merge!({
|
8
|
-
"supercharts:chart" => "BulletTrain::Supercharts::Scaffolders::ChartScaffolder"
|
8
|
+
"supercharts:chart" => "BulletTrain::Supercharts::Scaffolders::ChartScaffolder"
|
9
9
|
})
|
10
10
|
end
|
11
11
|
end
|
@@ -19,14 +19,14 @@ module BulletTrain
|
|
19
19
|
puts ""
|
20
20
|
exit
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
target_model, parent_models = argv
|
24
24
|
parent_models = parent_models.split(",")
|
25
25
|
parent_models += ["Team"]
|
26
26
|
parent_models = parent_models.map(&:classify).uniq
|
27
27
|
|
28
28
|
transformer = Scaffolding::SuperchartsChartTransformer.new(target_model, parent_models)
|
29
|
-
|
29
|
+
|
30
30
|
transformer.scaffold_supercharts
|
31
31
|
end
|
32
32
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "csv"
|
2
2
|
|
3
3
|
class Account::Scaffolding::CompletelyConcrete::TangibleThings::TangibleThingsChartController < Account::ApplicationController
|
4
4
|
include ActionView::Helpers::NumberHelper
|
@@ -7,18 +7,18 @@ class Account::Scaffolding::CompletelyConcrete::TangibleThings::TangibleThingsCh
|
|
7
7
|
# GET /account/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things/chart
|
8
8
|
def show
|
9
9
|
@tangible_things = @absolutely_abstract_creative_concept.completely_concrete_tangible_things
|
10
|
-
|
10
|
+
|
11
11
|
@timespan = params[:timespan]
|
12
12
|
case @timespan
|
13
13
|
when "ytd"
|
14
14
|
range = Time.now.beginning_of_year..Time.now
|
15
15
|
range_days = (range.max - range.min).seconds.in_days
|
16
|
-
if range_days > 4.months.in_days
|
17
|
-
|
16
|
+
@period = if range_days > 4.months.in_days
|
17
|
+
:month
|
18
18
|
elsif range_days > 1.month.in_days
|
19
|
-
|
19
|
+
:week
|
20
20
|
else
|
21
|
-
|
21
|
+
:day
|
22
22
|
end
|
23
23
|
series = @tangible_things.group_by_period(@period, :created_at, range: range, expand_range: true)
|
24
24
|
when "1w"
|
@@ -30,26 +30,13 @@ class Account::Scaffolding::CompletelyConcrete::TangibleThings::TangibleThingsCh
|
|
30
30
|
@period = :day
|
31
31
|
series = @tangible_things.group_by_period(@period, :created_at, range: range)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
counts = series.count
|
35
35
|
@total = counts.values.reduce(:+)
|
36
|
-
|
37
|
-
date_format_abbr =
|
38
|
-
|
39
|
-
|
40
|
-
"Week of %b %e"
|
41
|
-
elsif @period == :month
|
42
|
-
"%b"
|
43
|
-
end
|
44
|
-
|
45
|
-
date_format_full = if @period == :day
|
46
|
-
"%B %e"
|
47
|
-
elsif @period == :week
|
48
|
-
"week of %B %e"
|
49
|
-
elsif @period == :month
|
50
|
-
"%B, %Y"
|
51
|
-
end
|
52
|
-
|
36
|
+
|
37
|
+
date_format_abbr = t(["tangible_things.chart.date_abbr", @period].join("."))
|
38
|
+
date_format_full = t(["tangible_things.chart.date_full", @period].join("."))
|
39
|
+
|
53
40
|
@csv = CSV.generate(" ", headers: %w[date_abbr date_full count count_formatted], write_headers: true, encoding: "UTF-8") do |csv|
|
54
41
|
counts.each do |date, count|
|
55
42
|
csv.add_row [date.strftime(date_format_abbr), date.strftime(date_format_full), count, number_with_delimiter(count)]
|
@@ -1,16 +1,18 @@
|
|
1
1
|
require "scaffolding/supercharts_transformer"
|
2
2
|
|
3
3
|
class Scaffolding::SuperchartsChartTransformer < Scaffolding::SuperchartsTransformer
|
4
|
+
RUBY_NEW_CHARTS_HOOK = "# π super scaffolding will insert new charts above this line."
|
5
|
+
|
4
6
|
def scaffold_supercharts
|
5
7
|
super
|
6
|
-
|
8
|
+
|
7
9
|
# copy files over and do the appropriate string replace.
|
8
10
|
files = [
|
9
11
|
"./lib/scaffolding/app/controllers/account/scaffolding/completely_concrete/tangible_things/tangible_things_chart_controller.rb",
|
10
12
|
"./app/views/account/scaffolding/completely_concrete/tangible_things/tangible_things_chart",
|
11
|
-
"./app/views/shared/supercharts"
|
13
|
+
"./app/views/shared/supercharts"
|
12
14
|
].compact
|
13
|
-
|
15
|
+
|
14
16
|
files.each do |name|
|
15
17
|
if File.directory?(resolve_template_path(name))
|
16
18
|
scaffold_directory(name)
|
@@ -18,14 +20,64 @@ class Scaffolding::SuperchartsChartTransformer < Scaffolding::SuperchartsTransfo
|
|
18
20
|
scaffold_file(name)
|
19
21
|
end
|
20
22
|
end
|
21
|
-
|
23
|
+
|
24
|
+
# locale
|
25
|
+
locale_file = "./config/locales/en/scaffolding/completely_concrete/tangible_things.en.yml"
|
26
|
+
|
27
|
+
# add locale file if missing
|
28
|
+
unless File.file?(transform_string(locale_file))
|
29
|
+
scaffold_file(locale_file)
|
30
|
+
add_locale_helper_export_fix
|
31
|
+
end
|
32
|
+
|
33
|
+
# add locale strings for chart
|
34
|
+
scaffold_add_line_to_file(locale_file, RUBY_NEW_CHARTS_HOOK, " account:", prepend: true, increase_indent: true, exact_match: true)
|
35
|
+
# ensure the right indentation
|
36
|
+
scaffold_replace_line_in_file(locale_file, " #{RUBY_NEW_CHARTS_HOOK}", " #{RUBY_NEW_CHARTS_HOOK}")
|
37
|
+
|
38
|
+
locale_yaml = <<~YAML
|
39
|
+
chart:
|
40
|
+
filters:
|
41
|
+
1w:
|
42
|
+
abbr: 1w
|
43
|
+
label: "last week"
|
44
|
+
1m:
|
45
|
+
abbr: 1m
|
46
|
+
label: "last month"
|
47
|
+
ytd:
|
48
|
+
abbr: ytd
|
49
|
+
label: "year to date"
|
50
|
+
description:
|
51
|
+
1w: Tangible Things last 7 days
|
52
|
+
1m: Tangible Things last month
|
53
|
+
ytd: Tangible Things since start of year
|
54
|
+
contextual_description:
|
55
|
+
1w: Tangible Things on <span class="whitespace-nowrap">%label%</span>
|
56
|
+
1m: Tangible Things in <span class="whitespace-nowrap">%label%</span>
|
57
|
+
ytd: Tangible Things in <span class="whitespace-nowrap">%label%</span>
|
58
|
+
alt_description:
|
59
|
+
1w: Chart of Tangible Things last 7 days
|
60
|
+
1m: Chart of Tangible Things last month
|
61
|
+
ytd: Chart of Tangible Things since start of year
|
62
|
+
date_abbr:
|
63
|
+
day: "%e"
|
64
|
+
week: "Week of %b %e"
|
65
|
+
month: "%b"
|
66
|
+
date_full:
|
67
|
+
day: "%B %e"
|
68
|
+
week: "week of %B %e"
|
69
|
+
month: "%B, %Y"
|
70
|
+
YAML
|
71
|
+
|
72
|
+
scaffold_add_line_to_file("./config/locales/en/scaffolding/completely_concrete/tangible_things.en.yml", locale_yaml, RUBY_NEW_CHARTS_HOOK, prepend: true)
|
73
|
+
|
22
74
|
# add children to the show page of their parent.
|
23
75
|
unless cli_options["skip-parent"] || parent == "None"
|
24
76
|
lines_to_add = <<~RUBY
|
25
77
|
<div class="mt-4 [--chart-height:150px] md:[--chart-height:200px]">
|
26
78
|
<%= turbo_frame_tag :charts_tangible_things, src: polymorphic_path([:account, @creative_concept, :tangible_things, :chart], timespan: "1m") do %>
|
27
79
|
<%= render "shared/supercharts/chart_skeleton" do %>
|
28
|
-
|
80
|
+
<%= t('tangible_things.label') %>…
|
29
81
|
<% end %>
|
30
82
|
<% end %>
|
31
83
|
</div>
|
@@ -37,53 +89,53 @@ class Scaffolding::SuperchartsChartTransformer < Scaffolding::SuperchartsTransfo
|
|
37
89
|
prepend: true
|
38
90
|
)
|
39
91
|
end
|
40
|
-
|
92
|
+
|
41
93
|
# add user permissions.
|
42
94
|
add_ability_line_to_roles_yml
|
43
|
-
|
95
|
+
|
44
96
|
# apply routes.
|
45
97
|
# TODO this is a hack and should be in its own RouteFileManipulator class
|
46
98
|
lines = File.read("config/routes.rb").lines.map(&:chomp)
|
47
99
|
account_namespace_found = false
|
48
|
-
|
100
|
+
|
49
101
|
lines.each_with_index do |line, index|
|
50
102
|
if line.match?("namespace :account do")
|
51
103
|
account_namespace_found = true
|
52
104
|
elsif account_namespace_found && line.match?(transform_string("resources :tangible_things"))
|
53
105
|
chart_resource_lines = transform_string("collection do\nresource :chart, only: :show, module: :tangible_things, as: :tangible_things_chart, controller: :tangible_things_chart\nend")
|
54
|
-
if line.match?
|
55
|
-
|
106
|
+
lines[index] = if line.match?(/do$/)
|
107
|
+
"#{line}\n#{chart_resource_lines}\n"
|
56
108
|
else
|
57
|
-
|
109
|
+
"#{line} do\n#{chart_resource_lines}\nend"
|
58
110
|
end
|
59
111
|
end
|
60
112
|
end
|
61
|
-
|
113
|
+
|
62
114
|
File.write("config/routes.rb", lines.join("\n"))
|
63
|
-
|
115
|
+
|
64
116
|
puts `standardrb --fix ./config/routes.rb`
|
65
|
-
|
117
|
+
|
66
118
|
restart_server unless ENV["CI"].present?
|
67
119
|
end
|
68
|
-
|
120
|
+
|
69
121
|
def parent_show_file
|
70
122
|
@target_show_file ||= "./app/views/account/scaffolding/absolutely_abstract/creative_concepts/show.html.erb"
|
71
123
|
end
|
72
|
-
|
124
|
+
|
73
125
|
def transform_string(string)
|
74
126
|
[
|
75
127
|
"Scaffolding::CompletelyConcrete::TangibleThings::TangibleThingsChart",
|
76
|
-
"lib/scaffolding/app"
|
128
|
+
"lib/scaffolding/app"
|
77
129
|
].each do |needle|
|
78
130
|
# TODO There might be more to do here?
|
79
131
|
# What method is this calling?
|
80
132
|
string = string.gsub(needle, encode_double_replacement_fix(replacement_for(needle)))
|
81
133
|
end
|
82
|
-
|
134
|
+
|
83
135
|
string = super(string)
|
84
136
|
decode_double_replacement_fix(string)
|
85
137
|
end
|
86
|
-
|
138
|
+
|
87
139
|
def replacement_for(string)
|
88
140
|
case string
|
89
141
|
when "Scaffolding::CompletelyConcrete::TangibleThings::TangibleThingsChart"
|
@@ -94,4 +146,4 @@ class Scaffolding::SuperchartsChartTransformer < Scaffolding::SuperchartsTransfo
|
|
94
146
|
"π"
|
95
147
|
end
|
96
148
|
end
|
97
|
-
end
|
149
|
+
end
|
@@ -1,85 +1,83 @@
|
|
1
1
|
class Scaffolding::SuperchartsRoutesFileManipulator < Scaffolding::RoutesFileManipulator
|
2
|
-
|
3
2
|
def apply(base_namespaces, prepend_namespace_to_child: nil)
|
4
3
|
child_namespaces, child_resource, parent_namespaces, parent_resource = divergent_parts
|
5
|
-
|
4
|
+
|
6
5
|
within = find_or_create_namespaces(base_namespaces)
|
7
|
-
|
6
|
+
|
8
7
|
# e.g. Project and Projects::Deliverable
|
9
8
|
if parent_namespaces.empty? && child_namespaces.one? && parent_resource == child_namespaces.first
|
10
|
-
|
9
|
+
|
11
10
|
# resources :projects do
|
12
11
|
# scope module: 'projects' do
|
13
12
|
# resources :deliverables, only: collection_actions
|
14
13
|
# end
|
15
14
|
# end
|
16
|
-
|
15
|
+
|
17
16
|
parent_within = find_or_convert_resource_block(parent_resource, within: within)
|
18
|
-
|
17
|
+
|
19
18
|
# add the new resource within that namespace.
|
20
19
|
line = "scope module: '#{parent_resource}' do"
|
21
20
|
# TODO you haven't tested this yet.
|
22
21
|
unless (scope_within = find(/#{line}/, parent_within))
|
23
22
|
scope_within = insert([line, "end"], parent_within)
|
24
23
|
end
|
25
|
-
|
24
|
+
|
26
25
|
find_or_create_resource([child_resource], options: "only: collection_actions", within: scope_within)
|
27
|
-
|
26
|
+
|
28
27
|
# namespace :projects do
|
29
28
|
# resources :deliverables, except: collection_actions
|
30
29
|
# end
|
31
|
-
|
30
|
+
|
32
31
|
# We want to see if there are any namespaces one level above the parent itself,
|
33
32
|
# because namespaces with the same name as the resource can exist on the same level.
|
34
33
|
parent_block_start = find_block_parent(parent_within)
|
35
34
|
namespace_line_within = find_or_create_namespaces(child_namespaces, parent_block_start)
|
36
|
-
|
35
|
+
|
37
36
|
if prepend_namespace_to_child.present?
|
38
37
|
namespace_line_within = find_or_create_namespaces([prepend_namespace_to_child], namespace_line_within)
|
39
38
|
end
|
40
|
-
|
39
|
+
|
41
40
|
find_or_create_resource([child_resource], options: "except: collection_actions", within: namespace_line_within)
|
42
41
|
unless find_namespaces(child_namespaces, within)[child_namespaces.last]
|
43
42
|
raise "tried to insert `namespace :#{child_namespaces.last}` but it seems we failed"
|
44
43
|
end
|
45
|
-
|
44
|
+
|
46
45
|
# e.g. Projects::Deliverable and Objective Under It, Abstract::Concept and Concrete::Thing
|
47
46
|
elsif parent_namespaces.any?
|
48
|
-
|
47
|
+
|
49
48
|
# namespace :projects do
|
50
49
|
# resources :deliverables
|
51
50
|
# end
|
52
51
|
top_parent_namespace = find_namespaces(parent_namespaces, within)[parent_namespaces.first]
|
53
|
-
|
52
|
+
|
54
53
|
find_or_create_resource(child_namespaces + [child_resource], within: top_parent_namespace)
|
55
|
-
|
54
|
+
|
56
55
|
# resources :projects_deliverables, path: 'projects/deliverables' do
|
57
56
|
# resources :objectives
|
58
57
|
# end
|
59
58
|
block_parent_within = find_block_parent(top_parent_namespace)
|
60
59
|
parent_namespaces_and_resource = (parent_namespaces + [parent_resource]).join("_")
|
61
60
|
parent_within = find_or_create_resource_block([parent_namespaces_and_resource], options: "path: '#{parent_namespaces_and_resource.tr("_", "/")}'", within: block_parent_within)
|
62
|
-
|
61
|
+
|
63
62
|
if prepend_namespace_to_child.present?
|
64
63
|
parent_within = find_or_create_namespaces([prepend_namespace_to_child], parent_within)
|
65
64
|
end
|
66
|
-
|
65
|
+
|
67
66
|
find_or_create_resource(child_namespaces + [child_resource], within: parent_within)
|
68
67
|
else
|
69
|
-
|
68
|
+
|
70
69
|
begin
|
71
70
|
within = find_or_convert_resource_block(parent_resource, within: within)
|
72
71
|
rescue
|
73
72
|
within = find_or_convert_resource_block(parent_resource, options: "except: collection_actions", within: within)
|
74
73
|
end
|
75
|
-
|
74
|
+
|
76
75
|
if prepend_namespace_to_child.present?
|
77
76
|
within = find_or_create_namespaces([prepend_namespace_to_child], within)
|
78
77
|
end
|
79
|
-
|
78
|
+
|
80
79
|
find_or_create_resource(child_namespaces + [child_resource], options: define_concerns, within: within)
|
81
|
-
|
80
|
+
|
82
81
|
end
|
83
82
|
end
|
84
|
-
|
85
|
-
end
|
83
|
+
end
|
@@ -2,18 +2,16 @@ class Scaffolding::SuperchartsTransformer < Scaffolding::Transformer
|
|
2
2
|
def initialize(child, parents, cli_options = {})
|
3
3
|
super(child, parents, cli_options)
|
4
4
|
end
|
5
|
-
|
5
|
+
|
6
6
|
def scaffold_supercharts
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
+
# Update the routes to add the namespace and base resource
|
8
|
+
routes_manipulator = Scaffolding::RoutesFileManipulator.new("config/routes.rb", transform_string("Scaffolding::CompletelyConcrete::TangibleThings"), transform_string("Scaffolding::AbsolutelyAbstract::CreativeConcept"))
|
9
|
+
routes_manipulator.apply(["account"])
|
10
|
+
Scaffolding::FileManipulator.write("config/routes.rb", routes_manipulator.lines)
|
11
|
+
rescue BulletTrain::SuperScaffolding::CannotFindParentResourceException => exception
|
12
|
+
# TODO It would be great if we could automatically generate whatever the structure of the route needs to be and
|
13
|
+
# tell them where to try and inject it. Obviously we can't calculate the line number, otherwise the robots would
|
14
|
+
# have already inserted the routes, but at least we can try to do some of the complicated work for them.
|
15
|
+
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. ππ»ββοΈ"
|
18
16
|
end
|
19
|
-
end
|
17
|
+
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pascal LalibertΓ©
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|