five-two-nw-olivander 0.1.2.47 → 0.1.2.49

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: a38a3998950369b24606d91effaa34d2b306b9a16fcf8ef9f8ff3f91c11039a1
4
- data.tar.gz: c5d1f30f64cd53b333e4c42c34307cc16880e42b1a836857ad7c7589ad7f6588
3
+ metadata.gz: 002fba1f117b2435491c2b6627f1124a77f5fe03abe8bb892ee55ca5ce84c999
4
+ data.tar.gz: 33692e5979bc9cf09671052eebaaede0cbf15261f6ec6f2f07b889ecdee08d10
5
5
  SHA512:
6
- metadata.gz: 7cdebfcdf720aeb564ae713293a4ec5fd4e31efe5fb6dbb743499ef9d2bedd08d309cbdcdea0a765c960ea042495885e7465d0194dc13a0631dc5fad34c5e1a8
7
- data.tar.gz: f1fb914c35ddc747c5b85c41fa2f5f5c14d9dfba07a87abfc07993dee9424f285663197c804f461247afece637602f934be4838703ef006244f6ba8025c8243e
6
+ metadata.gz: 49cd7121ce896cca2e054b6e9b1f8e0ce96eb4835c2d639f0a5aca8c9e69780c785114755c55ada48050fa0c792d8fe58334ec7393a9215ad259fb480904c8c3
7
+ data.tar.gz: 9ffca213dde223e5ecda96b698d2ee3015c1ad8f794609c67705a9b95577f39a1e475a85e0893cf01a160a130e9e40091e485f689265df7a43ca1ec438be3402
@@ -63,7 +63,7 @@ module Olivander
63
63
 
64
64
  next unless respond_to?(:attachment_definitions)
65
65
 
66
- attachment_definitions.filter{ |x| puts x; puts inc; x == inc }.each do |ad|
66
+ attachment_definitions.filter{ |x| x == inc }.each do |ad|
67
67
  resource_field ad[0], :file
68
68
  end
69
69
  end
@@ -25,10 +25,16 @@ module Olivander
25
25
  routed_resource = route_builder.resources[plural_name.to_sym]
26
26
  return [] if routed_resource.nil?
27
27
 
28
- actions = resource.is_a?(Class) ?
29
- (routed_resource.unpersisted_crud_actions | routed_resource.collection_actions.select{ |x| !x.crud_action }) :
30
- (resource.persisted? ? (routed_resource.persisted_crud_actions | routed_resource.member_actions.select{ |x| !x.crud_action }): [])
31
- actions = actions.reject{ |a| a.sym == for_action || !EffectiveDatatables.authorization_method.call(controller, a.sym, resource) }
28
+ actions = if resource.is_a?(Class)
29
+ routed_resource.unpersisted_crud_actions | routed_resource.collection_actions.reject(&:crud_action)
30
+ else
31
+ if resource.persisted?
32
+ routed_resource.persisted_crud_actions | routed_resource.member_actions.reject(&:crud_action)
33
+ else
34
+ []
35
+ end
36
+ end
37
+ actions = actions.select{ |a| authorized_resource_action?(a.sym, resource, for_action) }
32
38
  preferred = %i[show edit destroy]
33
39
  [].tap do |arr|
34
40
  preferred.each do |p|
@@ -42,6 +48,12 @@ module Olivander
42
48
  end
43
49
  end
44
50
 
51
+ def authorized_resource_action?(action, resource, except = nil)
52
+ return false if action == except
53
+
54
+ respond_to?('can?') ? can?(action, resource) : true
55
+ end
56
+
45
57
  def resource_form_actions(route_builder, resource, for_action: :show)
46
58
  render partial: 'resource_form_actions', locals: { actions: authorized_resource_actions(route_builder, resource, for_action: for_action).select(&:show_in_form) }
47
59
  end
@@ -1,4 +1,4 @@
1
- - read_only = action_name != 'edit'
1
+ - read_only = !%w[edit new].include?(action_name)
2
2
  = simple_form_for(@resource) do |f|
3
3
  .card.card-primary
4
4
  .card-header
@@ -8,7 +8,9 @@
8
8
  .card-body
9
9
  =f.error_notification
10
10
  =f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present?
11
+ = render_optional_partial 'form_inside_before'
11
12
  = render Olivander::Components::ResourceFormComponent.new(@resource, f)
13
+ = render_optional_partial 'form_inside_after'
12
14
  .card-footer.text-right
13
15
  = link_to 'Cancel', @_effective_resource.action_path(:index), class: 'btn btn-secondary'
14
16
  - unless read_only
@@ -23,9 +23,11 @@
23
23
  :javascript
24
24
  $(document).ready(function(){
25
25
  function getUrl() {
26
- const reg = /\/new|\/[0-9]+[\/edit]*/,
27
- url = "" + window.location;
28
- return url.replace(reg, '');
26
+ const locationUrl = new URL(window.location),
27
+ reg = /\/new|\/[0-9]+[\/edit]*/;
28
+
29
+ locationUrl.pathname = locationUrl.pathname.replace(reg, '')
30
+ return locationUrl.href;
29
31
  }
30
32
  const url = getUrl();
31
33
 
@@ -1,3 +1,3 @@
1
1
  module Olivander
2
- VERSION = '0.1.2.47'.freeze
2
+ VERSION = '0.1.2.49'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.47
4
+ version: 0.1.2.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-25 00:00:00.000000000 Z
11
+ date: 2024-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chartkick