plutonium 0.19.3 → 0.19.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90334ca76362d14c0666cc221dda19671f8ded4348f65e61e7a0044251dbf153
4
- data.tar.gz: 9e941a439c725b2df639d0c48f3dbdaed1f73abcc515ef4cff938653ce8cadcd
3
+ metadata.gz: b27651d25eebb89d108051b5f2afb8f1703587eb91c84207cc4ec0862b4d45c2
4
+ data.tar.gz: 44e3394e35c5f2fe1c811a29697fc7e59e7224e296a8d2fdb707c33098a85eca
5
5
  SHA512:
6
- metadata.gz: 45c602ae6961272dde234ede40560e832f9d5ae81244d284c0691f17989ac4d64cf33a4f7fab3a7a7c57ec433fdd01d289ff1c4add954cab54673dfc1b420472
7
- data.tar.gz: b837a486e11096bc39678e4dcf3ca0a854f3718bbc6fc5c09cf8ab56400555bee09d074ecab7fdd797289ac61bcd36fd8a26d546761a390f0f5118156ff895ab
6
+ metadata.gz: c9ad4898ae89e4e0095a802357a2f4323c3025bc0bc7f2fb9543829ee23923f08ae632e764df357d3ce29a23a53a151a6399f2c7fd2c6d90b01ce21f3c5d7b3c
7
+ data.tar.gz: 06b6ecf29c1e65831a5f40dcc8d32a6110aa02e24ddadc053bc40e88cebd0230738854d11e40e5e29b770df0fe6f4b8b39d684d732b497f3503f41401cd5ee1a
@@ -128,11 +128,7 @@ module Plutonium
128
128
  @current_parent ||= begin
129
129
  parent_route_key = parent_route_param.to_s.gsub(/_id$/, "").to_sym
130
130
  parent_class = current_engine.resource_register.route_key_lookup[parent_route_key]
131
- parent_scope = if scoped_to_entity?
132
- parent_class.associated_with(current_scoped_entity)
133
- else
134
- parent_class.all
135
- end
131
+ parent_scope = authorized_scope(parent_class.all, context: {entity_scope: entity_scope_for_authorize})
136
132
  parent_scope = parent_scope.from_path_param(params[parent_route_param])
137
133
  current_parent = parent_scope.first!
138
134
  authorize! current_parent, to: :read?
@@ -13,9 +13,10 @@ module Plutonium
13
13
  def presentable_attributes
14
14
  @presentable_attributes ||= begin
15
15
  presentable_attributes = permitted_attributes
16
- if current_parent
16
+ if current_parent && !present_parent?
17
17
  presentable_attributes -= [parent_input_param, :"#{parent_input_param}_id"]
18
- elsif scoped_to_entity?
18
+ end
19
+ if scoped_to_entity? && !present_scoped_entity?
19
20
  presentable_attributes -= [scoped_entity_param_key, :"#{scoped_entity_param_key}_id"]
20
21
  end
21
22
  presentable_attributes
@@ -25,8 +26,12 @@ module Plutonium
25
26
  def submittable_attributes
26
27
  @submittable_attributes ||= begin
27
28
  submittable_attributes = permitted_attributes
28
- submittable_attributes -= [parent_input_param, :"#{parent_input_param}_id"] if current_parent
29
- submittable_attributes -= [scoped_entity_param_key, :"#{scoped_entity_param_key}_id"] if scoped_to_entity?
29
+ if current_parent && !submit_parent?
30
+ submittable_attributes -= [parent_input_param, :"#{parent_input_param}_id"]
31
+ end
32
+ if scoped_to_entity? && !submit_scoped_entity?
33
+ submittable_attributes -= [scoped_entity_param_key, :"#{scoped_entity_param_key}_id"]
34
+ end
30
35
  submittable_attributes
31
36
  end
32
37
  end
@@ -42,6 +47,14 @@ module Plutonium
42
47
  def build_form(record = resource_record!)
43
48
  current_definition.form_class.new(record, resource_fields: submittable_attributes, resource_definition: current_definition)
44
49
  end
50
+
51
+ def present_parent? = false
52
+
53
+ def present_scoped_entity? = false
54
+
55
+ def submit_parent? = present_parent?
56
+
57
+ def submit_scoped_entity? = present_scoped_entity?
45
58
  end
46
59
  end
47
60
  end
@@ -48,7 +48,7 @@ module Plutonium
48
48
 
49
49
  title = object.class.human_attribute_name(name)
50
50
  src = case reflection.macro
51
- when :belongs_to
51
+ when :belongs_to, :has_one
52
52
  associated = object.public_send name
53
53
  resource_url_for(associated, parent: nil) if associated
54
54
  when :has_many
@@ -1,5 +1,5 @@
1
1
  module Plutonium
2
- VERSION = "0.19.3"
2
+ VERSION = "0.19.5"
3
3
  NEXT_MAJOR_VERSION = VERSION.split(".").tap { |v|
4
4
  v[1] = v[1].to_i + 1
5
5
  v[2] = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plutonium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.3
4
+ version: 0.19.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-21 00:00:00.000000000 Z
11
+ date: 2025-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk