effective_resources 1.5.0 → 1.5.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
  SHA256:
3
- metadata.gz: 96ca5cf766ce1834be39c1cc4698eed91291824f5cc242fcd4daa5f287bcbe95
4
- data.tar.gz: 3297962f09ef0490a3c53ccd3eb7d82858ed0a553a935e8ce264a7947c70fcdb
3
+ metadata.gz: f9fae70e2bf9e0d17c6185c5e0431d216edb470593cae928a5c2dac1ff618546
4
+ data.tar.gz: 8282dbb19a27f4b8634e62413ad0ce6ef2685bac2dc2a314bf88759fe89d7920
5
5
  SHA512:
6
- metadata.gz: a88337e14e4d6df602ec530a07e57a48ac345fc25ade3c5ebaf34b9038c67decb76e17f58f7c431c0bd58e64cb589dfd0b4f4f3055b6082fb4f1b2e68f9f0ad2
7
- data.tar.gz: cb339dd8e0a39d7e0c78e483a0d122c4b7de0d682f031ec91cf1d9a2184fe527e96278edbd92176d18564d5bb6c9f7edacd4f0336b4eb222682bed52153f991d
6
+ metadata.gz: 99b8791ca2d3c50e9e2bebfadf4d66a5ba3a26ecf5dd974baf1deca28deb1f1b571bb85b07d4df9a77cd6ce57c673ea4437d87a14fc551be8df644a0e614669d
7
+ data.tar.gz: 5db56888ffad740845a5258514297e9a556c19a25593fa8a4f889fe424a99872d6cc0501505ea491a5f14699335f6b3fa5e41286ab0cead752fb10f706d0e00a
@@ -64,10 +64,14 @@ module Effective
64
64
  else
65
65
  if template_present?(action)
66
66
  format.html { render(action, locals: { action: action }) }
67
+ elsif request.referer.to_s.end_with?('/edit')
68
+ format.html { render :edit }
69
+ elsif request.referer.to_s.end_with?('/new')
70
+ format.html { render :new }
67
71
  else
68
72
  format.html do
69
73
  redirect_flash
70
- redirect_to(from_path.presence || resource_redirect_path(action))
74
+ redirect_to(resource_redirect_path(action))
71
75
  end
72
76
  end
73
77
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module EffectiveResourcesHelper
2
4
 
3
5
  # effective_bootstrap
@@ -74,18 +76,22 @@ module EffectiveResourcesHelper
74
76
  namespace ||= (effective_resource.namespace.to_sym if effective_resource.namespace)
75
77
 
76
78
  # Assign actions
77
- actions = if atts.key?(:actions) # We filter out any actions passed to us that aren't supported
78
- available = effective_resource.actions + atts[:actions].map { |k, v| v[:action] if v[:path] }.compact
79
- atts[:actions].inject({}) { |h, (commit, opts)| h[commit] = opts if available.include?(opts[:action]); h }
79
+ # We filter out any actions passed to us that aren't supported
80
+ actions = if atts.key?(:actions)
81
+ {}.tap do |actions|
82
+ atts[:actions].each do |commit, opts|
83
+ actions[commit] = opts if (effective_resource.actions.include?(opts[:action]) || opts[:path]).present?
84
+ end
85
+ end
80
86
  else
81
87
  (resource.kind_of?(Class) ? effective_resource.resource_klass_actions : effective_resource.resource_actions)
82
88
  end
83
89
 
84
90
  # Consider only, except, false and proc false
85
- only = Array(atts[:only]).compact
86
- except = Array(atts[:except]).compact
91
+ only = Array(atts[:only]) if atts[:only].present?
92
+ except = Array(atts[:except]) if atts[:except].present?
87
93
 
88
- actions = actions.select do |_, opts|
94
+ actions.select! do |_, opts|
89
95
  action = opts[:action]
90
96
 
91
97
  if only.present? && !only.include?(action)
@@ -100,8 +106,11 @@ module EffectiveResourcesHelper
100
106
  end
101
107
 
