para 0.9.3.2 → 0.9.4
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 +4 -4
- data/lib/para/breadcrumbs/controller.rb +1 -0
- data/lib/para/cloneable/include_tree_builder.rb +46 -14
- data/lib/para/components_cleaner.rb +7 -3
- data/lib/para/components_configuration.rb +8 -8
- data/lib/para/inputs/multi_select_input.rb +2 -0
- data/lib/para/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45b33c0018d1c19e222c84f62ef8c0eb3820fbbe60dcc6c99da7a40bf229fc1b
|
4
|
+
data.tar.gz: fe48b49c545495cc4103418d4c75f3d34447b1003ef690ac45076768509cfc30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8e403bd825fbeba4dd042eb2a01a0f17562b9ab145ec400aa216ed81ed07e483b2b22984e9c6a63b55408367ef7b0faf7022e931a262fe61640a1fffc7c03da
|
7
|
+
data.tar.gz: c9e6a4da03d11873890d5c7c1c338f109fe03f0ebfe605022b304bce43758f650e05580df1899b5c68bfe523d47b16e3988f86ed5247b9e999bd4dd1816fef87
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Para
|
2
4
|
module Cloneable
|
3
5
|
# This object acts as a service to compile a nested cloneable options hash to be
|
@@ -49,7 +51,7 @@ module Para
|
|
49
51
|
# }
|
50
52
|
#
|
51
53
|
class IncludeTreeBuilder
|
52
|
-
attr_reader :resource,
|
54
|
+
attr_reader :resource, :cloneable_options
|
53
55
|
|
54
56
|
def initialize(resource)
|
55
57
|
@resource = resource
|
@@ -73,26 +75,56 @@ module Para
|
|
73
75
|
# if it exist, which include the attributes that shouldn't be duplicated when
|
74
76
|
# the resource is cloned.
|
75
77
|
#
|
76
|
-
def build_cloneable_options_tree(resource)
|
78
|
+
def build_cloneable_options_tree(resource, path = [])
|
77
79
|
cloneable_options = resource.cloneable_options
|
78
|
-
options = {}
|
79
80
|
|
80
81
|
# Iterate over the resource's cloneable options' :include array and recursively
|
81
82
|
# add nested included resources to its own included resources.
|
82
83
|
options = cloneable_options[:include].each_with_object({}) do |reflection_name, hash|
|
84
|
+
# This avoids cyclic dependencies issues by stopping nested association
|
85
|
+
# inclusions before the cycle starts.
|
86
|
+
#
|
87
|
+
# For example, if a post includes its author, and the author includes its posts,
|
88
|
+
# this would make the system fail with a stack level too deep error. Here this
|
89
|
+
# guard allows the inclusion to stop at :
|
90
|
+
#
|
91
|
+
# { posts: { author: { posts: { author: {}}}}}
|
92
|
+
#
|
93
|
+
# Which ensures that, using the dictionary strategy of deep_cloneable, all
|
94
|
+
# posts' authors' posts will have their author mapped to an already cloned
|
95
|
+
# author when it comes to cloning the "author" 4th level of the include tree.
|
96
|
+
#
|
97
|
+
# This is not the most optimized solution, but works well enough as if the
|
98
|
+
# author's posts match previously cloned posts, they won't be cloned as they'll
|
99
|
+
# exist in the cloned resources dictionary.
|
100
|
+
next if path.length >= 4 &&
|
101
|
+
path[-4] == path[-2] &&
|
102
|
+
path[-2] == reflection_name &&
|
103
|
+
path[-3] == path[-1]
|
104
|
+
|
83
105
|
hash[reflection_name] = {}
|
84
106
|
|
85
|
-
|
86
|
-
|
87
|
-
|
107
|
+
unless (reflection = resource.class.reflections[reflection_name.to_s])
|
108
|
+
next
|
109
|
+
end
|
88
110
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
add_reflection_options(
|
111
|
+
reflection_options = hash[reflection_name]
|
112
|
+
association_target = resource.send(reflection_name)
|
113
|
+
|
114
|
+
if reflection.collection?
|
115
|
+
association_target.each do |nested_resource|
|
116
|
+
add_reflection_options(
|
117
|
+
reflection_options,
|
118
|
+
nested_resource,
|
119
|
+
[*path, reflection_name]
|
120
|
+
)
|
95
121
|
end
|
122
|
+
else
|
123
|
+
add_reflection_options(
|
124
|
+
reflection_options,
|
125
|
+
association_target,
|
126
|
+
[*path, reflection_name]
|
127
|
+
)
|
96
128
|
end
|
97
129
|
end
|
98
130
|
|
@@ -104,11 +136,11 @@ module Para
|
|
104
136
|
options
|
105
137
|
end
|
106
138
|
|
107
|
-
def add_reflection_options(reflection_options, nested_resource)
|
139
|
+
def add_reflection_options(reflection_options, nested_resource, path)
|
108
140
|
options = nested_resource.class.try(:cloneable_options)
|
109
141
|
return reflection_options unless options
|
110
142
|
|
111
|
-
target_options = build_cloneable_options_tree(nested_resource)
|
143
|
+
target_options = build_cloneable_options_tree(nested_resource, path)
|
112
144
|
reflection_options.deep_merge!(target_options)
|
113
145
|
end
|
114
146
|
|
@@ -1,17 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Para
|
2
4
|
class ComponentsCleaner
|
3
5
|
# Hide class instanciation
|
4
|
-
def self.run
|
6
|
+
def self.run
|
7
|
+
new.run
|
8
|
+
end
|
5
9
|
|
6
10
|
def run
|
7
11
|
components.each do |component|
|
8
|
-
|
12
|
+
if component.id != Para.components.components_ids_hash[component.identifier]
|
9
13
|
component.destroy
|
10
14
|
end
|
11
15
|
end
|
12
16
|
|
13
17
|
Para::ComponentSection.find_each do |section|
|
14
|
-
unless Para.components.
|
18
|
+
unless Para.components.sections_ids_hash[section.identifier]
|
15
19
|
section.destroy
|
16
20
|
end
|
17
21
|
end
|
@@ -76,6 +76,14 @@ module Para
|
|
76
76
|
nil
|
77
77
|
end
|
78
78
|
|
79
|
+
def sections_ids_hash
|
80
|
+
@sections_ids_hash ||= {}.with_indifferent_access
|
81
|
+
end
|
82
|
+
|
83
|
+
def components_ids_hash
|
84
|
+
@components_ids_hash ||= {}.with_indifferent_access
|
85
|
+
end
|
86
|
+
|
79
87
|
private
|
80
88
|
|
81
89
|
def build
|
@@ -93,14 +101,6 @@ module Para
|
|
93
101
|
end
|
94
102
|
end
|
95
103
|
|
96
|
-
def sections_ids_hash
|
97
|
-
@sections_ids_hash ||= {}.with_indifferent_access
|
98
|
-
end
|
99
|
-
|
100
|
-
def components_ids_hash
|
101
|
-
@components_ids_hash ||= {}.with_indifferent_access
|
102
|
-
end
|
103
|
-
|
104
104
|
# Only store sections cache for the request duration to avoid expired
|
105
105
|
# references to AR objects between requests
|
106
106
|
#
|
data/lib/para/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: para
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valentin Ballestrino
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '4.0'
|
20
20
|
- - "<="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '4.0'
|
30
30
|
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rails-i18n
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -852,7 +852,7 @@ homepage: http://github.com/glyph-fr/para
|
|
852
852
|
licenses:
|
853
853
|
- MIT
|
854
854
|
metadata: {}
|
855
|
-
post_install_message:
|
855
|
+
post_install_message:
|
856
856
|
rdoc_options: []
|
857
857
|
require_paths:
|
858
858
|
- lib
|
@@ -867,8 +867,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
867
867
|
- !ruby/object:Gem::Version
|
868
868
|
version: '0'
|
869
869
|
requirements: []
|
870
|
-
rubygems_version: 3.
|
871
|
-
signing_key:
|
870
|
+
rubygems_version: 3.3.7
|
871
|
+
signing_key:
|
872
872
|
specification_version: 4
|
873
873
|
summary: Rails admin engine
|
874
874
|
test_files: []
|