cortex-plugins-core 0.5.0 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b88d7586b26e56ce255dafceb0124d01e9cf27c
4
- data.tar.gz: 484b60478cfe4ce36b165d1513d8183affdcc5d3
3
+ metadata.gz: c977c3cd46774c8925c6214a86cb85f99ff8a29c
4
+ data.tar.gz: 84bbd9bd60aeae0bc11564589e6942e3b6f6516b
5
5
  SHA512:
6
- metadata.gz: f3d3fefcc3428c74fbfe3b4b5271bca209a74cf0044c802e05260b8807f49f568c755c69e43b5597b2379160e54a61f77213028f1bb3c204763dadbfc2020fbf
7
- data.tar.gz: d7a6a2894175c3195ea084a30d8f3cd4a380bf843fdad13352fa105aa939fbeb410bbba6556fea65557f6e47db96a2e6d35bf1e4b0b1f9a4521891a2963030e0
6
+ metadata.gz: 283db210452b4fbc6a6aac293ff267a34b20b0aa159955ac11ff6ca8c4cde7f8486a569c43b52f7e959f0f26effff3b4a55c9185921df15caf73081b8bd9fbc1
7
+ data.tar.gz: 8697b6460170cc789f21a74507f137db9a9eff1a869b4749283800daac2ef0124e4150dfd6e5913377a49fb742b0b1e8e2aa5bd3207690a2234445a8e05711e3
@@ -1,4 +1,4 @@
1
- (function (global) {
1
+ (function (global) {
2
2
  'use strict';
3
3
 
4
4
  global.CKEDITOR.plugins.add('cortex_media_insert', {
@@ -6,14 +6,14 @@
6
6
  init: function (editor) {
7
7
  editor.addCommand('insertMedia', {
8
8
  exec: function (editor) {
9
- window.MODALS.featured.open();
9
+ window.MODALS.wysiwyg.open();
10
10
 
11
11
  global.media_select = {};
12
12
  global.media_select_defer = $.Deferred();
13
13
  global.media_select_defer.promise(global.media_select);
14
14
 
15
15
  global.media_select.done(function (media) {
16
- window.MODALS.featured.close();
16
+ window.MODALS.wysiwyg.close();
17
17
 
18
18
  var mediaTag = editor.document.createElement('media');
19
19
  mediaTag.setAttribute('id', media.id);
@@ -1,2 +1,4 @@
1
1
  //= require ckeditor/init
2
2
  //= require ../ckeditor/config
3
+
4
+ //= require_tree ./cells
@@ -0,0 +1,19 @@
1
+ $('.media-select--featured').click(function (elem) {
2
+ var id = $(this).data().id;
3
+ var title = $(this).data().title;
4
+ var thumb_url = $(this).data().thumb;
5
+
6
+ $(".association_content_item_id").val(id);
7
+
8
+ $('.content-item-button__selection').remove();
9
+ $('.content-item-button').append(
10
+ '<div class="content-item-button__selection">' +
11
+ '<img src="' + thumb_url + '" height="50px">' +
12
+ '<div class="content-item-button__selection__text">' +
13
+ 'Selected Media: ' +
14
+ title +
15
+ '</div></div>'
16
+ );
17
+
18
+ window.MODALS.featured.close();
19
+ });
@@ -0,0 +1,4 @@
1
+ = render_associated_content_item_thumb
2
+ .content-item-button__selection__text
3
+ Selected Media:
4
+ = associated_content_item_title
@@ -3,11 +3,16 @@ module Plugins
3
3
  class AssetCell < Plugins::Core::Cell
4
4
  include ActionView::Helpers::NumberHelper
5
5
  include UtilityHelper
6
+ include Cells::AssociationHelper
6
7
 
7
8
  def input
8
9
  render
9
10
  end
10
11
 
12
+ def association
13
+ render
14
+ end
15
+
11
16
  private
12
17
 
13
18
  def render_allowed_asset_extensions
@@ -33,6 +38,14 @@ module Plugins
33
38
  def render_input
34
39
  @options[:form].file_field 'data[asset]'
35
40
  end
41
+
42
+ def associated_content_item_thumb_url
43
+ data['asset']['style_urls']['mini']
44
+ end
45
+
46
+ def render_associated_content_item_thumb
47
+ image_tag(associated_content_item_thumb_url, height: '50px')
48
+ end
36
49
  end
37
50
  end
38
51
  end
@@ -41,7 +41,7 @@ module Plugins
41
41
  end
42
42
 
43
43
  def link_to_asset
44
- link_to(asset['url'], asset['url'])
44
+ link_to asset['url'], asset['url'], target: '_blank'
45
45
  end
46
46
  end
47
47
  end
@@ -1,13 +1,19 @@
1
+ = render_field_id
2
+ = render_content_item_id
3
+
1
4
  = render_label
2
5
  %br
3
- %button.content_item_button.text-center.popup--open
4
- .button_content
6
+ %button.content-item-button.popup--open
7
+ .content-item-button__select.content-item-button__select--selected
5
8
  %i{ class: "material-icons icon" }
6
9
  cloud_upload
7
10
  %br
8
- %span.content_item_button-text
9
- Click to add a
11
+ %span.content-item-button__select__text
12
+ Click to select a
10
13
  = field.name
11
- from the media library
14
+ from the Media library
15
+ - if associated_content_item && associated_primary_field_type_class == AssetFieldType
16
+ .content-item-button__selection
17
+ = render_association_cell
12
18
  %small
13
19
  Recommended size: 1452px x 530px with a live area of 930px x 530px
@@ -7,8 +7,51 @@ module Plugins
7
7
 
8
8
  private
9
9
 
10
+ def value
11
+ data&.[]('content_item_id')
12
+ end
13
+
14
+ def associated_content_item
15
+ ContentItem.find_by_id(value)
16
+ end
17
+
18
+ def associated_primary_field
19
+ associated_content_item.content_type.fields.find_by_name(field.metadata['field_name'])
20
+ end
21
+
22
+ def associated_primary_field_type_class
23
+ associated_primary_field.field_type_instance.class
24
+ end
25
+
26
+ def associated_primary_field_item
27
+ associated_content_item.field_items.find_by_field_id associated_primary_field
28
+ end
29
+
30
+ def associated_content_item_title
31
+ # Gross hack, this should rely on 'primary title field' config feature in future, and should use a scope
32
+ title_field_item = associated_content_item.field_items.find do |field_item|
33
+ field_item.field.name == 'Title'
34
+ end
35
+
36
+ title_field_item.data['text']
37
+ end
38
+
10
39
  def render_label
11
- "Add #{field.name}"
40
+ "Select #{field.name}"
41
+ end
42
+
43
+ def render_content_item_id
44
+ @options[:form].hidden_field 'data[content_item_id]', value: value, class: 'association_content_item_id'
45
+ end
46
+
47
+ def render_association_cell
48
+ cell(Plugins::Core::AssetCell, associated_primary_field_item,
49
+ associated_content_item: associated_content_item,
50
+ associated_primary_field: associated_primary_field,
51
+ associated_primary_field_type_class: associated_primary_field_type_class,
52
+ associated_primary_field_item: associated_primary_field_item,
53
+ associated_content_item_title: associated_content_item_title)
54
+ .(:association)
12
55
  end
13
56
  end
14
57
  end
@@ -7,7 +7,7 @@ class BooleanFieldType < FieldType
7
7
 
8
8
  def field_item_as_indexed_json_for_field_type(field_item, options = {})
9
9
  json = {}
10
- json[mapping_field_name] = field_item.data['boolean']
10
+ json[mapping_field_name] = field_item.data['value']
11
11
  json
12
12
  end
13
13
 
@@ -1,4 +1,16 @@
1
1
  class ContentItemFieldType < FieldType
2
+ attr_accessor :content_item_id
3
+
4
+ def data=(data_hash)
5
+ @content_item_id = data_hash.deep_symbolize_keys[:content_item_id]
6
+ end
7
+
8
+ def field_item_as_indexed_json_for_field_type(field_item, options = {})
9
+ json = {}
10
+ json[mapping_field_name] = field_item.data['content_item_id']
11
+ json
12
+ end
13
+
2
14
  def mapping
3
15
  { name: mapping_field_name, type: :string, analyzer: :snowball }
4
16
  end
@@ -10,7 +10,7 @@ class DateTimeFieldType < FieldType
10
10
 
11
11
  def field_item_as_indexed_json_for_field_type(field_item, options = {})
12
12
  json = {}
13
- json[mapping_field_name] = field_item.data['date_time']
13
+ json[mapping_field_name] = field_item.data['timestamp']
14
14
  json
15
15
  end
16
16
 
@@ -10,7 +10,7 @@ class TagFieldType < FieldType
10
10
 
11
11
  def field_item_as_indexed_json_for_field_type(field_item, options = {})
12
12
  json = {}
13
- json[mapping_field_name] = field_item.data['tag']
13
+ json[mapping_field_name] = field_item.data['tag_list']
14
14
  json
15
15
  end
16
16
 
@@ -1,8 +1,10 @@
1
1
  class TextFieldType < FieldType
2
2
  attr_accessor :text
3
+ jsonb_accessor :data, text: :string
3
4
 
4
5
  validates :text, presence: true, if: :validate_presence?
5
6
  validate :text_length, if: :validate_length?
7
+ validate :text_unique, if: :validate_uniqueness?
6
8
 
7
9
  def data=(data_hash)
8
10
  @text = data_hash.deep_symbolize_keys[:text]
@@ -25,7 +27,7 @@ class TextFieldType < FieldType
25
27
  end
26
28
 
27
29
  def text_present
28
- errors.add(:text, "must be present") if @text.empty?
30
+ errors.add(:text, 'must be present') if @text.empty?
29
31
  end
30
32
 
31
33
  def text_length
@@ -33,6 +35,16 @@ class TextFieldType < FieldType
33
35
  validator.validate_each(self, :text, text)
34
36
  end
35
37
 
38
+ def text_unique
39
+ unless field.field_items.jsonb_contains(:data, text: text).empty?
40
+ errors.add(:text, "#{field.name} Must be unique")
41
+ end
42
+ end
43
+
44
+ def validate_uniqueness?
45
+ @validations.key? :uniqueness
46
+ end
47
+
36
48
  def validate_presence?
37
49
  @validations.key? :presence
38
50
  end
@@ -21,7 +21,7 @@ class TreeFieldType < FieldType
21
21
 
22
22
  def field_item_as_indexed_json_for_field_type(field_item, options = {})
23
23
  json = {}
24
- json[mapping_field_name] = field_item.data['tree']
24
+ json[mapping_field_name] = field_item.data['values']
25
25
  json
26
26
  end
27
27
 
@@ -10,7 +10,7 @@ class UserFieldType < FieldType
10
10
 
11
11
  def field_item_as_indexed_json_for_field_type(field_item, options = {})
12
12
  json = {}
13
- json[mapping_field_name] = field_item.data['user']
13
+ json[mapping_field_name] = field_item.data['user_id']
14
14
  json
15
15
  end
16
16
 
@@ -1,4 +1,5 @@
1
1
  require 'ckeditor'
2
+ require 'jsonb_accessor'
2
3
 
3
4
  module Cortex
4
5
  module Plugins
@@ -1,7 +1,7 @@
1
1
  module Cortex
2
2
  module Plugins
3
3
  module Core
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
6
6
  end
7
7
  end
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.5.0
4
+ version: 0.6.0
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-12-21 00:00:00.000000000 Z
11
+ date: 2017-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 4.2.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: jsonb_accessor
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.0.0.beta
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.0.0.beta
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: sqlite3
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,8 @@ files:
122
136
  - app/assets/javascripts/ckeditor/plugins/cortex_media_insert/icons/media.png
123
137
  - app/assets/javascripts/ckeditor/plugins/cortex_media_insert/plugin.js
124
138
  - app/assets/javascripts/cortex-field_types-core/application.js
139
+ - app/assets/javascripts/cortex-field_types-core/cells/content_item.js
140
+ - app/cells/plugins/core/asset/association.haml
125
141
  - app/cells/plugins/core/asset/input.haml
126
142
  - app/cells/plugins/core/asset_cell.rb
127
143
  - app/cells/plugins/core/asset_info/index.haml
@@ -187,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
203
  version: '0'
188
204
  requirements: []
189
205
  rubyforge_project:
190
- rubygems_version: 2.5.1
206
+ rubygems_version: 2.5.2
191
207
  signing_key:
192
208
  specification_version: 4
193
209
  summary: The combined set of Core FieldTypes for the Cortex CMS platform