dato 0.3.22 → 0.3.23
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/.travis.yml +0 -1
- data/lib/dato/local/item.rb +18 -0
- data/lib/dato/local/items_repo.rb +10 -0
- data/lib/dato/site/repo/item_type.rb +4 -4
- data/lib/dato/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f1dee8287f371f80c0d9f92c8c979a2857606e7
|
4
|
+
data.tar.gz: 94a2edd19020f70b7a5cb843fd7f75fe4511b00f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 034eb1820be90435bac07c73b816c8bfbee0ebca17ca5f152867c5bd761c6a09b39a0405a002b783bef1c587d8ea13f788052330349c7023f10d8a8093958ec6
|
7
|
+
data.tar.gz: b227eb6e849c5b9971d8fd3e2cb10babc4d1dd702424149daad80eb5044ff945acc8422a522c958a5fd5492cc5727392a5fd6f787a4d7364b10a99d56a108ee7
|
data/.travis.yml
CHANGED
data/lib/dato/local/item.rb
CHANGED
@@ -82,6 +82,14 @@ module Dato
|
|
82
82
|
entity.position
|
83
83
|
end
|
84
84
|
|
85
|
+
def parent
|
86
|
+
@items_repo.find(entity.parent_id) if item_type.tree && entity.parent_id
|
87
|
+
end
|
88
|
+
|
89
|
+
def children
|
90
|
+
@items_repo.children_of(id) if item_type.tree
|
91
|
+
end
|
92
|
+
|
85
93
|
def updated_at
|
86
94
|
Time.parse(entity.updated_at).utc
|
87
95
|
end
|
@@ -103,6 +111,16 @@ module Dato
|
|
103
111
|
|
104
112
|
base[:position] = position if item_type.sortable
|
105
113
|
|
114
|
+
if item_type.tree
|
115
|
+
base[:position] = position
|
116
|
+
base[:children] = children.map do |_i|
|
117
|
+
value.to_hash(
|
118
|
+
max_depth,
|
119
|
+
current_depth + 1
|
120
|
+
)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
106
124
|
fields.each_with_object(base) do |field, result|
|
107
125
|
value = send(field.api_key)
|
108
126
|
|
@@ -12,6 +12,7 @@ module Dato
|
|
12
12
|
@entities_repo = entities_repo
|
13
13
|
@collections_by_type = {}
|
14
14
|
@items_by_id = {}
|
15
|
+
@items_by_parent_id = {}
|
15
16
|
@item_type_methods = {}
|
16
17
|
|
17
18
|
build_cache!
|
@@ -21,6 +22,10 @@ module Dato
|
|
21
22
|
@items_by_id[id.to_s]
|
22
23
|
end
|
23
24
|
|
25
|
+
def children_of(id)
|
26
|
+
@items_by_parent_id[id.to_s]
|
27
|
+
end
|
28
|
+
|
24
29
|
def respond_to_missing?(method, include_private = false)
|
25
30
|
if collections_by_type.key?(method)
|
26
31
|
true
|
@@ -116,6 +121,11 @@ module Dato
|
|
116
121
|
end
|
117
122
|
|
118
123
|
@items_by_id[item.id] = item
|
124
|
+
|
125
|
+
if item_entity.respond_to?(:parent_id) && item_entity.parent_id
|
126
|
+
@items_by_parent_id[item_entity.parent_id] ||= []
|
127
|
+
@items_by_parent_id[item_entity.parent_id] << item
|
128
|
+
end
|
119
129
|
end
|
120
130
|
|
121
131
|
item_types.each do |item_type|
|
@@ -8,9 +8,9 @@ module Dato
|
|
8
8
|
def create(resource_attributes)
|
9
9
|
body = JsonApiSerializer.new(
|
10
10
|
type: :item_type,
|
11
|
-
attributes: %i(api_key name ordering_direction singleton sortable),
|
11
|
+
attributes: %i(api_key name ordering_direction singleton sortable tree),
|
12
12
|
relationships: { ordering_field: { collection: false, type: :field } },
|
13
|
-
required_attributes: %i(api_key name ordering_direction singleton sortable),
|
13
|
+
required_attributes: %i(api_key name ordering_direction singleton sortable tree),
|
14
14
|
required_relationships: %i(ordering_field)
|
15
15
|
).serialize(resource_attributes)
|
16
16
|
|
@@ -20,9 +20,9 @@ module Dato
|
|
20
20
|
def update(item_type_id, resource_attributes)
|
21
21
|
body = JsonApiSerializer.new(
|
22
22
|
type: :item_type,
|
23
|
-
attributes: %i(api_key name ordering_direction singleton sortable),
|
23
|
+
attributes: %i(api_key name ordering_direction singleton sortable tree),
|
24
24
|
relationships: { ordering_field: { collection: false, type: :field } },
|
25
|
-
required_attributes: %i(api_key name ordering_direction singleton sortable),
|
25
|
+
required_attributes: %i(api_key name ordering_direction singleton sortable tree),
|
26
26
|
required_relationships: %i(ordering_field)
|
27
27
|
).serialize(resource_attributes, item_type_id)
|
28
28
|
|
data/lib/dato/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Verna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|