effective_developer 0.0.10 → 0.1.1
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/MIT-LICENSE +1 -1
- data/app/models/effective/code_writer.rb +7 -7
- data/lib/effective_developer/version.rb +1 -1
- data/lib/generators/effective/ability_generator.rb +3 -3
- data/lib/generators/effective/controller_generator.rb +2 -5
- data/lib/generators/effective/datatable_generator.rb +4 -6
- data/lib/generators/effective/form_generator.rb +49 -8
- data/lib/generators/effective/helpers.rb +19 -74
- data/lib/generators/effective/menu_generator.rb +34 -8
- data/lib/generators/effective/migration_generator.rb +4 -39
- data/lib/generators/effective/model_generator.rb +5 -1
- data/lib/generators/effective/route_generator.rb +6 -5
- data/lib/generators/effective/scaffold_controller_generator.rb +1 -1
- data/lib/generators/effective/scaffold_generator.rb +1 -1
- data/lib/generators/effective/views_generator.rb +3 -6
- data/lib/scaffolds/controllers/controller.rb +51 -54
- data/lib/scaffolds/datatables/datatable.rb +34 -5
- data/lib/scaffolds/forms/{_form.html.haml → default/_form.html.haml} +5 -3
- data/lib/scaffolds/forms/fields/_field_belongs_to.html.haml +4 -0
- data/lib/scaffolds/forms/fields/_field_boolean.html.haml +2 -0
- data/lib/scaffolds/forms/fields/_field_date.html.haml +2 -0
- data/lib/scaffolds/forms/fields/_field_datetime.html.haml +2 -0
- data/lib/scaffolds/forms/fields/_field_decimal.html.haml +2 -0
- data/lib/scaffolds/forms/fields/_field_integer.html.haml +2 -0
- data/lib/scaffolds/forms/fields/_field_nested_resource.html.haml +11 -0
- data/lib/scaffolds/forms/fields/_field_string.html.haml +2 -0
- data/lib/scaffolds/forms/fields/_field_text.html.haml +2 -0
- data/lib/scaffolds/forms/fields/_nested_resource_fields.html.haml +12 -0
- data/lib/scaffolds/forms/tabpanel/_form.html.haml +32 -0
- data/lib/scaffolds/forms/tabpanel/_tab_fields.html.haml +6 -0
- data/lib/scaffolds/forms/tabpanel/_tab_nested_resource.html.haml +3 -0
- data/lib/scaffolds/models/model.rb +3 -3
- data/lib/scaffolds/views/_resource.html.haml +8 -3
- data/lib/scaffolds/views/edit.html.haml +9 -0
- data/lib/scaffolds/views/index.html.haml +5 -3
- data/lib/scaffolds/views/new.html.haml +1 -1
- data/lib/scaffolds/views/show.html.haml +10 -1
- metadata +30 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 928a57aff71b27e895d035bdc80c13f5d27f3b27
|
4
|
+
data.tar.gz: 1bc206677f022f78df6dfd28c8b87210dc8ef232
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5a5ddf11e47a7f9ed27287e49c890bd35ad9009d2fdb3043424304f7df8ec631e401df78fc8a3675d8a7e004b2286e703a5d92dc116869519f1f913afc5e8d3
|
7
|
+
data.tar.gz: 557cf3af3b565c4aa7e87ff9ebf9136e80f6c4b7d806ff9654fd4967b827f17946990566ded2c2c17e24d49b45f4e3b8fb68301f7dddbf8a62235481bf240aab
|
data/MIT-LICENSE
CHANGED
@@ -22,19 +22,19 @@ module Effective
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# Returns true if the insert happened, nil if no insert
|
25
|
-
def insert_after_last(content, &block)
|
25
|
+
def insert_after_last(content, depth: nil, content_depth: nil, &block)
|
26
26
|
index = last(&block)
|
27
27
|
return nil unless index
|
28
28
|
|
29
|
-
insert(content, index)
|
29
|
+
insert(content, index, depth: depth, content_depth: content_depth)
|
30
30
|
end
|
31
31
|
|
32
32
|
# Returns true if the insert happened, nil if no insert
|
33
|
-
def insert_before_last(content, &block)
|
33
|
+
def insert_before_last(content, depth: nil, content_depth: nil, &block)
|
34
34
|
index = last(&block)
|
35
35
|
return nil unless index
|
36
36
|
|
37
|
-
insert(content, index-1)
|
37
|
+
insert(content, index-1, depth: depth, content_depth: content_depth)
|
38
38
|
end
|
39
39
|
|
40
40
|
def within(content, &block)
|
@@ -53,7 +53,7 @@ module Effective
|
|
53
53
|
@from.pop; @to.pop
|
54
54
|
end
|
55
55
|
|
56
|
-
def insert(content, index, depth
|
56
|
+
def insert(content, index, depth: nil, content_depth: nil)
|
57
57
|
contents = (content.kind_of?(Array) ? content : content.split(newline)).map { |str| str.strip }
|
58
58
|
|
59
59
|
depth ||= depth_at(index)
|
@@ -67,7 +67,7 @@ module Effective
|
|
67
67
|
lines.insert(index, newline)
|
68
68
|
end
|
69
69
|
|
70
|
-
content_depth
|
70
|
+
content_depth ||= 0
|
71
71
|
|
72
72
|
index = index + 1 # Insert after the given line
|
73
73
|
|
@@ -199,7 +199,7 @@ module Effective
|
|
199
199
|
def open?(content)
|
200
200
|
stripped = ss(content)
|
201
201
|
|
202
|
-
[' do'].any? { |end_with| stripped.end_with?(end_with) } ||
|
202
|
+
[' do'].any? { |end_with| stripped.split('#').first.to_s.end_with?(end_with) } ||
|
203
203
|
['class ', 'module ', 'def ', 'if '].any? { |start_with| stripped.start_with?(start_with) }
|
204
204
|
end
|
205
205
|
|
@@ -21,7 +21,7 @@ module Effective
|
|
21
21
|
|
22
22
|
def create_ability
|
23
23
|
Effective::CodeWriter.new('app/models/ability.rb') do |w|
|
24
|
-
if namespaces.blank?
|
24
|
+
if resource.namespaces.blank?
|
25
25
|
if w.find { |line, depth| depth == 2 && line == ability }
|
26
26
|
say_status :identical, ability, :blue
|
27
27
|
else
|
@@ -33,7 +33,7 @@ module Effective
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
namespaces.each do |namespace|
|
36
|
+
resource.namespaces.each do |namespace|
|
37
37
|
w.within("if user.is?(:#{namespace})") do
|
38
38
|
if w.find { |line, depth| depth == 1 && line == ability }
|
39
39
|
say_status :identical, ability, :blue
|
@@ -70,7 +70,7 @@ module Effective
|
|
70
70
|
abilities = '[' + abilities.map { |action| ':' + action }.join(', ') + ']'
|
71
71
|
end
|
72
72
|
|
73
|
-
"can #{abilities}, #{class_name}"
|
73
|
+
"can #{abilities}, #{resource.class_name}"
|
74
74
|
)
|
75
75
|
end
|
76
76
|
end
|
@@ -22,10 +22,7 @@ module Effective
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def assign_attributes
|
25
|
-
@attributes =
|
26
|
-
Rails::Generators::GeneratedAttribute.parse(attribute)
|
27
|
-
end
|
28
|
-
|
25
|
+
@attributes = invoked_attributes.presence || (resource.belong_tos_attributes + resource_attributes)
|
29
26
|
self.class.send(:attr_reader, :attributes)
|
30
27
|
end
|
31
28
|
|
@@ -34,7 +31,7 @@ module Effective
|
|
34
31
|
end
|
35
32
|
|
36
33
|
def create_controller
|
37
|
-
template 'controllers/controller.rb',
|
34
|
+
template 'controllers/controller.rb', resource.controller_file
|
38
35
|
end
|
39
36
|
|
40
37
|
protected
|
@@ -15,13 +15,11 @@ module Effective
|
|
15
15
|
|
16
16
|
desc 'Creates an Effective::Datatable in your app/datatables folder.'
|
17
17
|
|
18
|
-
argument :
|
18
|
+
argument :actions, type: :array, default: ['crud'], banner: 'action action'
|
19
|
+
class_option :attributes, type: :array, default: [], desc: 'Included permitted params, otherwise read from model'
|
19
20
|
|
20
21
|
def assign_attributes
|
21
|
-
@attributes =
|
22
|
-
Rails::Generators::GeneratedAttribute.parse(attribute)
|
23
|
-
end
|
24
|
-
|
22
|
+
@attributes = invoked_attributes.presence || resource_attributes
|
25
23
|
self.class.send(:attr_reader, :attributes)
|
26
24
|
end
|
27
25
|
|
@@ -30,7 +28,7 @@ module Effective
|
|
30
28
|
end
|
31
29
|
|
32
30
|
def create_datatable
|
33
|
-
template 'datatables/datatable.rb',
|
31
|
+
template 'datatables/datatable.rb', resource.datatable_file
|
34
32
|
end
|
35
33
|
|
36
34
|
end
|
@@ -18,29 +18,70 @@ module Effective
|
|
18
18
|
argument :attributes, type: :array, default: [], banner: 'field[:type] field[:type]'
|
19
19
|
|
20
20
|
def assign_attributes
|
21
|
-
@attributes =
|
22
|
-
|
23
|
-
end
|
21
|
+
@attributes = invoked_attributes.presence || resource_attributes
|
22
|
+
self.class.send(:attr_reader, :attributes)
|
24
23
|
end
|
25
24
|
|
26
25
|
def invoke_form
|
27
26
|
say_status :invoke, :form, :white
|
28
27
|
end
|
29
28
|
|
30
|
-
def
|
31
|
-
|
29
|
+
def create_default_form
|
30
|
+
if resource.nested_resources.blank?
|
31
|
+
template 'forms/default/_form.html.haml', resource.view_file('form', partial: true)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_tabpanel_form
|
36
|
+
if resource.nested_resources.present?
|
37
|
+
template 'forms/tabpanel/_form.html.haml', resource.view_file('form', partial: true)
|
38
|
+
template 'forms/tabpanel/_tab_fields.html.haml', resource.view_file("form_#{resource.name}", partial: true)
|
39
|
+
end
|
40
|
+
|
41
|
+
class_eval { attr_accessor :nested_resource }
|
42
|
+
|
43
|
+
resource.nested_resources.each do |_, nested_resource|
|
44
|
+
@nested_resource = nested_resource
|
45
|
+
template 'forms/tabpanel/_tab_nested_resource.html.haml', resource.view_file("form_#{nested_resource.plural_name}", partial: true)
|
46
|
+
template 'forms/fields/_nested_resource_fields.html.haml', File.join('app/views', resource.namespace, (resource.namespace.present? ? '' : resource.class_path), nested_resource.name.to_s.underscore.pluralize, '_fields.html.haml')
|
47
|
+
end
|
32
48
|
end
|
33
49
|
|
34
50
|
protected
|
35
51
|
|
36
52
|
def form_for
|
37
|
-
if namespaces.blank?
|
38
|
-
|
53
|
+
if resource.namespaces.blank?
|
54
|
+
resource.name
|
39
55
|
else
|
40
|
-
'[' + namespaces.map { |ns| ':' + ns }.join(', ') + ', ' +
|
56
|
+
'[' + resource.namespaces.map { |ns| ':' + ns }.join(', ') + ', ' + resource.name + ']'
|
41
57
|
end
|
42
58
|
end
|
43
59
|
|
60
|
+
def render_field(attribute, depth: 0)
|
61
|
+
b = binding
|
62
|
+
|
63
|
+
partial = case attribute
|
64
|
+
when ActiveRecord::Reflection::BelongsToReflection
|
65
|
+
b.local_variable_set(:reference, attribute)
|
66
|
+
'belongs_to'
|
67
|
+
when ActiveRecord::Reflection::HasManyReflection
|
68
|
+
b.local_variable_set(:nested_resource, attribute)
|
69
|
+
'nested_resource'
|
70
|
+
when Effective::Resource
|
71
|
+
b.local_variable_set(:nested_resource, attribute)
|
72
|
+
'nested_resource'
|
73
|
+
else
|
74
|
+
b.local_variable_set(:attribute, attribute)
|
75
|
+
(attribute.type || :string).to_s
|
76
|
+
end
|
77
|
+
|
78
|
+
html = ERB.new(
|
79
|
+
File.read("#{File.dirname(__FILE__)}/../../scaffolds/forms/fields/_field_#{partial}.html.haml")
|
80
|
+
).result(b).split("\n").map { |line| (' ' * depth) + line }
|
81
|
+
|
82
|
+
html.length > 1 ? (html.join("\n") + "\n") : html.join
|
83
|
+
end
|
84
|
+
|
44
85
|
end
|
45
86
|
end
|
46
87
|
end
|
@@ -4,6 +4,10 @@ module Effective
|
|
4
4
|
|
5
5
|
protected
|
6
6
|
|
7
|
+
def resource
|
8
|
+
@resource ||= Effective::Resource.new(name)
|
9
|
+
end
|
10
|
+
|
7
11
|
def crud_actions
|
8
12
|
%w(index new create show edit update destroy)
|
9
13
|
end
|
@@ -24,96 +28,37 @@ module Effective
|
|
24
28
|
actions
|
25
29
|
end
|
26
30
|
|
31
|
+
# As per the command line invoked actions. These are Rails Generated Attributes
|
27
32
|
def invoked_attributes
|
28
33
|
if respond_to?(:attributes)
|
29
|
-
attributes
|
34
|
+
attributes
|
30
35
|
else
|
31
|
-
Array(options.attributes).compact
|
36
|
+
Array(options.attributes).compact.map { |att| Rails::Generators::GeneratedAttribute.parse(att) }
|
32
37
|
end
|
33
38
|
end
|
34
39
|
|
35
40
|
def invoked_attributes_args
|
36
|
-
invoked_attributes.present? ? (['--attributes'] + invoked_attributes) : []
|
41
|
+
invoked_attributes.present? ? (['--attributes'] + invokable(invoked_attributes)) : []
|
37
42
|
end
|
38
43
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
begin
|
44
|
-
attributes = klass.new().attributes
|
45
|
-
rescue ActiveRecord::StatementInvalid => e
|
46
|
-
pending = ActiveRecord::Migrator.new(:up, ActiveRecord::Migrator.migrations(ActiveRecord::Migrator.migrations_paths)).pending_migrations.present?
|
47
|
-
|
48
|
-
if e.message.include?('PG::UndefinedTable') && pending
|
49
|
-
migrate = ask("Unable to read the attributes of #{class_name}. There are pending migrations. Run db:migrate now? [y/n]")
|
50
|
-
system('bundle exec rake db:migrate') if migrate.to_s.include?('y')
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
begin
|
55
|
-
attributes = klass.new().attributes
|
56
|
-
rescue => e
|
57
|
-
puts "Unable to call #{class_name}.new().attributes. Continuing with empty attributes." if verbose
|
58
|
-
return []
|
59
|
-
end
|
60
|
-
|
61
|
-
attribute_names = attributes.keys - [klass.primary_key, 'created_at', 'updated_at']
|
62
|
-
attribute_names -= ['site_id'] if klass.respond_to?(:is_site_specific)
|
63
|
-
|
64
|
-
attribute_names.map do |attr|
|
65
|
-
if klass.respond_to?(:column_for_attribute) # Rails 4+
|
66
|
-
"#{attr}:#{klass.column_for_attribute(attr).try(:type) || 'string'}"
|
67
|
-
else
|
68
|
-
"#{attr}:#{klass.columns_hash[attr].try(:type) || 'string'}"
|
69
|
-
end
|
70
|
-
end
|
44
|
+
# Turns the GeneratedAttribute or Effective::Attribute into an array of strings
|
45
|
+
def invokable(attributes)
|
46
|
+
attributes.map { |att| "#{att.name}:#{att.type}" }
|
71
47
|
end
|
72
48
|
|
73
|
-
def
|
74
|
-
|
75
|
-
end
|
49
|
+
def resource_attributes
|
50
|
+
klass_attributes = resource.klass_attributes
|
76
51
|
|
77
|
-
|
78
|
-
|
79
|
-
@class_path = (name.include?('/') ? name[(name.rindex('/')+1)..-1] : name).split('::')
|
80
|
-
@class_path.map!(&:underscore)
|
81
|
-
@class_path[@class_path.length-1] = @class_path.last.singularize # Always singularize
|
82
|
-
@file_name = @class_path.pop
|
83
|
-
end
|
84
|
-
|
85
|
-
def namespaces
|
86
|
-
@namespaces ||= namespace_path.split('/')
|
87
|
-
end
|
52
|
+
if klass_attributes.blank?
|
53
|
+
pending = ActiveRecord::Migrator.new(:up, ActiveRecord::Migrator.migrations(ActiveRecord::Migrator.migrations_paths)).pending_migrations.present?
|
88
54
|
|
89
|
-
|
90
|
-
|
91
|
-
def namespace_path
|
92
|
-
name.include?('/') ? name[0...name.rindex('/')] : ''
|
93
|
-
end
|
55
|
+
migrate = ask("Unable to read the attributes of #{resource.klass}. There are pending migrations. Run db:migrate now? [y/n]")
|
56
|
+
system('bundle exec rake db:migrate') if migrate.to_s.include?('y')
|
94
57
|
|
95
|
-
|
96
|
-
if name.include?('/')
|
97
|
-
name[0...name.rindex('/')].classify + '::' + singular_name.classify.pluralize
|
98
|
-
else
|
99
|
-
singular_name.classify.pluralize
|
58
|
+
klass_attributes = resource.klass_attributes
|
100
59
|
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def index_path
|
104
|
-
[namespace_path.underscore.presence, plural_name, 'path'].compact.join('_')
|
105
|
-
end
|
106
|
-
|
107
|
-
def new_path
|
108
|
-
['new', namespace_path.underscore.presence, singular_name, 'path'].compact.join('_')
|
109
|
-
end
|
110
|
-
|
111
|
-
def edit_path
|
112
|
-
"edit_#{show_path}"
|
113
|
-
end
|
114
60
|
|
115
|
-
|
116
|
-
[namespace_path.underscore.presence, singular_name, 'path', "(@#{singular_name})"].compact.join('_')
|
61
|
+
klass_attributes.presence || resource.written_attributes
|
117
62
|
end
|
118
63
|
|
119
64
|
end
|
@@ -18,9 +18,9 @@ module Effective
|
|
18
18
|
|
19
19
|
def create_menu
|
20
20
|
begin
|
21
|
-
Effective::CodeWriter.new((['app/views'] + namespaces + ['_navbar.html.haml']).join('/')) do |w|
|
22
|
-
if w.find { |line, _| line ==
|
23
|
-
say_status :identical, index_path, :blue
|
21
|
+
Effective::CodeWriter.new((['app/views'] + resource.namespaces + ['_navbar.html.haml']).join('/')) do |w|
|
22
|
+
if w.find { |line, _| line == menu_content.last.strip }
|
23
|
+
say_status :identical, resource.index_path, :blue
|
24
24
|
else
|
25
25
|
index = w.last { |line, _| line.start_with?('- if can?') }
|
26
26
|
|
@@ -28,8 +28,8 @@ module Effective
|
|
28
28
|
say_status(:skipped, :menu, :yellow) and return
|
29
29
|
end
|
30
30
|
|
31
|
-
w.insert_raw(
|
32
|
-
say_status :menu, index_path, :green
|
31
|
+
w.insert_raw(menu_content, index+1, w.depth_at(index))
|
32
|
+
say_status :menu, resource.index_path, :green
|
33
33
|
end
|
34
34
|
end
|
35
35
|
rescue Errno::ENOENT
|
@@ -38,15 +38,41 @@ module Effective
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def create_effective_menus
|
42
|
+
begin
|
43
|
+
Effective::CodeWriter.new('lib/tasks/generate/effective_menus.rake') do |w|
|
44
|
+
if w.find { |line, _| line == effective_menus_content }
|
45
|
+
say_status :identical, resource.index_path, :blue
|
46
|
+
else
|
47
|
+
index = w.first { |line, _| line.start_with?('item') }
|
48
|
+
|
49
|
+
w.insert(effective_menus_content, index)
|
50
|
+
|
51
|
+
system('rake generate:effective_menus')
|
52
|
+
|
53
|
+
say_status :effective_menus, resource.plural_name + '_path', :green
|
54
|
+
end
|
55
|
+
end
|
56
|
+
rescue Errno::ENOENT
|
57
|
+
# This will raise an error if the navbar file isn't present
|
58
|
+
say_status :skipped, :effective_menus, :yellow
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
41
62
|
private
|
42
63
|
|
43
|
-
def
|
64
|
+
def menu_content
|
44
65
|
[
|
45
66
|
"\n",
|
46
|
-
"- if can? :manage, #{class_name}",
|
47
|
-
" %li= link_to '#{plural_name.titleize}', #{index_path}"
|
67
|
+
"- if can? :manage, #{resource.class_name}",
|
68
|
+
" %li= link_to '#{resource.plural_name.titleize}', #{resource.index_path}"
|
48
69
|
]
|
49
70
|
end
|
71
|
+
|
72
|
+
def effective_menus_content
|
73
|
+
"item '#{resource.plural_name.titleize}', :#{resource.plural_name}_path"
|
74
|
+
end
|
75
|
+
|
50
76
|
end
|
51
77
|
end
|
52
78
|
end
|
@@ -23,11 +23,11 @@ module Effective
|
|
23
23
|
|
24
24
|
def create_migration
|
25
25
|
if invoked_attributes.present?
|
26
|
-
Rails::Generators.invoke('migration', ["create_#{plural_name}"] + (invoked_attributes | timestamps))
|
27
|
-
elsif klass_attributes
|
26
|
+
Rails::Generators.invoke('migration', ["create_#{plural_name}"] + (invokable(invoked_attributes) | timestamps))
|
27
|
+
elsif resource.klass_attributes.present?
|
28
28
|
raise 'klass_attributes already exist. We cant migrate (yet). Exiting.'
|
29
|
-
elsif written_attributes.present?
|
30
|
-
Rails::Generators.invoke('migration', ["create_#{plural_name}"] + (written_attributes | timestamps))
|
29
|
+
elsif resource.written_attributes.present?
|
30
|
+
Rails::Generators.invoke('migration', ["create_#{plural_name}"] + invokable(resource.belong_tos_attributes) + (invokable(resource.written_attributes) | timestamps))
|
31
31
|
else
|
32
32
|
raise 'You need to specify some attributes or have a model file present'
|
33
33
|
end
|
@@ -35,41 +35,6 @@ module Effective
|
|
35
35
|
|
36
36
|
protected
|
37
37
|
|
38
|
-
# Written attributes include all belong_tos, as well as
|
39
|
-
# any Attributes comments as per our custom 'Attributes' comment block contained in the model file
|
40
|
-
|
41
|
-
# Attributes
|
42
|
-
# name :string
|
43
|
-
# description :text
|
44
|
-
#
|
45
|
-
# another :string
|
46
|
-
|
47
|
-
def written_attributes
|
48
|
-
@written_attributes ||= (
|
49
|
-
attributes = []
|
50
|
-
|
51
|
-
Effective::CodeWriter.new(File.join('app/models', class_path, "#{file_name}.rb")) do |w|
|
52
|
-
# belong_tos
|
53
|
-
references = w.select { |line| line.start_with?('belongs_to '.freeze) }
|
54
|
-
|
55
|
-
if references.present?
|
56
|
-
attributes += w.map(indexes: references) { |line| [[line.scan(/belongs_to\s+:(\w+)/).flatten.first, 'references']] }
|
57
|
-
end
|
58
|
-
|
59
|
-
# Attributes
|
60
|
-
first = w.find { |line| line == '# Attributes' }
|
61
|
-
break unless first
|
62
|
-
|
63
|
-
last = w.find(from: first) { |line| line.start_with?('#') == false && line.length > 0 }
|
64
|
-
break unless last
|
65
|
-
|
66
|
-
attributes += w.map(from: first+1, to: last-1) { |line| line.scan(/^\W+(\w+)\W+:(\w+)/).presence }
|
67
|
-
end
|
68
|
-
|
69
|
-
attributes.flatten(1).compact.map { |attribute| attribute.join(':') }
|
70
|
-
)
|
71
|
-
end
|
72
|
-
|
73
38
|
def timestamps
|
74
39
|
['created_at:datetime', 'updated_at:datetime']
|
75
40
|
end
|
@@ -20,11 +20,15 @@ module Effective
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def create_model
|
23
|
-
template 'models/model.rb',
|
23
|
+
template 'models/model.rb', resource.model_file
|
24
24
|
end
|
25
25
|
|
26
26
|
protected
|
27
27
|
|
28
|
+
def parent_class_name
|
29
|
+
options[:parent] || (Rails::VERSION::MAJOR > 4 ? 'ApplicationRecord' : 'ActiveRecord::Base')
|
30
|
+
end
|
31
|
+
|
28
32
|
def to_s_attribute
|
29
33
|
attributes.find { |att| ['display_name', 'name', 'title', 'subject'].include?(att.name) }
|
30
34
|
end
|
@@ -23,7 +23,7 @@ module Effective
|
|
23
23
|
blocks = []
|
24
24
|
|
25
25
|
Effective::CodeWriter.new('config/routes.rb') do |w|
|
26
|
-
namespaces.each do |namespace|
|
26
|
+
resource.namespaces.each do |namespace|
|
27
27
|
index = nil
|
28
28
|
|
29
29
|
w.within(blocks.last) do
|
@@ -33,15 +33,16 @@ module Effective
|
|
33
33
|
index ? (blocks << index) : break
|
34
34
|
end
|
35
35
|
|
36
|
-
content = namespaces[blocks.length..-1].map { |
|
36
|
+
content = resource.namespaces[blocks.length..-1].map { |namespace| "namespace :#{namespace} do"} +
|
37
|
+
[resources].flatten + (['end'] * (resource.namespaces.length - blocks.length))
|
37
38
|
|
38
39
|
w.within(blocks.last) do
|
39
40
|
if content.length == 1 && w.find { |line, depth| depth == 1 && line == content.first }
|
40
41
|
say_status :identical, content.first, :blue
|
41
42
|
else
|
42
|
-
w.insert_after_last(content) { |line, depth| depth == 1 && line.start_with?('resources') } ||
|
43
|
-
w.insert_before_last(content) { |line, depth| depth == 1 && line.start_with?('root') } ||
|
44
|
-
w.insert_before_last(content) { |line, depth| line == 'end' }
|
43
|
+
w.insert_after_last(content, content_depth: blocks.length) { |line, depth| depth == 1 && line.start_with?('resources') } ||
|
44
|
+
w.insert_before_last(content, content_depth: blocks.length) { |line, depth| depth == 1 && line.start_with?('root') } ||
|
45
|
+
w.insert_before_last(content, content_depth: blocks.length) { |line, depth| line == 'end' }
|
45
46
|
|
46
47
|
say_status :route, content.join("\n\t\t")
|
47
48
|
end
|
@@ -39,7 +39,7 @@ module Effective
|
|
39
39
|
say_status(:skipped, :datatable, :yellow) and return
|
40
40
|
end
|
41
41
|
|
42
|
-
Rails::Generators.invoke('effective:datatable', [name] +
|
42
|
+
Rails::Generators.invoke('effective:datatable', [name] + invoked_actions + invoked_attributes_args)
|
43
43
|
end
|
44
44
|
|
45
45
|
def invoke_views
|
@@ -46,7 +46,7 @@ module Effective
|
|
46
46
|
say_status(:skipped, :datatable, :yellow) and return
|
47
47
|
end
|
48
48
|
|
49
|
-
Rails::Generators.invoke('effective:datatable', [name] +
|
49
|
+
Rails::Generators.invoke('effective:datatable', [name] + invoked_actions + invoked_attributes_args)
|
50
50
|
end
|
51
51
|
|
52
52
|
def invoke_views
|
@@ -17,10 +17,7 @@ module Effective
|
|
17
17
|
class_option :attributes, type: :array, default: [], desc: 'Included form attributes, otherwise read from model'
|
18
18
|
|
19
19
|
def assign_attributes
|
20
|
-
@attributes =
|
21
|
-
Rails::Generators::GeneratedAttribute.parse(attribute)
|
22
|
-
end
|
23
|
-
|
20
|
+
@attributes = invoked_attributes.presence || resource_attributes
|
24
21
|
self.class.send(:attr_reader, :attributes)
|
25
22
|
end
|
26
23
|
|
@@ -30,10 +27,10 @@ module Effective
|
|
30
27
|
|
31
28
|
def create_views
|
32
29
|
(invoked_actions & available_actions).each do |action|
|
33
|
-
template "views/#{action}.html.haml",
|
30
|
+
template "views/#{action}.html.haml", resource.view_file(action)
|
34
31
|
end
|
35
32
|
|
36
|
-
template
|
33
|
+
template 'views/_resource.html.haml', resource.view_file(resource.name, partial: true)
|
37
34
|
end
|
38
35
|
|
39
36
|
private
|
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
require_dependency '<%= namespaced_path %>/application_controller'
|
3
|
-
|
4
|
-
<% end -%>
|
5
|
-
<% module_namespacing do -%>
|
6
|
-
class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.presence, ApplicationController].compact.join('::') %>
|
1
|
+
class <%= resource.namespaced_class_name %>Controller < <%= [resource.namespace.try(:classify).presence, ApplicationController].compact.join('::') %>
|
7
2
|
before_action :authenticate_user! # Devise enforce user is present
|
8
3
|
|
9
4
|
<% if defined?(EffectiveResources) -%>
|
@@ -12,34 +7,34 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres
|
|
12
7
|
<% end -%>
|
13
8
|
<% if actions.delete('index') && !defined?(EffectiveResources) -%>
|
14
9
|
def index
|
15
|
-
@page_title = '<%= plural_name.titleize %>'
|
16
|
-
authorize! :index, <%= class_name %>
|
10
|
+
@page_title = '<%= resource.plural_name.titleize %>'
|
11
|
+
authorize! :index, <%= resource.class_name %>
|
17
12
|
|
18
|
-
@datatable = <%= namespaced_class_name %>Datatable.new(params[:scopes])
|
13
|
+
@datatable = <%= resource.namespaced_class_name %>Datatable.new(params[:scopes])
|
19
14
|
end
|
20
15
|
|
21
16
|
<% end -%>
|
22
17
|
<% if actions.delete('new') && !defined?(EffectiveResources) -%>
|
23
18
|
def new
|
24
|
-
@<%=
|
19
|
+
@<%= resource.name %> = <%= resource.class_name %>.new
|
25
20
|
|
26
|
-
@page_title = 'New <%= human_name %>'
|
27
|
-
authorize! :new, @<%=
|
21
|
+
@page_title = 'New <%= resource.human_name %>'
|
22
|
+
authorize! :new, @<%= resource.name %>
|
28
23
|
end
|
29
24
|
|
30
25
|
<% end -%>
|
31
26
|
<% if actions.delete('create') && !defined?(EffectiveResources) -%>
|
32
27
|
def create
|
33
|
-
@<%=
|
28
|
+
@<%= resource.name %> = <%= resource.class_name %>.new(<%= resource.name %>_params)
|
34
29
|
|
35
|
-
@page_title = 'New <%= human_name %>'
|
36
|
-
authorize! :create, @<%=
|
30
|
+
@page_title = 'New <%= resource.human_name %>'
|
31
|
+
authorize! :create, @<%= resource.name %>
|
37
32
|
|
38
|
-
if @<%=
|
39
|
-
flash[:success] = 'Successfully created <%=
|
33
|
+
if @<%= resource.name %>.save
|
34
|
+
flash[:success] = 'Successfully created <%= resource.name %>'
|
40
35
|
redirect_to(redirect_path)
|
41
36
|
else
|
42
|
-
flash.now[:danger] = "Unable to create <%=
|
37
|
+
flash.now[:danger] = "Unable to create <%= resource.name %>: #{@<%= resource.name %>.errors.full_messages.to_sentence}"
|
43
38
|
render :new
|
44
39
|
end
|
45
40
|
end
|
@@ -47,34 +42,34 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres
|
|
47
42
|
<% end -%>
|
48
43
|
<% if actions.delete('show') && !defined?(EffectiveResources) -%>
|
49
44
|
def show
|
50
|
-
@<%=
|
45
|
+
@<%= resource.name %> = <%= resource.class_name %>.find(params[:id])
|
51
46
|
|
52
|
-
@page_title = @<%=
|
53
|
-
authorize! :show, @<%=
|
47
|
+
@page_title = @<%= resource.name %>.to_s
|
48
|
+
authorize! :show, @<%= resource.name %>
|
54
49
|
end
|
55
50
|
|
56
51
|
<% end -%>
|
57
52
|
<% if actions.delete('edit') && !defined?(EffectiveResources) -%>
|
58
53
|
def edit
|
59
|
-
@<%=
|
54
|
+
@<%= resource.name %> = <%= resource.class_name %>.find(params[:id])
|
60
55
|
|
61
|
-
@page_title = "Edit #{@<%=
|
62
|
-
authorize! :edit, @<%=
|
56
|
+
@page_title = "Edit #{@<%= resource.name %>}"
|
57
|
+
authorize! :edit, @<%= resource.name %>
|
63
58
|
end
|
64
59
|
|
65
60
|
<% end -%>
|
66
61
|
<% if actions.delete('update') && !defined?(EffectiveResources) -%>
|
67
62
|
def update
|
68
|
-
@<%=
|
63
|
+
@<%= resource.name %> = <%= resource.class_name %>.find(params[:id])
|
69
64
|
|
70
|
-
@page_title = "Edit #{@<%=
|
71
|
-
authorize! :update, @<%=
|
65
|
+
@page_title = "Edit #{@<%= resource.name %>}"
|
66
|
+
authorize! :update, @<%= resource.name %>
|
72
67
|
|
73
|
-
if @<%=
|
74
|
-
flash[:success] = 'Successfully updated <%=
|
68
|
+
if @<%= resource.name %>.update_attributes(<%= resource.name %>_params)
|
69
|
+
flash[:success] = 'Successfully updated <%= resource.name %>'
|
75
70
|
redirect_to(redirect_path)
|
76
71
|
else
|
77
|
-
flash.now[:danger] = "Unable to update <%=
|
72
|
+
flash.now[:danger] = "Unable to update <%= resource.name %>: #{@<%= resource.name %>.errors.full_messages.to_sentence}"
|
78
73
|
render :edit
|
79
74
|
end
|
80
75
|
end
|
@@ -82,62 +77,65 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres
|
|
82
77
|
<% end -%>
|
83
78
|
<% if actions.delete('destroy') && !defined?(EffectiveResources) -%>
|
84
79
|
def destroy
|
85
|
-
@<%=
|
86
|
-
authorize! :destroy, @<%=
|
80
|
+
@<%= resource.name %> = <%= resource.class_name %>.find(params[:id])
|
81
|
+
authorize! :destroy, @<%= resource.name %>
|
87
82
|
|
88
|
-
if @<%=
|
89
|
-
flash[:success] = 'Successfully deleted <%=
|
83
|
+
if @<%= resource.name %>.destroy
|
84
|
+
flash[:success] = 'Successfully deleted <%= resource.name %>'
|
90
85
|
else
|
91
|
-
flash[:danger] = "Unable to delete <%=
|
86
|
+
flash[:danger] = "Unable to delete <%= resource.name %>: #{@<%= resource.name %>.errors.full_messages.to_sentence}"
|
92
87
|
end
|
93
88
|
|
94
|
-
redirect_to <%= index_path %>
|
89
|
+
redirect_to <%= resource.index_path %>
|
95
90
|
end
|
96
91
|
|
97
92
|
<% end -%>
|
98
93
|
<% if actions.delete('unarchive') -%>
|
99
94
|
def unarchive
|
100
|
-
@<%=
|
101
|
-
authorize! :unarchive, @<%=
|
95
|
+
@<%= resource.name %> = <%= resource.class_name %>.find(params[:id])
|
96
|
+
authorize! :unarchive, @<%= resource.name %>
|
102
97
|
|
103
|
-
if @<%=
|
104
|
-
flash[:success] = 'Successfully restored <%=
|
98
|
+
if @<%= resource.name %>.unarchive
|
99
|
+
flash[:success] = 'Successfully restored <%= resource.name %>'
|
105
100
|
else
|
106
|
-
flash.now[:danger] = "Unable to restore <%=
|
101
|
+
flash.now[:danger] = "Unable to restore <%= resource.name %>: #{@<%= resource.name %>.errors.full_messages.to_sentence}"
|
107
102
|
end
|
108
103
|
|
109
|
-
redirect_to <%= index_path %>
|
104
|
+
redirect_to <%= resource.index_path %>
|
110
105
|
end
|
111
106
|
|
112
107
|
<% end -%>
|
113
108
|
<% actions.each do |action| -%>
|
114
109
|
def <%= action %>
|
115
|
-
@<%=
|
110
|
+
@<%= resource.name %> = <%= resource.class_name %>.find(params[:id])
|
116
111
|
|
117
|
-
@page_title = "<%= action.titleize %> #{@<%=
|
118
|
-
authorize! :<%= action %>, @<%=
|
112
|
+
@page_title = "<%= action.titleize %> #{@<%= resource.name %>}"
|
113
|
+
authorize! :<%= action %>, @<%= resource.name %>
|
119
114
|
end
|
120
115
|
|
121
116
|
<% end -%>
|
122
117
|
protected
|
123
118
|
|
124
|
-
def <%=
|
125
|
-
params.require(:<%=
|
126
|
-
<%
|
127
|
-
<%= slice.map { |
|
119
|
+
def <%= resource.name %>_params
|
120
|
+
params.require(:<%= resource.name %>).permit(:id,
|
121
|
+
<% attributes.each_slice(8).with_index do |slice, index| -%>
|
122
|
+
<%= slice.map { |att| permitted_param_for(att.name) }.join(', ') %><%= ',' if (((index+1) * 8) < attributes.length || resource.nested_resources.present?) %>
|
123
|
+
<% end -%>
|
124
|
+
<% resource.nested_resources.each_with_index do |(_, nested_resource), index| -%>
|
125
|
+
<%= nested_resource.name %>_attributes: [:id, :_destroy, <%= (nested_resource.belong_tos_attributes + nested_resource.attributes).map { |att| ':' + att.name.to_s }.join(', ') %>]<%= ',' if index < resource.nested_resources.length-1 %>
|
128
126
|
<% end -%>
|
129
127
|
)
|
130
128
|
end
|
131
129
|
|
132
|
-
<% if
|
130
|
+
<% if defined?(EffectiveResources) -%>
|
133
131
|
def redirect_path
|
134
132
|
case params[:commit].to_s
|
135
133
|
when 'Save'
|
136
|
-
<%=
|
134
|
+
<%= resource.edit_path_helper %>
|
137
135
|
when 'Save and Continue'
|
138
|
-
<%= index_path %>
|
136
|
+
<%= resource.index_path %>
|
139
137
|
when 'Save and Add New'
|
140
|
-
<%= new_path %>
|
138
|
+
<%= resource.new_path %>
|
141
139
|
else
|
142
140
|
raise 'Unexpected redirect path'
|
143
141
|
end
|
@@ -145,4 +143,3 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres
|
|
145
143
|
|
146
144
|
<% end -%>
|
147
145
|
end
|
148
|
-
<% end -%>
|
@@ -1,14 +1,43 @@
|
|
1
|
-
class <%= namespaced_class_name %>Datatable < Effective::Datatable
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
class <%= resource.namespaced_class_name %>Datatable < Effective::Datatable
|
2
|
+
<% if resource.scopes.present? -%>
|
3
|
+
scopes do<% ([:all] + resource.scopes).uniq.each_with_index do |scope, index| %>
|
4
|
+
scope :<%= scope -%><%= ', default: true' if index == 0 -%>
|
5
5
|
<% end %>
|
6
|
+
end
|
7
|
+
|
8
|
+
<% end -%>
|
9
|
+
datatable do
|
10
|
+
default_order :<%= attributes.find { |att| att.name == 'updated_at' } || attributes.first %>, :desc
|
11
|
+
|
12
|
+
<% resource.belong_tos.each do |reference| -%>
|
13
|
+
table_column :<%= reference.name %>
|
14
|
+
<% end -%>
|
6
15
|
|
16
|
+
<% attributes.each do |attribute| -%>
|
17
|
+
table_column :<%= attribute.name %>
|
18
|
+
<% end -%>
|
19
|
+
|
20
|
+
<% if (invoked_actions - crud_actions).present? -%>
|
21
|
+
actions_column do |<%= singular_name %>|
|
22
|
+
<% (invoked_actions - crud_actions).each_with_index do |action, index| -%>
|
23
|
+
glyphicon_to('ok', <%= resource.action_path_helper(action, at: false) %>, title: '<%= action.titleize %>')<%= ' +' if (index+1) < (invoked_actions - crud_actions).length %>
|
24
|
+
<% end -%>
|
25
|
+
end
|
26
|
+
<% else -%>
|
7
27
|
actions_column
|
28
|
+
<% end -%>
|
8
29
|
end
|
9
30
|
|
31
|
+
<% if resource.scopes.blank? -%>
|
32
|
+
def collection
|
33
|
+
<%= resource.class_name %>.all
|
34
|
+
end
|
35
|
+
<% else -%>
|
10
36
|
def collection
|
11
|
-
<%= class_name %>.all
|
37
|
+
col = <%= resource.class_name %>.all
|
38
|
+
col = col.send(current_scope) if current_scope
|
39
|
+
col
|
12
40
|
end
|
41
|
+
<% end -%>
|
13
42
|
|
14
43
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
= simple_form_for(<%= form_for %>) do |f|
|
2
|
-
<%
|
3
|
-
|
2
|
+
<% resource.belong_tos.each do |reference| -%>
|
3
|
+
<%= render_field(reference, depth: 1) %>
|
4
|
+
<% end -%>
|
5
|
+
<% attributes.each do |attribute| -%>
|
6
|
+
<%= render_field(attribute, depth: 1) %>
|
4
7
|
<% end -%>
|
5
|
-
|
6
8
|
<% if defined?(EffectiveResources) -%>
|
7
9
|
= simple_form_submit(f)
|
8
10
|
<% else -%>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#<%= nested_resource.plural_name %>
|
2
|
+
= f.simple_fields_for :<%= nested_resource.plural_name %>, f.object.<%= nested_resource.plural_name %> do |fields|
|
3
|
+
= render '<%= [resource.namespace.presence, nested_resource.plural_name].compact.join('/') %>/fields', f: fields
|
4
|
+
|
5
|
+
- if can? :update, f.object
|
6
|
+
= f.error :<%= nested_resource.plural_name %>, class: 'alert alert-danger'
|
7
|
+
.links
|
8
|
+
= link_to_add_association(f, :<%= nested_resource.plural_name %>, partial: '<%= [resource.namespace.presence, nested_resource.plural_name].compact.join('/') %>/fields') do
|
9
|
+
%button.btn.btn-success
|
10
|
+
%span.glyphicon.glyphicon-plus-sign
|
11
|
+
Add another <%= nested_resource.name.titleize.downcase %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
.row.nested-fields
|
2
|
+
<% nested_resource.belong_tos_attributes.each do |attribute| -%>
|
3
|
+
.col-sm-2<%= render_field(attribute, depth: 1).sub(' ', '') -%>
|
4
|
+
|
5
|
+
<% end -%>
|
6
|
+
<% nested_resource.attributes.each do |attribute| -%>
|
7
|
+
.col-sm-2<%= render_field(attribute, depth: 1).sub(' ', '') -%>
|
8
|
+
|
9
|
+
<% end -%>
|
10
|
+
.col-sm-1
|
11
|
+
= link_to_remove_association(f, data: { confirm: 'Really remove?'}) do
|
12
|
+
%span.glyphicon.glyphicon-trash
|
@@ -0,0 +1,32 @@
|
|
1
|
+
= simple_form_for(<%= form_for %>) do |f|
|
2
|
+
%div{role: 'tabpanel'}
|
3
|
+
%ul.nav.nav-tabs{role: 'tablist'}
|
4
|
+
%li.active{role: 'presentation'}
|
5
|
+
%a{'data-toggle': 'tab', role: 'tab', 'aria-controls': '<%= resource.name %>-tab', href: '#<%= resource.name %>-tab'}
|
6
|
+
<%= resource.human_name.titleize %>
|
7
|
+
|
8
|
+
<% resource.nested_resources.each do |_, nested_resource| -%>
|
9
|
+
%li{role: 'presentation'}
|
10
|
+
%a{'data-toggle': 'tab', role: 'tab', 'aria-controls': '<%= nested_resource.plural_name %>-tab', href: '#<%= nested_resource.plural_name %>-tab'}
|
11
|
+
<%= nested_resource.plural_name.titleize %>
|
12
|
+
|
13
|
+
<% end -%>
|
14
|
+
.tab-content
|
15
|
+
#<%= resource.name %>-tab.tab-pane.active{role: 'tabpanel'}
|
16
|
+
= render 'form_<%= resource.name %>', f: f
|
17
|
+
|
18
|
+
<% resource.nested_resources.each do |_, nested_resource| -%>
|
19
|
+
#<%= nested_resource.plural_name %>-tab.tab-pane{role: 'tabpanel'}
|
20
|
+
= render 'form_<%= nested_resource.plural_name %>', f: f
|
21
|
+
|
22
|
+
<% end -%>
|
23
|
+
%hr
|
24
|
+
|
25
|
+
<% if defined?(EffectiveResources) -%>
|
26
|
+
= simple_form_submit(f)
|
27
|
+
<% else -%>
|
28
|
+
%p.text-right
|
29
|
+
= f.button :submit, 'Save', data: { disable_with: 'Saving...' }
|
30
|
+
= f.button :submit, 'Save and Continue', data: { disable_with: 'Saving...' }
|
31
|
+
= f.button :submit, 'Save and Add New', data: { disable_with: 'Saving...' }
|
32
|
+
<% end -%>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
|
-
class <%= class_name %> < <%= parent_class_name.classify %>
|
2
|
+
class <%= resource.class_name %> < <%= parent_class_name.classify %>
|
3
3
|
<% attributes.select(&:reference?).each do |attribute| -%>
|
4
4
|
belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %><%= ', required: true' if attribute.required? %>
|
5
5
|
<% end -%>
|
@@ -28,11 +28,11 @@ class <%= class_name %> < <%= parent_class_name.classify %>
|
|
28
28
|
|
29
29
|
<% if to_s_attribute.present? -%>
|
30
30
|
def to_s
|
31
|
-
<%= to_s_attribute.name %> || 'New <%= human_name %>'
|
31
|
+
<%= to_s_attribute.name %> || 'New <%= resource.human_name %>'
|
32
32
|
end
|
33
33
|
<% else -%>
|
34
34
|
def to_s
|
35
|
-
'<%= human_name %>'
|
35
|
+
'<%= resource.human_name %>'
|
36
36
|
end
|
37
37
|
<% end -%>
|
38
38
|
<% if archived_attribute.present? -%>
|
@@ -1,7 +1,12 @@
|
|
1
1
|
%table.table
|
2
2
|
%tbody
|
3
|
-
<%
|
3
|
+
<% resource.belong_tos.each do |reference| -%>
|
4
4
|
%tr
|
5
|
-
%th <%=
|
6
|
-
%td= <%=
|
5
|
+
%th <%= reference.name.to_s.titleize %>
|
6
|
+
%td= <%= resource.name %>.<%= reference.name %>
|
7
|
+
<% end %>
|
8
|
+
<% attributes.each do |attribute| -%>
|
9
|
+
%tr
|
10
|
+
%th <%= attribute.name.titleize %>
|
11
|
+
%td= <%= resource.name %>.<%= attribute.name %>
|
7
12
|
<% end %>
|
@@ -1,3 +1,12 @@
|
|
1
1
|
%h1= @page_title
|
2
2
|
|
3
|
+
<% if (invoked_actions - crud_actions).present? -%>
|
4
|
+
%p.text-right
|
5
|
+
<% (invoked_actions - crud_actions).each do |action| -%>
|
6
|
+
- if can?(:<%= action.to_s %>, @<%= resource.name %>)
|
7
|
+
= link_to '<%= action.titleize %>', <%= resource.action_path_helper(action, at: true) %>, class: 'btn btn-primary',
|
8
|
+
data: { confirm: 'Really <%= action.to_s.titleize %>?' }
|
9
|
+
|
10
|
+
<% end -%>
|
11
|
+
<% end -%>
|
3
12
|
= render 'form', <%= singular_name %>: @<%= singular_name %>
|
@@ -1,10 +1,12 @@
|
|
1
1
|
%h1= @page_title
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
<% if actions.include?('new') -%>
|
4
|
+
- if can?(:new, <%= resource.class_name %>)
|
5
|
+
%p.text-right= link_to 'New <%= resource.human_name %>', <%= resource.new_path %>, class: 'btn btn-primary'
|
5
6
|
|
7
|
+
<% end -%>
|
6
8
|
- if @datatable.present?
|
7
9
|
= render_datatable_scopes(@datatable)
|
8
10
|
= render_datatable(@datatable)
|
9
11
|
- else
|
10
|
-
%p There are no <%= plural_name %>.
|
12
|
+
%p There are no <%= resource.plural_name %>.
|
@@ -1,3 +1,12 @@
|
|
1
1
|
%h1= @page_title
|
2
2
|
|
3
|
-
|
3
|
+
<% if (invoked_actions - crud_actions).present? -%>
|
4
|
+
%p.text-right
|
5
|
+
<% (invoked_actions - crud_actions).each do |action| -%>
|
6
|
+
- if can?(:<%= action.to_s %>, @<%= resource.name %>)
|
7
|
+
= link_to '<%= action.titleize %>', <%= resource.action_path_helper(action, at: true) %>, class: 'btn btn-default',
|
8
|
+
data: { confirm: 'Really <%= action.to_s.titleize %>?' }
|
9
|
+
|
10
|
+
<% end -%>
|
11
|
+
<% end -%>
|
12
|
+
= render @<%= resource.name %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_developer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: effective_resources
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: Provides some quality of life developer tools.
|
28
42
|
email:
|
29
43
|
- info@codeandeffect.com
|
@@ -56,7 +70,20 @@ files:
|
|
56
70
|
- lib/generators/effective_developer/install_generator.rb
|
57
71
|
- lib/scaffolds/controllers/controller.rb
|
58
72
|
- lib/scaffolds/datatables/datatable.rb
|
59
|
-
- lib/scaffolds/forms/_form.html.haml
|
73
|
+
- lib/scaffolds/forms/default/_form.html.haml
|
74
|
+
- lib/scaffolds/forms/fields/_field_belongs_to.html.haml
|
75
|
+
- lib/scaffolds/forms/fields/_field_boolean.html.haml
|
76
|
+
- lib/scaffolds/forms/fields/_field_date.html.haml
|
77
|
+
- lib/scaffolds/forms/fields/_field_datetime.html.haml
|
78
|
+
- lib/scaffolds/forms/fields/_field_decimal.html.haml
|
79
|
+
- lib/scaffolds/forms/fields/_field_integer.html.haml
|
80
|
+
- lib/scaffolds/forms/fields/_field_nested_resource.html.haml
|
81
|
+
- lib/scaffolds/forms/fields/_field_string.html.haml
|
82
|
+
- lib/scaffolds/forms/fields/_field_text.html.haml
|
83
|
+
- lib/scaffolds/forms/fields/_nested_resource_fields.html.haml
|
84
|
+
- lib/scaffolds/forms/tabpanel/_form.html.haml
|
85
|
+
- lib/scaffolds/forms/tabpanel/_tab_fields.html.haml
|
86
|
+
- lib/scaffolds/forms/tabpanel/_tab_nested_resource.html.haml
|
60
87
|
- lib/scaffolds/importers/csv_importer.rb
|
61
88
|
- lib/scaffolds/models/model.rb
|
62
89
|
- lib/scaffolds/views/_resource.html.haml
|