effective_resources 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d2f4f585bbb5859066bf26049f670a026ad0df2
|
4
|
+
data.tar.gz: e10b256b516418051208158bc06a8dc76b46f1e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33229026829624749822b3d54d0188b1979faf226d425b88f97dee7fe9618309d7f0630c7402ae36de704aabe5c9370af76e98f112de9b46583c240242f85835
|
7
|
+
data.tar.gz: 54286cafb8da006ef388c2d0a2ac0cf95c0b582e2f2bdb0f591188289bb05c32350f8452d11efd9ef23f3095ec3ada32a8a2fba7717bb85d3ccc0ffe8db94f01
|
@@ -27,12 +27,19 @@ module Effective
|
|
27
27
|
|
28
28
|
referer = request.referer.to_s
|
29
29
|
|
30
|
-
|
30
|
+
edit_path = send(effective_resource.edit_path, resource) if respond_to?(effective_resource.edit_path)
|
31
|
+
new_path = effective_resource.new_path if respond_to?(effective_resource.new_path)
|
32
|
+
show_path = effective_resource.show_path if respond_to?(effective_resource.show_path)
|
33
|
+
|
34
|
+
if edit_path && referer.end_with?(edit_path)
|
31
35
|
@page_title ||= "Edit #{resource}"
|
32
36
|
render :edit
|
33
|
-
elsif referer.end_with?(
|
37
|
+
elsif new_path && referer.end_with?(new_path)
|
34
38
|
@page_title ||= "New #{resource_name.titleize}"
|
35
39
|
render :new
|
40
|
+
elsif show_path && referer.end_with?(show_path)
|
41
|
+
@page_title ||= resource_name.titleize
|
42
|
+
render :show
|
36
43
|
else
|
37
44
|
@page_title ||= resource.to_s
|
38
45
|
flash[:danger] = flash.now[:danger]
|
@@ -48,6 +55,13 @@ module Effective
|
|
48
55
|
end
|
49
56
|
end
|
50
57
|
|
58
|
+
# page_title 'My Title', only: [:new]
|
59
|
+
def page_title(label, opts = {})
|
60
|
+
instance_eval do
|
61
|
+
before_action(opts) { @page_title = label }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
51
65
|
end
|
52
66
|
|
53
67
|
def index
|
@@ -121,7 +135,7 @@ module Effective
|
|
121
135
|
def destroy
|
122
136
|
self.resource = resource_class.find(params[:id])
|
123
137
|
|
124
|
-
@page_title
|
138
|
+
@page_title ||= "Destroy #{resource}"
|
125
139
|
EffectiveResources.authorized?(self, :destroy, resource)
|
126
140
|
|
127
141
|
if resource.destroy
|
@@ -143,8 +157,8 @@ module Effective
|
|
143
157
|
def resource_redirect_path
|
144
158
|
case params[:commit].to_s
|
145
159
|
when 'Save' ; send(effective_resource.edit_path, resource)
|
146
|
-
when 'Save and Continue' ; send(effective_resource.index_path)
|
147
160
|
when 'Save and Add New' ; send(effective_resource.new_path)
|
161
|
+
when 'Save and Continue' ; send(resource_index_path)
|
148
162
|
when 'Save and Return'
|
149
163
|
request.referer.present? ? request.referer : send(resource_index_path)
|
150
164
|
else
|
@@ -229,6 +243,7 @@ module Effective
|
|
229
243
|
["#{resource_name}_params", "#{resource_plural_name}_params", 'permitted_params'].find { |name| respond_to?(name, true) } || 'params'
|
230
244
|
end
|
231
245
|
|
246
|
+
# Override this with Team.where(team: current_user.team) to build and create with team
|
232
247
|
def resource_scope_method_name
|
233
248
|
["#{resource_name}_scope", "#{resource_plural_name}_scope", 'resource_scope', 'default_scope'].find { |name| respond_to?(name, true) }
|
234
249
|
end
|
@@ -35,7 +35,16 @@ module Effective
|
|
35
35
|
when ActiveRecord::Base
|
36
36
|
{ as: :select }.merge(Effective::Resource.new(type).search_form_field_collection)
|
37
37
|
else
|
38
|
-
|
38
|
+
name = name.to_s
|
39
|
+
|
40
|
+
# If the method is named :status, and there is a Class::STATUSES
|
41
|
+
if (klass || NilClass).const_defined?(name.pluralize.upcase)
|
42
|
+
{ as: :select, collection: klass.const_get(name.pluralize.upcase) }
|
43
|
+
elsif (klass || NilClass).const_defined?(name.singularize.upcase)
|
44
|
+
{ as: :select, collection: klass.const_get(name.singularize.upcase) }
|
45
|
+
else
|
46
|
+
{ as: :string }
|
47
|
+
end
|
39
48
|
end
|
40
49
|
end
|
41
50
|
|
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.5
|
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-
|
11
|
+
date: 2017-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|