effective_resources 0.7.12 → 0.7.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/app/helpers/effective_resources_helper.rb +18 -8
- data/app/models/effective/resources/actions.rb +11 -1
- data/app/models/effective/resources/init.rb +1 -1
- data/app/models/effective/resources/naming.rb +1 -1
- data/lib/effective_resources/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 287350db2bd99d6ee44fb82d7a31ff7a138b13d6
|
4
|
+
data.tar.gz: b624b6db3fdb2ae627fc201a36c53ec615f10bf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8083ed649eee3b427b455487e21485ec01c8e46f242404eb6e551b470a165ed9d2793ec9f07ad1fa4b6eefbabf15d26583ea8559adcf60e2512ad78c08c0032c
|
7
|
+
data.tar.gz: fe26139eb7170c782064ab0c82d0dd0ad56114657f40972ef2e0bb33816a8b0111196983a1050483b01fb0da7638179d4345b6719c91ec08449aee712dc61f78
|
data/README.md
CHANGED
@@ -158,6 +158,23 @@ Call `simple_form_save(f)` like follows:
|
|
158
158
|
|
159
159
|
to render just the `Save` button, with appropriate data-disable, title, etc.
|
160
160
|
|
161
|
+
### Effective Form with
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
|
165
|
+
= effective_form_with(model: user, url: user_settings_path) do |f|
|
166
|
+
= effective_submit(f)
|
167
|
+
= effective_save(f)
|
168
|
+
|
169
|
+
= effective_save(f) do
|
170
|
+
= f.save 'Save'
|
171
|
+
= f.save 'Another'
|
172
|
+
|
173
|
+
= effective_save(f, 'Save It')
|
174
|
+
|
175
|
+
= effective_submit(f) do
|
176
|
+
= f.save 'Will be appended'
|
177
|
+
|
161
178
|
## License
|
162
179
|
|
163
180
|
MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
|
@@ -23,18 +23,28 @@ module EffectiveResourcesHelper
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
# Group by class and render
|
27
|
+
buttons = actions.group_by { |_, opts| opts[:class] }.flat_map do |_, btns|
|
28
|
+
btns.map { |name, opts| form.save(name, opts) }
|
29
|
+
end.join.html_safe
|
30
|
+
|
31
|
+
effective_save(form) do
|
32
|
+
(block_given? ? capture(&block) : ''.html_safe) + buttons
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def effective_save(form, label = 'Save', &block) # effective_bootstrap
|
26
38
|
wrapper = (form.layout == :horizontal) ? { class: 'form-group form-actions row' } : { class: 'form-group form-actions' }
|
27
39
|
|
28
40
|
content_tag(:div, wrapper) do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
if block_given?
|
34
|
-
buttons = [capture(&block), ''] + buttons
|
35
|
-
end
|
41
|
+
icon('spinner') + (block_given? ? capture(&block) : form.save(label, class: 'btn btn-primary'))
|
42
|
+
end
|
43
|
+
end
|
36
44
|
|
37
|
-
|
45
|
+
def effective_save_button(form, label = 'Save', &block)
|
46
|
+
content_tag(:div, class: 'form-actions') do
|
47
|
+
icon('spinner') + (block_given? ? capture(&block) : form.save(label, class: 'btn btn-primary'))
|
38
48
|
end
|
39
49
|
end
|
40
50
|
|
@@ -8,7 +8,7 @@ module Effective
|
|
8
8
|
@_routes ||= (
|
9
9
|
matches = [[namespace, plural_name].compact.join('/'), [namespace, name].compact.join('/')]
|
10
10
|
|
11
|
-
|
11
|
+
routes_engine.routes.routes.select do |route|
|
12
12
|
matches.any? { |match| match == route.defaults[:controller] }
|
13
13
|
end.inject({}) do |h, route|
|
14
14
|
h[route.defaults[:action].to_sym] = route; h
|
@@ -16,6 +16,16 @@ module Effective
|
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
19
|
+
# Effective::Resource.new('effective/order', namespace: :admin)
|
20
|
+
def routes_engine
|
21
|
+
case class_name
|
22
|
+
when 'Effective::Order'
|
23
|
+
EffectiveOrders::Engine
|
24
|
+
else
|
25
|
+
Rails.application
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
19
29
|
# Effective::Resource.new('admin/posts').action_path_helper(:edit) => 'edit_admin_posts_path'
|
20
30
|
# This will return empty for create, update and destroy
|
21
31
|
def action_path_helper(action)
|
@@ -24,7 +24,7 @@ module Effective
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def namespaced_class_name # 'Admin::Effective::Post'
|
27
|
-
(Array(namespaces).map { |name| name.classify } + [class_name]) * '::'
|
27
|
+
(Array(namespaces).map { |name| name.to_s.classify } + [class_name]) * '::'
|
28
28
|
end
|
29
29
|
|
30
30
|
def namespace # 'admin/things'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.13
|
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: 2018-03-
|
11
|
+
date: 2018-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.0.0
|
27
27
|
description: Make any controller an effective resource controller.
|
28
28
|
email:
|
29
29
|
- info@codeandeffect.com
|