push_type_core 0.4.0 → 0.5.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/fields/push_type/array_field.rb +0 -1
- data/app/fields/push_type/asset_field.rb +32 -0
- data/app/fields/push_type/date_field.rb +7 -1
- data/app/fields/push_type/matrix_field.rb +33 -0
- data/app/fields/push_type/number_field.rb +2 -2
- data/app/fields/push_type/repeater_field.rb +19 -0
- data/app/fields/push_type/select_field.rb +44 -0
- data/app/fields/push_type/tag_list_field.rb +3 -1
- data/app/fields/push_type/taxonomy_field.rb +62 -0
- data/app/fields/push_type/time_field.rb +18 -0
- data/lib/push_type/version.rb +1 -1
- data/test/dummy/config/initializers/push_type.rb +1 -1
- data/test/dummy/config/secrets.yml +2 -2
- data/test/dummy/db/schema.rb +1 -1
- data/test/dummy/log/test.log +2632 -2630
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/-Sjd8yE8radAZWLZz1Hn9eTc5vPZke6_-U1eg-KNjy8.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/0_aw7up97T_NTvobuzf-o1Xpynz3Eqo7lyRTdE_M3kg.cache +3 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/BL-JC9Mha5EbAlzAR0-4qZvqO8u_54SF5Z2ZaoDjlfw.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/H3MYWnNh74SPmIVutQpgqiLFgQBaPIZ8rUXz8S1IXfQ.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/I6zXuKkTIFbRK1A1tWK7nMeIhOXwx4iMRyZCdQatqy8.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/OC9Pezno0-bFKhuLASN_oxeMelP7hAYHfMDOdC916tY.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/RwmiAHIoiRN917L4TQ8saQaj1DsQgMpS97RYvkK2D5M.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/YfvOcAtfd0a4AoZRwhfEPbutzGvytNV3PLH99tHHVec.cache +1 -0
- data/test/dummy/tmp/generators/app/presenters/page_presenter.rb +12 -0
- data/test/lib/push_type/field_type_test.rb +0 -1
- metadata +42 -28
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/generators/app/models/category.rb +0 -6
- data/test/dummy/tmp/generators/app/views/taxonomies/category.html.erb +0 -3
- /data/test/dummy/db/migrate/{20150423122725_create_push_type_users.push_type.rb → 20150429164551_create_push_type_users.push_type.rb} +0 -0
- /data/test/dummy/db/migrate/{20150423122726_create_push_type_nodes.push_type.rb → 20150429164552_create_push_type_nodes.push_type.rb} +0 -0
- /data/test/dummy/db/migrate/{20150423122727_create_push_type_node_hierarchies.push_type.rb → 20150429164553_create_push_type_node_hierarchies.push_type.rb} +0 -0
- /data/test/dummy/db/migrate/{20150423122728_create_push_type_assets.push_type.rb → 20150429164554_create_push_type_assets.push_type.rb} +0 -0
- /data/test/dummy/db/migrate/{20150423122729_create_push_type_taxonomies.push_type.rb → 20150429164555_create_push_type_taxonomies.push_type.rb} +0 -0
- /data/test/dummy/db/migrate/{20150423122730_create_push_type_taxonomy_hierarchies.push_type.rb → 20150429164556_create_push_type_taxonomy_hierarchies.push_type.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f8ea5a931226f90d15d5e52be67d53690c761e6
|
4
|
+
data.tar.gz: 8ac8f4b6233f1dc4eca90f1b077add21bf5e0828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a56e27c024e809456ebc8caa5f2bb6fc0c45c73d8a01d8b9443679484cc0a6fd23d851ebca7ca3e059459d018de7af0cb2894e47a967a1ff8740e5a06257e55b
|
7
|
+
data.tar.gz: 76d4de9a0bc8d7bdd64be5dd4134d2d9299ff6ce533f6547154722f8cc3ca6a5a14ec43645370c9dc9b297b4e3031e688f454b965c450cea365a83b6126299e6
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module PushType
|
2
|
+
class AssetField < PushType::FieldType
|
3
|
+
|
4
|
+
def template
|
5
|
+
@opts[:template] || 'asset'
|
6
|
+
end
|
7
|
+
|
8
|
+
def id_attr
|
9
|
+
"#{ name }-asset-modal"
|
10
|
+
end
|
11
|
+
|
12
|
+
def from_json(val)
|
13
|
+
return if val.blank?
|
14
|
+
PushType::Asset.find(val)
|
15
|
+
end
|
16
|
+
|
17
|
+
initialized_on_node do |object, field|
|
18
|
+
object.class_eval do
|
19
|
+
|
20
|
+
define_method field.relation_id_method do
|
21
|
+
field_store[field.name]
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def relation_id_method
|
28
|
+
(name + '_id').to_sym
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -1,12 +1,18 @@
|
|
1
1
|
module PushType
|
2
2
|
class DateField < PushType::FieldType
|
3
|
+
|
4
|
+
def template
|
5
|
+
@opts[:template] || 'date'
|
6
|
+
end
|
7
|
+
|
3
8
|
def form_helper
|
4
9
|
@opts[:form_helper] || :date_field
|
5
10
|
end
|
6
11
|
|
7
12
|
def from_json(val)
|
8
|
-
return
|
13
|
+
return if val.blank?
|
9
14
|
val.to_date
|
10
15
|
end
|
16
|
+
|
11
17
|
end
|
12
18
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module PushType
|
2
|
+
class MatrixField < ArrayField
|
3
|
+
|
4
|
+
def param
|
5
|
+
{ name.to_sym => mapping.keys }
|
6
|
+
end
|
7
|
+
|
8
|
+
def template
|
9
|
+
@opts[:template] || :matrix
|
10
|
+
end
|
11
|
+
|
12
|
+
def mapping
|
13
|
+
@mapping ||= (@opts[:mapping] || []).reduce({}) do |h, col|
|
14
|
+
col.is_a?(Hash) ? h.merge(col) : h.update(col => form_helper)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_json(val)
|
19
|
+
return if val.blank?
|
20
|
+
super.reject { |v| v.blank? or v.values.all?(&:blank?) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def from_json(val)
|
24
|
+
return if val.blank?
|
25
|
+
super.reject { |v| v.blank? or v.values.all?(&:blank?) }.map { |h| struct.new(*h.values) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def struct
|
29
|
+
@struct ||= Struct.new *mapping.keys
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module PushType
|
2
|
+
class RepeaterField < ArrayField
|
3
|
+
|
4
|
+
def template
|
5
|
+
@opts[:template] || :repeater
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_json(val)
|
9
|
+
return if val.blank?
|
10
|
+
super.reject(&:blank?)
|
11
|
+
end
|
12
|
+
|
13
|
+
def from_json(val)
|
14
|
+
return if val.blank?
|
15
|
+
super.reject(&:blank?)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module PushType
|
2
|
+
class SelectField < PushType::FieldType
|
3
|
+
|
4
|
+
def param
|
5
|
+
multiple? ? { name.to_sym => [] } : super
|
6
|
+
end
|
7
|
+
|
8
|
+
def template
|
9
|
+
@opts[:template] || 'select'
|
10
|
+
end
|
11
|
+
|
12
|
+
def choices
|
13
|
+
return [] unless @opts[:choices]
|
14
|
+
if @opts[:choices].respond_to? :call
|
15
|
+
@opts[:choices].call
|
16
|
+
else
|
17
|
+
@opts[:choices]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def field_options
|
22
|
+
{ include_blank: 'Please select...' }.merge(@opts[:field_options] || {})
|
23
|
+
end
|
24
|
+
|
25
|
+
def html_options
|
26
|
+
super.merge(multiple: multiple?)
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_json(val)
|
30
|
+
return if val.blank?
|
31
|
+
multiple? ? Array(val).reject(&:blank?) : super
|
32
|
+
end
|
33
|
+
|
34
|
+
def from_json(val)
|
35
|
+
return if val.blank?
|
36
|
+
multiple? ? Array(val).reject(&:blank?) : super
|
37
|
+
end
|
38
|
+
|
39
|
+
def multiple?
|
40
|
+
@opts[:multiple] || false
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -8,14 +8,16 @@ module PushType
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def html_options
|
11
|
-
{ multiple: true, placeholder: 'Tags...' }.merge(super)
|
11
|
+
{ multiple: true, placeholder: 'Tags...' }.merge(super)
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_json(val)
|
15
|
+
return if val.blank?
|
15
16
|
super.reject(&:blank?)
|
16
17
|
end
|
17
18
|
|
18
19
|
def from_json(val)
|
20
|
+
return if val.blank?
|
19
21
|
super.reject(&:blank?)
|
20
22
|
end
|
21
23
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module PushType
|
2
|
+
class TaxonomyField < SelectField
|
3
|
+
|
4
|
+
def template
|
5
|
+
@opts[:template] || 'taxonomy'
|
6
|
+
end
|
7
|
+
|
8
|
+
def choices
|
9
|
+
[]
|
10
|
+
end
|
11
|
+
|
12
|
+
def from_json(val)
|
13
|
+
return if val.blank?
|
14
|
+
ids = multiple? ? Array(val).reject(&:blank?) : super
|
15
|
+
taxonomy_class.find(ids)
|
16
|
+
end
|
17
|
+
|
18
|
+
initialized_on_node do |object, field|
|
19
|
+
object.class_eval do
|
20
|
+
|
21
|
+
define_method field.relation_id_method do
|
22
|
+
field_store[field.name]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def singular_name
|
29
|
+
multiple? ? name.singularize : name
|
30
|
+
end
|
31
|
+
|
32
|
+
def taxonomy_class
|
33
|
+
(@opts[:taxonomy_class] || singular_name).to_s.classify.constantize
|
34
|
+
end
|
35
|
+
|
36
|
+
def taxonomy_tree_to_json
|
37
|
+
flatten_tree taxonomy_class.hash_tree
|
38
|
+
end
|
39
|
+
|
40
|
+
def relation_id_method
|
41
|
+
suffix = multiple? ? '_ids' : '_id'
|
42
|
+
(singular_name + suffix).to_sym
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def flatten_tree(hash_tree, d = 0)
|
48
|
+
hash_tree.flat_map do |parent, children|
|
49
|
+
[
|
50
|
+
{
|
51
|
+
value: parent.id,
|
52
|
+
text: parent.title,
|
53
|
+
depth: d
|
54
|
+
},
|
55
|
+
flatten_tree(children, d+1)
|
56
|
+
]
|
57
|
+
end.flatten
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module PushType
|
2
|
+
class TimeField < PushType::FieldType
|
3
|
+
|
4
|
+
def template
|
5
|
+
@opts[:template] || 'date'
|
6
|
+
end
|
7
|
+
|
8
|
+
def form_helper
|
9
|
+
@opts[:form_helper] || :time_field
|
10
|
+
end
|
11
|
+
|
12
|
+
def from_json(val)
|
13
|
+
return if val.blank?
|
14
|
+
val.to_time
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/push_type/version.rb
CHANGED
@@ -33,6 +33,6 @@ PushType.setup do |config|
|
|
33
33
|
# secret_access_key: ENV['SECRET_ACCESS_KEY_ID']
|
34
34
|
# }
|
35
35
|
|
36
|
-
# config.dragonfly_secret = '
|
36
|
+
# config.dragonfly_secret = 'd571eeb04d9704bb74753159c285af20ffe0fcb4929f64956ec3c5a1318fa9a6'
|
37
37
|
|
38
38
|
end
|
@@ -11,10 +11,10 @@
|
|
11
11
|
# if you're sharing your code publicly.
|
12
12
|
|
13
13
|
development:
|
14
|
-
secret_key_base:
|
14
|
+
secret_key_base: 6e9bd798728b20da17b3f222b00e2824a73c4b33f73e04e5a7d8835ecc3c0bbd10dada7b60b0779ca0644c7f6420c78009d7460e41348449157aeaeee774c864
|
15
15
|
|
16
16
|
test:
|
17
|
-
secret_key_base:
|
17
|
+
secret_key_base: f3a2e8ea6252bdc4b022ad54c56a2ab165c079bf2d456396d369ad101fef16328bd8f33dba7e4b7c440590b000cc00251dc79eac2c456247b0b1a6994117a650
|
18
18
|
|
19
19
|
# Do not keep production secrets in the repository,
|
20
20
|
# instead read values from the environment.
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20150429164556) do
|
15
15
|
|
16
16
|
# These are extensions that must be enabled in order to support this database
|
17
17
|
enable_extension "plpgsql"
|