102
108
  # Select Partial
103
- partial = ['effective/resource/actions', partial.to_s].join('_') if partial.kind_of?(Symbol)
104
- partial = (partial.presence || 'effective/resource/actions') + '.html'
109
+ partial = if partial.kind_of?(Symbol)
110
+ "effective/resource/actions_#{partial}.html"
111
+ else
112
+ "#{partial.presence || 'effective/resource/actions'}.html"
113
+ end
105
114
 
106
115
  # Assign Locals
107
116
  locals = {
@@ -2,21 +2,27 @@
2
2
 
3
3
  module EffectiveResourcesPrivateHelper
4
4
  REPLACE_PAGE_ACTIONS = {'update' => :edit, 'create' => :new}
5
+ BLACKLIST = [:default, :only, :except, :if, :unless, :redirect, :success, :danger, :klass]
6
+
7
+ DATA_CONFIRM = 'data-confirm'
5
8
 
6
9
  def permitted_resource_actions(resource, actions)
7
10
  page_action = REPLACE_PAGE_ACTIONS[params[:action]] || params[:action].try(:to_sym) || :save
8
11
  executor = Effective::ResourceExec.new(self, resource)
9
12
 
10
- actions.select do |commit, args|
13
+ actions.each_with_object({}) do |(commit, args), h|
11
14
  action = (args[:action] == :save ? (resource.new_record? ? :create : :update) : args[:action])
12
15
 
13
- (args.key?(:only) ? args[:only].include?(page_action) : true) &&
14
- (args.key?(:except) ? !args[:except].include?(page_action) : true) &&
15
- (args.key?(:if) ? executor.instance_exec(&args[:if]) : true) &&
16
- (args.key?(:unless) ? !executor.instance_exec(&args[:unless]) : true) &&
17
- EffectiveResources.authorized?(controller, action, resource)
18
- end.inject({}) do |h, (commit, args)|
16
+ permitted = (args.key?(:only) ? args[:only].include?(page_action) : true) &&
17
+ (args.key?(:except) ? !args[:except].include?(page_action) : true) &&
18
+ (args.key?(:if) ? executor.instance_exec(&args[:if]) : true) &&
19
+ (args.key?(:unless) ? !executor.instance_exec(&args[:unless]) : true) &&
20
+ EffectiveResources.authorized?(controller, action, resource)
21
+
22
+ next unless permitted
23
+
19
24
  opts = args.except(:default, :only, :except, :if, :unless, :redirect, :success, :danger, :klass)
25
+ resource_to_s = resource.to_s.presence || resource.class.name.underscore
20
26
 
21
27
  # Transform data: { ... } hash into 'data-' keys
22
28
  if opts.key?(:data)
@@ -32,34 +38,34 @@ module EffectiveResourcesPrivateHelper
32
38
  end
33
39
 
34
40
  # Replace resource name in any token strings
35
- if opts.key?('data-confirm')
36
- opts['data-confirm'] = opts['data-confirm'].gsub('@resource', (resource.to_s.presence || resource.class.name.gsub('::', ' ').underscore.gsub('_', ' ')).to_s)
41
+ if opts[DATA_CONFIRM].present? && opts[DATA_CONFIRM].include?('@resource'.freeze)
42
+ opts[DATA_CONFIRM] = opts[DATA_CONFIRM].gsub('@resource'.freeze, resource_to_s)
37
43
  end
38
44
 
39
45
  # Assign class
40
46
  opts[:class] ||= (
41
- if opts['data-method'].to_s == 'delete'
42
- 'btn btn-danger'
47
+ if opts['data-method'.freeze] == 'delete'.freeze
48
+ 'btn btn-danger'.freeze
43
49
  elsif h.length == 0
44
- 'btn btn-primary'
50
+ 'btn btn-primary'.freeze
45
51
  elsif defined?(EffectiveBootstrap)
46
- 'btn btn-secondary'
52
+ 'btn btn-secondary'.freeze
47
53
  else
48
- 'btn btn-default'
54
+ 'btn btn-default'.freeze
49
55
  end
50
56
  )
51
57
 
52
58
  # Assign title
53
59
  opts[:title] ||= case opts[:action]
54
60
  when :save then commit
55
- when :edit then "Edit #{resource}"
56
- when :show then "#{resource}"
57
- when :destroy then "Delete #{resource}"
61
+ when :edit then "Edit #{resource_to_s}"
62
+ when :show then "#{resource_to_s}"
63
+ when :destroy then "Delete #{resource_to_s}"
58
64
  when :index then "All #{resource.class.name.gsub('::', ' ').underscore.gsub('_', ' ').titleize.pluralize}"
59
- else "#{opts[:action].to_s.titleize} #{resource}"
65
+ else "#{opts[:action].to_s.titleize} #{resource_to_s}"
60
66
  end
61
67
 
62
- h[commit] = opts; h
68
+ h[commit] = opts
63
69
  end
64
70
  end
65
71
 
@@ -51,4 +51,3 @@ module ActsAsTokened
51
51
  end
52
52
 
53
53
  end
54
-
@@ -44,6 +44,7 @@ module Effective
44
44
  when :string ; :string
45
45
  when :text ; :string
46
46
  when :time ; :time
47
+ when :uuid ; :uuid
47
48
  when FalseClass ; :boolean
48
49
  when (defined?(Integer) ? Integer : Fixnum) ; :integer
49
50
  when Float ; :decimal
@@ -139,6 +140,8 @@ module Effective
139
140
  value.to_s
140
141
  end
141
142
  end
143
+ when :uuid
144
+ value.to_s
142
145
  when :active_storage
143
146
  value.to_s
144
147
  else
@@ -1,6 +1,9 @@
1
1
  module Effective
2
2
  class ModelReader
3
- DATATYPES = [:binary, :boolean, :date, :datetime, :decimal, :float, :hstore, :inet, :integer, :string, :text, :permitted_param]
3
+ DATATYPES = [
4
+ :binary, :boolean, :date, :datetime, :decimal, :float, :hstore, :inet, :integer,
5
+ :string, :text, :uuid, :permitted_param
6
+ ]
4
7
 
5
8
  attr_reader :attributes
6
9
 
@@ -1,12 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Effective
2
4
  module Resources
3
5
  module Actions
6
+ EMPTY_HASH = {}
7
+ POST_VERBS = ['POST', 'PUT', 'PATCH']
8
+ CRUD_ACTIONS = %i(index new create show edit update destroy)
4
9
 
5
10
  # This was written for the Edit actions fallback templates and Datatables
6
11
  # Effective::Resource.new('admin/posts').routes[:index]
7
12
  def routes
8
13
  @routes ||= (
9
- matches = [[namespace, plural_name].compact.join('/'.freeze), [namespace, name].compact.join('/'.freeze)]
14
+ matches = [[namespace, plural_name].compact.join('/'), [namespace, name].compact.join('/')]
10
15
 
11
16
  routes_engine.routes.routes.select do |route|
12
17
  matches.any? { |match| match == route.defaults[:controller] } && !route.name.to_s.end_with?('root')
@@ -19,7 +24,7 @@ module Effective
19
24
  # Effective::Resource.new('effective/order', namespace: :admin)
20
25
  def routes_engine
21
26
  case class_name
22
- when 'Effective::Order'.freeze
27
+ when 'Effective::Order'
23
28
  EffectiveOrders::Engine
24
29
  else
25
30
  Rails.application
@@ -30,12 +35,14 @@ module Effective
30
35
  # This will return empty for create, update and destroy
31
36
  def action_path_helper(action)
32
37
  return unless routes[action]
33
- return (routes[action].name + '_path'.freeze) if routes[action].name.present?
38
+ return (routes[action].name + '_path') if routes[action].name.present?
34
39
  end
35
40
 
36
41
  # Effective::Resource.new('admin/posts').action_path(:edit, Post.last) => '/admin/posts/3/edit'
37
42
  # Will work for any action. Returns the real path
38
- def action_path(action, resource = nil, opts = {})
43
+ def action_path(action, resource = nil, opts = nil)
44
+ opts ||= EMPTY_HASH
45
+
39
46
  if klass.nil? && resource.present? && initialized_name.kind_of?(ActiveRecord::Reflection::BelongsToReflection)
40
47
  return Effective::Resource.new(resource, namespace: namespace).action_path(action, resource, opts)
41
48
  end
@@ -53,12 +60,26 @@ module Effective
53
60
  end
54
61
  end
55
62
 
56
- # This generates the correct route when an object is overriding to_param
57
- if (resource || instance).respond_to?(:attributes)
58
- formattable = (resource || instance).attributes.symbolize_keys.merge(id: (resource || instance).to_param)
63
+ target = (resource || instance)
64
+
65
+ formattable = if routes[action].parts.include?(:id)
66
+ if target.respond_to?(:to_param) && target.respond_to?(:id) && (target.to_param != target.id.to_s)
67
+ routes[action].parts.each_with_object({}) do |part, h|
68
+ if part == :id
69
+ h[part] = target.to_param
70
+ elsif part == :format
71
+ # Nothing
72
+ elsif target.respond_to?(part)
73
+ h[part] = target.public_send(part)
74
+ end
75
+ end
76
+ else
77
+ target
78
+ end
59
79
  end
60
80
 
61
- path = routes[action].format(formattable || {}).presence
81
+ # Generate the path
82
+ path = routes[action].format(formattable || EMPTY_HASH)
62
83
 
63
84
  if path.present? && opts.present?
64
85
  uri = URI.parse(path)
@@ -70,74 +91,85 @@ module Effective
70
91
  end
71
92
 
72
93
  def actions
73
- routes.keys
94
+ @route_actions ||= routes.keys
74
95
  end
75
96
 
76
97
  def crud_actions
77
- actions & %i(index new create show edit update destroy)
98
+ @crud_actions ||= (actions & CRUD_ACTIONS)
78
99
  end
79
100
 
80
101
  # GET actions
81
102
  def collection_actions
82
- routes.values.map { |route| route.defaults[:action].to_sym if is_collection_route?(route) }.compact
103
+ @collection_actions ||= (
104
+ routes.map { |_, route| route.defaults[:action].to_sym if is_collection_route?(route) }.tap(&:compact!)
105
+ )
83
106
  end
84
107
 
85
108
  def collection_get_actions
86
- routes.values.map { |route| route.defaults[:action].to_sym if is_collection_route?(route) && is_get_route?(route) }.compact
109
+ @collection_get_actions ||= (
110
+ routes.map { |_, route| route.defaults[:action].to_sym if is_collection_route?(route) && is_get_route?(route) }.tap(&:compact!)
111
+ )
87
112
  end
88
113
 
89
114
  def collection_post_actions
90
- routes.values.map { |route| route.defaults[:action].to_sym if is_collection_route?(route) && is_post_route?(route) }.compact
115
+ @collection_post_actions ||= (
116
+ routes.map { |_, route| route.defaults[:action].to_sym if is_collection_route?(route) && is_post_route?(route) }.tap(&:compact!)
117
+ )
91
118
  end
92
119
 
93
120
  # All actions
94
121
  def member_actions
95
- routes.values.map { |route| route.defaults[:action].to_sym if is_member_route?(route) }.compact
122
+ @member_actions ||= (
123
+ routes.map { |_, route| route.defaults[:action].to_sym if is_member_route?(route) }.tap(&:compact!)
124
+ )
96
125
  end
97
126
 
98
127
  # GET actions
99
128
  def member_get_actions
100
- routes.values.map { |route| route.defaults[:action].to_sym if is_member_route?(route) && is_get_route?(route) }.compact
129
+ @member_get_actions ||= (
130
+ routes.map { |_, route| route.defaults[:action].to_sym if is_member_route?(route) && is_get_route?(route) }.tap(&:compact!)
131
+ )
101
132
  end
102
133
 
103
134
  def member_delete_actions
104
- routes.values.map { |route| route.defaults[:action].to_sym if is_member_route?(route) && is_delete_route?(route) }.compact
135
+ @member_delete_actions ||= (
136
+ routes.map { |_, route| route.defaults[:action].to_sym if is_member_route?(route) && is_delete_route?(route) }.tap(&:compact!)
137
+ )
105
138
  end
106
139
 
107
140
  # POST/PUT/PATCH actions
108
141
  def member_post_actions
109
- routes.values.map { |route| route.defaults[:action].to_sym if is_member_route?(route) && is_post_route?(route) }.compact
142
+ @member_post_actions ||= (
143
+ routes.map { |_, route| route.defaults[:action].to_sym if is_member_route?(route) && is_post_route?(route) }.tap(&:compact!)
144
+ )
110
145
  end
111
146
 
112
147
  # Same as controller_path in the view
113
148
  def controller_path
114
- [namespace, plural_name].compact * '/'.freeze
149
+ [namespace, plural_name].compact * '/'
115
150
  end
116
151
 
117
152
  private
118
153
 
119
154
  def is_member_route?(route)
120
- (route.path.required_names || []).include?('id'.freeze)
155
+ (route.path.required_names || []).include?('id')
121
156
  end
122
157
 
123
158
  def is_collection_route?(route)
124
- (route.path.required_names || []).include?('id'.freeze) == false
159
+ (route.path.required_names || []).include?('id') == false
125
160
  end
126
161
 
127
162
  def is_get_route?(route)
128
- route.verb.to_s.include?('GET'.freeze)
163
+ route.verb == 'GET'
129
164
  end
130
165
 
131
166
  def is_delete_route?(route)
132
- route.verb.to_s.include?('DELETE'.freeze)
167
+ route.verb == 'DELETE'
133
168
  end
134
169
 
135
170
  def is_post_route?(route)
136
- ['POST', 'PUT', 'PATCH'].freeze.any? { |verb| route.verb == verb }
171
+ POST_VERBS.include?(route.verb)
137
172
  end
138
173
  end
139
174
  end
140
175
  end
141
-
142
-
143
-
@@ -26,7 +26,10 @@ module Effective
26
26
 
27
27
  def has_ones
28
28
  return [] unless klass.respond_to?(:reflect_on_all_associations)
29
- klass.reflect_on_all_associations(:has_one).reject { |ass| ass.class_name.to_s.start_with?('ActiveStorage::') }
29
+
30
+ blacklist = ['ActiveStorage::', 'ActionText::']
31
+
32
+ klass.reflect_on_all_associations(:has_one).reject { |ass| blacklist.any? { |val| ass.class_name.start_with?(val) } }
30
33
  end
31
34
 
32
35
  def has_ones_ids
@@ -66,6 +69,14 @@ module Effective
66
69
  active_storage_has_ones.map { |ass| ass.name.to_s.gsub(/_attachment\z/, '').to_sym }
67
70
  end
68
71
 
72
+ def active_texts
73
+ klass.reflect_on_all_associations(:has_one).select { |ass| ass.class_name == 'ActionText::RichText' }
74
+ end
75
+
76
+ def active_texts_has_ones_ids
77
+ active_texts.map { |ass| ass.name.to_s.gsub(/\Arich_text_/, '').to_sym }
78
+ end
79
+
69
80
  def nested_resources
70
81
  return [] unless klass.respond_to?(:reflect_on_all_associations)
71
82
  klass.reflect_on_all_associations(:has_many).select { |ass| ass.options[:autosave] } +
@@ -153,7 +164,3 @@ module Effective
153
164
  end
154
165
  end
155
166
  end
156
-
157
-
158
-
159
-
@@ -52,6 +52,12 @@ module Effective
52
52
  end
53
53
  end
54
54
 
55
+ def active_text_attributes
56
+ {}.tap do |retval|
57
+ active_texts_has_ones_ids.each { |k, v| retval[k] = [:string] }
58
+ end
59
+ end
60
+
55
61
  # All will include primary_key, created_at, updated_at and belongs_tos
56
62
  # This is the attributes as defined by the effective_resources do .. end block
57
63
  # { :name => [:string, { permitted: false }], ... }
@@ -66,6 +72,7 @@ module Effective
66
72
  .merge(effective_addresses_attributes)
67
73
  .merge(effective_assets_attributes)
68
74
  .merge(active_storage_attributes)
75
+ .merge(active_text_attributes)
69
76
  .merge(atts)
70
77
  else # This is the migrator. This should match table_attributes
71
78
  belong_tos_attributes.merge(atts.reject { |_, v| v[0] == :permitted_param })
@@ -137,7 +144,3 @@ module Effective
137
144
  end
138
145
  end
139
146
  end
140
-
141
-
142
-
143
-
@@ -1,3 +1,5 @@
1
+ # frozen_sting_literals: true
2
+
1
3
  module Effective
2
4
  module Resources
3
5
  module Controller
@@ -29,22 +31,26 @@ module Effective
29
31
  end
30
32
 
31
33
  (member_post_actions - crud_actions).each do |action| # default true means it will be overwritten by dsl methods
32
- buttons[action.to_s.titleize] = case action
34
+ action_name = action.to_s.titleize
35
+
36
+ buttons[action_name] = case action
33
37
  when :archive
34
- { action: action, default: true, if: -> { !resource.archived? }, class: 'btn btn-danger', 'data-method' => :post, 'data-confirm' => "Really #{action} @resource?"}
38
+ { action: action, default: true, if: -> { !resource.archived? }, class: 'btn btn-danger', 'data-method' => :post, 'data-confirm' => "Really #{action_name} @resource?"}
35
39
  when :unarchive
36
- { action: action, default: true, if: -> { resource.archived? }, 'data-method' => :post, 'data-confirm' => "Really #{action} @resource?" }
40
+ { action: action, default: true, if: -> { resource.archived? }, 'data-method' => :post, 'data-confirm' => "Really #{action_name} @resource?" }
37
41
  else
38
- { action: action, default: true, 'data-method' => :post, 'data-confirm' => "Really #{action} @resource?"}
42
+ { action: action, default: true, 'data-method' => :post, 'data-confirm' => "Really #{action_name} @resource?"}
39
43
  end
40
44
  end
41
45
 
42
46
  member_delete_actions.each do |action|
47
+ action_name = action.to_s.titleize
48
+
43
49
  if action == :destroy
44
50
  next if buttons.values.find { |v| v[:action] == :archive }.present?
45
51
  buttons['Delete'] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really delete @resource?" }
46
52
  else
47
- buttons[action.to_s.titleize] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really #{action} @resource?" }
53
+ buttons[action_name] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really #{action_name} @resource?" }
48
54
  end
49
55
  end
50
56
 
@@ -66,33 +72,39 @@ module Effective
66
72
  # It is used by datatables
67
73
  def resource_actions
68
74
  {}.tap do |actions|
69
- (member_get_actions & crud_actions).reverse_each do |action|
75
+ member_get_actions.reverse_each do |action|
76
+ next unless crud_actions.include?(action)
70
77
  actions[action.to_s.titleize] = { action: action, default: true }
71
78
  end
72
79
 
73
- (member_get_actions - crud_actions).each do |action|
80
+ member_get_actions.each do |action|
81
+ next if crud_actions.include?(action)
74
82
  actions[action.to_s.titleize] = { action: action, default: true }
75
83
  end
76
84
 
77
- (member_post_actions - crud_actions).each do |action|
78
- actions[action.to_s.titleize] = { action: action, default: true, 'data-method' => :post, 'data-confirm' => "Really #{action} @resource?" }
85
+ member_post_actions.each do |action|
86
+ next if crud_actions.include?(action)
79
87
 
80
- actions[action.to_s.titleize] = case action
88
+ action_name = action.to_s.titleize
89
+
90
+ actions[action_name] = case action
81
91
  when :archive
82
- { action: action, default: true, if: -> { !resource.archived? }, class: 'btn btn-danger', 'data-method' => :post, 'data-confirm' => "Really #{action} @resource?"}
92
+ { action: action, default: true, if: -> { !resource.archived? }, class: 'btn btn-danger', 'data-method' => :post, 'data-confirm' => "Really #{action_name} @resource?"}
83
93
  when :unarchive
84
- { action: action, default: true, if: -> { resource.archived? }, 'data-method' => :post, 'data-confirm' => "Really #{action} @resource?" }
94
+ { action: action, default: true, if: -> { resource.archived? }, 'data-method' => :post, 'data-confirm' => "Really #{action_name} @resource?" }
85
95
  else
86
- { action: action, default: true, 'data-method' => :post, 'data-confirm' => "Really #{action} @resource?" }
96
+ { action: action, default: true, 'data-method' => :post, 'data-confirm' => "Really #{action_name} @resource?" }
87
97
  end
88
98
  end
89
99
 
90
100
  member_delete_actions.each do |action|
101
+ action_name = action.to_s.titleize
102
+
91
103
  if action == :destroy
92
- next if actions.values.find { |v| v[:action] == :archive }.present?
104
+ next if actions.find { |_, v| v[:action] == :archive }.present?
93
105
  actions['Delete'] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really delete @resource?" }
94
106
  else
95
- actions[action.to_s.titleize] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really #{action} @resource?" }
107
+ actions[action_name] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really #{action_name} @resource?" }
96
108
  end
97
109
  end
98
110
  end
@@ -158,6 +158,12 @@ module Effective
158
158
  else
159
159
  relation.where("#{sql_column} = ?", term)
160
160
  end
161
+ when :uuid
162
+ if fuzzy
163
+ relation.where("#{sql_column}::text #{ilike} ?", "%#{term}%")
164
+ else
165
+ relation.where("#{sql_column}::text = ?", term)
166
+ end
161
167
  else
162
168
  raise "unsupported sql type #{sql_type}"
163
169
  end
@@ -1,5 +1,6 @@
1
1
  - permitted_resource_actions(resource, actions).each do |label, opts|
2
- = link_to(label, (effective_resource.action_path(opts[:action], resource) || '#'), opts.except(:action))
2
+ - action = opts.delete(:action)
3
+ = link_to(label, (effective_resource.action_path(action, resource) || '#'), opts)
3
4
 
4
5
  = instance_exec(resource, &format_block) if local_assigns[:format_block]
5
6
  = yield if block_given?
@@ -1,6 +1,9 @@
1
1
  = dropdown(variation: :dropleft, btn_class: btn_class) do
2
2
  - permitted_resource_actions(resource, actions).each do |label, opts|
3
- = dropdown_link_to(label, (effective_resource.action_path(opts[:action], resource) || '#'), opts.except(:action, :class).merge(btn_class: btn_class))
3
+ - action = opts.delete(:action)
4
+ - opts.delete(:class)
5
+
6
+ = dropdown_link_to(label, (effective_resource.action_path(action, resource) || '#'), opts)
4
7
 
5
8
  = instance_exec(resource, &format_block) if local_assigns[:format_block]
6
9
  = yield(resource) if block_given?
@@ -1,5 +1,8 @@
1
1
  - permitted_resource_actions(resource, actions).each do |label, opts|
2
- = glyphicon_to(opts[:action], (effective_resource.action_path(opts[:action], resource) || '#'), opts.except(:action, :class))
2
+ - action = opts.delete(:action)
3
+ - opts.delete(:class)
4
+
5
+ = glyphicon_to(action, (effective_resource.action_path(action, resource) || '#'), opts)
3
6
 
4
7
  = instance_exec(resource, &format_block) if local_assigns[:format_block]
5
8
  = yield(resource) if block_given?
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.5.0'.freeze
2
+ VERSION = '1.5.5'.freeze
3
3
  end
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: 1.5.0
4
+ version: 1.5.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: 2020-08-13 00:00:00.000000000 Z
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails