Skip to content

Commit c094414

Browse files
committed
Merge branch 'develop'
2 parents 2332aab + 0ed8a3d commit c094414

32 files changed

+270
-782
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ gem 'rails', '~> 4.2.6'
1212

1313
# Cortex-specific
1414
gem 'cortex-exceptions', '~> 0.0.4'
15+
gem 'cortex-field_types-core', '~> 0.1.1'
1516

1617
# API
1718
gem 'grape', '~> 0.16'
@@ -42,7 +43,7 @@ gem 'pg', '~> 0.18.4'
4243
gem 'hashie-forbidden_attributes', '~> 0.1.1'
4344
gem 'ranked-model', '~> 0.4.0'
4445
gem 'redis-rails', '~> 4.0'
45-
gem 'pomona', '~> 0.6.0'
46+
gem 'pomona', '~> 0.7'
4647

4748
# Middleware
4849
gem 'rack-cors', '~> 0.4.0', require: 'rack/cors'

Gemfile.lock

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ GEM
142142
concurrent-ruby (1.0.2)
143143
connection_pool (2.2.0)
144144
cortex-exceptions (0.0.4)
145+
cortex-field_types-core (0.1.1)
146+
cells (~> 4.1)
147+
cells-haml (~> 0.0.10)
148+
cells-rails (~> 0.0.6)
149+
rails (~> 4.2.6)
145150
database_cleaner (1.5.3)
146151
debug_inspector (0.0.2)
147152
descendants_tracker (0.0.4)
@@ -511,7 +516,7 @@ GEM
511516
cliver (~> 0.3.1)
512517
multi_json (~> 1.0)
513518
websocket-driver (>= 0.2.0)
514-
pomona (0.6.0)
519+
pomona (0.7.0)
515520
progress (3.1.1)
516521
pry (0.10.3)
517522
coderay (~> 1.1.0)
@@ -739,6 +744,7 @@ DEPENDENCIES
739744
cells-rails (~> 0.0.6)
740745
codeclimate-test-reporter (~> 0.4.8)
741746
cortex-exceptions (~> 0.0.4)
747+
cortex-field_types-core (~> 0.1.1)
742748
database_cleaner (~> 1.5.1)
743749
devise (~> 4.1.1)
744750
doorkeeper (~> 3.1)
@@ -786,7 +792,7 @@ DEPENDENCIES
786792
pg (~> 0.18.4)
787793
phantomjs (~> 1.9.8)
788794
poltergeist
789-
pomona (~> 0.6.0)
795+
pomona (~> 0.7)
790796
pry-doc
791797
pry-nav
792798
pry-rails
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
class FieldCell < Cell::ViewModel
2-
self.view_paths << 'lib'
3-
1+
class FieldTypeCell < Cell::ViewModel
42
property :field
53
property :data
64

app/cells/wizard/field/show.haml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
= context[:form].fields_for 'field_items', field_item do |field_item_form|
2-
- if field_item.field.field_type == "text_field_type"
3-
= cell('cortex/field_types/core/text/text', field_item, form: field_item_form, default_value: '').(:input)
4-
- if field_item.field.field_type == "boolean_field_type"
5-
= cell('cortex/field_types/core/boolean/boolean', field_item, form: field_item_form, field_name: field_item.field.name, default_value: false).(:checkbox)
6-
- if field_item.field.field_type == "tree_field_type"
7-
= # cell('cortex/field_types/core/tree/tree', FieldItem.new(field: field), form: field_item_form, index: index).(:tree)
8-
- if field_item.field.field_type == "date_time_field_type"
9-
= cell('cortex/field_types/core/date_time/date_time', field_item, form: field_item_form, default_value: '').(:datepicker)
10-
- if field_item.field.field_type == "tag_field_type"
11-
= cell('cortex/field_types/core/tag/tag', field_item, form: field_item_form, default_value: []).(:tag_picker)
12-
- if field_item.field.field_type == "user_field_type"
13-
= cell('cortex/field_types/core/user/user', field_item, form: field_item_form, default_value: User.all.first.id, user_data: User.all).(:dropdown)
2+
- if field_item.field.field_type_instance.class == TextFieldType
3+
= cell(FieldTypes::Core::TextCell, field_item, form: field_item_form).(:input)
4+
- if field_item.field.field_type_instance.class == BooleanFieldType
5+
= cell(FieldTypes::Core::BooleanCell, field_item, form: field_item_form, field_name: field_item.field.name, default_value: false).(:checkbox)
6+
- if field_item.field.field_type_instance.class == TreeFieldType
7+
= cell(FieldTypes::Core::TreeCell, field_item, form: field_item_form, metadata: field_item.field.metadata["allowed_values"], field: field).(display_format)
8+
- if field_item.field.field_type_instance.class == DateTimeFieldType
9+
= cell(FieldTypes::Core::DateTimeCell, field_item, form: field_item_form, default_value: '').(:datepicker)
10+
- if field_item.field.field_type_instance.class == TagFieldType
11+
= cell(FieldTypes::Core::TagCell, field_item, form: field_item_form, default_value: []).(:tag_picker)
12+
- if field_item.field.field_type_instance.class == UserFieldType
13+
= cell(FieldTypes::Core::UserCell, field_item, form: field_item_form, default_value: User.all.first.id, user_data: User.all).(:dropdown)

app/cells/wizard/field_cell.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class FieldCell < Cell::ViewModel
33
property :id
44
property :label
55
property :input
6+
property :display_format
67

78
def show
89
render

app/helpers/content_item_helper.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def field_items_attributes_params
1717
end
1818

1919
permitted_keys = {}
20-
field_items_attributes_as_array.each {|hash| hash.each_key {|key| permitted_keys [key.to_s] = [] } }
20+
field_items_attributes_as_array.each { |hash| hash.each_key { |key| permitted_keys[key.to_s] = [] } }
2121

2222
permit_attribute_params(field_items_attributes_as_array, permitted_keys)
2323
end
@@ -26,21 +26,29 @@ def permit_attribute_params(param_array, permitted_keys)
2626
param_array.each do |param_hash|
2727
permitted_keys.keys.each do |key|
2828
if param_hash[key].is_a?(Hash)
29-
permitted_keys[key] << param_hash[key].keys
29+
permitted_keys[key] << permit_param(param_hash[key])
3030
end
3131
permitted_keys[key].flatten!
3232
end
3333
end
34-
34+
3535
sanitize_parameters(permitted_keys)
3636
end
3737

38+
def permit_param(param)
39+
if param.values[0].is_a?(Hash)
40+
{ param.keys[0].to_sym => param.values[0].keys }
41+
else
42+
param.keys[0]
43+
end
44+
end
45+
3846
def sanitize_parameters(permitted_keys)
3947
permitted_keys.map do |key, value|
4048
if value.empty?
4149
key
4250
else
43-
{ key => value }
51+
{ key => value.uniq }
4452
end
4553
end
4654
end

app/models/category_tree.rb

Lines changed: 0 additions & 36 deletions
This file was deleted.

app/models/content_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def self.permissions
2525

2626
def content_items_index_name
2727
content_type_name_sanitized = name.parameterize('_')
28-
"#{Rails.env}_content_type_#{content_type_name_sanitized}_content_items"
28+
"#{Rails.env}_content_type_#{content_type_name_sanitized}_#{id}_content_items"
2929
end
3030

3131
def wizard_decorator

app/models/media.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Media < ActiveRecord::Base
3333
:micro => {geometry: '50x50>', format: :jpg},
3434
:ar_post => {geometry: '1140x', format: :jpg}
3535
},
36-
:processors => [:thumbnail, :paperclip_optimizer],
36+
:processors => [:thumbnail],
3737
:preserve_files => 'true',
3838
# :path => ':class/:attachment/:style-:id.:extension'
3939
:path => ':class/:attachment/careerbuilder-:style-:id.:extension',

0 commit comments

Comments
 (0)