five-two-nw-olivander 0.1.2.13 → 0.1.2.15

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: 3fafc0f233f53a5a60c3be296bc128cbbb3700959f82b05cf41029ac144c6a89
4
- data.tar.gz: d6a987479ebe1d30a5f4671a0ca6ede3912f852e1c9cb2e549053802dc42340e
3
+ metadata.gz: c162440a26c8e6f7df1adfe3b568705fcefed8383f8c35fb3ee586cdb47e5af9
4
+ data.tar.gz: a20899ee325a8c056ab694615e3f56c2ab72f9ba99a3d0c1b5bb674f26e49e6f
5
5
  SHA512:
6
- metadata.gz: 2aafa57f69b573299d2857fa04ebe05db1407c0c83c1657c54afbe6eda6e164caf670909e53e30362b2e952d666648126a97b463f50ecd116d9384d7c48c9993
7
- data.tar.gz: 8b3d2b995b2afa004fc2bb2fe313a1aabf448d638ddd45d5ff24fe33bf04674b6be97afe1b67c636fd612a478e6ed75190daddd9b42271fc8e0f64e29d691831
6
+ metadata.gz: ddfda85d4db1af90c5b64a9cb30e1c1d631b17ad2cff1643ca0540de24057842176c1f49572c501c07f2167cc4548d671823ed35ab34c5caa6fbc855b9a93a66
7
+ data.tar.gz: 7956f79b03ba67ba808c68a8f0c7562ff2393a3386705a4a39f029b52056021d0c4ca2092da1107cfe3bf59b0defd868e22644c90f0a0e32d928e64b43322858
@@ -6,7 +6,7 @@ module Olivander
6
6
  :no_route, :path_helper
7
7
 
8
8
  def initialize(sym, action: nil, controller: nil, verb: :get, confirm: false, turbo_frame: nil, collection: false, crud_action: false,
9
- show_in_form: true, show_in_datatable: true, no_route: false)
9
+ show_in_form: true, show_in_datatable: true, no_route: false, path_helper: nil)
10
10
  self.sym = sym
11
11
  self.action = action || sym
12
12
  self.controller = controller
@@ -18,6 +18,7 @@ module Olivander
18
18
  self.show_in_form = show_in_form
19
19
  self.show_in_datatable = show_in_datatable
20
20
  self.no_route = no_route
21
+ self.path_helper = path_helper
21
22
  end
22
23
  end
23
24
 
@@ -96,13 +97,14 @@ module Olivander
96
97
  self.current_resource = nil
97
98
  end
98
99
 
99
- def action(sym, verb: :get, confirm: false, turbo_frame: nil, collection: false, show_in_datatable: true, show_in_form: true, no_route: false, controller: nil, action: nil)
100
+ def action(sym, verb: :get, confirm: false, turbo_frame: nil, collection: false, show_in_datatable: true,
101
+ show_in_form: true, no_route: false, controller: nil, action: nil, path_helper: nil)
100
102
  raise 'Must be invoked in a resource block' unless current_resource.present?
101
103
 
102
104
  controller ||= current_resource.model
103
105
  current_resource.actions << ResourceAction.new(
104
106
  sym, action: action, controller: controller, verb: verb, confirm: confirm, turbo_frame: turbo_frame, collection: collection,
105
- show_in_datatable: show_in_datatable, show_in_form: show_in_form, no_route: no_route
107
+ show_in_datatable: show_in_datatable, show_in_form: show_in_form, no_route: no_route, path_helper: path_helper
106
108
  )
107
109
  end
108
110
 
@@ -18,7 +18,8 @@ module Olivander
18
18
  end
19
19
 
20
20
  def authorized_resource_actions(route_builder, resource, for_action: :show)
21
- plural_name = resource.is_a?(Class) ? resource.table_name : resource.class.table_name
21
+ raw_name = resource.is_a?(Class) ? resource.name : resource.class.name
22
+ plural_name = raw_name.demodulize.underscore.pluralize
22
23
  routed_resource = route_builder.resources[plural_name.to_sym]
23
24
  return [] if routed_resource.nil?
24
25
 
@@ -6,3 +6,7 @@
6
6
  .col-12
7
7
  = render_resource_form(@resource)
8
8
 
9
+ - begin
10
+ = render partial: 'show_additional'
11
+ - rescue ActionView::MissingTemplate
12
+ - Rails.logger.debug "did not find additional show partial"
@@ -1,4 +1,5 @@
1
1
  - route_builder = @context&.route_builder || datatable.class::ROUTE_BUILDER
2
2
  = dropdown(variation: :dropleft, btn_class: btn_class) do
3
3
  - authorized_resource_actions(route_builder, resource, for_action: action_name).select{ |x| x.show_in_datatable }.each do |a|
4
- = dropdown_link_to a.sym, send(a.path_helper, resource.id)
4
+ - path = a.path_helper.is_a?(Proc) ? a.path_helper.call(resource) : send(a.path_helper, resource.id)
5
+ = dropdown_link_to a.sym, path
@@ -1,3 +1,3 @@
1
1
  module Olivander
2
- VERSION = "0.1.2.13"
2
+ VERSION = "0.1.2.15"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: five-two-nw-olivander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.13
4
+ version: 0.1.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dennis
@@ -189,7 +189,6 @@ files:
189
189
  - app/controllers/concerns/olivander/resources/route_builder.rb
190
190
  - app/controllers/olivander/application_controller.rb
191
191
  - app/datatables/olivander/datatable.rb
192
- - app/datatables/test_datatable.rb
193
192
  - app/helpers/olivander/application_helper.rb
194
193
  - app/jobs/olivander/application_job.rb
195
194
  - app/mailers/olivander/application_mailer.rb
@@ -1,15 +0,0 @@
1
- class TestDatatable < Effective::Datatable
2
- datatable do
3
- col :id
4
- col :name
5
- col :description
6
- end
7
-
8
- collection do
9
- [
10
- [1, 'doo'],
11
- [2, 'doo'],
12
- [3, 'doo'],
13
- ]
14
- end
15
- end