hot-glue 0.5.2 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +15 -0
- data/.gitignore +3 -1
- data/.ruby-version +1 -0
- data/.travis.yml +2 -2
- data/Gemfile +17 -7
- data/LICENSE +2 -16
- data/README.md +188 -92
- data/README2.md +0 -2
- data/config/database.yml +22 -8
- data/db/schema.rb +149 -0
- data/lib/generators/hot_glue/install_generator.rb +1 -55
- data/lib/generators/hot_glue/scaffold_generator.rb +85 -5
- data/lib/generators/hot_glue/templates/controller.rb.erb +15 -44
- data/lib/generators/hot_glue/templates/erb/_line.erb +2 -2
- data/lib/generators/hot_glue/templates/erb/_list.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_new_button.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_new_form.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/create.turbo_stream.erb +2 -2
- data/lib/generators/hot_glue/templates/erb/destroy.turbo_stream.erb +2 -2
- data/lib/generators/hot_glue/templates/erb/edit.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/edit.turbo_stream.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +1 -1
- data/lib/generators/hot_glue/templates/system_spec.rb.erb +11 -124
- data/lib/hotglue/version.rb +1 -1
- data/script/clean_generated_code +20 -0
- data/script/test +47 -0
- metadata +10 -8
- data/.circleci/config.yml +0 -71
- data/Gemfile.lock +0 -230
- data/Rakefile +0 -42
- data/bin/rails +0 -14
- data/db/schema.rb +0 -1
data/db/schema.rb
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema[7.0].define(version: 2022_03_23_000410) do
|
14
|
+
create_table "abcs", force: :cascade do |t|
|
15
|
+
t.string "name"
|
16
|
+
t.datetime "created_at", null: false
|
17
|
+
t.datetime "updated_at", null: false
|
18
|
+
end
|
19
|
+
|
20
|
+
create_table "appointments", force: :cascade do |t|
|
21
|
+
t.integer "pet_id"
|
22
|
+
t.datetime "created_at", null: false
|
23
|
+
t.datetime "updated_at", null: false
|
24
|
+
end
|
25
|
+
|
26
|
+
create_table "atw_display_names", force: :cascade do |t|
|
27
|
+
t.string "display_name"
|
28
|
+
t.integer "xyz_id"
|
29
|
+
t.datetime "created_at", null: false
|
30
|
+
t.datetime "updated_at", null: false
|
31
|
+
end
|
32
|
+
|
33
|
+
create_table "atw_full_names", force: :cascade do |t|
|
34
|
+
t.string "full_name"
|
35
|
+
t.integer "xyz_id"
|
36
|
+
t.datetime "created_at", null: false
|
37
|
+
t.datetime "updated_at", null: false
|
38
|
+
end
|
39
|
+
|
40
|
+
create_table "atw_to_labels", force: :cascade do |t|
|
41
|
+
t.string "to_label"
|
42
|
+
t.integer "xyz_id"
|
43
|
+
t.datetime "created_at", null: false
|
44
|
+
t.datetime "updated_at", null: false
|
45
|
+
end
|
46
|
+
|
47
|
+
create_table "borkeds", force: :cascade do |t|
|
48
|
+
t.integer "xyz_id"
|
49
|
+
t.integer "missing_label_table_id"
|
50
|
+
t.datetime "created_at", null: false
|
51
|
+
t.datetime "updated_at", null: false
|
52
|
+
end
|
53
|
+
|
54
|
+
create_table "cantelopes", force: :cascade do |t|
|
55
|
+
t.string "name"
|
56
|
+
t.string "_a_show_only_field"
|
57
|
+
t.datetime "created_at", null: false
|
58
|
+
t.datetime "updated_at", null: false
|
59
|
+
end
|
60
|
+
|
61
|
+
create_table "dfgs", force: :cascade do |t|
|
62
|
+
t.integer "user_id"
|
63
|
+
t.string "name"
|
64
|
+
t.datetime "created_at", null: false
|
65
|
+
t.datetime "updated_at", null: false
|
66
|
+
t.integer "cantelope_id"
|
67
|
+
end
|
68
|
+
|
69
|
+
create_table "families", force: :cascade do |t|
|
70
|
+
t.string "name"
|
71
|
+
t.datetime "created_at", null: false
|
72
|
+
t.datetime "updated_at", null: false
|
73
|
+
end
|
74
|
+
|
75
|
+
create_table "ghis", force: :cascade do |t|
|
76
|
+
t.integer "dfg_id"
|
77
|
+
t.integer "xyz_id"
|
78
|
+
t.datetime "created_at", null: false
|
79
|
+
t.datetime "updated_at", null: false
|
80
|
+
end
|
81
|
+
|
82
|
+
create_table "hgis", force: :cascade do |t|
|
83
|
+
t.string "name"
|
84
|
+
t.integer "how_many"
|
85
|
+
t.text "hello"
|
86
|
+
t.datetime "created_at", null: false
|
87
|
+
t.datetime "updated_at", null: false
|
88
|
+
end
|
89
|
+
|
90
|
+
create_table "humen", force: :cascade do |t|
|
91
|
+
t.string "name"
|
92
|
+
t.datetime "created_at", null: false
|
93
|
+
t.datetime "updated_at", null: false
|
94
|
+
end
|
95
|
+
|
96
|
+
create_table "jkls", force: :cascade do |t|
|
97
|
+
t.integer "hgi_id"
|
98
|
+
t.string "name"
|
99
|
+
t.string "blurb"
|
100
|
+
t.text "long_description"
|
101
|
+
t.float "cost"
|
102
|
+
t.integer "how_many_printed"
|
103
|
+
t.datetime "approved_at", precision: nil
|
104
|
+
t.date "release_on"
|
105
|
+
t.time "time_of_day"
|
106
|
+
t.boolean "selected"
|
107
|
+
t.integer "genre"
|
108
|
+
t.datetime "created_at", null: false
|
109
|
+
t.datetime "updated_at", null: false
|
110
|
+
end
|
111
|
+
|
112
|
+
create_table "missing_label_tables", force: :cascade do |t|
|
113
|
+
t.datetime "created_at", null: false
|
114
|
+
t.datetime "updated_at", null: false
|
115
|
+
end
|
116
|
+
|
117
|
+
create_table "pets", force: :cascade do |t|
|
118
|
+
t.string "name"
|
119
|
+
t.integer "human_id"
|
120
|
+
t.datetime "created_at", null: false
|
121
|
+
t.datetime "updated_at", null: false
|
122
|
+
end
|
123
|
+
|
124
|
+
create_table "users", force: :cascade do |t|
|
125
|
+
t.string "email", default: "", null: false
|
126
|
+
t.string "encrypted_password", default: "", null: false
|
127
|
+
t.string "reset_password_token"
|
128
|
+
t.datetime "reset_password_sent_at", precision: nil
|
129
|
+
t.datetime "remember_created_at", precision: nil
|
130
|
+
t.integer "family_id"
|
131
|
+
t.datetime "created_at", null: false
|
132
|
+
t.datetime "updated_at", null: false
|
133
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
134
|
+
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
135
|
+
end
|
136
|
+
|
137
|
+
create_table "visits", force: :cascade do |t|
|
138
|
+
t.string "name"
|
139
|
+
t.integer "user_id"
|
140
|
+
t.datetime "created_at", null: false
|
141
|
+
t.datetime "updated_at", null: false
|
142
|
+
end
|
143
|
+
|
144
|
+
create_table "xyzs", force: :cascade do |t|
|
145
|
+
t.integer "nothing_id"
|
146
|
+
t.datetime "created_at", null: false
|
147
|
+
t.datetime "updated_at", null: false
|
148
|
+
end
|
149
|
+
end
|
@@ -26,58 +26,6 @@ module HotGlue
|
|
26
26
|
puts "IMPORTANT: You have selected to install Hot Glue with Bootstrap layout (legacy). Be sure to always use ``--layout=bootstrap` when building your scaffold. No Hot Glue theme will be installed at this time.` "
|
27
27
|
end
|
28
28
|
|
29
|
-
### INTERACTIVE LICENSING
|
30
|
-
|
31
|
-
|
32
|
-
print "Do you have a license key (y/N)? "
|
33
|
-
do_you_have_a_license = STDIN.gets.strip || "N"
|
34
|
-
|
35
|
-
if do_you_have_a_license.downcase == "y"
|
36
|
-
print "Please enter the EMAIL you used to purchase a Hot Glue license, \nTeachable tutorial, or Helios Merch Shop product: "
|
37
|
-
license_email = STDIN.gets.strip
|
38
|
-
require 'open-uri'
|
39
|
-
|
40
|
-
# ask HeliosDev.shop if this email is good
|
41
|
-
stream = URI.open("https://heliosdev.shop/check_licenses/hot-glue?email=#{license_email}")
|
42
|
-
resp = JSON.parse(stream.read)
|
43
|
-
|
44
|
-
if resp['status'] == 'success'
|
45
|
-
if resp['redirect']
|
46
|
-
HotGlue::Helpers.open_page(resp['redirect'])
|
47
|
-
end
|
48
|
-
puts "\n" + " * " + resp['response'] + " * \n\n"
|
49
|
-
else
|
50
|
-
puts "\n" + " * " + resp['response'] + " * \n\n"
|
51
|
-
|
52
|
-
print "You can get a license in one of the follow ways: \n"
|
53
|
-
print "https://heliosdev.shop/hot-glue-license \n"
|
54
|
-
print "https://jfb.teachable.com/p/hot-glue-in-depth-tutorial \n"
|
55
|
-
print "https://shop.heliosdev.shop/ \n"
|
56
|
-
print "All purchases come with a Hot Glue lifetime license for individuals and hobbyists\n"
|
57
|
-
return
|
58
|
-
end
|
59
|
-
else
|
60
|
-
print "Please pick an option to get a Hot Glue license: \n"
|
61
|
-
print "1) Professional/Business with support (see heliosdev.shop/hot-glue-license for prices) \n"
|
62
|
-
print "2) Individual/hobbyist: Get the tutorial on Teachable ($60) \n"
|
63
|
-
print "3) Individual/hobbyist: Get some merchandise ($5 and up) \n"
|
64
|
-
print "Please type 1, 2, or 3: "
|
65
|
-
choice = STDIN.gets.strip
|
66
|
-
|
67
|
-
if choice == "1"
|
68
|
-
HotGlue::Helpers.open_page("https://heliosdev.shop/hot-glue-license?utm_campaing=hotglue-installer")
|
69
|
-
elsif choice == "2"
|
70
|
-
HotGlue::Helpers.open_page("https://jfb.teachable.com/p/hot-glue-in-depth-tutorial?utm_source=hotglue-installer")
|
71
|
-
print "All purchases come with a Hot Glue lifetime license for individuals and hobbyists\n"
|
72
|
-
|
73
|
-
else
|
74
|
-
HotGlue::Helpers.open_page("https://shop.heliosdev.shop/?utm_source=hotglue-installer")
|
75
|
-
print "ALSO check out the HOT GLUE TUTORIAL here: \n"
|
76
|
-
print "https://jfb.teachable.com/p/hot-glue-in-depth-tutorial \n"
|
77
|
-
print "All purchases come with a Hot Glue lifetime license for individuals and hobbyists\n"
|
78
|
-
end
|
79
|
-
return
|
80
|
-
end
|
81
29
|
|
82
30
|
@markup = options['markup']
|
83
31
|
if @markup == "haml"
|
@@ -171,11 +119,9 @@ module HotGlue
|
|
171
119
|
|
172
120
|
|
173
121
|
begin
|
174
|
-
|
175
122
|
if !File.exists?("config/hot_glue.yml")
|
176
123
|
yaml = {layout: @layout,
|
177
|
-
markup: @markup
|
178
|
-
license_email: license_email}.to_yaml
|
124
|
+
markup: @markup}.to_yaml
|
179
125
|
File.write("#{'spec/dummy/' if Rails.env.test?}config/hot_glue.yml", yaml)
|
180
126
|
|
181
127
|
end
|
@@ -122,7 +122,8 @@ module HotGlue
|
|
122
122
|
class_option :smart_layout, type: :boolean, default: false
|
123
123
|
class_option :markup, type: :string, default: nil # deprecated -- use in app config instead
|
124
124
|
class_option :layout, type: :string, default: nil # if used here it will override what is in the config
|
125
|
-
class_option :hawk, type: :string, default: nil
|
125
|
+
class_option :hawk, type: :string, default: nil
|
126
|
+
class_option :with_turbo_streams, type: :boolean, default: false
|
126
127
|
|
127
128
|
class_option :no_list_label, type: :boolean, default: false
|
128
129
|
|
@@ -130,8 +131,8 @@ module HotGlue
|
|
130
131
|
|
131
132
|
|
132
133
|
# determines if the labels show up BEFORE or AFTER on the NEW/EDIT (form)
|
133
|
-
class_option :form_labels_position, default: 'after' # choices are before, after, omit
|
134
|
-
class_option :form_placeholder_labels, default: false # puts the field names into the placeholder labels
|
134
|
+
class_option :form_labels_position, type: :string, default: 'after' # choices are before, after, omit
|
135
|
+
class_option :form_placeholder_labels, type: :boolean, default: false # puts the field names into the placeholder labels
|
135
136
|
|
136
137
|
|
137
138
|
# NOT YET IMPLEMENTED
|
@@ -415,7 +416,7 @@ module HotGlue
|
|
415
416
|
|
416
417
|
@menu_file_exists = true if @nested_set.none? && File.exists?("#{Rails.root}/app/views/#{namespace_with_trailing_dash}_menu.#{@markup}")
|
417
418
|
|
418
|
-
|
419
|
+
@turbo_streams = !!options['with_turbo_streams']
|
419
420
|
end
|
420
421
|
|
421
422
|
def setup_hawk_keys
|
@@ -627,7 +628,7 @@ module HotGlue
|
|
627
628
|
end
|
628
629
|
|
629
630
|
def objest_nest_factory_setup
|
630
|
-
res = ""
|
631
|
+
res = " "
|
631
632
|
if @auth
|
632
633
|
last_parent = ", #{@auth_identifier}: #{@auth}"
|
633
634
|
end
|
@@ -653,6 +654,10 @@ module HotGlue
|
|
653
654
|
@singular
|
654
655
|
end
|
655
656
|
|
657
|
+
def testing_name
|
658
|
+
singular_class_name.gsub("::","_").downcase
|
659
|
+
end
|
660
|
+
|
656
661
|
def singular_class_name
|
657
662
|
@singular_class
|
658
663
|
end
|
@@ -665,6 +670,59 @@ module HotGlue
|
|
665
670
|
@auth_identifier
|
666
671
|
end
|
667
672
|
|
673
|
+
def test_capybara_block
|
674
|
+
(@columns - @show_only).map { |col|
|
675
|
+
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
676
|
+
case type
|
677
|
+
when :date
|
678
|
+
" " + "new_#{col} = Date.current + (rand(100).days) \n" +
|
679
|
+
' ' + "find(\"[name='#{testing_name}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
680
|
+
when :time
|
681
|
+
# " " + "new_#{col} = DateTime.current + (rand(100).days) \n" +
|
682
|
+
# ' ' + "find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
683
|
+
|
684
|
+
when :datetime
|
685
|
+
" " + "new_#{col} = DateTime.current + (rand(100).days) \n" +
|
686
|
+
' ' + "find(\"[name='#{testing_name}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
687
|
+
|
688
|
+
when :integer
|
689
|
+
|
690
|
+
if col.to_s.ends_with?("_id")
|
691
|
+
assoc = col.to_s.gsub('_id','')
|
692
|
+
" #{col}_selector = find(\"[name='#{singular}[#{col}]']\").click \n" +
|
693
|
+
" #{col}_selector.first('option', text: #{assoc}1.name).select_option"
|
694
|
+
else
|
695
|
+
" new_#{col} = rand(10) \n" +
|
696
|
+
" find(\"[name='#{testing_name}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
697
|
+
|
698
|
+
end
|
699
|
+
|
700
|
+
when :enum
|
701
|
+
" list_of_#{col.to_s} = #{singular_class}.defined_enums['#{col.to_s}'].keys \n" +
|
702
|
+
" " + "new_#{col.to_s} = list_of_#{col.to_s}[rand(list_of_#{col.to_s}.length)].to_s \n" +
|
703
|
+
' find("select[name=\'' + singular + '[' + col.to_s + ']\'] option[value=\'#{new_' + col.to_s + '}\']").select_option'
|
704
|
+
|
705
|
+
when :boolean
|
706
|
+
" new_#{col} = rand(2).floor \n" +
|
707
|
+
" find(\"[name='#{testing_name}[#{col}]'][value='\#{new_" + col.to_s + "}']\").choose"
|
708
|
+
when :string
|
709
|
+
if col.to_s.include?("email")
|
710
|
+
" " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
|
711
|
+
" find(\"[name='#{testing_name}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
712
|
+
|
713
|
+
else
|
714
|
+
" " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
|
715
|
+
" find(\"[name='#{testing_name}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
716
|
+
end
|
717
|
+
when :text
|
718
|
+
" " + "new_#{col} = FFaker::Lorem.paragraphs(1).join("") \n" +
|
719
|
+
" find(\"[name='#{testing_name}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
720
|
+
end
|
721
|
+
|
722
|
+
}.join("\n")
|
723
|
+
end
|
724
|
+
|
725
|
+
|
668
726
|
def path_helper_args
|
669
727
|
if @nested_set.any? && @nested
|
670
728
|
[(@nested_set).collect{|a| "#{a[:singular]}"} , singular].join(",")
|
@@ -883,6 +941,28 @@ module HotGlue
|
|
883
941
|
|
884
942
|
end
|
885
943
|
|
944
|
+
def append_model_callbacks
|
945
|
+
# somehow the generator invokes this
|
946
|
+
if options['with_turbo_streams'] == true
|
947
|
+
dest_filename = cc_filename_with_extensions("#{singular_class.underscore}", "rb")
|
948
|
+
dest_filepath = File.join("#{'dummy/' if Rails.env.test?}app/models", dest_filename)
|
949
|
+
|
950
|
+
|
951
|
+
puts "appending turbo callbacks to #{dest_filepath}"
|
952
|
+
|
953
|
+
text = File.read(dest_filepath)
|
954
|
+
|
955
|
+
append_text = "class #{singular_class} < ApplicationRecord\n"
|
956
|
+
if !text.include?("include ActionView::RecordIdentifier")
|
957
|
+
append_text << " include ActionView::RecordIdentifier\n"
|
958
|
+
end
|
959
|
+
append_text << " after_update_commit lambda { broadcast_replace_to self, target: \"#{@namespace}__\#{dom_id(self)}\", partial: \"#{@namespace}/#{@plural}/line\" }\n after_destroy_commit lambda { broadcast_remove_to self, target: \"#{@namespace}__\#{dom_id(self)}\"}\n"
|
960
|
+
|
961
|
+
replace = text.gsub(/class #{singular_class} < ApplicationRecord/, append_text)
|
962
|
+
File.open(dest_filepath, "w") {|file| file.puts replace}
|
963
|
+
end
|
964
|
+
end
|
965
|
+
|
886
966
|
def namespace_with_dash
|
887
967
|
if @namespace
|
888
968
|
"/#{@namespace}"
|
@@ -68,22 +68,13 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
68
68
|
|
69
69
|
def index
|
70
70
|
load_all_<%= plural %>
|
71
|
-
respond_to do |format|
|
72
|
-
format.html
|
73
|
-
end
|
74
71
|
end
|
75
72
|
|
76
|
-
<% if create_action %> def new
|
77
|
-
<%
|
78
|
-
@<%= singular_name %> = <%= class_name %>.new(<% if eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)
|
79
|
-
|
80
|
-
<% elsif @object_owner_optional && any_nested? %>
|
73
|
+
<% if create_action %> def new <% if @object_owner_sym %>
|
74
|
+
@<%= singular_name %> = <%= class_name %>.new(<% if eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>) <% elsif @object_owner_optional && any_nested? %>
|
81
75
|
@<%= singular_name %> = <%= class_name %>.new({}.merge(<%= @nested_set.last[:singular] %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {})) <% else %>
|
82
76
|
@<%= singular_name %> = <%= class_name %>.new(<% if any_nested? %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)
|
83
77
|
<% end %>
|
84
|
-
respond_to do |format|
|
85
|
-
format.html
|
86
|
-
end
|
87
78
|
end
|
88
79
|
|
89
80
|
def create
|
@@ -95,46 +86,30 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
95
86
|
if @<%= singular_name %>.save
|
96
87
|
flash[:notice] = "Successfully created #{@<%= singular %>.<%= display_class %>}"
|
97
88
|
load_all_<%= plural %>
|
98
|
-
|
99
|
-
format.turbo_stream
|
100
|
-
format.html { redirect_to <%= path_helper_plural %> }
|
101
|
-
end
|
89
|
+
render :create
|
102
90
|
else
|
103
91
|
flash[:alert] = "Oops, your <%= singular_name %> could not be created. #{@hawk_alarm}"
|
104
|
-
|
105
|
-
format.turbo_stream
|
106
|
-
format.html
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
<% end %> def show
|
112
|
-
respond_to do |format|
|
113
|
-
format.html
|
92
|
+
render :create, status: :unprocessable_entity
|
114
93
|
end
|
115
94
|
end
|
116
95
|
|
96
|
+
<% end %>
|
117
97
|
<% unless @no_edit %> def edit
|
118
|
-
|
119
|
-
format.turbo_stream
|
120
|
-
format.html
|
121
|
-
end
|
98
|
+
render :edit
|
122
99
|
end
|
123
100
|
|
124
101
|
<% end %><% if @build_update_action %> def update
|
125
|
-
modified_params = modify_date_inputs_on_params(<%= singular %>_params<%= @auth ? ', ' + @auth : '' %>)<%= controller_update_params_tap_away_magic_buttons %>
|
126
|
-
|
127
|
-
<%= controller_magic_button_update_actions %>
|
102
|
+
modified_params = modify_date_inputs_on_params(<%= singular %>_params<%= @auth ? ', ' + @auth : '' %>)<%= controller_update_params_tap_away_magic_buttons %><% if @hawk_keys.any? %>
|
103
|
+
modified_params = hawk_params( {<%= hawk_to_ruby %>}, modified_params)<% end %>
|
104
|
+
<%= controller_magic_button_update_actions %>
|
105
|
+
if @<%= singular_name %>.update(modified_params)
|
106
|
+
<% if @display_list_after_update %> load_all_<%= plural %><% end %>
|
128
107
|
flash[:notice] = (flash[:notice] || "") << "Saved #{@<%= singular %>.<%= display_class %>}"
|
129
|
-
flash[:alert] = @hawk_alarm
|
108
|
+
flash[:alert] = @hawk_alarm if @hawk_alarm
|
109
|
+
render :update
|
130
110
|
else
|
131
111
|
flash[:alert] = (flash[:alert] || "") << "<%= singular_name.titlecase %> could not be saved. #{@hawk_alarm}"
|
132
|
-
|
133
|
-
end
|
134
|
-
<% if @display_list_after_update %> load_all_<%= plural %><% end %>
|
135
|
-
respond_to do |format|
|
136
|
-
format.turbo_stream
|
137
|
-
format.html
|
112
|
+
render :update, status: :unprocessable_entity
|
138
113
|
end
|
139
114
|
end
|
140
115
|
|
@@ -145,14 +120,10 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
145
120
|
flash[:alert] = "<%= singular_name.titlecase %> could not be deleted."
|
146
121
|
end
|
147
122
|
load_all_<%= plural %>
|
148
|
-
respond_to do |format|
|
149
|
-
format.turbo_stream
|
150
|
-
format.html { redirect_to <%= path_helper_plural %> }
|
151
|
-
end
|
152
123
|
end<% end %>
|
153
124
|
|
154
125
|
def <%=singular_name%>_params
|
155
|
-
params.require(:<%=
|
126
|
+
params.require(:<%= testing_name %>).permit( <%= (@columns - @show_only) + @magic_buttons.collect(&:to_sym) %> )
|
156
127
|
end
|
157
128
|
|
158
129
|
def namespace
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<% if @turbo_streams %><\%= turbo_stream_from <%= singular %> %>
|
2
|
+
<% end %><\%= turbo_frame_tag "<%= @namespace %>__#{ dom_id(<%= singular %>) }" do %>
|
3
3
|
<div class='row scaffold-row' data-id='<\%= <%= singular %>.id %>' data-edit='false'>
|
4
4
|
<\%= render partial: '<%= show_path_partial %>', locals: { <%= singular %>: <%= singular %> }<% @nested_set.each do |nest_arg| %>.merge(defined?(<%= nest_arg[:singular] %>) ? {<%= nest_arg[:singular] %>: <%= nest_arg[:singular] %>, nested_for: "<%= nest_arg[:singular] %>-#{<%= nest_arg[:singular] %>.id}"} : {})<% end %> %>
|
5
5
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<\%= turbo_frame_tag "<%= plural %>-list" <%= nested_for_turbo_id_list_constructor %> do %>
|
1
|
+
<\%= turbo_frame_tag "<%= @namespace %>__<%= plural %>-list" <%= nested_for_turbo_id_list_constructor %> do %>
|
2
2
|
<div class="<%= @container_name %> scaffold-list">
|
3
3
|
<% unless @no_list || @no_list_label || (@nested_set.any? && !@nested_set.collect{|x| x[:optional]}.any?) %>
|
4
4
|
<% unless list_label.nil? %><h4>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<\%= turbo_frame_tag "<%= singular %>-new" do %>
|
1
|
+
<\%= turbo_frame_tag "<%= @namespace %>__<%= singular %>-new" do %>
|
2
2
|
<div>
|
3
3
|
<\%= link_to "New <%= thing_label %>", <%= new_path_name %>, disable_with: "Loading...", class: "new-<%= singular %>-button btn btn-primary pull-right <%= 'btn-sm' if @nested_set.any? %> " %>
|
4
4
|
</div>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<\% if @<%= singular %>.errors.none? %>
|
2
|
-
<\%= turbo_stream.replace "<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
|
2
|
+
<\%= turbo_stream.replace "<%= @namespace %>__<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
|
3
3
|
<\%= render partial: "list", locals: {<%= plural %>: @<%= plural %>}<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {nested_for: \"" + arg[:singular] + "-\#{@" + arg[:singular] + ".id}\"" + ", " + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> \%>
|
4
4
|
<\% end %>
|
5
5
|
<\% end %>
|
6
|
-
<\%= turbo_stream.replace "<%= singular %>-new" do %>
|
6
|
+
<\%= turbo_stream.replace "<%= @namespace %>__<%= singular %>__<%= singular %>-new" do %>
|
7
7
|
<\% if @<%= singular %>.errors.none? %>
|
8
8
|
<\%= render partial: "new_button", locals: {}<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {" + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> %>
|
9
9
|
<\% else %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<\%= turbo_stream.replace "<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
|
1
|
+
<\%= turbo_stream.replace "<%= @namespace %>__<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
|
2
2
|
<\%= render partial: "list", locals: {<%=plural%>: @<%=plural%> }<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {nested_for: \"" + arg[:singular] + "-\#{@" + arg[:singular] + ".id}\"" + ", " + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> \%>
|
3
|
-
<\% end %>
|
3
|
+
<\% end %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<\%= link_to "<i class='fa fa-arrow-circle-left 2x'></i> Back to list".html_safe, <%= path_helper_plural %> %>
|
2
2
|
|
3
|
-
<\%= turbo_frame_tag "<%=
|
3
|
+
<\%= turbo_frame_tag "<%= @namespace %>__#{dom_id(@<%= singular %>)}" do %>
|
4
4
|
|
5
5
|
<div class="cell editable" style="position: relative;">
|
6
6
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if !@display_list_after_update %><\%= turbo_stream.replace "<%=
|
1
|
+
<% if !@display_list_after_update %><\%= turbo_stream.replace "<%= namespace %>__#{dom_id(@<%= singular %>)}" do %>
|
2
2
|
<\%= render partial: 'line', locals: {<%= singular %>: @<%= singular %> }<%= @nested_set.collect{|arg| ".merge(@#{arg[:singular]} ? {#{arg[:singular]}: @#{arg[:singular]}} : {})" }.join %> \%>
|
3
3
|
<\% end %><% else %><\%= turbo_stream.replace "<%= plural %>-list" do %>
|
4
4
|
<\%= render partial: '<%= list_path_partial %>', locals: {<%= plural %>: @<%= plural %>}<%= @nested_set.collect{|arg| ".merge(@#{arg[:singular]} ? {#{arg[:singular]}: @#{arg[:singular]}} : {})" }.join %> \%>
|