infopark_fiona7 1.2.0.1.3 → 1.2.0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fiona7/builder/obj_builder.rb +11 -1
- data/lib/fiona7/version.rb +1 -1
- metadata +2 -10
- data/app/assets/javascripts/fiona7/templates.js +0 -106
- data/app/assets/javascripts/scrivito_patches/ajax_error_handling.js +0 -24
- data/app/assets/javascripts/scrivito_patches/attribute_serializer.js +0 -259
- data/app/assets/javascripts/scrivito_patches/binary_utils.js +0 -33
- data/app/assets/javascripts/scrivito_patches/cms_rest_api.js +0 -490
- data/app/assets/javascripts/scrivito_patches/models/api/basic_obj.js +0 -650
- data/app/assets/javascripts/scrivito_patches/models/binary_field_element.js +0 -53
- data/app/assets/javascripts/scrivito_patches/obj_serializer.js +0 -91
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cba5228a981890aa7cfb8f6c59c2e3fbaff1553
|
4
|
+
data.tar.gz: 08330c953d938833085ccdbfbbf68f2490b2400a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2846235f3e810fe9899fc4ed254896c8e5abf2ce9b5d9dcc99a1d5490e6b933230eb1c7e939f5489f28700a96b1bd5ffd25184f100afe1493ee38835b78a5a2f
|
7
|
+
data.tar.gz: bb5baf49c42113c9379fff3671123b17072ecab572ea9de0020c3b55a3075fd616970436a31dac105cb2363f04cd1507a63859845b532d1617aa55a601b4bf1e
|
@@ -138,13 +138,23 @@ module Fiona7
|
|
138
138
|
full_text = ::YAML.load(@obj.attr_values["X_full_text"]) rescue {}
|
139
139
|
full_text = {} unless full_text.kind_of?(Hash)
|
140
140
|
full_text["_widget_pool"] ||= {}
|
141
|
-
full_text["_widget_pool"].deep_merge!(
|
141
|
+
full_text["_widget_pool"].deep_merge!(filtered_widget_pool)
|
142
142
|
full_text.to_yaml
|
143
143
|
rescue => e
|
144
144
|
Rails.logger.error("Unable to store information for search engine: #{e.message}")
|
145
145
|
nil
|
146
146
|
end
|
147
147
|
|
148
|
+
def filtered_widget_pool
|
149
|
+
(@widget_pool || {}).deep_dup.tap do |filtered|
|
150
|
+
filtered.each do |k, values|
|
151
|
+
if values.kind_of?(Hash)
|
152
|
+
values.delete_if {|k, v| !(v.respond_to?(:first) && ["string", "enum", "stringlist", "text", "html", "multienum"].include?(v.first)) }
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end.as_json
|
156
|
+
end
|
157
|
+
|
148
158
|
def name_and_parent_path_from_path(path)
|
149
159
|
components = path.split('/')
|
150
160
|
name = components.pop.presence
|
data/lib/fiona7/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark_fiona7
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.1.
|
4
|
+
version: 1.2.0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Przedmojski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -134,18 +134,10 @@ files:
|
|
134
134
|
- app/assets/images/fiona7-logo.png
|
135
135
|
- app/assets/images/fiona7-marker.png
|
136
136
|
- app/assets/javascripts/fiona7.js
|
137
|
-
- app/assets/javascripts/fiona7/templates.js
|
138
137
|
- app/assets/javascripts/fiona7_ui.js
|
139
|
-
- app/assets/javascripts/scrivito_patches/ajax_error_handling.js
|
140
|
-
- app/assets/javascripts/scrivito_patches/attribute_serializer.js
|
141
|
-
- app/assets/javascripts/scrivito_patches/binary_utils.js
|
142
|
-
- app/assets/javascripts/scrivito_patches/cms_rest_api.js
|
143
138
|
- app/assets/javascripts/scrivito_patches/models/ajax.js
|
144
|
-
- app/assets/javascripts/scrivito_patches/models/api/basic_obj.js
|
145
|
-
- app/assets/javascripts/scrivito_patches/models/binary_field_element.js
|
146
139
|
- app/assets/javascripts/scrivito_patches/models/blob.js
|
147
140
|
- app/assets/javascripts/scrivito_patches/models/obj.js
|
148
|
-
- app/assets/javascripts/scrivito_patches/obj_serializer.js
|
149
141
|
- app/assets/stylesheets/fiona7-login.css.scss
|
150
142
|
- app/assets/stylesheets/fiona7.css.scss
|
151
143
|
- app/assets/stylesheets/fiona7_ui.css.scss
|
@@ -1,106 +0,0 @@
|
|
1
|
-
(function() {
|
2
|
-
this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {});
|
3
|
-
this.ScrivitoHandlebarsTemplates["task_list_dialog/content"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
|
4
|
-
var stack1;
|
5
|
-
|
6
|
-
return " <table class=\"scrivito_changes_table\">\n"
|
7
|
-
+ ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.tasks : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
8
|
-
+ "\n <tbody>\n"
|
9
|
-
+ ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.tasks : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.program(7, data, 0),"data":data})) != null ? stack1 : "")
|
10
|
-
+ " </tbody>\n </table>\n";
|
11
|
-
},"2":function(container,depth0,helpers,partials,data) {
|
12
|
-
return " <thead>\n <tr>\n <th>\n <span>\n "
|
13
|
-
+ container.escapeExpression((helpers.translate || (depth0 && depth0.translate) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"task_list_dialog.user_login",{"name":"translate","hash":{},"data":data}))
|
14
|
-
+ "\n </span>\n </th>\n <th>\n <span>\n "
|
15
|
-
+ container.escapeExpression((helpers.translate || (depth0 && depth0.translate) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"task_list_dialog.group_name",{"name":"translate","hash":{},"data":data}))
|
16
|
-
+ "\n </span>\n </th>\n <th>\n <span>\n "
|
17
|
-
+ container.escapeExpression((helpers.translate || (depth0 && depth0.translate) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"changes_dialog.description_for_editor",{"name":"translate","hash":{},"data":data}))
|
18
|
-
+ "\n </span>\n </th>\n <th>\n <span>\n "
|
19
|
-
+ container.escapeExpression((helpers.translate || (depth0 && depth0.translate) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"changes_dialog.obj_class",{"name":"translate","hash":{},"data":data}))
|
20
|
-
+ "\n </span>\n </th>\n <th>\n <span>\n "
|
21
|
-
+ container.escapeExpression((helpers.translate || (depth0 && depth0.translate) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"task_list_dialog.comment",{"name":"translate","hash":{},"data":data}))
|
22
|
-
+ "\n </span>\n </th>\n <th>\n <span>\n "
|
23
|
-
+ container.escapeExpression((helpers.translate || (depth0 && depth0.translate) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"changes_dialog.last_changed",{"name":"translate","hash":{},"data":data}))
|
24
|
-
+ "\n </span>\n </th>\n </tr>\n </thead>\n";
|
25
|
-
},"4":function(container,depth0,helpers,partials,data) {
|
26
|
-
var stack1;
|
27
|
-
|
28
|
-
return " "
|
29
|
-
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.tasks : depth0),{"name":"each","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
30
|
-
+ "\n";
|
31
|
-
},"5":function(container,depth0,helpers,partials,data) {
|
32
|
-
return container.escapeExpression((helpers.render || (depth0 && depth0.render) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"task_list_dialog/row",depth0,{"name":"render","hash":{},"data":data}));
|
33
|
-
},"7":function(container,depth0,helpers,partials,data) {
|
34
|
-
return " <tr>\n <td class=\"scrivito_empty_result\" colspan=\"5\">"
|
35
|
-
+ container.escapeExpression((helpers.translate || (depth0 && depth0.translate) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"task_list_dialog.empty",{"name":"translate","hash":{},"data":data}))
|
36
|
-
+ "</td>\n </tr>\n";
|
37
|
-
},"9":function(container,depth0,helpers,partials,data) {
|
38
|
-
return " <tr><td colspan=\"5\"><i class=\"scrivito_icon scrivito_spinning\"></i></td></tr>\n";
|
39
|
-
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
|
40
|
-
var stack1, helper;
|
41
|
-
|
42
|
-
return "<div class=\"scrivito_changes_dialog_content scrivito_auto_height\">\n <div class=\"scrivito_modal_header\">\n <h3>\n <i class=\"scrivito_icon\"></i> "
|
43
|
-
+ container.escapeExpression(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"title","hash":{},"data":data}) : helper)))
|
44
|
-
+ "\n </h3>\n </div>\n\n <div class=\"scrivito_modal_body scrivito_auto_height\">\n"
|
45
|
-
+ ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.is_loaded : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(9, data, 0),"data":data})) != null ? stack1 : "")
|
46
|
-
+ " </div>\n</div>\n\n<div class=\"scrivito_modal_footer\">\n <a href=\"#\" class=\"scrivito_button scrivito_left fiona7_toggle_task_list_type\">\n "
|
47
|
-
+ container.escapeExpression(((helper = (helper = helpers.mode_button || (depth0 != null ? depth0.mode_button : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"mode_button","hash":{},"data":data}) : helper)))
|
48
|
-
+ "\n </a>\n <a href=\"#\" class=\"scrivito_button scrivito_cancel scrivito_green\">"
|
49
|
-
+ container.escapeExpression((helpers.translate || (depth0 && depth0.translate) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"done",{"name":"translate","hash":{},"data":data}))
|
50
|
-
+ "</a>\n</div>\n";
|
51
|
-
},"useData":true});
|
52
|
-
return this.ScrivitoHandlebarsTemplates["task_list_dialog/content"];
|
53
|
-
}).call(this);
|
54
|
-
(function() {
|
55
|
-
this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {});
|
56
|
-
this.ScrivitoHandlebarsTemplates["task_list_dialog/row"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
|
57
|
-
var stack1, helper;
|
58
|
-
|
59
|
-
return "<tr title=\""
|
60
|
-
+ container.escapeExpression(((helper = (helper = helpers.tooltip || (depth0 != null ? depth0.tooltip : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"tooltip","hash":{},"data":data}) : helper)))
|
61
|
-
+ "\" data-scrivito-obj-id=\""
|
62
|
-
+ container.escapeExpression(((helper = (helper = helpers.obj_id || (depth0 != null ? depth0.obj_id : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"obj_id","hash":{},"data":data}) : helper)))
|
63
|
-
+ "\">\n <td>\n <span>\n "
|
64
|
-
+ container.escapeExpression(((helper = (helper = helpers.user_login || (depth0 != null ? depth0.user_login : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"user_login","hash":{},"data":data}) : helper)))
|
65
|
-
+ "\n </span>\n </td>\n\n <td>\n <span>\n "
|
66
|
-
+ container.escapeExpression(((helper = (helper = helpers.group_name || (depth0 != null ? depth0.group_name : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"group_name","hash":{},"data":data}) : helper)))
|
67
|
-
+ "\n </span>\n </td>\n\n <td><span class=\"scrivito_title\">"
|
68
|
-
+ container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.obj_data : depth0)) != null ? stack1.description_for_editor : stack1), depth0))
|
69
|
-
+ "</span>\n <td><span class=\"scrivito_obj_class\">"
|
70
|
-
+ container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.obj_data : depth0)) != null ? stack1.obj_class : stack1), depth0))
|
71
|
-
+ "</span></td>\n\n <td>\n <span>\n "
|
72
|
-
+ container.escapeExpression(((helper = (helper = helpers.comment || (depth0 != null ? depth0.comment : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"comment","hash":{},"data":data}) : helper)))
|
73
|
-
+ "\n </span>\n </td>\n\n <td>\n <span>\n <time datetime=\""
|
74
|
-
+ container.escapeExpression(((helper = (helper = helpers.last_changed || (depth0 != null ? depth0.last_changed : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"last_changed","hash":{},"data":data}) : helper)))
|
75
|
-
+ "\" title=\""
|
76
|
-
+ container.escapeExpression((helpers.localize_date || (depth0 && depth0.localize_date) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.last_changed : depth0),{"name":"localize_date","hash":{},"data":data}))
|
77
|
-
+ "\">\n "
|
78
|
-
+ container.escapeExpression((helpers.localizeDateRelative || (depth0 && depth0.localizeDateRelative) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.last_changed : depth0),{"name":"localizeDateRelative","hash":{},"data":data}))
|
79
|
-
+ "\n </time>\n </span>\n </td>\n</tr>\n";
|
80
|
-
},"useData":true});
|
81
|
-
return this.ScrivitoHandlebarsTemplates["task_list_dialog/row"];
|
82
|
-
}).call(this);
|
83
|
-
(function() {
|
84
|
-
this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {});
|
85
|
-
this.ScrivitoHandlebarsTemplates["task_list_dialog"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
|
86
|
-
return "<div class=\"scrivito_changes_overview scrivito_modal_large adjust_dialog\" >\n <div class=\"scrivito_changes_dialog_content scrivito_auto_height\"></div>\n <div class=\"scrivito_modal_footer\">\n <a href=\"#\" class=\"scrivito_button scrivito_cancel scrivito_green\">"
|
87
|
-
+ container.escapeExpression((helpers.translate || (depth0 && depth0.translate) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"done",{"name":"translate","hash":{},"data":data}))
|
88
|
-
+ "</a>\n </div>\n</div>\n";
|
89
|
-
},"useData":true});
|
90
|
-
return this.ScrivitoHandlebarsTemplates["task_list_dialog"];
|
91
|
-
}).call(this);
|
92
|
-
(function() {
|
93
|
-
this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {});
|
94
|
-
this.ScrivitoHandlebarsTemplates["task_list_menu_item"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
|
95
|
-
var stack1, helper;
|
96
|
-
|
97
|
-
return "<li id=\"fiona7_task_list\" class=\"scrivito_menu_item fiona7_task_list\">\n<span title=\""
|
98
|
-
+ container.escapeExpression(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"title","hash":{},"data":data}) : helper)))
|
99
|
-
+ "\"><i class=\"scrivito_icon\">"
|
100
|
-
+ ((stack1 = ((helper = (helper = helpers.icon || (depth0 != null ? depth0.icon : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"icon","hash":{},"data":data}) : helper))) != null ? stack1 : "")
|
101
|
-
+ "</i> "
|
102
|
-
+ container.escapeExpression(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"title","hash":{},"data":data}) : helper)))
|
103
|
-
+ " </span>\n</li>\n";
|
104
|
-
},"useData":true});
|
105
|
-
return this.ScrivitoHandlebarsTemplates["task_list_menu_item"];
|
106
|
-
}).call(this);
|
@@ -1,24 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
(function () {
|
4
|
-
_.extend(scrivito, {
|
5
|
-
handleAjaxError: function handleAjaxError(error) {
|
6
|
-
var message = undefined;
|
7
|
-
|
8
|
-
// -- PATCH BEGINS HERE --
|
9
|
-
if (error && typeof error === 'object' && error.message) {
|
10
|
-
scrivito.alertDialog(error.message);
|
11
|
-
} else {
|
12
|
-
message = scrivito.t('ajax_error.communication');
|
13
|
-
scrivito.errorDialog(scrivito.t('ajax_error.message_for_editor'), [message]);
|
14
|
-
}
|
15
|
-
// -- PATCH ENDS HERE --
|
16
|
-
|
17
|
-
scrivito.logError(error);
|
18
|
-
},
|
19
|
-
|
20
|
-
withAjaxErrorHandling: function withAjaxErrorHandling(promise) {
|
21
|
-
return promise['catch'](scrivito.handleAjaxError);
|
22
|
-
}
|
23
|
-
});
|
24
|
-
})();
|
@@ -1,259 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
(function () {
|
4
|
-
scrivito.AttributeSerializer = {
|
5
|
-
serialize: function serialize(objClass, attributes) {
|
6
|
-
return _.mapObject(attributes, function (value, name) {
|
7
|
-
if (scrivito.Attribute.isSystemAttribute(name)) {
|
8
|
-
return value;
|
9
|
-
}
|
10
|
-
|
11
|
-
var attribute = objClass && objClass.attribute(name);
|
12
|
-
|
13
|
-
if (!attribute) {
|
14
|
-
throw new scrivito.ScrivitoError('Attribute "' + name + '" is not defined for obj class "' + objClass.name + '".');
|
15
|
-
}
|
16
|
-
|
17
|
-
return [serializeAttributeType(attribute.type, name), serializeAttributeValue(attribute, value, name)];
|
18
|
-
});
|
19
|
-
}
|
20
|
-
};
|
21
|
-
|
22
|
-
function serializeAttributeType(type, name) {
|
23
|
-
switch (type) {
|
24
|
-
case 'enum':
|
25
|
-
return 'string';
|
26
|
-
case 'float':
|
27
|
-
case 'integer':
|
28
|
-
return 'number';
|
29
|
-
case 'multienum':
|
30
|
-
return 'stringlist';
|
31
|
-
case 'binary':
|
32
|
-
case 'date':
|
33
|
-
case 'html':
|
34
|
-
case 'link':
|
35
|
-
case 'linklist':
|
36
|
-
case 'reference':
|
37
|
-
case 'referencelist':
|
38
|
-
case 'string':
|
39
|
-
case 'stringlist':
|
40
|
-
case 'widgetlist':
|
41
|
-
return type;
|
42
|
-
default:
|
43
|
-
throw new scrivito.ScrivitoError('Attribute "' + name + '" is of unsupported type "' + type + '".');
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
function serializeAttributeValue(attribute, value, name) {
|
48
|
-
if (value === null) {
|
49
|
-
return value;
|
50
|
-
}
|
51
|
-
|
52
|
-
switch (attribute.type) {
|
53
|
-
case 'binary':
|
54
|
-
return serializeBinaryAttributeValue(value, name);
|
55
|
-
case 'date':
|
56
|
-
return serializeDateAttributeValue(value, name);
|
57
|
-
case 'enum':
|
58
|
-
return serializeEnumAttributeValue(attribute, value, name);
|
59
|
-
case 'float':
|
60
|
-
return serializeFloatAttributeValue(value, name);
|
61
|
-
case 'integer':
|
62
|
-
return serializeIntegerAttributeValue(value, name);
|
63
|
-
case 'link':
|
64
|
-
return serializeLinkAttributeValue(value, name);
|
65
|
-
case 'linklist':
|
66
|
-
return serializeLinklistAttributeValue(value, name);
|
67
|
-
case 'multienum':
|
68
|
-
return serializeMultienumAttributeValue(attribute, value, name);
|
69
|
-
case 'reference':
|
70
|
-
return serializeReferenceAttributeValue(value, name);
|
71
|
-
case 'referencelist':
|
72
|
-
return serializeReferencelistAttributeValue(value, name);
|
73
|
-
case 'widgetlist':
|
74
|
-
return serializeWidgetlistAttributeValue(value);
|
75
|
-
default:
|
76
|
-
return value;
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
function invalidAttributeValue(value, name, expected) {
|
81
|
-
throw new scrivito.ScrivitoError('Unexpected value ' + scrivito.prettyPrint(value) + ' for' + (' attribute "' + name + '". Expected: ' + expected));
|
82
|
-
}
|
83
|
-
|
84
|
-
function serializeBinaryAttributeValue(_x, _x2) {
|
85
|
-
var _again = true;
|
86
|
-
|
87
|
-
_function: while (_again) {
|
88
|
-
var value = _x,
|
89
|
-
name = _x2;
|
90
|
-
_again = false;
|
91
|
-
|
92
|
-
// -- PATCH BEGINS HERE --
|
93
|
-
if (value instanceof scrivito.Binary) {
|
94
|
-
return { id: value.id };
|
95
|
-
} else if (value === null) {
|
96
|
-
return null;
|
97
|
-
} else if (value instanceof scrivito.UploadedBlob) {
|
98
|
-
_x = value.copy();
|
99
|
-
_x2 = name;
|
100
|
-
_again = true;
|
101
|
-
continue _function;
|
102
|
-
} else if (value instanceof scrivito.FutureBinary) {
|
103
|
-
var futureBinary = value;
|
104
|
-
|
105
|
-
if (futureBinary.idToCopy) {
|
106
|
-
var blob = {
|
107
|
-
id_to_copy: futureBinary.idToCopy
|
108
|
-
};
|
109
|
-
if (futureBinary.filename) blob.filename = futureBinary.filename;
|
110
|
-
if (futureBinary.contentType) blob.content_type = futureBinary.contentType;
|
111
|
-
|
112
|
-
return blob;
|
113
|
-
} else if (futureBinary.source) {
|
114
|
-
return { blob_to_upload: futureBinary.source, filename: futureBinary.filename };
|
115
|
-
}
|
116
|
-
} else if (scrivito.BinaryUtils.isFile(value) || scrivito.BinaryUtils.isBlob(value)) {
|
117
|
-
return value;
|
118
|
-
} else if (value && typeof value === 'object' && value.id_to_copy) {
|
119
|
-
return value;
|
120
|
-
} else {
|
121
|
-
invalidAttributeValue(value, name, 'A Binary.');
|
122
|
-
}
|
123
|
-
// -- PATCH ENDS HERE --
|
124
|
-
}
|
125
|
-
}
|
126
|
-
|
127
|
-
function serializeDateAttributeValue(value, name) {
|
128
|
-
if (_.isDate(value)) {
|
129
|
-
return scrivito.types.formatDateToString(value);
|
130
|
-
}
|
131
|
-
if (scrivito.types.isValidDateString(value)) {
|
132
|
-
return value;
|
133
|
-
}
|
134
|
-
|
135
|
-
invalidAttributeValue(value, name, 'A Date.');
|
136
|
-
}
|
137
|
-
|
138
|
-
function serializeEnumAttributeValue(attribute, value, name) {
|
139
|
-
var validValues = attribute.validValues();
|
140
|
-
if (!_.contains(validValues, value)) {
|
141
|
-
var e = 'Valid attribute values are contained in its "validValues" array [' + validValues + '].';
|
142
|
-
invalidAttributeValue(value, name, e);
|
143
|
-
}
|
144
|
-
return value;
|
145
|
-
}
|
146
|
-
|
147
|
-
function serializeFloatAttributeValue(value, name) {
|
148
|
-
if (!scrivito.types.isValidFloat(value)) {
|
149
|
-
var invalidValue = value;
|
150
|
-
if (_.isNumber(value)) {
|
151
|
-
invalidValue = String(value);
|
152
|
-
}
|
153
|
-
invalidAttributeValue(invalidValue, name, 'A Number, that is #isFinite().');
|
154
|
-
}
|
155
|
-
return value;
|
156
|
-
}
|
157
|
-
|
158
|
-
function serializeIntegerAttributeValue(value, name) {
|
159
|
-
if (!scrivito.types.isValidInteger(value)) {
|
160
|
-
invalidAttributeValue(value, name, 'A Number, that is #isSafeInteger().');
|
161
|
-
}
|
162
|
-
return value;
|
163
|
-
}
|
164
|
-
|
165
|
-
function serializeLinkAttributeValue(value, name) {
|
166
|
-
if (!validLinkObject(value)) {
|
167
|
-
invalidAttributeValue(value, name, 'A scrivito.Link instance.');
|
168
|
-
}
|
169
|
-
|
170
|
-
return convertLinkToCmsApi(value);
|
171
|
-
}
|
172
|
-
|
173
|
-
function serializeLinklistAttributeValue(value, name) {
|
174
|
-
if (!Array.isArray(value) || !_.all(value, validLinkObject)) {
|
175
|
-
invalidAttributeValue(value, name, 'An array of scrivito.Link instances.');
|
176
|
-
}
|
177
|
-
|
178
|
-
return _.map(value, convertLinkToCmsApi);
|
179
|
-
}
|
180
|
-
|
181
|
-
function validLinkObject(value) {
|
182
|
-
if (value instanceof scrivito.Link) {
|
183
|
-
return true;
|
184
|
-
}
|
185
|
-
|
186
|
-
// check if value is backend compatible
|
187
|
-
if (!_.isObject(value)) {
|
188
|
-
return false;
|
189
|
-
}
|
190
|
-
var invalidKeys = _.without(_.keys(value), 'fragment', 'obj_id', 'query', 'target', 'title', 'url');
|
191
|
-
return _.isEmpty(invalidKeys);
|
192
|
-
}
|
193
|
-
|
194
|
-
function convertLinkToCmsApi(value) {
|
195
|
-
var backendLink = {
|
196
|
-
fragment: value.fragment,
|
197
|
-
query: value.query,
|
198
|
-
target: value.target,
|
199
|
-
title: value.title,
|
200
|
-
url: value.url
|
201
|
-
};
|
202
|
-
backendLink.obj_id = value.objId || value.obj_id;
|
203
|
-
|
204
|
-
return _.mapObject(backendLink, function (v) {
|
205
|
-
return v || null;
|
206
|
-
});
|
207
|
-
}
|
208
|
-
|
209
|
-
function serializeMultienumAttributeValue(attribute, value, name) {
|
210
|
-
var validValues = attribute.validValues();
|
211
|
-
var errorMessage = 'An array with values from ' + scrivito.prettyPrint(validValues) + '.';
|
212
|
-
|
213
|
-
if (!Array.isArray(value) || !_.all(value, _.isString)) {
|
214
|
-
invalidAttributeValue(value, name, errorMessage);
|
215
|
-
}
|
216
|
-
|
217
|
-
var forbiddenValues = _.difference(value, validValues);
|
218
|
-
if (forbiddenValues.length) {
|
219
|
-
var e = errorMessage + ' Forbidden values: ' + scrivito.prettyPrint(forbiddenValues) + '.';
|
220
|
-
invalidAttributeValue(value, name, e);
|
221
|
-
}
|
222
|
-
return value;
|
223
|
-
}
|
224
|
-
|
225
|
-
function serializeReferenceAttributeValue(value, name) {
|
226
|
-
if (!isValidReference(value)) {
|
227
|
-
invalidAttributeValue(value, name, 'A BasicObj or a String ID.');
|
228
|
-
}
|
229
|
-
return serializeSingleReferenceValue(value);
|
230
|
-
}
|
231
|
-
|
232
|
-
function serializeReferencelistAttributeValue(value, name) {
|
233
|
-
if (!isValidReferencelistValue(value)) {
|
234
|
-
invalidAttributeValue(value, name, 'An array with BasicObjs or String IDs.');
|
235
|
-
}
|
236
|
-
return _.map(value, serializeSingleReferenceValue);
|
237
|
-
}
|
238
|
-
|
239
|
-
function serializeSingleReferenceValue(value) {
|
240
|
-
if (value instanceof scrivito.BasicObj) {
|
241
|
-
return value.id;
|
242
|
-
}
|
243
|
-
return value;
|
244
|
-
}
|
245
|
-
|
246
|
-
function isValidReference(value) {
|
247
|
-
return _.isString(value) || _.isNumber(value) || value instanceof scrivito.BasicObj;
|
248
|
-
}
|
249
|
-
|
250
|
-
function isValidReferencelistValue(value) {
|
251
|
-
return _.isArray(value) && _.every(value, function (v) {
|
252
|
-
return isValidReference(v);
|
253
|
-
});
|
254
|
-
}
|
255
|
-
|
256
|
-
function serializeWidgetlistAttributeValue(value) {
|
257
|
-
return _.pluck(value, 'id');
|
258
|
-
}
|
259
|
-
})();
|