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 +4 -4
- data/app/assets/javascripts/ckeditor/plugins/cortex_media_insert/plugin.js +3 -3
- data/app/assets/javascripts/cortex-field_types-core/application.js +2 -0
- data/app/assets/javascripts/cortex-field_types-core/cells/content_item.js +19 -0
- data/app/cells/plugins/core/asset/association.haml +4 -0
- data/app/cells/plugins/core/asset_cell.rb +13 -0
- data/app/cells/plugins/core/asset_info_cell.rb +1 -1
- data/app/cells/plugins/core/content_item/popup.haml +11 -5
- data/app/cells/plugins/core/content_item_cell.rb +44 -1
- data/app/models/boolean_field_type.rb +1 -1
- data/app/models/content_item_field_type.rb +12 -0
- data/app/models/date_time_field_type.rb +1 -1
- data/app/models/tag_field_type.rb +1 -1
- data/app/models/text_field_type.rb +13 -1
- data/app/models/tree_field_type.rb +1 -1
- data/app/models/user_field_type.rb +1 -1
- data/lib/cortex/plugins/core/engine.rb +1 -0
- data/lib/cortex/plugins/core/version.rb +1 -1
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c977c3cd46774c8925c6214a86cb85f99ff8a29c
|
4
|
+
data.tar.gz: 84bbd9bd60aeae0bc11564589e6942e3b6f6516b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
16
|
+
window.MODALS.wysiwyg.close();
|
17
17
|
|
18
18
|
var mediaTag = editor.document.createElement('media');
|
19
19
|
mediaTag.setAttribute('id', media.id);
|
@@ -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
|
+
});
|
@@ -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
|
@@ -1,13 +1,19 @@
|
|
1
|
+
= render_field_id
|
2
|
+
= render_content_item_id
|
3
|
+
|
1
4
|
= render_label
|
2
5
|
%br
|
3
|
-
%button.
|
4
|
-
.
|
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.
|
9
|
-
Click to
|
11
|
+
%span.content-item-button__select__text
|
12
|
+
Click to select a
|
10
13
|
= field.name
|
11
|
-
from the
|
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
|
-
"
|
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
|
@@ -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['
|
13
|
+
json[mapping_field_name] = field_item.data['timestamp']
|
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,
|
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
|
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
|
+
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:
|
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.
|
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
|