madmin 0.1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +50 -63
- data/Rakefile +5 -6
- data/app/assets/config/manifest.js +2 -0
- data/app/assets/stylesheets/actiontext.scss +36 -0
- data/app/assets/stylesheets/{madmin/application.css → application.css} +2 -9
- data/app/controllers/madmin/base_controller.rb +5 -9
- data/app/controllers/madmin/dashboard_controller.rb +1 -3
- data/app/controllers/madmin/resource_controller.rb +81 -0
- data/app/helpers/madmin/application_helper.rb +10 -8
- data/app/views/layouts/madmin/application.html.erb +23 -25
- data/app/views/madmin/application/_form.html.erb +25 -0
- data/app/views/madmin/application/_javascript.html.erb +24 -0
- data/app/views/madmin/application/_navigation.html.erb +6 -0
- data/app/views/madmin/application/edit.html.erb +3 -0
- data/app/views/madmin/application/index.html.erb +47 -0
- data/app/views/madmin/application/new.html.erb +3 -0
- data/app/views/madmin/application/show.html.erb +24 -0
- data/app/views/madmin/dashboard/show.html.erb +1 -0
- data/app/views/madmin/fields/attachment/_form.html.erb +2 -0
- data/app/views/madmin/fields/attachment/_index.html.erb +3 -0
- data/app/views/madmin/fields/attachment/_show.html.erb +3 -0
- data/app/views/madmin/fields/attachments/_form.html.erb +2 -0
- data/app/views/madmin/fields/attachments/_index.html.erb +1 -0
- data/app/views/madmin/fields/attachments/_show.html.erb +7 -0
- data/app/views/madmin/fields/belongs_to/_form.html.erb +2 -14
- data/app/views/madmin/fields/belongs_to/_index.html.erb +3 -7
- data/app/views/madmin/fields/belongs_to/_show.html.erb +3 -8
- data/app/views/madmin/fields/boolean/_form.html.erb +2 -0
- data/app/views/madmin/fields/boolean/_index.html.erb +1 -0
- data/app/views/madmin/fields/boolean/_show.html.erb +1 -0
- data/app/views/madmin/fields/date/_form.html.erb +2 -0
- data/app/views/madmin/fields/date/_index.html.erb +1 -0
- data/app/views/madmin/fields/date/_show.html.erb +1 -0
- data/app/views/madmin/fields/date_time/_form.html.erb +2 -0
- data/app/views/madmin/fields/date_time/_index.html.erb +1 -0
- data/app/views/madmin/fields/date_time/_show.html.erb +1 -0
- data/app/views/madmin/fields/decimal/_form.html.erb +2 -0
- data/app/views/madmin/fields/decimal/_index.html.erb +1 -0
- data/app/views/madmin/fields/decimal/_show.html.erb +1 -0
- data/app/views/madmin/fields/enum/_form.html.erb +2 -0
- data/app/views/madmin/fields/enum/_index.html.erb +1 -0
- data/app/views/madmin/fields/enum/_show.html.erb +1 -0
- data/app/views/madmin/fields/float/_form.html.erb +2 -0
- data/app/views/madmin/fields/float/_index.html.erb +1 -0
- data/app/views/madmin/fields/float/_show.html.erb +1 -0
- data/app/views/madmin/fields/has_many/_form.html.erb +2 -0
- data/app/views/madmin/fields/has_many/_index.html.erb +1 -0
- data/app/views/madmin/fields/has_many/_show.html.erb +4 -14
- data/app/views/madmin/fields/has_one/_form.html.erb +3 -0
- data/app/views/madmin/fields/has_one/_index.html.erb +3 -0
- data/app/views/madmin/fields/has_one/_show.html.erb +3 -12
- data/app/views/madmin/fields/integer/_form.html.erb +2 -0
- data/app/views/madmin/fields/integer/_index.html.erb +1 -0
- data/app/views/madmin/fields/integer/_show.html.erb +1 -0
- data/app/views/madmin/fields/json/_form.html.erb +2 -0
- data/app/views/madmin/fields/json/_index.html.erb +1 -0
- data/app/views/madmin/fields/json/_show.html.erb +1 -0
- data/app/views/madmin/fields/polymorphic/_form.html.erb +5 -32
- data/app/views/madmin/fields/polymorphic/_index.html.erb +3 -1
- data/app/views/madmin/fields/polymorphic/_show.html.erb +3 -14
- data/app/views/madmin/fields/rich_text/_form.html.erb +4 -0
- data/app/views/madmin/fields/rich_text/_index.html.erb +1 -0
- data/app/views/madmin/fields/rich_text/_show.html.erb +3 -0
- data/app/views/madmin/fields/string/_form.html.erb +2 -0
- data/app/views/madmin/fields/string/_index.html.erb +1 -0
- data/app/views/madmin/fields/string/_show.html.erb +1 -0
- data/app/views/madmin/fields/text/_form.html.erb +2 -4
- data/app/views/madmin/fields/text/_index.html.erb +1 -1
- data/app/views/madmin/fields/text/_show.html.erb +1 -8
- data/app/views/madmin/fields/time/_form.html.erb +2 -0
- data/app/views/madmin/fields/time/_index.html.erb +1 -0
- data/app/views/madmin/fields/time/_show.html.erb +1 -0
- data/lib/generators/madmin/install/install_generator.rb +31 -12
- data/lib/generators/madmin/install/templates/controller.rb.tt +22 -0
- data/lib/generators/madmin/resource/resource_generator.rb +83 -47
- data/lib/generators/madmin/resource/templates/controller.rb.tt +4 -0
- data/lib/generators/madmin/resource/templates/resource.rb.tt +11 -0
- data/lib/generators/madmin/views/edit_generator.rb +16 -0
- data/lib/generators/madmin/views/form_generator.rb +15 -0
- data/lib/generators/madmin/views/index_generator.rb +15 -0
- data/lib/generators/madmin/views/layout_generator.rb +21 -0
- data/lib/generators/madmin/views/navigation_generator.rb +15 -0
- data/lib/generators/madmin/views/new_generator.rb +16 -0
- data/lib/generators/madmin/views/show_generator.rb +15 -0
- data/lib/generators/madmin/views/views_generator.rb +8 -8
- data/lib/madmin.rb +34 -23
- data/lib/madmin/engine.rb +5 -2
- data/lib/madmin/field.rb +22 -46
- data/lib/madmin/fields/attachment.rb +6 -0
- data/lib/madmin/fields/attachments.rb +9 -0
- data/lib/madmin/fields/belongs_to.rb +18 -0
- data/lib/madmin/fields/boolean.rb +6 -0
- data/lib/madmin/fields/date.rb +6 -0
- data/lib/madmin/fields/date_time.rb +6 -0
- data/lib/madmin/fields/decimal.rb +6 -0
- data/lib/madmin/fields/enum.rb +9 -0
- data/lib/madmin/fields/float.rb +6 -0
- data/lib/madmin/fields/has_many.rb +18 -0
- data/lib/madmin/fields/has_one.rb +6 -0
- data/lib/madmin/fields/integer.rb +6 -0
- data/lib/madmin/fields/json.rb +6 -0
- data/lib/madmin/fields/polymorphic.rb +17 -0
- data/lib/madmin/fields/rich_text.rb +6 -0
- data/lib/madmin/fields/string.rb +6 -0
- data/lib/madmin/fields/text.rb +6 -0
- data/lib/madmin/fields/time.rb +6 -0
- data/lib/madmin/generator_helpers.rb +24 -0
- data/lib/madmin/namespace.rb +35 -0
- data/lib/madmin/resource.rb +176 -0
- data/lib/madmin/version.rb +1 -1
- data/lib/madmin/view_generator.rb +42 -0
- data/lib/tasks/madmin_tasks.rake +7 -0
- metadata +106 -111
- data/app/assets/config/madmin_manifest.js +0 -2
- data/app/assets/javascripts/madmin/application.js +0 -15
- data/app/assets/javascripts/madmin/dashboard.js +0 -2
- data/app/assets/javascripts/madmin/resources.js +0 -36
- data/app/assets/stylesheets/madmin/dashboard.css +0 -4
- data/app/assets/stylesheets/madmin/resources.css +0 -4
- data/app/controllers/madmin/application_controller.rb +0 -16
- data/app/controllers/madmin/resources_controller.rb +0 -97
- data/app/decorators/madmin/resource_decorator.rb +0 -16
- data/app/helpers/madmin/fields/polymorphic_helper.rb +0 -25
- data/app/jobs/madmin/application_job.rb +0 -4
- data/app/mailers/madmin/application_mailer.rb +0 -6
- data/app/models/madmin/application_record.rb +0 -5
- data/app/views/application/_navigation.html.erb +0 -17
- data/app/views/madmin/dashboard/index.html.erb +0 -6
- data/app/views/madmin/fields/check_box/_form.html.erb +0 -4
- data/app/views/madmin/fields/check_box/_index.html.erb +0 -1
- data/app/views/madmin/fields/check_box/_show.html.erb +0 -8
- data/app/views/madmin/fields/email/_form.html.erb +0 -4
- data/app/views/madmin/fields/email/_index.html.erb +0 -1
- data/app/views/madmin/fields/email/_show.html.erb +0 -8
- data/app/views/madmin/fields/number/_form.html.erb +0 -4
- data/app/views/madmin/fields/number/_index.html.erb +0 -1
- data/app/views/madmin/fields/number/_show.html.erb +0 -8
- data/app/views/madmin/fields/password/_form.html.erb +0 -4
- data/app/views/madmin/fields/password/_index.html.erb +0 -1
- data/app/views/madmin/fields/password/_show.html.erb +0 -8
- data/app/views/madmin/fields/select/_form.html.erb +0 -4
- data/app/views/madmin/fields/select/_index.html.erb +0 -1
- data/app/views/madmin/fields/select/_show.html.erb +0 -8
- data/app/views/madmin/fields/text_area/_form.html.erb +0 -4
- data/app/views/madmin/fields/text_area/_index.html.erb +0 -1
- data/app/views/madmin/fields/text_area/_show.html.erb +0 -8
- data/app/views/madmin/resources/_form.html.erb +0 -15
- data/app/views/madmin/resources/_scopes.html.erb +0 -10
- data/app/views/madmin/resources/edit.html.erb +0 -2
- data/app/views/madmin/resources/index.html.erb +0 -13
- data/app/views/madmin/resources/index/_content.html.erb +0 -33
- data/app/views/madmin/resources/new.html.erb +0 -2
- data/app/views/madmin/resources/show.html.erb +0 -10
- data/config/routes.rb +0 -11
- data/lib/generators/madmin/controller/USAGE +0 -8
- data/lib/generators/madmin/controller/controller_generator.rb +0 -10
- data/lib/generators/madmin/page/USAGE +0 -8
- data/lib/generators/madmin/page/page_generator.rb +0 -20
- data/lib/generators/madmin/page/templates/template.html.erb +0 -2
- data/lib/generators/madmin/page/templates/template.rb.erb +0 -10
- data/lib/generators/madmin/resource/templates/resource.rb.erb +0 -11
- data/lib/madmin/field/associatable.rb +0 -58
- data/lib/madmin/field/belongs_to.rb +0 -9
- data/lib/madmin/field/check_box.rb +0 -8
- data/lib/madmin/field/date_time.rb +0 -8
- data/lib/madmin/field/email.rb +0 -8
- data/lib/madmin/field/has_many.rb +0 -9
- data/lib/madmin/field/has_one.rb +0 -9
- data/lib/madmin/field/number.rb +0 -8
- data/lib/madmin/field/password.rb +0 -8
- data/lib/madmin/field/polymorphic.rb +0 -57
- data/lib/madmin/field/select.rb +0 -13
- data/lib/madmin/field/text.rb +0 -8
- data/lib/madmin/field/text_area.rb +0 -8
- data/lib/madmin/resourceable.rb +0 -72
- data/lib/madmin/resourceable/class_methods.rb +0 -152
- data/lib/madmin/resources.rb +0 -13
@@ -0,0 +1 @@
|
|
1
|
+
<%= field.value(record) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= field.value(record) %>
|
@@ -1,4 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
<%= form.text_field field.key, class: "form-control" %>
|
4
|
-
</div>
|
1
|
+
<%= form.label field.attribute_name, class: "inline-block w-32 flex-shrink-0" %>
|
2
|
+
<%= form.text_area field.attribute_name, class: "form-input" %>
|
@@ -1 +1 @@
|
|
1
|
-
<%= field.
|
1
|
+
<%= field.value(record) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= field.value(record) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= field.value(record) %>
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "rails/generators/base"
|
2
1
|
require "madmin/generator_helpers"
|
3
2
|
|
4
3
|
module Madmin
|
@@ -6,25 +5,45 @@ module Madmin
|
|
6
5
|
class InstallGenerator < Rails::Generators::Base
|
7
6
|
include Madmin::GeneratorHelpers
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
source_root File.expand_path("../templates", __FILE__)
|
9
|
+
|
10
|
+
def eager_load
|
11
|
+
Rails.application.eager_load!
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_controller
|
15
|
+
template("controller.rb.tt", "app/controllers/madmin/application_controller.rb")
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_routes
|
19
|
+
if route_namespace_exists?
|
20
|
+
route "root to: \"dashboard#show\"", indentation: 4, sentinel: /namespace :madmin do\s*\n/m
|
21
|
+
else
|
22
|
+
route "root to: \"dashboard#show\"", namespace: [:madmin]
|
12
23
|
end
|
13
24
|
end
|
14
25
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
26
|
+
def generate_resources
|
27
|
+
generateable_models.each do |model|
|
28
|
+
if model.table_exists?
|
29
|
+
call_generator "madmin:resource", model.to_s
|
30
|
+
else
|
31
|
+
puts "Skipping #{model} because database table does not exist"
|
32
|
+
end
|
33
|
+
end
|
20
34
|
end
|
21
35
|
|
22
36
|
private
|
23
37
|
|
24
|
-
|
25
|
-
|
38
|
+
# Skip Abstract classes, ActiveRecord::Base, and auto-generated HABTM models
|
39
|
+
def generateable_models
|
40
|
+
active_record_models.reject do |model|
|
41
|
+
model.abstract_class? || model == ActiveRecord::Base || model.name.start_with?("HABTM_")
|
42
|
+
end
|
43
|
+
end
|
26
44
|
|
27
|
-
|
45
|
+
def active_record_models
|
46
|
+
ObjectSpace.each_object(ActiveRecord::Base.singleton_class)
|
28
47
|
end
|
29
48
|
end
|
30
49
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Madmin
|
2
|
+
class ApplicationController < Madmin::BaseController
|
3
|
+
before_action :authenticate_admin_user
|
4
|
+
|
5
|
+
def authenticate_admin_user
|
6
|
+
# TODO: Add your authentication logic here
|
7
|
+
|
8
|
+
# For example, we could redirect if the user isn't an admin
|
9
|
+
# redirect_to "/", alert: "Not authorized." unless user_signed_in? && current_user.admin?
|
10
|
+
end
|
11
|
+
|
12
|
+
# Authenticate with Clearance
|
13
|
+
# include Clearance::Controller
|
14
|
+
# before_action :require_login
|
15
|
+
|
16
|
+
# Authenticate with Devise
|
17
|
+
# before_action :authenticate_user!
|
18
|
+
|
19
|
+
# Authenticate with Basic Auth
|
20
|
+
# http_basic_authenticate_with(name: Rails.application.credentials.admin_username, password: Rails.application.credentials.admin_password)
|
21
|
+
end
|
22
|
+
end
|
@@ -1,75 +1,111 @@
|
|
1
|
-
require "rails/generators/named_base"
|
2
|
-
require "madmin/generator_helpers"
|
3
|
-
|
4
1
|
module Madmin
|
5
2
|
module Generators
|
6
3
|
class ResourceGenerator < Rails::Generators::NamedBase
|
7
|
-
|
8
|
-
boolean: "Field::CheckBox",
|
9
|
-
date: "Field::DateTime",
|
10
|
-
datetime: "Field::DateTime",
|
11
|
-
enum: "Field::Text",
|
12
|
-
float: "Field::Number",
|
13
|
-
integer: "Field::Number",
|
14
|
-
time: "Field::DateTime",
|
15
|
-
text: "Field::TextArea",
|
16
|
-
string: "Field::Text",
|
17
|
-
}
|
4
|
+
include Madmin::GeneratorHelpers
|
18
5
|
|
19
6
|
source_root File.expand_path("../templates", __FILE__)
|
20
7
|
|
21
|
-
def
|
22
|
-
|
23
|
-
"resource.rb.erb",
|
24
|
-
Rails.root.join("app/madmin/resources/#{file_name}.rb"),
|
25
|
-
)
|
8
|
+
def eager_load
|
9
|
+
Rails.application.eager_load!
|
26
10
|
end
|
27
11
|
|
28
|
-
|
12
|
+
def generate_resource
|
13
|
+
template "resource.rb", "app/madmin/resources/#{file_path}_resource.rb"
|
14
|
+
end
|
29
15
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
16
|
+
def generate_controller
|
17
|
+
destination = Rails.root.join("app/controllers/madmin/#{file_path.pluralize}_controller.rb")
|
18
|
+
template("controller.rb", destination)
|
19
|
+
end
|
34
20
|
|
35
|
-
|
36
|
-
|
21
|
+
def generate_route
|
22
|
+
if route_namespace_exists?
|
23
|
+
route "resources :#{plural_name}", namespace: class_path, indentation: 4, sentinel: /namespace :madmin do\s*\n/m
|
24
|
+
else
|
25
|
+
route "resources :#{plural_name}", namespace: [:madmin] + class_path
|
26
|
+
end
|
37
27
|
end
|
38
28
|
|
29
|
+
private
|
30
|
+
|
39
31
|
def associations
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
32
|
+
model.reflections.reject { |name, association|
|
33
|
+
# Hide these special associations
|
34
|
+
name.starts_with?("rich_text") ||
|
35
|
+
name.ends_with?("_attachment") ||
|
36
|
+
name.ends_with?("_attachments") ||
|
37
|
+
name.ends_with?("_blob") ||
|
38
|
+
name.ends_with?("_blobs")
|
39
|
+
}.keys
|
40
|
+
end
|
41
|
+
|
42
|
+
def attributes
|
43
|
+
model.attribute_names + virtual_attributes - redundant_attributes
|
44
|
+
end
|
45
|
+
|
46
|
+
def virtual_attributes
|
47
|
+
virtual = []
|
48
|
+
|
49
|
+
# Add virtual attributes for ActionText and ActiveStorage
|
50
|
+
model.reflections.each do |name, association|
|
51
|
+
if name.starts_with?("rich_text")
|
52
|
+
virtual << name.split("rich_text_").last
|
53
|
+
elsif name.ends_with?("_attachment")
|
54
|
+
virtual << name.split("_attachment").first
|
55
|
+
elsif name.ends_with?("_attachments")
|
56
|
+
virtual << name.split("_attachments").first
|
49
57
|
end
|
50
58
|
end
|
59
|
+
|
60
|
+
virtual
|
51
61
|
end
|
52
62
|
|
53
|
-
def
|
54
|
-
|
63
|
+
def redundant_attributes
|
64
|
+
redundant = []
|
55
65
|
|
56
|
-
|
57
|
-
if association.
|
58
|
-
|
59
|
-
elsif association.
|
60
|
-
|
66
|
+
model.reflections.each do |name, association|
|
67
|
+
if association.has_one?
|
68
|
+
next
|
69
|
+
elsif association.collection?
|
70
|
+
next
|
71
|
+
elsif association.polymorphic?
|
72
|
+
redundant << "#{name}_id"
|
73
|
+
redundant << "#{name}_type"
|
74
|
+
elsif name.starts_with?("rich_text")
|
75
|
+
redundant << name
|
76
|
+
else # belongs to
|
77
|
+
redundant << "#{name}_id"
|
61
78
|
end
|
62
79
|
end
|
63
80
|
|
64
|
-
|
81
|
+
redundant
|
82
|
+
end
|
83
|
+
|
84
|
+
def model
|
85
|
+
@model ||= class_name.constantize
|
65
86
|
end
|
66
87
|
|
67
|
-
def
|
68
|
-
|
88
|
+
def formatted_options_for_attribute(name)
|
89
|
+
options = options_for_attribute(name)
|
90
|
+
return if options.blank?
|
91
|
+
|
92
|
+
", " + options.map { |key, value|
|
93
|
+
"#{key}: #{value}"
|
94
|
+
}.join(", ")
|
69
95
|
end
|
70
96
|
|
71
|
-
def
|
72
|
-
|
97
|
+
def options_for_attribute(name)
|
98
|
+
if %w[id created_at updated_at].include?(name)
|
99
|
+
{form: false}
|
100
|
+
|
101
|
+
# Attributes without a database column
|
102
|
+
elsif !model.column_names.include?(name)
|
103
|
+
{index: false}
|
104
|
+
|
105
|
+
# Counter cache columns are typically not editable
|
106
|
+
elsif name.ends_with?("_count")
|
107
|
+
{form: false}
|
108
|
+
end
|
73
109
|
end
|
74
110
|
end
|
75
111
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class <%= class_name %>Resource < Madmin::Resource
|
2
|
+
# Attributes
|
3
|
+
<% attributes.each do |attribute_name| -%>
|
4
|
+
attribute :<%= attribute_name %><%= formatted_options_for_attribute(attribute_name) %>
|
5
|
+
<% end -%>
|
6
|
+
|
7
|
+
# Associations
|
8
|
+
<% associations.each do |association_name| -%>
|
9
|
+
attribute :<%= association_name %>
|
10
|
+
<% end -%>
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "madmin/view_generator"
|
2
|
+
|
3
|
+
module Madmin
|
4
|
+
module Generators
|
5
|
+
module Views
|
6
|
+
class EditGenerator < Madmin::ViewGenerator
|
7
|
+
source_root template_source_path
|
8
|
+
|
9
|
+
def copy_edit
|
10
|
+
copy_resource_template("edit")
|
11
|
+
copy_resource_template("_form")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "madmin/view_generator"
|
2
|
+
|
3
|
+
module Madmin
|
4
|
+
module Generators
|
5
|
+
module Views
|
6
|
+
class FormGenerator < Madmin::ViewGenerator
|
7
|
+
source_root template_source_path
|
8
|
+
|
9
|
+
def copy_form
|
10
|
+
copy_resource_template("_form")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "madmin/view_generator"
|
2
|
+
|
3
|
+
module Madmin
|
4
|
+
module Generators
|
5
|
+
module Views
|
6
|
+
class IndexGenerator < Madmin::ViewGenerator
|
7
|
+
source_root template_source_path
|
8
|
+
|
9
|
+
def copy_template
|
10
|
+
copy_resource_template("index")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "madmin/view_generator"
|
2
|
+
|
3
|
+
module Madmin
|
4
|
+
module Generators
|
5
|
+
module Views
|
6
|
+
class LayoutGenerator < Madmin::ViewGenerator
|
7
|
+
source_root template_source_path
|
8
|
+
|
9
|
+
def copy_template
|
10
|
+
copy_file(
|
11
|
+
"../../layouts/madmin/application.html.erb",
|
12
|
+
"app/views/layouts/madmin/application.html.erb"
|
13
|
+
)
|
14
|
+
|
15
|
+
call_generator("madmin:views:navigation")
|
16
|
+
copy_resource_template("_javascript")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "madmin/view_generator"
|
2
|
+
|
3
|
+
module Madmin
|
4
|
+
module Generators
|
5
|
+
module Views
|
6
|
+
class NavigationGenerator < Madmin::ViewGenerator
|
7
|
+
source_root template_source_path
|
8
|
+
|
9
|
+
def copy_navigation
|
10
|
+
copy_resource_template("_navigation")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "madmin/view_generator"
|
2
|
+
|
3
|
+
module Madmin
|
4
|
+
module Generators
|
5
|
+
module Views
|
6
|
+
class NewGenerator < Madmin::ViewGenerator
|
7
|
+
source_root template_source_path
|
8
|
+
|
9
|
+
def copy_new
|
10
|
+
copy_resource_template("new")
|
11
|
+
copy_resource_template("_form")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "madmin/view_generator"
|
2
|
+
|
3
|
+
module Madmin
|
4
|
+
module Generators
|
5
|
+
module Views
|
6
|
+
class ShowGenerator < Madmin::ViewGenerator
|
7
|
+
source_root template_source_path
|
8
|
+
|
9
|
+
def copy_template
|
10
|
+
copy_resource_template("show")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require "
|
1
|
+
require "madmin/view_generator"
|
2
2
|
|
3
3
|
module Madmin
|
4
4
|
module Generators
|
5
|
-
class ViewsGenerator <
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
class ViewsGenerator < Madmin::ViewGenerator
|
6
|
+
def copy_templates
|
7
|
+
view = "madmin:views:"
|
8
|
+
call_generator("#{view}index", resource_path, "--namespace", namespace)
|
9
|
+
call_generator("#{view}show", resource_path, "--namespace", namespace)
|
10
|
+
call_generator("#{view}new", resource_path, "--namespace", namespace)
|
11
|
+
call_generator("#{view}edit", resource_path, "--namespace", namespace)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|