cortex-plugins-core 0.4.6 → 0.4.7
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/app/cells/plugins/core/checkbox/checkbox.haml +3 -3
- data/app/cells/plugins/core/content_item/popup.haml +13 -0
- data/app/cells/plugins/core/content_item_cell.rb +15 -0
- data/app/cells/plugins/core/float/input.haml +5 -0
- data/app/cells/plugins/core/float_cell.rb +47 -0
- data/app/cells/plugins/core/integer/input.haml +5 -0
- data/app/cells/plugins/core/integer_cell.rb +43 -0
- data/app/cells/plugins/core/text_cell.rb +1 -1
- data/app/cells/plugins/core/tree/checkboxes.haml +4 -1
- data/app/models/content_item_field_type.rb +11 -0
- data/app/models/float_field_type.rb +40 -0
- data/app/models/integer_field_type.rb +40 -0
- data/app/models/tree_field_type.rb +6 -2
- data/lib/cortex/plugins/core/version.rb +1 -1
- metadata +12 -4
- data/app/models/asset_field_type.rb.orig +0 -154
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ab0c34b932761efc4ebd2026af72662f94922c2
|
4
|
+
data.tar.gz: e6d838af5da99b6747a8a892623d724a848e4e21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67587d700272125c526c62fd6449099e6ecf031143750d966cf920cfe60f681e49c3e5fe3bc11da511a5d3a5466e0b40c45afc523565a5f23fa22e066a6199ef
|
7
|
+
data.tar.gz: 817f9b3353b1437faad67083447209e2c1aff059c08196ca5b08e833208d528cf35f609835feee3c3c4ac3d351bb6d197776be0bb7fc9affe7adc20aa6d36358
|
@@ -1,7 +1,7 @@
|
|
1
1
|
%label.mdl-checkbox.mdl-js-checkbox.mdl-js-ripple-effect{ for: @options[:node]["id"] }
|
2
|
-
=
|
3
|
-
=
|
2
|
+
= @options[:form].check_box "data[values][#{@options[:node]['id']}]", { checked: value, class: 'mdl-checkbox__input', id: @options[:node]["id"] }, 1, nil
|
3
|
+
= @options[:form].label :data, display_lineage, class: 'mdl-checkbox__label'
|
4
4
|
|
5
5
|
- if @options[:node]["children"].any?
|
6
6
|
- @options[:node]["children"].each do |child|
|
7
|
-
= cell(Plugins::Core::CheckboxCell, nil, node: child, child: child_identifier, data: @options[:data]).(:checkbox)
|
7
|
+
= cell(Plugins::Core::CheckboxCell, nil, form: @options[:form], node: child, child: child_identifier, data: @options[:data]).(:checkbox)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
= render_label
|
2
|
+
%br
|
3
|
+
%button.content_item_button.text-center.popup--open
|
4
|
+
.button_content
|
5
|
+
%i{ class: "material-icons icon" }
|
6
|
+
cloud_upload
|
7
|
+
%br
|
8
|
+
%span.content_item_button-text
|
9
|
+
Click to add a
|
10
|
+
= field.name
|
11
|
+
from the media library
|
12
|
+
%small
|
13
|
+
Recommended size: 1452px x 530px with a live area of 930px x 530px
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Plugins
|
2
|
+
module Core
|
3
|
+
class FloatCell < Plugins::Core::Cell
|
4
|
+
def input
|
5
|
+
render
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def max
|
11
|
+
field.validations[:max]
|
12
|
+
end
|
13
|
+
|
14
|
+
def min
|
15
|
+
field.validations[:min]
|
16
|
+
end
|
17
|
+
|
18
|
+
def step
|
19
|
+
field.validations[:step] || 0.01
|
20
|
+
end
|
21
|
+
|
22
|
+
def input_display
|
23
|
+
@options[:input_options]&.[](:display)
|
24
|
+
end
|
25
|
+
|
26
|
+
def input_classes
|
27
|
+
input_display&.[](:classes)
|
28
|
+
end
|
29
|
+
|
30
|
+
def input_styles
|
31
|
+
input_display&.[](:styles)
|
32
|
+
end
|
33
|
+
|
34
|
+
def value
|
35
|
+
data&.[]('float') || @options[:default_value]
|
36
|
+
end
|
37
|
+
|
38
|
+
def render_label
|
39
|
+
@options[:form].label 'data[float]', field.name, class: 'mdl-textfield__label'
|
40
|
+
end
|
41
|
+
|
42
|
+
def render_input
|
43
|
+
@options[:form].number_field 'data[float]', value: value, placeholder: @options[:placeholder], step: step, max: max, min: min , class: 'mdl-textfield__input'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Plugins
|
2
|
+
module Core
|
3
|
+
class IntegerCell < Plugins::Core::Cell
|
4
|
+
def input
|
5
|
+
render
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def max
|
11
|
+
field.validations[:max]
|
12
|
+
end
|
13
|
+
|
14
|
+
def min
|
15
|
+
field.validations[:min]
|
16
|
+
end
|
17
|
+
|
18
|
+
def input_display
|
19
|
+
@options[:input_options]&.[](:display)
|
20
|
+
end
|
21
|
+
|
22
|
+
def input_classes
|
23
|
+
input_display&.[](:classes)
|
24
|
+
end
|
25
|
+
|
26
|
+
def input_styles
|
27
|
+
input_display&.[](:styles)
|
28
|
+
end
|
29
|
+
|
30
|
+
def value
|
31
|
+
data&.[]('integer') || @options[:default_value]
|
32
|
+
end
|
33
|
+
|
34
|
+
def render_label
|
35
|
+
@options[:form].label 'data[integer]', field.name, class: 'mdl-textfield__label'
|
36
|
+
end
|
37
|
+
|
38
|
+
def render_input
|
39
|
+
@options[:form].number_field 'data[integer]', value: value, placeholder: @options[:placeholder] , max: max, min: min, class: 'mdl-textfield__input'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
%h4
|
2
2
|
= render_label
|
3
3
|
|
4
|
+
%p
|
5
|
+
Please select 1-2 Categories.
|
6
|
+
|
4
7
|
- @options[:metadata]["data"]["tree_array"].each do |node|
|
5
8
|
= render_field_id
|
6
|
-
= cell(Plugins::Core::CheckboxCell, nil, node: node, data: data).(:checkbox)
|
9
|
+
= cell(Plugins::Core::CheckboxCell, nil, form: @options[:form], node: node, data: data).(:checkbox)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class FloatFieldType < FieldType
|
2
|
+
attr_accessor :float
|
3
|
+
|
4
|
+
validates :float, presence: true, if: Proc.new { |float| validate_key(:presence) }
|
5
|
+
validates_numericality_of :float, unless: "float.nil?"
|
6
|
+
validate :less_than, if: Proc.new { |float| validate_key(:max) }
|
7
|
+
validate :greater_than, if: Proc.new { |float| validate_key(:min) }
|
8
|
+
|
9
|
+
def data=(data_hash)
|
10
|
+
@float = data_hash.deep_symbolize_keys[:float]
|
11
|
+
end
|
12
|
+
|
13
|
+
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
14
|
+
json = {}
|
15
|
+
json[mapping_field_name] = field_item.data['float']
|
16
|
+
json
|
17
|
+
end
|
18
|
+
|
19
|
+
def mapping
|
20
|
+
{name: mapping_field_name, type: :float}
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def mapping_field_name
|
26
|
+
"#{field_name.parameterize('_')}_float"
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_key(key)
|
30
|
+
@validations.key? key
|
31
|
+
end
|
32
|
+
|
33
|
+
def less_than
|
34
|
+
errors.add(:float, "must be less_than #{@validations[:max]}") if :float <= @validations[:max]
|
35
|
+
end
|
36
|
+
|
37
|
+
def greater_than
|
38
|
+
errors.add(:float, "must be greater_than #{@validations[:min]}") if :float >= @validations[:min]
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class IntegerFieldType < FieldType
|
2
|
+
attr_accessor :integer
|
3
|
+
|
4
|
+
validates :integer, presence: true, if: Proc.new { |int| validate_key(:presence) }
|
5
|
+
validates_numericality_of :integer, unless: "integer.nil?"
|
6
|
+
validate :less_than, if: Proc.new { |int| validate_key(:max) }
|
7
|
+
validate :greater_than, if: Proc.new { |int| validate_key(:min) }
|
8
|
+
|
9
|
+
def data=(data_hash)
|
10
|
+
@integer = data_hash.deep_symbolize_keys[:integer]
|
11
|
+
end
|
12
|
+
|
13
|
+
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
14
|
+
json = {}
|
15
|
+
json[mapping_field_name] = field_item.data['integer']
|
16
|
+
json
|
17
|
+
end
|
18
|
+
|
19
|
+
def mapping
|
20
|
+
{name: mapping_field_name, type: :integer}
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def mapping_field_name
|
26
|
+
"#{field_name.parameterize('_')}_integer"
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_key
|
30
|
+
@validations.key? key
|
31
|
+
end
|
32
|
+
|
33
|
+
def less_than
|
34
|
+
errors.add(:integer, "must be less_than #{@validations[:max]}") if :integer <= @validations[:max]
|
35
|
+
end
|
36
|
+
|
37
|
+
def greater_than
|
38
|
+
errors.add(:integer, "must be greater_than #{@validations[:min]}") if :integer >= @validations[:min]
|
39
|
+
end
|
40
|
+
end
|
@@ -5,13 +5,17 @@ class TreeFieldType < FieldType
|
|
5
5
|
validate :minimum, if: :validate_minimum?
|
6
6
|
validate :maximum, if: :validate_maximum?
|
7
7
|
|
8
|
+
def data
|
9
|
+
@values
|
10
|
+
end
|
11
|
+
|
8
12
|
def data=(data_hash)
|
9
13
|
values = data_hash.deep_symbolize_keys[:values]
|
10
14
|
|
11
15
|
if values.is_a?(Hash)
|
12
|
-
@values = values.keys
|
16
|
+
@values = { values: values.keys }
|
13
17
|
else
|
14
|
-
@values = [values]
|
18
|
+
@values = { values: [values] }
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cortex-plugins-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CareerBuilder Employer Site & Content Products
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -130,8 +130,14 @@ files:
|
|
130
130
|
- app/cells/plugins/core/cell.rb
|
131
131
|
- app/cells/plugins/core/checkbox/checkbox.haml
|
132
132
|
- app/cells/plugins/core/checkbox_cell.rb
|
133
|
+
- app/cells/plugins/core/content_item/popup.haml
|
134
|
+
- app/cells/plugins/core/content_item_cell.rb
|
133
135
|
- app/cells/plugins/core/date_time/datepicker.haml
|
134
136
|
- app/cells/plugins/core/date_time_cell.rb
|
137
|
+
- app/cells/plugins/core/float/input.haml
|
138
|
+
- app/cells/plugins/core/float_cell.rb
|
139
|
+
- app/cells/plugins/core/integer/input.haml
|
140
|
+
- app/cells/plugins/core/integer_cell.rb
|
135
141
|
- app/cells/plugins/core/tag/tag_picker.haml
|
136
142
|
- app/cells/plugins/core/tag_cell.rb
|
137
143
|
- app/cells/plugins/core/text/input.haml
|
@@ -144,9 +150,11 @@ files:
|
|
144
150
|
- app/cells/plugins/core/user/dropdown.haml
|
145
151
|
- app/cells/plugins/core/user_cell.rb
|
146
152
|
- app/models/asset_field_type.rb
|
147
|
-
- app/models/asset_field_type.rb.orig
|
148
153
|
- app/models/boolean_field_type.rb
|
154
|
+
- app/models/content_item_field_type.rb
|
149
155
|
- app/models/date_time_field_type.rb
|
156
|
+
- app/models/float_field_type.rb
|
157
|
+
- app/models/integer_field_type.rb
|
150
158
|
- app/models/tag_field_type.rb
|
151
159
|
- app/models/text_field_type.rb
|
152
160
|
- app/models/tree_field_type.rb
|
@@ -176,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
184
|
version: '0'
|
177
185
|
requirements: []
|
178
186
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.5.
|
187
|
+
rubygems_version: 2.5.2
|
180
188
|
signing_key:
|
181
189
|
specification_version: 4
|
182
190
|
summary: The combined set of Core FieldTypes for the Cortex CMS platform
|
@@ -1,154 +0,0 @@
|
|
1
|
-
class AssetFieldType < FieldType
|
2
|
-
attr_accessor :asset_file_name,
|
3
|
-
:asset_content_type,
|
4
|
-
:asset_file_size,
|
5
|
-
:asset_updated_at,
|
6
|
-
:asset
|
7
|
-
|
8
|
-
attr_reader :dimensions,
|
9
|
-
:existing_data
|
10
|
-
|
11
|
-
before_save :extract_dimensions
|
12
|
-
|
13
|
-
do_not_validate_attachment_file_type :asset
|
14
|
-
validates :asset, attachment_presence: true, if: :validate_presence?
|
15
|
-
validate :validate_asset_size, if: :validate_size?
|
16
|
-
validate :validate_asset_content_type, if: :validate_content_type?
|
17
|
-
|
18
|
-
def metadata=(metadata_hash)
|
19
|
-
@metadata = metadata_hash.deep_symbolize_keys
|
20
|
-
@existing_data = metadata_hash[:existing_data]
|
21
|
-
Paperclip::HasAttachedFile.define_on(self.class, :asset, existing_metadata)
|
22
|
-
end
|
23
|
-
|
24
|
-
def data=(data_hash)
|
25
|
-
self.asset = data_hash.deep_symbolize_keys[:asset]
|
26
|
-
end
|
27
|
-
|
28
|
-
def data
|
29
|
-
{
|
30
|
-
<<<<<<< HEAD
|
31
|
-
'asset': {
|
32
|
-
'file_name': asset_file_name,
|
33
|
-
'url': asset.url,
|
34
|
-
'dimensions': dimensions,
|
35
|
-
'content_type': asset_content_type,
|
36
|
-
'file_size': asset_file_size,
|
37
|
-
'updated_at': asset_updated_at
|
38
|
-
},
|
39
|
-
'asset_field_type_id': id
|
40
|
-
=======
|
41
|
-
'asset': {
|
42
|
-
'file_name': asset_file_name,
|
43
|
-
'url': asset.url,
|
44
|
-
'style_urls': style_urls,
|
45
|
-
'dimensions': dimensions,
|
46
|
-
'content_type': asset_content_type,
|
47
|
-
'file_size': asset_file_size,
|
48
|
-
'updated_at': asset_updated_at
|
49
|
-
}
|
50
|
-
>>>>>>> Implement storage of thumbnail/style URLs, asset wizard info box, and asset thumbnail in index
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
55
|
-
json = {}
|
56
|
-
json[mapping_field_name] = asset_file_name
|
57
|
-
json
|
58
|
-
end
|
59
|
-
|
60
|
-
def mapping
|
61
|
-
{name: mapping_field_name, type: :string, analyzer: :keyword}
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def image?
|
67
|
-
asset_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png)$}
|
68
|
-
end
|
69
|
-
|
70
|
-
def extract_dimensions
|
71
|
-
return unless image?
|
72
|
-
tempfile = asset.queued_for_write[:original]
|
73
|
-
unless tempfile.nil?
|
74
|
-
geometry = Paperclip::Geometry.from_file(tempfile)
|
75
|
-
@dimensions = {
|
76
|
-
width: geometry.width.to_i,
|
77
|
-
height: geometry.height.to_i
|
78
|
-
}
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def allowed_content_types
|
83
|
-
validations[:allowed_extensions].collect do |allowed_content_type|
|
84
|
-
MimeMagic.by_extension(allowed_content_type).type
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def mapping_field_name
|
89
|
-
"#{field_name.parameterize('_')}_asset_file_name"
|
90
|
-
end
|
91
|
-
|
92
|
-
def validate_presence?
|
93
|
-
validations.key? :presence
|
94
|
-
end
|
95
|
-
|
96
|
-
def attachment_size_validator
|
97
|
-
AttachmentSizeValidator.new(validations[:size].merge(attributes: :asset))
|
98
|
-
end
|
99
|
-
|
100
|
-
def attachment_content_type_validator
|
101
|
-
AttachmentContentTypeValidator.new({content_type: allowed_content_types}.merge(attributes: :asset))
|
102
|
-
end
|
103
|
-
|
104
|
-
alias_method :valid_presence_validation?, :validate_presence?
|
105
|
-
|
106
|
-
def validate_size?
|
107
|
-
begin
|
108
|
-
attachment_size_validator
|
109
|
-
true
|
110
|
-
rescue ArgumentError, NoMethodError
|
111
|
-
false
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def validate_content_type?
|
116
|
-
begin
|
117
|
-
attachment_content_type_validator
|
118
|
-
true
|
119
|
-
rescue ArgumentError, NoMethodError
|
120
|
-
false
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def validate_asset_size
|
125
|
-
attachment_size_validator.validate_each(self, :asset, asset)
|
126
|
-
end
|
127
|
-
|
128
|
-
def validate_asset_content_type
|
129
|
-
attachment_content_type_validator.validate_each(self, :asset, asset)
|
130
|
-
end
|
131
|
-
|
132
|
-
def style_urls
|
133
|
-
if existing_data.empty?
|
134
|
-
(metadata[:styles].map { |key, value| [key, asset.url(key)] }).to_h
|
135
|
-
else
|
136
|
-
existing_data[:asset][:style_urls]
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def existing_metadata
|
141
|
-
metadata.except!(:existing_data)
|
142
|
-
|
143
|
-
<<<<<<< HEAD
|
144
|
-
unless @existing_data.empty?
|
145
|
-
metadata[:path].gsub(":id", @existing_data['asset_field_type_id']) if metadata[:path]
|
146
|
-
=======
|
147
|
-
unless existing_data.empty?
|
148
|
-
metadata[:path] = updated_url(existing_data['asset']['url'])
|
149
|
-
>>>>>>> Implement storage of thumbnail/style URLs, asset wizard info box, and asset thumbnail in index
|
150
|
-
end
|
151
|
-
|
152
|
-
metadata
|
153
|
-
end
|
154
|
-
end
|