Skip to content

Commit 43ab048

Browse files
committed
Merge branch 'develop'
2 parents a74823d + 77fb351 commit 43ab048

15 files changed

+234
-162
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%label.mdl-checkbox.mdl-js-checkbox.mdl-js-ripple-effect{ for: @options[:node]["id"] }
2-
= context[:form].check_box "data[values][#{@options[:node]['id']}]", { checked: value, class: 'mdl-checkbox__input', id: @options[:node]["id"] }, 1, nil
3-
= context[:form].label :data, display_lineage, class: 'mdl-checkbox__label'
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'
44

55
- if @options[:node]["children"].any?
66
- @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)
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Plugins
2+
module Core
3+
class ContentItemCell < Plugins::Core::Cell
4+
def popup
5+
render
6+
end
7+
8+
private
9+
10+
def render_label
11+
"Add #{field.name}"
12+
end
13+
end
14+
end
15+
end
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.mdl-textfield.mdl-js-textfield.mdl-textfield--floating-label
2+
= render_field_id
3+
= render_label
4+
= render_input
5+

app/cells/plugins/core/float_cell.rb

+47
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.mdl-textfield.mdl-js-textfield
2+
= render_field_id
3+
= render_label
4+
= render_input
5+
+43
Original file line numberDiff line numberDiff line change
@@ -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

app/cells/plugins/core/text_cell.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def input_classes
2626
def input_styles
2727
input_display&.[](:styles)
2828
end
29-
29+
3030
def value
3131
data&.[]('text') || @options[:default_value]
3232
end
+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
%h4
22
= render_label
33

4+
%p
5+
Please select 1-2 Categories.
6+
47
- @options[:metadata]["data"]["tree_array"].each do |node|
58
= 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)

app/models/asset_field_type.rb.orig

-154
This file was deleted.

app/models/content_item_field_type.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class ContentItemFieldType < FieldType
2+
def mapping
3+
{ name: mapping_field_name, type: :string, analyzer: :snowball }
4+
end
5+
6+
private
7+
8+
def mapping_field_name
9+
"#{field_name.parameterize('_')}_content_item"
10+
end
11+
end

app/models/float_field_type.rb

+40
Original file line numberDiff line numberDiff line change
@@ -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 commit comments

Comments
 (0)