Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
toastercup committed Dec 16, 2016
2 parents a74823d + 77fb351 commit 43ab048
Show file tree
Hide file tree
Showing 15 changed files with 234 additions and 162 deletions.
6 changes: 3 additions & 3 deletions app/cells/plugins/core/checkbox/checkbox.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%label.mdl-checkbox.mdl-js-checkbox.mdl-js-ripple-effect{ for: @options[:node]["id"] }
= context[:form].check_box "data[values][#{@options[:node]['id']}]", { checked: value, class: 'mdl-checkbox__input', id: @options[:node]["id"] }, 1, nil
= context[:form].label :data, display_lineage, class: 'mdl-checkbox__label'
= @options[:form].check_box "data[values][#{@options[:node]['id']}]", { checked: value, class: 'mdl-checkbox__input', id: @options[:node]["id"] }, 1, nil
= @options[:form].label :data, display_lineage, class: 'mdl-checkbox__label'

- if @options[:node]["children"].any?
- @options[:node]["children"].each do |child|
= cell(Plugins::Core::CheckboxCell, nil, node: child, child: child_identifier, data: @options[:data]).(:checkbox)
= cell(Plugins::Core::CheckboxCell, nil, form: @options[:form], node: child, child: child_identifier, data: @options[:data]).(:checkbox)
13 changes: 13 additions & 0 deletions app/cells/plugins/core/content_item/popup.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
= render_label
%br
%button.content_item_button.text-center.popup--open
.button_content
%i{ class: "material-icons icon" }
cloud_upload
%br
%span.content_item_button-text
Click to add a
= field.name
from the media library
%small
Recommended size: 1452px x 530px with a live area of 930px x 530px
15 changes: 15 additions & 0 deletions app/cells/plugins/core/content_item_cell.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Plugins
module Core
class ContentItemCell < Plugins::Core::Cell
def popup
render
end

private

def render_label
"Add #{field.name}"
end
end
end
end
5 changes: 5 additions & 0 deletions app/cells/plugins/core/float/input.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.mdl-textfield.mdl-js-textfield.mdl-textfield--floating-label
= render_field_id
= render_label
= render_input

47 changes: 47 additions & 0 deletions app/cells/plugins/core/float_cell.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module Plugins
module Core
class FloatCell < Plugins::Core::Cell
def input
render
end

private

def max
field.validations[:max]
end

def min
field.validations[:min]
end

def step
field.validations[:step] || 0.01
end

def input_display
@options[:input_options]&.[](:display)
end

def input_classes
input_display&.[](:classes)
end

def input_styles
input_display&.[](:styles)
end

def value
data&.[]('float') || @options[:default_value]
end

def render_label
@options[:form].label 'data[float]', field.name, class: 'mdl-textfield__label'
end

def render_input
@options[:form].number_field 'data[float]', value: value, placeholder: @options[:placeholder], step: step, max: max, min: min , class: 'mdl-textfield__input'
end
end
end
end
5 changes: 5 additions & 0 deletions app/cells/plugins/core/integer/input.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.mdl-textfield.mdl-js-textfield
= render_field_id
= render_label
= render_input

43 changes: 43 additions & 0 deletions app/cells/plugins/core/integer_cell.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module Plugins
module Core
class IntegerCell < Plugins::Core::Cell
def input
render
end

private

def max
field.validations[:max]
end

def min
field.validations[:min]
end

def input_display
@options[:input_options]&.[](:display)
end

def input_classes
input_display&.[](:classes)
end

def input_styles
input_display&.[](:styles)
end

def value
data&.[]('integer') || @options[:default_value]
end

def render_label
@options[:form].label 'data[integer]', field.name, class: 'mdl-textfield__label'
end

def render_input
@options[:form].number_field 'data[integer]', value: value, placeholder: @options[:placeholder] , max: max, min: min, class: 'mdl-textfield__input'
end
end
end
end
2 changes: 1 addition & 1 deletion app/cells/plugins/core/text_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def input_classes
def input_styles
input_display&.[](:styles)
end

def value
data&.[]('text') || @options[:default_value]
end
Expand Down
5 changes: 4 additions & 1 deletion app/cells/plugins/core/tree/checkboxes.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
%h4
= render_label

%p
Please select 1-2 Categories.

- @options[:metadata]["data"]["tree_array"].each do |node|
= render_field_id
= cell(Plugins::Core::CheckboxCell, nil, node: node, data: data).(:checkbox)
= cell(Plugins::Core::CheckboxCell, nil, form: @options[:form], node: node, data: data).(:checkbox)
154 changes: 0 additions & 154 deletions app/models/asset_field_type.rb.orig

This file was deleted.

11 changes: 11 additions & 0 deletions app/models/content_item_field_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ContentItemFieldType < FieldType
def mapping
{ name: mapping_field_name, type: :string, analyzer: :snowball }
end

private

def mapping_field_name
"#{field_name.parameterize('_')}_content_item"
end
end
40 changes: 40 additions & 0 deletions app/models/float_field_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class FloatFieldType < FieldType
attr_accessor :float

validates :float, presence: true, if: Proc.new { |float| validate_key(:presence) }
validates_numericality_of :float, unless: "float.nil?"
validate :less_than, if: Proc.new { |float| validate_key(:max) }
validate :greater_than, if: Proc.new { |float| validate_key(:min) }

def data=(data_hash)
@float = data_hash.deep_symbolize_keys[:float]
end

def field_item_as_indexed_json_for_field_type(field_item, options = {})
json = {}
json[mapping_field_name] = field_item.data['float']
json
end

def mapping
{name: mapping_field_name, type: :float}
end

private

def mapping_field_name
"#{field_name.parameterize('_')}_float"
end

def validate_key(key)
@validations.key? key
end

def less_than
errors.add(:float, "must be less_than #{@validations[:max]}") if :float <= @validations[:max]
end

def greater_than
errors.add(:float, "must be greater_than #{@validations[:min]}") if :float >= @validations[:min]
end
end
Loading

0 comments on commit 43ab048

Please sign in to comment.