forest_liana 1.3.18 → 1.3.19
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a6ef592b7aec3837d2dc0e9aa0c0e53ef769edc
|
4
|
+
data.tar.gz: 73a6c573d1e7b47e6a20a41c3e79d98d603c8f75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f756eaac706fc386c56804745e04dc07ce576bc9553528b5b7979b4928e91f2eb892b901412878e797045032a926f271dc94604903ae5bff4e950be237545ba
|
7
|
+
data.tar.gz: b33f900ac08db1e5c24d977be7658ac83b710339e7394697bd7f63c11a6df0d95d7609ca1df7b5268ae2d4b4592a70c38aacfccfda8d7d6a3a4a70dd1723b685
|
@@ -73,6 +73,13 @@ module ForestLiana
|
|
73
73
|
def relationship_related_link(attribute_name)
|
74
74
|
ret = {}
|
75
75
|
|
76
|
+
# Has many smart field
|
77
|
+
current = self.has_many_relationships[attribute_name]
|
78
|
+
if current.try(:[], :options).try(:[], :name) == attribute_name
|
79
|
+
ret[:href] = "/forest/#{object.class.table_name}/#{object.id}/#{attribute_name}"
|
80
|
+
return ret
|
81
|
+
end
|
82
|
+
|
76
83
|
if intercom_integration?
|
77
84
|
case attribute_name
|
78
85
|
when :intercom_conversations
|
@@ -20,6 +20,7 @@ More info at: https://github.com/ForestAdmin/forest-rails/releases/tag/1.2.0"
|
|
20
20
|
|
21
21
|
if ForestLiana.secret_key
|
22
22
|
create_apimap
|
23
|
+
require_lib_forest_liana
|
23
24
|
send_apimap
|
24
25
|
end
|
25
26
|
end
|
@@ -58,6 +59,13 @@ More info at: https://github.com/ForestAdmin/forest-rails/releases/tag/1.2.0"
|
|
58
59
|
setup_intercom_integration if intercom_integration?
|
59
60
|
end
|
60
61
|
|
62
|
+
def require_lib_forest_liana
|
63
|
+
path = Rails.root.join('lib', 'forest_liana', '**', '*.rb')
|
64
|
+
Dir.glob(File.expand_path(path, __FILE__)).each do |file|
|
65
|
+
require file
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
61
69
|
def send_apimap
|
62
70
|
json = JSONAPI::Serializer.serialize(ForestLiana.apimap, {
|
63
71
|
is_collection: true,
|
@@ -2,12 +2,13 @@ module ForestLiana::Collection
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
module ClassMethods
|
5
|
+
attr_accessor :active_record_class
|
5
6
|
attr_accessor :collection_name
|
6
7
|
attr_accessor :is_read_only
|
7
8
|
attr_accessor :is_searchable
|
8
9
|
|
9
|
-
def collection(
|
10
|
-
self.collection_name =
|
10
|
+
def collection(collection_name, opts = {})
|
11
|
+
self.collection_name = collection_name.to_s
|
11
12
|
self.is_read_only = opts[:read_only] || false
|
12
13
|
self.is_searchable = opts[:is_searchable] || true
|
13
14
|
end
|
@@ -17,8 +18,23 @@ module ForestLiana::Collection
|
|
17
18
|
model.actions << ForestLiana::Model::Action.new(opts)
|
18
19
|
end
|
19
20
|
|
20
|
-
def field(name, opts)
|
21
|
-
model.fields << opts.merge({ field: name })
|
21
|
+
def field(name, opts, &block)
|
22
|
+
model.fields << opts.merge({ field: name, is_searchable: false })
|
23
|
+
ForestLiana::UserSpace.const_get(serializer_name).class_eval do
|
24
|
+
attribute(name, &block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def has_many(name, opts, &block)
|
29
|
+
model.fields << opts.merge({
|
30
|
+
field: name,
|
31
|
+
is_searchable: false,
|
32
|
+
type: ['String']
|
33
|
+
})
|
34
|
+
|
35
|
+
ForestLiana::UserSpace.const_get(serializer_name).class_eval do
|
36
|
+
has_many(name, name: name)
|
37
|
+
end
|
22
38
|
end
|
23
39
|
|
24
40
|
private
|
@@ -41,6 +57,31 @@ module ForestLiana::Collection
|
|
41
57
|
|
42
58
|
collection
|
43
59
|
end
|
60
|
+
|
61
|
+
def active_record_class
|
62
|
+
ForestLiana::SchemaUtils.find_model_from_table_name(self.collection_name)
|
63
|
+
end
|
64
|
+
|
65
|
+
def serializer_name
|
66
|
+
class_name = active_record_class.table_name.classify
|
67
|
+
module_name = class_name.deconstantize
|
68
|
+
|
69
|
+
name = module_name if module_name
|
70
|
+
name += class_name.demodulize
|
71
|
+
|
72
|
+
"ForestLiana::UserSpace::#{name}Serializer"
|
73
|
+
end
|
74
|
+
|
75
|
+
def serializer_name_for_reference(reference)
|
76
|
+
association = opts[:reference].split('.').first
|
77
|
+
class_name = association.classify
|
78
|
+
module_name = class_name.deconstantize
|
79
|
+
|
80
|
+
name = module_name if module_name
|
81
|
+
name += class_name.demodulize
|
82
|
+
|
83
|
+
"ForestLiana::UserSpace::#{name}Serializer"
|
84
|
+
end
|
44
85
|
end
|
45
86
|
end
|
46
87
|
|
data/lib/forest_liana/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_liana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Munda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|