express_admin 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/fonts/ionicons.eot +0 -0
- data/app/assets/fonts/ionicons.svg +1028 -697
- data/app/assets/fonts/ionicons.ttf +0 -0
- data/app/assets/fonts/ionicons.woff +0 -0
- data/app/assets/stylesheets/express_admin/components/_h_box.sass +2 -0
- data/app/assets/stylesheets/express_admin/components/_v_box.sass +2 -0
- data/app/assets/stylesheets/express_admin/plugins/_select2.sass +4 -0
- data/app/assets/stylesheets/express_admin/screen.sass +3 -0
- data/app/assets/stylesheets/express_admin/shared/_icons.sass +2 -0
- data/app/assets/stylesheets/express_admin/shared/_tables.sass +3 -3
- data/app/assets/stylesheets/ionicons/ionicons.scss +2968 -0
- data/app/components/express_admin/h_box.rb +11 -0
- data/app/components/express_admin/icon.rb +7 -0
- data/app/components/express_admin/icon_link.rb +34 -0
- data/app/components/express_admin/layout_component.rb +37 -0
- data/app/components/express_admin/pane.rb +4 -4
- data/app/components/express_admin/smart_form.rb +2 -1
- data/app/components/express_admin/smart_table.rb +16 -4
- data/app/components/express_admin/v_box.rb +10 -0
- data/app/views/layouts/express_admin/admin.html.et +1 -1
- data/app/views/shared/express_admin/_navigation_bar.html.et +6 -3
- data/config/initializers/request_store_current_user.rb +9 -0
- data/lib/express_admin/routes.rb +17 -0
- data/lib/express_admin/version.rb +1 -1
- data/lib/express_admin.rb +1 -0
- data/lib/generators/express_admin/install/install_generator.rb +1 -1
- data/lib/generators/express_admin/install/templates/controllers/admin_controller.rb.erb +19 -21
- data/lib/generators/express_admin/scaffold/scaffold_generator.rb +5 -30
- data/lib/generators/express_admin/scaffold/templates/controller/controller.rb +6 -8
- data/lib/generators/express_admin/scaffold/templates/index.html.et.erb +6 -8
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +2556 -0
- data/test/lib/generators/express_admin/install_generator_test.rb +1 -1
- data/test/lib/generators/express_admin/scaffold_generator_test.rb +4 -6
- data/vendor/gems/express_templates/express_templates-0.7.0.gem +0 -0
- data/vendor/gems/express_templates/express_templates-0.7.1.gem +0 -0
- data/vendor/gems/express_templates/lib/arbre/patches.rb +13 -1
- data/vendor/gems/express_templates/lib/express_templates/components/capabilities/resourceful.rb +9 -1
- data/vendor/gems/express_templates/lib/express_templates/components/forms/select.rb +17 -7
- data/vendor/gems/express_templates/lib/express_templates/components/forms/submit.rb +1 -1
- data/vendor/gems/express_templates/lib/express_templates/version.rb +1 -1
- data/vendor/gems/express_templates/test/components/forms/express_form_test.rb +1 -1
- data/vendor/gems/express_templates/test/components/forms/select_test.rb +1 -1
- data/vendor/gems/express_templates/test/components/forms/submit_test.rb +16 -1
- data/vendor/gems/express_templates/test/dummy/log/test.log +1575 -0
- metadata +30 -5
- data/app/assets/stylesheets/ionicons/ionicons.sass +0 -1873
@@ -0,0 +1,34 @@
|
|
1
|
+
module ExpressAdmin
|
2
|
+
class IconLink < ExpressTemplates::Components::Configurable
|
3
|
+
|
4
|
+
emits -> {
|
5
|
+
if config[:right]
|
6
|
+
a(anchor_args) {
|
7
|
+
text_node config[:text]
|
8
|
+
icon(config[:icon_name].to_sym)
|
9
|
+
}
|
10
|
+
else
|
11
|
+
a(anchor_args) {
|
12
|
+
icon(config[:icon_name].to_sym)
|
13
|
+
text_node config[:text]
|
14
|
+
}
|
15
|
+
end
|
16
|
+
}
|
17
|
+
|
18
|
+
def anchor_args
|
19
|
+
args = {class: class_list,
|
20
|
+
href: config[:href]}
|
21
|
+
args[:id] = config[:id] if config[:id]
|
22
|
+
args[:target] = config[:target] if config[:target]
|
23
|
+
args['data-delete'] = config[:delete] if config[:delete]
|
24
|
+
args['data-confirm'] = config[:confirm] if config[:confirm]
|
25
|
+
args[:title] = config[:title] if config[:title]
|
26
|
+
args
|
27
|
+
end
|
28
|
+
|
29
|
+
def icon_options
|
30
|
+
[:icon_name, :text, :right]
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -1,7 +1,44 @@
|
|
1
1
|
module ExpressAdmin
|
2
2
|
class LayoutComponent < ExpressTemplates::Components::Configurable
|
3
|
+
|
3
4
|
def dom_id
|
4
5
|
config.try(:[], :id)
|
5
6
|
end
|
7
|
+
|
8
|
+
def component_options
|
9
|
+
[:id, :class, :style] + supported_style_options
|
10
|
+
end
|
11
|
+
|
12
|
+
def component_classes
|
13
|
+
add_class config[:id].to_s
|
14
|
+
add_class config[:class]
|
15
|
+
class_names
|
16
|
+
end
|
17
|
+
|
18
|
+
def supported_style_options
|
19
|
+
[:height, :width]
|
20
|
+
end
|
21
|
+
|
22
|
+
def provided_style_attributes
|
23
|
+
config.select {|k,v| supported_style_options.include?(k) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def style_attributes
|
27
|
+
attribs = config[:style] || {}
|
28
|
+
attribs.merge(provided_style_attributes).map do |k, v|
|
29
|
+
"#{k}: #{v}"
|
30
|
+
end.join('; ')
|
31
|
+
end
|
32
|
+
|
33
|
+
def pass_along_attributes
|
34
|
+
config.reject {|k,v| component_options.include?(k) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def container_div_attributes
|
38
|
+
pass_along_attributes
|
39
|
+
.merge(id: dom_id, class: component_classes)
|
40
|
+
.merge(style: style_attributes)
|
41
|
+
end
|
42
|
+
|
6
43
|
end
|
7
44
|
end
|
@@ -4,7 +4,7 @@ module ExpressAdmin
|
|
4
4
|
class Pane < LayoutComponent
|
5
5
|
|
6
6
|
emits -> (block) {
|
7
|
-
div(
|
7
|
+
div(container_div_attributes) {
|
8
8
|
heading if title || status
|
9
9
|
block.call(self) if block
|
10
10
|
}
|
@@ -31,9 +31,9 @@ module ExpressAdmin
|
|
31
31
|
config[:status] || nil
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
34
|
+
def component_options
|
35
|
+
super +
|
36
|
+
[:title, :status]
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
@@ -32,7 +32,8 @@ module ExpressAdmin
|
|
32
32
|
'check_box' => 'checkbox'}
|
33
33
|
field_type = attrib.field_type.to_s.sub(/_field$/,'')
|
34
34
|
if relation = attrib.name.match(/(\w+)_id$/).try(:[], 1)
|
35
|
-
|
35
|
+
# TODO: should allow select2 override
|
36
|
+
select(attrib.name, options: config["#{relation}_collection".to_sym], select2: true)
|
36
37
|
else
|
37
38
|
if field_type == 'text_area'
|
38
39
|
textarea attrib.name.to_sym, rows: 10
|
@@ -20,7 +20,7 @@ module ExpressAdmin
|
|
20
20
|
}
|
21
21
|
}
|
22
22
|
tbody {
|
23
|
-
|
23
|
+
collection.each do |item|
|
24
24
|
tr(id: row_id(item), class: row_class(item)) {
|
25
25
|
display_columns.each do |column|
|
26
26
|
td(class: column.name) {
|
@@ -55,9 +55,21 @@ module ExpressAdmin
|
|
55
55
|
helpers.send(resource_path_helper, item.to_param)
|
56
56
|
end
|
57
57
|
|
58
|
+
def should_show_delete?(item)
|
59
|
+
if item.respond_to?(:can_delete?) && item.can_delete?
|
60
|
+
true
|
61
|
+
elsif !item.respond_to?(:can_delete?)
|
62
|
+
true
|
63
|
+
else
|
64
|
+
false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
58
68
|
def actions_column(item)
|
59
69
|
td {
|
60
|
-
|
70
|
+
if should_show_delete?(item)
|
71
|
+
link_to 'Delete', resource_path(item), method: :delete, data: {confirm: 'Are you sure?'}, class: 'button small secondary'
|
72
|
+
end
|
61
73
|
}
|
62
74
|
end
|
63
75
|
|
@@ -80,13 +92,13 @@ module ExpressAdmin
|
|
80
92
|
def cell_value(item, accessor)
|
81
93
|
if accessor.respond_to?(:call)
|
82
94
|
value = begin
|
83
|
-
|
95
|
+
eval "(#{accessor.source}).call(item).to_s"
|
84
96
|
rescue
|
85
97
|
'Error: '+$!.to_s
|
86
98
|
end
|
87
99
|
elsif attrib = accessor.to_s.match(/(\w+)_link$/).try(:[], 1)
|
88
100
|
# TODO: only works with non-namespaced routes
|
89
|
-
value = helpers.link_to item.send(attrib),
|
101
|
+
value = helpers.link_to item.send(attrib), resource_path(item)
|
90
102
|
elsif attrib = accessor.to_s.match(/(\w+)_in_words/).try(:[], 1)
|
91
103
|
value = item.send(attrib) ? (helpers.time_ago_in_words(item.send(attrib))+' ago') : 'never'
|
92
104
|
else
|
@@ -2,7 +2,7 @@
|
|
2
2
|
html {
|
3
3
|
head {
|
4
4
|
title { title_content }
|
5
|
-
meta(name: "description", content: "#{description_meta_content}")
|
5
|
+
meta(name: "description", content: "#{helpers.description_meta_content}")
|
6
6
|
meta(name: "viewport", content: "width=device-width, initial-scale=1.0")
|
7
7
|
admin_javascript_and_css_includes
|
8
8
|
yield(:page_css)
|
@@ -7,8 +7,11 @@ nav(class: 'top-bar') {
|
|
7
7
|
}
|
8
8
|
}
|
9
9
|
mega_menu_component
|
10
|
-
li {
|
11
|
-
|
10
|
+
li {
|
11
|
+
icon_link(icon_name: 'android-open', text: 'View Site', href: '/', target: '_blank')
|
12
|
+
}
|
13
|
+
render(partial: 'shared/nav_bar_actions')
|
14
|
+
li { flash_message_component } unless helpers.flash.empty?
|
12
15
|
}
|
13
16
|
}
|
14
17
|
div(class: 'secondary-menu') {
|
@@ -16,7 +19,7 @@ nav(class: 'top-bar') {
|
|
16
19
|
li {
|
17
20
|
a {
|
18
21
|
current_user_gravatar
|
19
|
-
|
22
|
+
span {'Profile' }
|
20
23
|
}
|
21
24
|
sign_in_or_sign_out
|
22
25
|
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ExpressAdmin
|
2
|
+
class Routes
|
3
|
+
def self.register(&block)
|
4
|
+
registered_route_blocks << block
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.registered_route_blocks
|
8
|
+
@blocks ||= []
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.draw(application_routes)
|
12
|
+
registered_route_blocks.each do |route_block|
|
13
|
+
application_routes.instance_eval(&route_block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/express_admin.rb
CHANGED
@@ -21,7 +21,7 @@ module ExpressAdmin
|
|
21
21
|
|
22
22
|
def create_admin_controller
|
23
23
|
template 'controllers/admin_controller.rb.erb',
|
24
|
-
File.join('app/controllers', @project_name, '
|
24
|
+
File.join('app/controllers', @project_name, 'admin_controller.rb')
|
25
25
|
end
|
26
26
|
|
27
27
|
def create_admin_layout
|
@@ -1,34 +1,32 @@
|
|
1
1
|
require_dependency "application_controller"
|
2
2
|
|
3
3
|
module <%= project_class %>
|
4
|
-
|
5
|
-
|
6
|
-
inherit_resources # Use inherited_resources
|
4
|
+
class AdminController < ApplicationController
|
5
|
+
inherit_resources # Use inherited_resources
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
helper ::ExpressAdmin::AdminHelper
|
8
|
+
before_filter :authenticate_user! if defined?(Devise)
|
9
|
+
layout "<%= project_name %>/admin"
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
before_filter :load_collection, only: [:show]
|
12
|
+
before_filter :build_new_resource, only: [:index]
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
14
|
+
def show
|
15
|
+
show! do |format|
|
16
|
+
format.html { render :index }
|
19
17
|
end
|
18
|
+
end
|
20
19
|
|
21
|
-
|
20
|
+
private
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def load_collection
|
23
|
+
collection # from InheritedResources
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
def build_new_resource
|
27
|
+
@resource_params = {}
|
28
|
+
build_resource
|
29
|
+
end
|
31
30
|
|
32
|
-
end
|
33
31
|
end
|
34
32
|
end
|
@@ -20,7 +20,7 @@ module ExpressAdmin
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def generate_controller
|
23
|
-
controller_file_path = File.join(["app/controllers", project_name,
|
23
|
+
controller_file_path = File.join(["app/controllers", project_name, "#{controller_file_name}_controller.rb"].compact)
|
24
24
|
template "controller/controller.rb", controller_file_path
|
25
25
|
end
|
26
26
|
|
@@ -30,23 +30,9 @@ module ExpressAdmin
|
|
30
30
|
inject_into_file 'config/routes.rb', " resources :#{controller_file_name}\n",
|
31
31
|
after: "scope '#{project_path}' do\n"
|
32
32
|
else
|
33
|
-
|
34
|
-
|
35
|
-
if module_name # <-- should be namespaced?
|
36
|
-
admin_route = <<-EOD
|
37
|
-
namespace :admin do
|
38
|
-
scope '#{module_name}' do
|
39
|
-
resources :#{controller_file_name}, except: [:edit]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
EOD
|
43
|
-
else
|
44
|
-
admin_route = <<-EOD
|
45
|
-
namespace :admin do
|
46
|
-
resources :#{controller_file_name}, except: [:edit]
|
47
|
-
end
|
33
|
+
admin_route = <<-EOD
|
34
|
+
resources :#{controller_file_name}, except: [:edit]
|
48
35
|
EOD
|
49
|
-
end
|
50
36
|
inject_into_file 'config/routes.rb', admin_route,
|
51
37
|
after: "#{namespaced?}::Engine.routes.draw do\n"
|
52
38
|
end
|
@@ -54,7 +40,7 @@ EOD
|
|
54
40
|
|
55
41
|
def add_menu_item
|
56
42
|
path = if namespaced?
|
57
|
-
"#{
|
43
|
+
"#{controller_file_name}_path"
|
58
44
|
else
|
59
45
|
"admin_#{controller_file_name}_path"
|
60
46
|
end
|
@@ -95,17 +81,6 @@ menu_entry = %Q(
|
|
95
81
|
controller_class_path.last if controller_class_path.size.eql?(2)
|
96
82
|
end
|
97
83
|
|
98
|
-
def admin_controller_path
|
99
|
-
# place the generated controller into an Admin module
|
100
|
-
acp = controller_class_path.dup
|
101
|
-
if acp.empty?
|
102
|
-
acp.push 'admin'
|
103
|
-
else
|
104
|
-
acp.insert(1,'admin').compact.slice(1..-1)
|
105
|
-
end
|
106
|
-
File.join acp
|
107
|
-
end
|
108
|
-
|
109
84
|
def model_class_name
|
110
85
|
class_path_parts = class_name.split("::")
|
111
86
|
class_path_parts.unshift namespace.to_s if namespaced?
|
@@ -113,7 +88,7 @@ menu_entry = %Q(
|
|
113
88
|
end
|
114
89
|
|
115
90
|
def admin_view_path
|
116
|
-
path_parts = ["app/views", project_name,
|
91
|
+
path_parts = ["app/views", project_name, controller_file_name]
|
117
92
|
File.join path_parts.compact
|
118
93
|
end
|
119
94
|
|
@@ -1,14 +1,12 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
|
-
|
3
|
-
class <%= controller_class_name %>Controller < AdminController
|
2
|
+
class <%= controller_class_name %>Controller < AdminController
|
4
3
|
|
5
|
-
|
4
|
+
defaults resource_class: <%= model_class_name %>
|
6
5
|
|
7
|
-
|
6
|
+
private
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
8
|
+
def <%= singular_table_name %>_params
|
9
|
+
params.require(:<%= singular_table_name %>).permit!
|
10
|
+
end
|
13
11
|
end
|
14
12
|
<% end -%>
|
@@ -1,10 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
smart_form(:<%= singular_table_name %>)
|
8
|
-
}
|
1
|
+
main_region {
|
2
|
+
smart_table(:<%= plural_table_name %>)
|
3
|
+
}
|
4
|
+
sidebar_region {
|
5
|
+
widget_box(:<%= singular_table_name %>) {
|
6
|
+
smart_form(:<%= singular_table_name %>)
|
9
7
|
}
|
10
8
|
}
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|