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
@@ -10,7 +10,7 @@ class ExpressAdmin::Generators::InstallGeneratorTest < Rails::Generators::TestCa
|
|
10
10
|
def test_install_on_invoke
|
11
11
|
run_generator
|
12
12
|
|
13
|
-
assert_file 'app/controllers/tmp/
|
13
|
+
assert_file 'app/controllers/tmp/admin_controller.rb' do |content|
|
14
14
|
assert_match /module Tmp/, content
|
15
15
|
assert_match /class AdminController < ApplicationController/, content
|
16
16
|
assert_match /before_filter :authenticate_user! if defined\?\(Devise\)/, content
|
@@ -18,11 +18,10 @@ class ExpressAdmin::Generators::ScaffoldGeneratorTest < Rails::Generators::TestC
|
|
18
18
|
assert_migration "db/migrate/create_agents.rb"
|
19
19
|
|
20
20
|
# View
|
21
|
-
assert_file "app/views/
|
21
|
+
assert_file "app/views/agents/index.html.et"
|
22
22
|
|
23
23
|
# Controller
|
24
|
-
assert_file "app/controllers/
|
25
|
-
assert_match(/module Admin/, content)
|
24
|
+
assert_file "app/controllers/agents_controller.rb" do |content|
|
26
25
|
assert_match(/class AgentsController < AdminController/, content)
|
27
26
|
|
28
27
|
assert_match(/defaults resource_class: Agent/, content)
|
@@ -32,7 +31,6 @@ class ExpressAdmin::Generators::ScaffoldGeneratorTest < Rails::Generators::TestC
|
|
32
31
|
# Routes
|
33
32
|
assert_file "config/routes.rb" do |content|
|
34
33
|
assert_match(/Dummy::Engine.routes.draw/, content)
|
35
|
-
assert_match(/namespace :admin do/, content)
|
36
34
|
assert_match(/resources :agents/, content)
|
37
35
|
end
|
38
36
|
end
|
@@ -44,10 +42,10 @@ class ExpressAdmin::Generators::ScaffoldGeneratorTest < Rails::Generators::TestC
|
|
44
42
|
assert_no_file "app/models/dummy/agent.rb"
|
45
43
|
|
46
44
|
# View
|
47
|
-
assert_no_file "app/views/dummy/
|
45
|
+
assert_no_file "app/views/dummy/agents/index.html.et"
|
48
46
|
|
49
47
|
# Controller
|
50
|
-
assert_no_file "app/controllers/dummy/
|
48
|
+
assert_no_file "app/controllers/dummy/agents_controller.rb"
|
51
49
|
|
52
50
|
# Route
|
53
51
|
assert_file "config/routes.rb" do |route|
|
Binary file
|
Binary file
|
@@ -39,12 +39,24 @@ module Arbre
|
|
39
39
|
elsif assigns && assigns.has_key?(name)
|
40
40
|
assigns[name]
|
41
41
|
elsif helpers.respond_to?(name)
|
42
|
-
|
42
|
+
helper_method(name, *args, &block)
|
43
43
|
else
|
44
44
|
super
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
# In order to not pollute our templates with helpers. prefixed
|
49
|
+
# everywhere we want to try to distinguish helpers that are almost
|
50
|
+
# always used as parameters to other methods such as path helpers
|
51
|
+
# and not add them as elements
|
52
|
+
def helper_method(name, *args, &block)
|
53
|
+
if name.match /_path$/
|
54
|
+
helpers.send(name, *args, &block)
|
55
|
+
else
|
56
|
+
current_arbre_element.add_child helpers.send(name, *args, &block)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
48
60
|
end
|
49
61
|
|
50
62
|
end
|
data/vendor/gems/express_templates/lib/express_templates/components/capabilities/resourceful.rb
CHANGED
@@ -97,7 +97,15 @@ module ExpressTemplates
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def collection
|
100
|
-
config[:collection]
|
100
|
+
if config[:collection]
|
101
|
+
if config[:collection].respond_to?(:call)
|
102
|
+
config[:collection].call()
|
103
|
+
else
|
104
|
+
config[:collection]
|
105
|
+
end
|
106
|
+
else
|
107
|
+
helpers.collection
|
108
|
+
end
|
101
109
|
end
|
102
110
|
|
103
111
|
def collection_path
|
@@ -37,7 +37,7 @@ module ExpressTemplates
|
|
37
37
|
def use_supplied_options
|
38
38
|
opts = supplied_component_options[:options]
|
39
39
|
if opts.respond_to?(:call) # can be a proc
|
40
|
-
opts.call()
|
40
|
+
opts.call(resource)
|
41
41
|
else
|
42
42
|
opts
|
43
43
|
end
|
@@ -47,9 +47,23 @@ module ExpressTemplates
|
|
47
47
|
resource.class.distinct(field_name.to_sym).pluck(field_name.to_sym)
|
48
48
|
end
|
49
49
|
|
50
|
+
def normalize_for_helper(supplied_options)
|
51
|
+
supplied_options.map do |opt|
|
52
|
+
[opt.respond_to?(:name) ? opt.name : opt.to_s,
|
53
|
+
opt.respond_to?(:id) ? opt.id : opt.to_s]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def selected_value
|
58
|
+
field_options[:selected]||resource.send(field_name)
|
59
|
+
end
|
60
|
+
|
50
61
|
def options_from_supplied_or_field_values
|
51
62
|
if select_options_supplied?
|
52
|
-
|
63
|
+
helpers.options_for_select(
|
64
|
+
normalize_for_helper(use_supplied_options),
|
65
|
+
selected_value
|
66
|
+
)
|
53
67
|
else
|
54
68
|
generate_options_from_field_values
|
55
69
|
end
|
@@ -68,11 +82,7 @@ module ExpressTemplates
|
|
68
82
|
end
|
69
83
|
|
70
84
|
def simple_options_with_selection
|
71
|
-
|
72
|
-
helpers.options_for_select(options_from_supplied_or_field_values, selection)
|
73
|
-
else
|
74
|
-
helpers.options_for_select(options_from_supplied_or_field_values, resource.send(field_name))
|
75
|
-
end
|
85
|
+
helpers.options_for_select(options_from_supplied_or_field_values, selected_value)
|
76
86
|
end
|
77
87
|
|
78
88
|
# Returns the options which will be supplied to the select_tag helper.
|
@@ -40,7 +40,7 @@ class ExpressFormTest < ActiveSupport::TestCase
|
|
40
40
|
end
|
41
41
|
|
42
42
|
test "simplest_form contains submit" do
|
43
|
-
assert_match '<input type="submit" name="commit" value="Save" />', simplest_form
|
43
|
+
assert_match '<input type="submit" name="commit" value="Save it!" />', simplest_form
|
44
44
|
end
|
45
45
|
|
46
46
|
test "simplest_form uses form_action for the action" do
|
@@ -24,7 +24,7 @@ class SelectTest < ActiveSupport::TestCase
|
|
24
24
|
assert_match /<label.*for="person_gender"/, html
|
25
25
|
end
|
26
26
|
|
27
|
-
test "select generates correct options when values are specified" do
|
27
|
+
test "select generates correct options when values are specified as array" do
|
28
28
|
html = arbre {
|
29
29
|
express_form(:person) {
|
30
30
|
select :gender, options: ['Male', 'Female'], selected: 'Male'
|
@@ -11,7 +11,22 @@ class SubmitTest < ActiveSupport::TestCase
|
|
11
11
|
fragment = -> (ctx) {
|
12
12
|
submit "Save it!"
|
13
13
|
}
|
14
|
-
assert_match '<div class="field-wrapper"><input type="submit" name="commit" value="Save it!" /></div>',
|
14
|
+
assert_match '<div class="field-wrapper"><input type="submit" name="commit" value="Save it!" /></div>',
|
15
15
|
arbre(&fragment)
|
16
16
|
end
|
17
|
+
test "submit accepts a class option" do
|
18
|
+
fragment = -> (ctx) {
|
19
|
+
submit class: 'button'
|
20
|
+
}
|
21
|
+
assert_match '<div class="field-wrapper"><input type="submit" name="commit" value="Save" class="button" /></div>',
|
22
|
+
arbre(&fragment)
|
23
|
+
end
|
24
|
+
test "submit accepts a class option when string provided as first param" do
|
25
|
+
fragment = -> (ctx) {
|
26
|
+
submit 'XYZ', class: 'button'
|
27
|
+
}
|
28
|
+
assert_match '<div class="field-wrapper"><input type="submit" name="commit" value="XYZ" class="button" /></div>',
|
29
|
+
arbre(&fragment)
|
30
|
+
end
|
31
|
+
|
17
32
|
end
|