effective_resources 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/effective/crud_controller.rb +11 -3
- data/app/views/application/edit.html.haml +17 -16
- data/app/views/application/index.html.haml +3 -3
- data/app/views/application/new.html.haml +2 -1
- data/app/views/application/show.html.haml +17 -16
- data/lib/effective_resources/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ea8856025d95c68494d488970226e6c212a919d
|
4
|
+
data.tar.gz: b024cdc31307bf491b9432d7bb24e84928edb16a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80b4b4aec2b1bc80403e808e72949904c4a8d791e7c42f2f848aa4056424ea937514d3896565a1c82e53a747564f2fb0b7788ac5378e07590abf899e952218ef
|
7
|
+
data.tar.gz: 60b75dbf6e5c7cedd1448e6599090b9be54106bb6cbd1603a48fb90ada7cc8034999d1613c710e0fcc721ee67cb428032b9cd22350a28530e3299849482ce9cd
|
@@ -18,7 +18,7 @@ module Effective
|
|
18
18
|
raise "expected @#{resource_name} to respond to #{action}!" unless resource.respond_to?("#{action}!")
|
19
19
|
|
20
20
|
begin
|
21
|
-
|
21
|
+
resource.send("#{action}!") || raise('exception')
|
22
22
|
|
23
23
|
flash[:success] = "Successfully #{action}#{action.to_s.end_with?('e') ? 'd' : 'ed'} #{resource_human_name}"
|
24
24
|
redirect_back fallback_location: resource_redirect_path
|
@@ -130,7 +130,12 @@ module Effective
|
|
130
130
|
flash[:danger] = "Unable to delete #{resource_human_name}: #{resource.errors.full_messages.to_sentence}"
|
131
131
|
end
|
132
132
|
|
133
|
-
request.referer.present?
|
133
|
+
if request.referer.present? && !request.referer.include?(send(effective_resource.show_path))
|
134
|
+
redirect_to(request.referer)
|
135
|
+
else
|
136
|
+
redirect_to(send(resource_index_path))
|
137
|
+
end
|
138
|
+
|
134
139
|
end
|
135
140
|
|
136
141
|
protected
|
@@ -140,7 +145,10 @@ module Effective
|
|
140
145
|
when 'Save' ; send(effective_resource.edit_path, resource)
|
141
146
|
when 'Save and Continue' ; send(effective_resource.index_path)
|
142
147
|
when 'Save and Add New' ; send(effective_resource.new_path)
|
143
|
-
|
148
|
+
when 'Save and Return'
|
149
|
+
request.referer.present? ? request.referer : send(resource_index_path)
|
150
|
+
else
|
151
|
+
send((effective_resource.show_path(check: true) || effective_resource.edit_path), resource)
|
144
152
|
end
|
145
153
|
end
|
146
154
|
|
@@ -1,20 +1,21 @@
|
|
1
1
|
- resource = (@_effective_resource || Effective::Resource.new(controller_path))
|
2
|
-
- @resource = instance_variable_get('@' + resource.name)
|
2
|
+
- @resource = instance_variable_get('@' + resource.name) if resource.name
|
3
3
|
|
4
|
-
|
5
|
-
.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
- if
|
12
|
-
|
13
|
-
|
4
|
+
- if @resource
|
5
|
+
.row
|
6
|
+
.col-sm-6
|
7
|
+
%h1= @page_title
|
8
|
+
.col-sm-6
|
9
|
+
%p.text-right
|
10
|
+
- resource.member_post_actions.each do |action|
|
11
|
+
- if EffectiveResources.authorized?(controller, action.to_sym, @resource)
|
12
|
+
- if resource.action_post_path(action, check: true).present?
|
13
|
+
= link_to action.titleize, send(resource.action_post_path(action), @resource), class: 'btn btn-primary',
|
14
|
+
data: { confirm: "Really #{action} #{@resource}?", method: :post }
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
- if EffectiveResources.authorized?(controller, :destroy, @resource)
|
17
|
+
- if resource.destroy_path(check: true).present?
|
18
|
+
= link_to 'Delete', send(resource.destroy_path, @resource), class: 'btn btn-danger',
|
19
|
+
data: { confirm: "Really delete #{@resource}?", method: :delete }
|
19
20
|
|
20
|
-
= render 'form', resource.name.to_sym => @resource
|
21
|
+
= render 'form', resource.name.to_sym => @resource
|
@@ -11,13 +11,13 @@
|
|
11
11
|
- if @datatable
|
12
12
|
= render_datatable(@datatable)
|
13
13
|
|
14
|
-
- elsif instance_variable_get('@' + resource.plural_name)
|
14
|
+
- elsif instance_variable_get('@' + resource.plural_name).respond_to?(:to_partial_path)
|
15
15
|
= render instance_variable_get('@' + resource.plural_name)
|
16
16
|
|
17
|
-
- elsif instance_variable_get('@' + resource.name)
|
17
|
+
- elsif instance_variable_get('@' + resource.name).respond_to?(:to_partial_path)
|
18
18
|
= render instance_variable_get('@' + resource.name)
|
19
19
|
|
20
20
|
- elsif Rails.env.development?
|
21
21
|
%p effective_resources index view is not sure what to render.
|
22
|
-
%p Define an @datatable, @#{resource.plural_name}, or @#{resource.name}.
|
22
|
+
%p Define an @datatable, @#{resource.try(:plural_name) || 'a plural'}, or @#{resource.try(:name) || 'a singular'}.
|
23
23
|
%p or include Effective::CrudController in your controller
|
@@ -1,20 +1,21 @@
|
|
1
1
|
- resource = (@_effective_resource || Effective::Resource.new(controller_path))
|
2
|
-
- @resource = instance_variable_get('@' + resource.name)
|
2
|
+
- @resource = instance_variable_get('@' + resource.name) if resource.name
|
3
3
|
|
4
|
-
|
5
|
-
.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
- if
|
12
|
-
|
13
|
-
|
4
|
+
- if @resource
|
5
|
+
.row
|
6
|
+
.col-sm-6
|
7
|
+
%h1= @page_title
|
8
|
+
.col-sm-6
|
9
|
+
%p.text-right
|
10
|
+
- resource.member_post_actions.each do |action|
|
11
|
+
- if EffectiveResources.authorized?(controller, action.to_sym, @resource)
|
12
|
+
- if resource.action_post_path(action, check: true).present?
|
13
|
+
= link_to action.titleize, send(resource.action_post_path(action), @resource), class: 'btn btn-primary',
|
14
|
+
data: { confirm: "Really #{action} #{@resource}?", method: :post }
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
- if EffectiveResources.authorized?(controller, :destroy, @resource)
|
17
|
+
- if resource.destroy_path(check: true).present?
|
18
|
+
= link_to 'Delete', send(resource.destroy_path, @resource), class: 'btn btn-danger',
|
19
|
+
data: { confirm: "Really delete #{@resource}?", method: :delete }
|
19
20
|
|
20
|
-
= render @resource
|
21
|
+
= render @resource
|
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.4.
|
4
|
+
version: 0.4.3
|
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: 2017-08-
|
11
|
+
date: 2017-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|