common_core_js 0.0.2.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/assets/config/manifest.js +3 -0
- data/app/views/common/_common_create.js.erb +17 -0
- data/app/views/common/_common_destroy.js.erb +11 -0
- data/app/views/common/_common_edit.js.erb +13 -0
- data/app/views/common/_common_edit_form.haml +16 -0
- data/app/views/common/_common_index.js.erb +1 -0
- data/app/views/common/_common_new.js.erb +9 -0
- data/app/views/common/_common_new_form.haml +10 -0
- data/app/views/common/_common_show_form.haml +11 -0
- data/app/views/common/_common_update.js.erb +8 -0
- data/lib/.DS_Store +0 -0
- data/lib/common_core_js.rb +10 -0
- data/lib/generators/common_core/USAGE +8 -0
- data/lib/generators/common_core/erb/scaffold/common_core_scaffold_generator.rb +26 -0
- data/lib/generators/common_core/scaffold_generator.rb +231 -0
- data/lib/generators/common_core/templates/_edit.haml +1 -0
- data/lib/generators/common_core/templates/_form.haml +0 -0
- data/lib/generators/common_core/templates/_line.haml +0 -0
- data/lib/generators/common_core/templates/_list.haml +20 -0
- data/lib/generators/common_core/templates/_new.haml +1 -0
- data/lib/generators/common_core/templates/controller.rb +98 -0
- data/lib/generators/common_core/templates/create.js.erb +1 -0
- data/lib/generators/common_core/templates/destroy.js.erb +1 -0
- data/lib/generators/common_core/templates/edit.js.erb +1 -0
- data/lib/generators/common_core/templates/index.js.erb +1 -0
- data/lib/generators/common_core/templates/new.js.erb +1 -0
- data/lib/generators/common_core/templates/update.js.erb +6 -0
- data/lib/version.rb +4 -0
- metadata +138 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a1409fc4b861506634c105233ecd7562a94d6cd4256aeee556ea99763eb54e40
|
4
|
+
data.tar.gz: d8a0ae1dfb94af15ee0925758bec9dada9fe96631a41fae2a70b545bf2df3852
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b28c45efde7fd2c13c807a963b72d1ebd44d998a9cff1ed57ac8ab9484c4fe377e194b98413e8a5870009f3172c02132ec6d2ec8eaa5194edabe321a0697c896
|
7
|
+
data.tar.gz: b90df55216345e8c6069496ea5ebaca4b4882a77e0ca9a2d5c694c085107ab1015ea5397d3cf95b33167ffe7322c8cc325bbe74f8e08e8485291f7e33fcea033
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% insert_above_or_below = 'append' if !insert_above_or_below %>
|
2
|
+
|
3
|
+
<% scope = "" %>
|
4
|
+
<% if controller.common_scope %>
|
5
|
+
<% scope = controller.common_scope.map{|k,v| '.' + k.to_s + "-table > tbody > tr[data-id=".html_safe + v.id.to_s + ']'}.join(" ").html_safe %>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
|
9
|
+
<% if object.errors.any? %>
|
10
|
+
$(".flash-notices").html("<%= j render 'layouts/flash_notices' %>");
|
11
|
+
$("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-form").html("<%= j render(partial: 'dashboard/errors', locals: {resource: object}) %>")
|
12
|
+
$("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-form").append("<%= j render(partial: "new", locals: { singular.to_sym => object}) %><i class='fa fa-times-circle fa-2x' data-name='<%=singular%>' data-role='close-button' />").slideDown();
|
13
|
+
<% else %>
|
14
|
+
$("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-form").slideUp();
|
15
|
+
$("<%= (scope + " ") if controller.common_scope %> .<%= singular %>-table").<%= insert_above_or_below %>("<%= j render(partial: "line", locals: {singular.to_sym => object }) %>")
|
16
|
+
$("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-button").fadeIn();
|
17
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
<% if object.errors.none? %>
|
3
|
+
$(".<%= singular %>-list table tr[data-id=<%= object.id %>]").css({color: 'red', 'text-decoration': 'line-through'});
|
4
|
+
$(".<%= singular %>-list table tr[data-id=<%= object.id %>]").fadeOut(750,function () {
|
5
|
+
$(".<%= singular %>-list").html("<%= j render partial: "list", locals: {plural.to_sym => all_objects} %>")
|
6
|
+
})
|
7
|
+
|
8
|
+
<% else %>
|
9
|
+
$(".flash-notices").html("<%= j render 'layouts/flash_notices' %>");
|
10
|
+
$(".<%= singular %>-list").html("<%= j render(partial: 'dashboard/errors', locals: {resource: object}) %><br/<%= j render partial: "list", locals: {plural.to_sym => all_objects} %>")
|
11
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
(function() {
|
2
|
+
let edit_clone = $("<tr data-id=<%= object.id %> data-edit='true' style='display: none'></tr>")
|
3
|
+
edit_clone.html("<%= j render partial: 'edit', locals: {singular.to_sym => object, url: url, colspan: controller.default_colspan} %>")
|
4
|
+
let top_pos = $('.<%= singular %>-table [data-id=<%= object.id %>]').offset().top
|
5
|
+
$('.<%= singular %>-table > tbody > tr[data-id=<%= object.id %>]:not([data-edit=\'true\'])').fadeOut(() => {
|
6
|
+
$(edit_clone).insertAfter('.<%= singular %>-table > tbody > tr[data-id=<%= object.id %>]')
|
7
|
+
$(edit_clone).fadeIn();
|
8
|
+
|
9
|
+
let fifth_window_height = Number(window.innerHeight*(1/5));
|
10
|
+
$('html, body').animate({scrollTop: top_pos - fifth_window_height},500);
|
11
|
+
});
|
12
|
+
})()
|
13
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
%td{style: "position: relative;", colspan: controller.default_colspan}
|
2
|
+
Editing
|
3
|
+
- if object.try(:to_label)
|
4
|
+
= object.to_label
|
5
|
+
- elsif object.try(:name)
|
6
|
+
= object.name
|
7
|
+
- else
|
8
|
+
(no name)
|
9
|
+
|
10
|
+
= form_with model: object, url: url do |f|
|
11
|
+
= render partial: "form", locals: {singular.to_sym => object, f: f}
|
12
|
+
.row
|
13
|
+
.col-md-12
|
14
|
+
= f.submit "Save", class: "btn btn-primary pull-right"
|
15
|
+
|
16
|
+
%i.fa.fa-times-circle.fa-2x{ 'data-name' => singular, 'data-row-id' => object.id, 'data-role' => 'close-button'}
|
@@ -0,0 +1 @@
|
|
1
|
+
$('.<%= singular %>-list').html("<%= j render partial: "dashboard/#{plural}/list", locals: {plural.to_sym => objects} %>")
|
@@ -0,0 +1,9 @@
|
|
1
|
+
|
2
|
+
<% scope = "" %>
|
3
|
+
<% if controller.common_scope %>
|
4
|
+
<% scope = controller.common_scope.map{|k,v| '.' + k.to_s + "-table > tbody > tr[data-id=".html_safe + v.id.to_s + ']'}.join(" ").html_safe %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
$("<%= (scope + " ") if controller.common_scope %> .new-<%= singular %>-button").fadeOut(function() {
|
8
|
+
$("<%= (scope + " ") if controller.common_scope %> .new-<%= singular %>-form").html("<%= j render(partial: "new" ) %><i class='fa fa-times-circle fa-2x' data-name='<%= singular %>' data-role='close-button' />").slideDown();
|
9
|
+
})
|
@@ -0,0 +1,10 @@
|
|
1
|
+
%h3
|
2
|
+
New
|
3
|
+
= singular.titlecase
|
4
|
+
|
5
|
+
= form_with model: object, url: url, method: "post" do |f|
|
6
|
+
= render partial: "dashboard/#{plural}/form", locals: {singular.to_sym => object, f: f}
|
7
|
+
|
8
|
+
.row
|
9
|
+
.col-md-12
|
10
|
+
= f.submit "Save", class: "btn btn-primary pull-right"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
%td{style: "position: relative;"}
|
2
|
+
- if object.try(:to_label)
|
3
|
+
= object.to_label
|
4
|
+
- elsif object.try(:name)
|
5
|
+
= object.name
|
6
|
+
- else
|
7
|
+
- raise "#{object.inspect} does not implement either a to_label or a name"
|
8
|
+
.show-area
|
9
|
+
= render partial: "form", locals: {singular.to_sym => object, f: form_faker(object)}
|
10
|
+
|
11
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% if object.errors.any? %>
|
2
|
+
<% pass_through_locals ||= {} %>
|
3
|
+
$(".<%= singular %>-table tr[data-id=<%= object.id %>][data-edit='true']").html("<%= j render(partial: 'dashboard/errors', locals: {resource: object}) %><%= j render partial: 'edit', locals: {singular.to_sym => object, url: url, colspan: controller.default_colspan}.merge(pass_through_locals || {}) %>")
|
4
|
+
$(".flash-notices").html("<%= j render 'layouts/flash_notices' %>");
|
5
|
+
<% else %>
|
6
|
+
$(".<%= singular %>-table tr[data-id=<%= object.id %>]:not([data-edit='true'])").replaceWith("<%= j render partial: 'line', locals: {singular.to_sym => object } %>").fadeIn()
|
7
|
+
$(".<%= singular %>-table tr[data-id=<%= object.id %>][data-edit='true']").remove();
|
8
|
+
<% end %>
|
data/lib/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Erb
|
2
|
+
module Generators
|
3
|
+
class CommonCoreScaffoldGenerator < Rails::Generators::NamedBase
|
4
|
+
|
5
|
+
include Rails::Generators::ResourceHelpers
|
6
|
+
|
7
|
+
# BECAUSE THIS CLASS REPLACES Erb::Generators::Base
|
8
|
+
def formats
|
9
|
+
[format]
|
10
|
+
end
|
11
|
+
|
12
|
+
def format
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def handler
|
17
|
+
:erb
|
18
|
+
end
|
19
|
+
|
20
|
+
def filename_with_extensions(name, file_format = format)
|
21
|
+
byebug
|
22
|
+
[name, file_format, handler].compact.join(".")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
require 'rails/generators/erb/scaffold/scaffold_generator'
|
2
|
+
|
3
|
+
module CommonCore
|
4
|
+
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
5
|
+
|
6
|
+
|
7
|
+
hook_for :form_builder, :as => :scaffold
|
8
|
+
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
attr_accessor :path, :singular, :plural, :singular_class, :nest_with
|
11
|
+
|
12
|
+
|
13
|
+
def initialize(*meta_args) #:nodoc:
|
14
|
+
super
|
15
|
+
|
16
|
+
begin
|
17
|
+
object = eval(class_name)
|
18
|
+
rescue StandardError => e
|
19
|
+
puts "Ooops... it looks like there is no object for #{class_name}. Please define the object + database table first."
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
@columns = object.columns.map(&:name).map(&:to_sym).reject{|x| x==:updated_at || x==:created_at || x==:id}
|
25
|
+
rescue StandardError => e
|
26
|
+
puts "Ooops... it looks like is an object for #{class_name}. Please create the database table with fields first. "
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
args = meta_args[0]
|
31
|
+
@singular = args[0].tableize.singularize # should be in form hello_world
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
@plural = @singular + "s" # supply to override; leave blank to use default
|
39
|
+
@singular_class = @singular.titleize.gsub(" ", "")
|
40
|
+
@nest = nil
|
41
|
+
@namespace = nil
|
42
|
+
@nested_args = []
|
43
|
+
|
44
|
+
@auth = "current_user"
|
45
|
+
@auth_identifier = nil
|
46
|
+
|
47
|
+
args[1..-1].each do |a|
|
48
|
+
var_name, var_value = a.split("=")
|
49
|
+
case (var_name)
|
50
|
+
|
51
|
+
when "plural"
|
52
|
+
@plural = var_value
|
53
|
+
when "nest"
|
54
|
+
@nest = var_value
|
55
|
+
when "namespace"
|
56
|
+
@namespace = var_value
|
57
|
+
when "auth"
|
58
|
+
@auth = var_value
|
59
|
+
when "auth_identifier"
|
60
|
+
@auth_identifier = var_value || ""
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
flags = meta_args[1]
|
67
|
+
flags.each do |f|
|
68
|
+
case (f)
|
69
|
+
when "--god"
|
70
|
+
@auth = nil
|
71
|
+
when "--with-index"
|
72
|
+
@with_index = true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
if @auth_identifier.nil?
|
79
|
+
@auth_identifier = @auth.gsub("current_", "")
|
80
|
+
end
|
81
|
+
|
82
|
+
if !@nest.nil?
|
83
|
+
@nested_args = @nest.split("/")
|
84
|
+
|
85
|
+
@nested_args_plural = {}
|
86
|
+
@nested_args.each do |a|
|
87
|
+
@nested_args_plural[a] = a + "s"
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def formats
|
94
|
+
[format]
|
95
|
+
end
|
96
|
+
|
97
|
+
def format
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
|
101
|
+
def copy_controller_and_spec_files
|
102
|
+
|
103
|
+
@default_colspan = @columns.size
|
104
|
+
template "controller.rb", File.join("app/controllers", "#{plural}_controller.rb")
|
105
|
+
# template "index", File.join("app/views", "app/views/#{self.name.downcase}/index")
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
def list_column_headings
|
111
|
+
@columns.map(&:to_s).map{|col_name| ' %th{:scope => "col"} ' + col_name.humanize}.join("\r")
|
112
|
+
end
|
113
|
+
|
114
|
+
def controller_class_name
|
115
|
+
plural.titleize.gsub(" ", "") + "Controller"
|
116
|
+
end
|
117
|
+
|
118
|
+
def singular_name
|
119
|
+
@singular
|
120
|
+
end
|
121
|
+
|
122
|
+
def plural_name
|
123
|
+
plural
|
124
|
+
end
|
125
|
+
|
126
|
+
def auth_identifier
|
127
|
+
@auth_identifier
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
def path_helper
|
132
|
+
"#{@namespace+"_" if @namespace}#{(@nested_args.join("_") + "_" if @nested_args.any?)}#{plural}_path"
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
def path_arity
|
137
|
+
(nested_objects_arity + ", " if @nested_args) + "@" + singular
|
138
|
+
end
|
139
|
+
|
140
|
+
def line_path_partial
|
141
|
+
"#{@namespace+"/" if @namespace}#{singular}/line"
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
def nested_assignments
|
146
|
+
@nested_args.map{|a| "#{a}: @#{a}"}.join(", ") #metaprgramming into Ruby hash
|
147
|
+
end
|
148
|
+
|
149
|
+
def nested_objects_arity
|
150
|
+
@nested_args.map{|a| "@#{a}"}.join(", ")
|
151
|
+
end
|
152
|
+
|
153
|
+
def nested_arity_for_path
|
154
|
+
@nested_args.join(", ") #metaprgramming into arity for the Rails path helper
|
155
|
+
end
|
156
|
+
|
157
|
+
def object_scope
|
158
|
+
if @auth
|
159
|
+
if @nested_args.any?
|
160
|
+
@auth
|
161
|
+
else
|
162
|
+
"@" + @nested_args.last + "s"
|
163
|
+
end
|
164
|
+
else
|
165
|
+
class_name
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def any_nested?
|
170
|
+
@nested_args.any?
|
171
|
+
end
|
172
|
+
|
173
|
+
def all_objects_variable
|
174
|
+
# needs the authenticated root user
|
175
|
+
"#{@auth}#{'.' + @nested_args.map{|a| "#{@nested_args_plural[a]}.find(@#{a})"}.join('.') + "." if @nested_args}#{plural}"
|
176
|
+
end
|
177
|
+
|
178
|
+
def auth_object
|
179
|
+
@auth
|
180
|
+
end
|
181
|
+
|
182
|
+
def copy_view_files
|
183
|
+
js_views.each do |view|
|
184
|
+
formats.each do |format|
|
185
|
+
|
186
|
+
filename = cc_filename_with_extensions(view, ["js","erb"])
|
187
|
+
template filename, File.join("app/views", controller_file_path, filename)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
haml_views.each do |view|
|
192
|
+
formats.each do |format|
|
193
|
+
|
194
|
+
filename = cc_filename_with_extensions(view, "haml")
|
195
|
+
template filename, File.join("app/views", controller_file_path, filename)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def js_views
|
201
|
+
%w(index create destroy edit new update)
|
202
|
+
end
|
203
|
+
|
204
|
+
def haml_views
|
205
|
+
%w(_edit _form _line _list _new)
|
206
|
+
end
|
207
|
+
|
208
|
+
|
209
|
+
def handler
|
210
|
+
:erb
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
def create_merge_params
|
215
|
+
if @auth
|
216
|
+
".merge!(#{@auth_identifier}: #{@auth})"
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
private # thor does something fancy like sending the class all of its own methods during some strange run sequence
|
221
|
+
# does not like public methods
|
222
|
+
|
223
|
+
def cc_filename_with_extensions(name, file_format = format)
|
224
|
+
[name, file_format].compact.join(".")
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
= render partial: "common/common_edit_form", locals: {singular: '<%= @singular %>', object: <%= @singular %>, url: <%= path_helper %>(<%= path_arity %>), colspan: colspan}
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
= link_to "New <%= singular.gsub('_',' ') %>", <%= path_helper %>(<%= nested_arity_for_path %>), disable_with: "Loading...", remote: true, class: "new-<%= singular %>-button btn btn-primary pull-right"
|
3
|
+
|
4
|
+
.clearfix
|
5
|
+
.new-<%= singular %>-form{style: "display: none; position: relative;"}
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
%table.table.table-striped.<%= singular %>-table
|
10
|
+
%thead
|
11
|
+
%tr
|
12
|
+
<%= list_column_headings %>
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
%tbody
|
17
|
+
- if <%= plural %>.empty?
|
18
|
+
None
|
19
|
+
- <%= plural %>.each do |<%= singular %>|
|
20
|
+
= render partial: '<%= line_path_partial %>', locals: {<%= singular %>: <%= singular %>, <%= nested_assignments %> }
|
@@ -0,0 +1 @@
|
|
1
|
+
= render partial: "common/common_new_form", locals: {singular: '<%= singular %>', plural: "<%= plural %>", object: @<%= singular %>, url: <%= path_helper %>(<%= nested_objects_arity %>)}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
class <%= controller_class_name %> < ApplicationController
|
2
|
+
<% unless @auth_identifier.empty? %>
|
3
|
+
before_action :authenticate_<%= auth_identifier %>!
|
4
|
+
|
5
|
+
<% end %>
|
6
|
+
<% if any_nested? %> <% @nested_args.each do |arg| %>
|
7
|
+
before_action :load_<%= arg %><% end %> <% end %>
|
8
|
+
before_action :load_<%= singular_name %>, only: [:show, :edit, :update, :destroy]
|
9
|
+
|
10
|
+
|
11
|
+
<% if any_nested? %><% nest_chain = [] %> <% @nested_args.each do |arg| %>
|
12
|
+
<% if nest_chain.empty?
|
13
|
+
this_scope = "#{@auth ? auth_object : class_name}.#{arg}s"
|
14
|
+
else
|
15
|
+
this_scope = "@#{nest_chain.last}.#{arg}s"
|
16
|
+
end
|
17
|
+
nest_chain << arg %>
|
18
|
+
def load_<%= arg %>
|
19
|
+
@<%= arg %> = <%= this_scope %>.find(params[:<%= arg %>_id])
|
20
|
+
end<% end %> <% end %>
|
21
|
+
|
22
|
+
def load_<%= singular_name %>
|
23
|
+
@<%= singular_name %> = <%= @auth ? auth_object+"." : '' %><% if !nest_chain || nest_chain.empty? %><%= object_scope %>.<% end %>find(params[:id])
|
24
|
+
end
|
25
|
+
|
26
|
+
def index
|
27
|
+
@<%= plural_name %> = <%= @auth ? auth_object+"." : '' %><% if !nest_chain || nest_chain.empty? %><%= object_scope %>.<% end %>where(<%=class_name %>.arel_table[:email].matches("%#{@__general_string}%"))
|
28
|
+
.page(params[:page])
|
29
|
+
|
30
|
+
respond_to do |format|
|
31
|
+
format.js<% if @with_index %>
|
32
|
+
format.html {render 'all_<%=plural_name %>.haml'}<% end %>
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def new
|
37
|
+
@<%= singular_name %> = <%= class_name %>.new()<%= create_merge_params %>
|
38
|
+
respond_to do |format|
|
39
|
+
format.js
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def create
|
44
|
+
@<%=singular_name %> = <%=class_name %>.create(<%=singular_name %>_params<%= create_merge_params %>)
|
45
|
+
respond_to do |format|
|
46
|
+
if @<%= singular_name %>.save
|
47
|
+
format.js
|
48
|
+
else
|
49
|
+
flash[:alert] = "Oops, your <%=singular_name %> could not be saved."
|
50
|
+
format.js
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def show
|
56
|
+
respond_to do |format|
|
57
|
+
format.html
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def edit
|
62
|
+
|
63
|
+
respond_to do |format|
|
64
|
+
format.js
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def update
|
69
|
+
|
70
|
+
respond_to do |format|
|
71
|
+
if !@<%=singular_name %>.save
|
72
|
+
flash[:alert] = "<%=singular_name.titlecase %> could not be saved"
|
73
|
+
end
|
74
|
+
format.js {}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def destroy
|
79
|
+
respond_to do |format|
|
80
|
+
begin
|
81
|
+
@<%=singular_name%>.destroy
|
82
|
+
rescue StandardError => e
|
83
|
+
flash[:alert] = "<%=singular_name.titlecase %> could not be deleted"
|
84
|
+
end
|
85
|
+
format.js {}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def <%=singular_name%>_params
|
90
|
+
params.require(:<%=singular_name%>).permit( <%= @columns %> )
|
91
|
+
end
|
92
|
+
|
93
|
+
def default_colspan
|
94
|
+
<%= @default_colspan %>
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
<%%= render partial: 'common/common_create', locals: {object: @<%= singular %>, singular: "<%= singular %>", plural: "<%= plural %>"} %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%%= render partial: 'common/common_destroy', locals: {object: @<%= singular %>, singular: "<%= singular %>", plural: "<%= plural %>", all_objects: <%= all_objects_variable %>} %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%%= render partial: 'common/common_edit', locals: {object: @<%= singular_name %>, singular: "<%= singular_name %>", plural: "<%= plural_name %>", url: <%= path_helper %>(<%= path_arity %>)} %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%%= render partial: 'common/common_index', locals: {objects: @<%= plural_name %>, singular: "<%= singular_name %>", plural: "<%= plural_name %>"} %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%%= render partial: 'common/common_new', locals: {object: @<%= singular %>, singular: "<%= singular %>", plural: "<%= plural %>"} %>
|
data/lib/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: common_core_js
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Fleetwood-Boldt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: kaminari
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.2.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.2.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: haml-rails
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.0.1
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.0.1
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: simplecov
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.17'
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.17'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.17'
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.17'
|
73
|
+
description: Simple, plug & play Rails scaffolding with really simple Javascript
|
74
|
+
email: jason.fb@datatravels.com
|
75
|
+
executables: []
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- app/assets/config/manifest.js
|
80
|
+
- app/views/common/_common_create.js.erb
|
81
|
+
- app/views/common/_common_destroy.js.erb
|
82
|
+
- app/views/common/_common_edit.js.erb
|
83
|
+
- app/views/common/_common_edit_form.haml
|
84
|
+
- app/views/common/_common_index.js.erb
|
85
|
+
- app/views/common/_common_new.js.erb
|
86
|
+
- app/views/common/_common_new_form.haml
|
87
|
+
- app/views/common/_common_show_form.haml
|
88
|
+
- app/views/common/_common_update.js.erb
|
89
|
+
- lib/.DS_Store
|
90
|
+
- lib/common_core_js.rb
|
91
|
+
- lib/generators/common_core/USAGE
|
92
|
+
- lib/generators/common_core/erb/scaffold/common_core_scaffold_generator.rb
|
93
|
+
- lib/generators/common_core/scaffold_generator.rb
|
94
|
+
- lib/generators/common_core/templates/_edit.haml
|
95
|
+
- lib/generators/common_core/templates/_form.haml
|
96
|
+
- lib/generators/common_core/templates/_line.haml
|
97
|
+
- lib/generators/common_core/templates/_list.haml
|
98
|
+
- lib/generators/common_core/templates/_new.haml
|
99
|
+
- lib/generators/common_core/templates/controller.rb
|
100
|
+
- lib/generators/common_core/templates/create.js.erb
|
101
|
+
- lib/generators/common_core/templates/destroy.js.erb
|
102
|
+
- lib/generators/common_core/templates/edit.js.erb
|
103
|
+
- lib/generators/common_core/templates/index.js.erb
|
104
|
+
- lib/generators/common_core/templates/new.js.erb
|
105
|
+
- lib/generators/common_core/templates/update.js.erb
|
106
|
+
- lib/version.rb
|
107
|
+
homepage: http://rubygems.org/gems/common-core-js
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata:
|
111
|
+
source_code_uri: https://github.com/jasonfb/common_core_js
|
112
|
+
post_install_message: "---------------------------------------------\nWelcome to Common
|
113
|
+
Core\n\nrails generate common_score:scaffold Thing\n\n * Build plug-and-play
|
114
|
+
scaffolding mixing HAML with jQuery-based Javascript\n * Automatically Reads
|
115
|
+
Your Models (make them first!)\n * Excellent for CRUD, lists with pagination,
|
116
|
+
searching, sorting.\n * Wonderful for prototyping\n * Plays with Devise, Kaminari,
|
117
|
+
Haml-Rails\n * Nest your routes model-by-model for built-in poor man's authentication\n
|
118
|
+
\ * Throw it away when you're done. \n\nsee README for complete instructions.\n---------------------------------------------\n"
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
- app
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 1.3.1
|
133
|
+
requirements: []
|
134
|
+
rubygems_version: 3.0.3
|
135
|
+
signing_key:
|
136
|
+
specification_version: 4
|
137
|
+
summary: A gem build scaffolding.
|
138
|
+
test_files: []
|