express_admin 1.4.11 → 1.5.0
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/app/assets/javascripts/express_admin.js +1 -1
- data/app/assets/stylesheets/express_admin/components/_pane.sass +7 -0
- data/app/assets/stylesheets/express_admin/components/_v_box.sass +1 -1
- data/app/assets/stylesheets/express_admin/globals/_variables.sass +1 -0
- data/app/assets/stylesheets/express_admin/shared/_tables.sass +10 -9
- data/app/components/express_admin/page_header.rb +11 -8
- data/lib/core_extensions/active_record_base_commands.rb +0 -0
- data/lib/express_admin/commandable.rb +37 -0
- data/lib/express_admin/commands.rb +46 -0
- data/lib/express_admin/standard_actions.rb +3 -7
- data/lib/express_admin/version.rb +1 -1
- data/lib/express_admin.rb +2 -0
- data/test/controllers/standard_controller_test.rb +8 -1
- data/test/dummy/app/controllers/categories_controller.rb +2 -0
- data/test/dummy/app/controllers/parts_controller.rb +2 -0
- data/test/dummy/app/controllers/widgets_controller.rb +2 -0
- data/test/dummy/app/models/widget.rb +6 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- metadata +10 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ee970ef95e2385137a11fa6508edacd01faeae8
|
4
|
+
data.tar.gz: 9fb8fd28dacf2d2c4bfd81cfcdf603e6be99f678
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c627d21e2cfdfed8d54317c2f05aa401614781431afa7aabcb98f8c8c0604075de1005ed1f070024ad3b18273d4035536fd81e9c61931a968a1f351ed2b3df7c
|
7
|
+
data.tar.gz: 7c6897243cc55e89e07c80eccd7089a051078b9602ad4918985dfe13657b6e4332d8c065edd7ecd4d7a9c1ead4bc279995e62b9b6255e98e778cfd5db637a73f
|
@@ -1,2 +1,2 @@
|
|
1
1
|
.v-box
|
2
|
-
@include grid-block($orientation: vertical)
|
2
|
+
@include grid-block($orientation: vertical)
|
@@ -21,15 +21,16 @@
|
|
21
21
|
|
22
22
|
// Still a bit hacky. Need to polish this more
|
23
23
|
// This was done to contain the giant table in rbac's routes#index
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
// Might not need this anymore because of 77b7136
|
25
|
+
// .large-table-container
|
26
|
+
// @include breakpoint(small)
|
27
|
+
// height: 300px
|
28
|
+
//
|
29
|
+
// @include breakpoint(medium)
|
30
|
+
// height: 500px
|
31
|
+
//
|
32
|
+
// @include breakpoint(large)
|
33
|
+
// height: 800px
|
33
34
|
|
34
35
|
.definition-table
|
35
36
|
tbody
|
@@ -1,14 +1,17 @@
|
|
1
1
|
module ExpressAdmin
|
2
2
|
class PageHeader < ExpressTemplates::Components::Base
|
3
|
-
ETC = ExpressTemplates::Components
|
4
3
|
|
5
4
|
contains -> {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
if content_for?(:page_header)
|
6
|
+
h1 {
|
7
|
+
content_for(:page_header)
|
8
|
+
}
|
9
|
+
end
|
10
|
+
if content_for?(:page_header_lead)
|
11
|
+
para(class: 'lead') {
|
12
|
+
content_for(:page_header_lead)
|
13
|
+
}
|
14
|
+
end
|
12
15
|
}
|
13
16
|
end
|
14
|
-
end
|
17
|
+
end
|
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ExpressAdmin
|
2
|
+
class Commandable
|
3
|
+
def initialize(defaults = {})
|
4
|
+
@defaults = defaults
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(mapper, options = {})
|
8
|
+
options = @defaults.merge(options)
|
9
|
+
controller_name = mapper.send(:parent_resource).controller
|
10
|
+
resource_class = "#{controller_name.classify.pluralize}Controller".constantize.resource_class
|
11
|
+
resource_class.commands.each do |action|
|
12
|
+
# post :foo, to: "module/controller#foo"
|
13
|
+
mapper.member do
|
14
|
+
mapper.post action, to: "#{controller_name}##{action}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module ActionDispatch::Routing::Mapper::Resources
|
23
|
+
def resources_with_commandable(*resources, &block)
|
24
|
+
unless @concerns[:commandable]
|
25
|
+
concern :commandable, ExpressAdmin::Commandable.new
|
26
|
+
end
|
27
|
+
|
28
|
+
resources_without_commandable(*resources) do |resource|
|
29
|
+
block.call(resource) unless block.nil?
|
30
|
+
concerns :commandable
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
alias :resources_without_commandable :resources
|
35
|
+
alias :resources :resources_with_commandable
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module ExpressAdmin
|
2
|
+
module Commands
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
include InstanceMethods
|
6
|
+
extend ClassMethods
|
7
|
+
|
8
|
+
class_attribute :commands
|
9
|
+
self.commands = []
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
|
15
|
+
def exposes_command(command)
|
16
|
+
exposes_commands command
|
17
|
+
end
|
18
|
+
|
19
|
+
def exposes_commands(*commands)
|
20
|
+
self.commands += commands
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module InstanceMethods
|
25
|
+
# If not using, AASM, override this for disallowing commands
|
26
|
+
def unavailable_commands
|
27
|
+
[]
|
28
|
+
end
|
29
|
+
|
30
|
+
def available_commands
|
31
|
+
if respond_to?(:aasm)
|
32
|
+
commands & aasm_event_triggers
|
33
|
+
else
|
34
|
+
commands - unavailable_commands
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
def aasm_event_triggers
|
40
|
+
aasm.events.map(&:name).map(&:to_s).map {|s| "#{s}!"}.map(&:to_sym)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
ActiveRecord::Base.include(ExpressAdmin::Commands)
|
@@ -32,7 +32,7 @@ module ExpressAdmin
|
|
32
32
|
|
33
33
|
if self.resource_class.respond_to?(:commands)
|
34
34
|
self.resource_class.commands.each do |command|
|
35
|
-
define_command_method(command)
|
35
|
+
define_command_method(command.to_s.gsub(/\!\Z/, ''), command)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -48,8 +48,8 @@ module ExpressAdmin
|
|
48
48
|
|
49
49
|
protected
|
50
50
|
|
51
|
-
def define_command_method(command)
|
52
|
-
define_method(
|
51
|
+
def define_command_method(action, command)
|
52
|
+
define_method(action) do
|
53
53
|
load_resource
|
54
54
|
begin
|
55
55
|
resource.send(command)
|
@@ -246,10 +246,6 @@ module ExpressAdmin
|
|
246
246
|
"@#{resource_name}".to_sym
|
247
247
|
end
|
248
248
|
|
249
|
-
# def resource_class
|
250
|
-
# self.class.to_s.gsub(/Controller$/, '').singularize.classify.constantize
|
251
|
-
# end
|
252
|
-
|
253
249
|
# Foo::WidgetsController -> widget
|
254
250
|
def resource_name
|
255
251
|
self.class.resource_name
|
data/lib/express_admin.rb
CHANGED
@@ -19,6 +19,7 @@ module ExpressAdmin
|
|
19
19
|
eigenclass.send(:define_method, :params) do
|
20
20
|
ActionController::Parameters.new(params.with_indifferent_access)
|
21
21
|
end
|
22
|
+
# hack so we can call the action without all controller stuff
|
22
23
|
eigenclass.send(:define_method, :respond_to) do |&block|
|
23
24
|
block.call(ActionController::MimeResponds::Collector.new([], 'text/html'))
|
24
25
|
end
|
@@ -110,8 +111,14 @@ module ExpressAdmin
|
|
110
111
|
|
111
112
|
test ".define_command_method defines a command action method on the controller" do
|
112
113
|
refute widgets_controller.respond_to?(:foo)
|
113
|
-
widgets_controller.class.send(:define_command_method, :foo)
|
114
|
+
widgets_controller.class.send(:define_command_method, :foo, :foo!)
|
114
115
|
assert widgets_controller.respond_to?(:foo)
|
115
116
|
end
|
117
|
+
|
118
|
+
test "if a resource exposes commands, the controllers should have an action for the command" do
|
119
|
+
assert widgets_controller.respond_to?(:twiddle), "widgets_controller#twiddle should be there"
|
120
|
+
widgets_controller(id: widgets(:one).id).twiddle
|
121
|
+
assert widgets(:one).reload.column2.eql?("twiddled"), "widgets_controller#twiddle didn't twiddle the widget"
|
122
|
+
end
|
116
123
|
end
|
117
124
|
end
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: express_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Talcott Smith
|
@@ -427,8 +427,11 @@ files:
|
|
427
427
|
- config/initializers/request_store_current_user.rb
|
428
428
|
- config/initializers/tinymce-rails.rb
|
429
429
|
- config/tinymce.yml
|
430
|
+
- lib/core_extensions/active_record_base_commands.rb
|
430
431
|
- lib/core_extensions/string_promptify.rb
|
431
432
|
- lib/express_admin.rb
|
433
|
+
- lib/express_admin/commandable.rb
|
434
|
+
- lib/express_admin/commands.rb
|
432
435
|
- lib/express_admin/engine.rb
|
433
436
|
- lib/express_admin/menu.rb
|
434
437
|
- lib/express_admin/routes.rb
|
@@ -461,7 +464,10 @@ files:
|
|
461
464
|
- test/dummy/app/controllers/admin/parts_controller.rb
|
462
465
|
- test/dummy/app/controllers/admin/widgets_controller.rb
|
463
466
|
- test/dummy/app/controllers/application_controller.rb
|
467
|
+
- test/dummy/app/controllers/categories_controller.rb
|
464
468
|
- test/dummy/app/controllers/demo_controller.rb
|
469
|
+
- test/dummy/app/controllers/parts_controller.rb
|
470
|
+
- test/dummy/app/controllers/widgets_controller.rb
|
465
471
|
- test/dummy/app/helpers/application_helper.rb
|
466
472
|
- test/dummy/app/helpers/demo_helper.rb
|
467
473
|
- test/dummy/app/models/category.rb
|
@@ -797,7 +803,10 @@ test_files:
|
|
797
803
|
- test/dummy/app/controllers/admin/parts_controller.rb
|
798
804
|
- test/dummy/app/controllers/admin/widgets_controller.rb
|
799
805
|
- test/dummy/app/controllers/application_controller.rb
|
806
|
+
- test/dummy/app/controllers/categories_controller.rb
|
800
807
|
- test/dummy/app/controllers/demo_controller.rb
|
808
|
+
- test/dummy/app/controllers/parts_controller.rb
|
809
|
+
- test/dummy/app/controllers/widgets_controller.rb
|
801
810
|
- test/dummy/app/helpers/application_helper.rb
|
802
811
|
- test/dummy/app/helpers/demo_helper.rb
|
803
812
|
- test/dummy/app/models/category.rb
|