infopark_fiona7 1.2.0.1.1 → 1.2.0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a6ec5e35fd0d8751ebef7a921e1041b74b6991f
4
- data.tar.gz: 0340bd069fc11e65504711408488f8a6b088a7ec
3
+ metadata.gz: 3f5bb4843c2d6cb45900e106c45a2c816a6ac92a
4
+ data.tar.gz: bbede3ca4e3ab7853ec1d9e1ba061bf3e3a0e835
5
5
  SHA512:
6
- metadata.gz: 9c37220478fa274a9afaff2535af1bdfcf6cdc4d25b14ea6f9f219738fa36a6c4314b633317977c86be20ea3f8d055480141bcd5b9c99f4c0860a5337a4e8127
7
- data.tar.gz: 23adf98f303eb22bfe138f66934fc421b9f0dbbdf11619ef99bfdce3f1df1dd897ef5acfa7f66430a242c494f9bd4d986643378743aca3bfc33376864d553c91
6
+ metadata.gz: 1bdd5bb80f3f4efbcae3de2e21d1b9b488ccc5e5efa2971e0642d1e527aefa0f1f8425bc654a528148637561c69c3557623d329b487df2b94915f58b99faf94a
7
+ data.tar.gz: bd3f869317c4d8eebd51930ce3ca4d576c522f1deb8669009c4b3ab6a18cab0152b786891dddf7340469c726e9ff86972c57e656e723900355926e1db13407e6
@@ -0,0 +1,106 @@
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\">&#xf023;</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\">&#xf06f;</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);
@@ -0,0 +1,24 @@
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
+ })();
@@ -0,0 +1,259 @@
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
+ })();
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ (function () {
4
+ scrivito.BinaryUtils = {
5
+ validateBinaryOptions: function validateBinaryOptions(options) {
6
+ if (_.has(options, 'filename') && !options.filename) {
7
+ throw new scrivito.ArgumentError('filename cannot be blank');
8
+ }
9
+
10
+ if (_.has(options, 'content_type') && !options.content_type) {
11
+ throw new scrivito.ArgumentError('content_type cannot be blank');
12
+ }
13
+
14
+ if (_.has(options, 'contentType') && !options.contentType) {
15
+ throw new scrivito.ArgumentError('contentType cannot be blank');
16
+ }
17
+ },
18
+
19
+ isBlob: function isBlob(obj) {
20
+ return !!obj && _.isNumber(obj.size) && _.isString(obj.type);
21
+ },
22
+
23
+ isFile: function isFile(obj) {
24
+ return this.isBlob(obj) && _.isDate(obj.lastModifiedDate) && _.isString(obj.name);
25
+ },
26
+
27
+ // -- PATCH BEGINS HERE --
28
+ isBlobWithName: function isBlobWithName(obj) {
29
+ return obj && typeof obj === 'object' && this.isBlob(obj.blob_to_upload);
30
+ }
31
+ };
32
+ })();
33
+ // -- PATCH ENDS HERE --
@@ -0,0 +1,490 @@
1
+ 'use strict';
2
+
3
+ var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();
4
+
5
+ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
6
+
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
8
+
9
+ (function () {
10
+ var MIN_REQUEST_TIME = 5;
11
+ var DEFAULT_REQUEST_TIMEOUT = 120000; // <-- PATCH HERE
12
+ var backendEndpoint = undefined;
13
+ var tenant = undefined;
14
+
15
+ scrivito.CmsRestApi = {
16
+ init: function init(endpoint, initTenant) {
17
+ backendEndpoint = endpoint;
18
+ tenant = initTenant;
19
+ },
20
+
21
+ get: function get(path, requestParams) {
22
+ return fetch('GET', path, requestParams);
23
+ },
24
+
25
+ put: function put(path, requestParams) {
26
+ return fetch('PUT', path, requestParams);
27
+ },
28
+
29
+ post: function post(path, requestParams) {
30
+ return fetch('POST', path, requestParams);
31
+ },
32
+
33
+ 'delete': function _delete(path) {
34
+ return fetch('DELETE', path);
35
+ }
36
+ };
37
+
38
+ var Timer = (function () {
39
+ function Timer() {
40
+ var timeout = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT_REQUEST_TIMEOUT : arguments[0];
41
+
42
+ _classCallCheck(this, Timer);
43
+
44
+ this.timesOutAt = Date.now() + timeout;
45
+ }
46
+
47
+ _createClass(Timer, [{
48
+ key: 'timedOut',
49
+ value: function timedOut() {
50
+ return this.remainingTime() < MIN_REQUEST_TIME;
51
+ }
52
+ }, {
53
+ key: 'remainingTime',
54
+ value: function remainingTime() {
55
+ return Math.max(this.timesOutAt - Date.now(), 0);
56
+ }
57
+ }, {
58
+ key: 'cover',
59
+ value: function cover(time) {
60
+ return time <= this.timesOutAt - MIN_REQUEST_TIME;
61
+ }
62
+ }]);
63
+
64
+ return Timer;
65
+ })();
66
+
67
+ function fetch(method, path, requestParams) {
68
+ return request(method, path, requestParams).then(function (result) {
69
+ if (result && result.task && _.size(result) === 1) {
70
+ return handleTask(result.task);
71
+ }
72
+ return result;
73
+ });
74
+ }
75
+
76
+ function request(method, path, requestParams) {
77
+ var timer = new Timer();
78
+ return retryOnceOnError(timer, method, function () {
79
+ return retryOnRateLimit(timer, function () {
80
+ return scrivito.SessionKeeper.performWithToken(function (token) {
81
+ var ajaxDeferred = ajax(method, path, requestParams, timer.remainingTime(), token);
82
+ return scrivito.Promise.resolve(ajaxDeferred)['catch'](checkAuthorization);
83
+ });
84
+ })['catch'](function (error) {
85
+ return raiseError(error);
86
+ });
87
+ });
88
+ }
89
+
90
+ function retryOnceOnError(timer, method, requestCallback) {
91
+ if (method === 'POST') {
92
+ return requestCallback();
93
+ }
94
+
95
+ return requestCallback()['catch'](function (error) {
96
+ if (!timer.timedOut()) {
97
+ if (error instanceof scrivito.BackendError) {
98
+ return requestCallback();
99
+ }
100
+ if (error instanceof scrivito.NetworkError) {
101
+ return requestCallback();
102
+ }
103
+ }
104
+ throw error;
105
+ });
106
+ }
107
+
108
+ function retryOnRateLimit(timer, requestCallback) {
109
+ var retry = function retry(retryCount) {
110
+ return requestCallback()['catch'](function (error) {
111
+ if (error.status === 429) {
112
+ var timeout = calculateTimeout(error.getResponseHeader('Retry-After'), retryCount);
113
+ if (timer.cover(Date.now() + timeout)) {
114
+ return scrivito.Promise.resolve(scrivito.waitMs(timeout)).then(function () {
115
+ return retry(retryCount + 1);
116
+ });
117
+ }
118
+ throw new scrivito.RateLimitExceededError('rate limit exceeded', 429);
119
+ }
120
+ throw error;
121
+ });
122
+ };
123
+
124
+ return retry(0);
125
+ }
126
+
127
+ function calculateTimeout(retryAfter, retryCount) {
128
+ var calculatedTimeout = Math.pow(2, retryCount) * 0.5 * 1000;
129
+ return Math.max(calculatedTimeout, retryAfter * 1000);
130
+ }
131
+
132
+ function raiseError(error) {
133
+ if (error.status === undefined || !_.isNumber(error.status)) {
134
+ throw error;
135
+ } else if (error.status === 0) {
136
+ throw new scrivito.NetworkError(error.statusText, error.status);
137
+ }
138
+
139
+ var errorBody = parseError(error);
140
+ var specificOutput = errorBody.error;
141
+
142
+ if (error.status === 403) {
143
+ throw new scrivito.AccessDeniedError(specificOutput, error.status, errorBody.code);
144
+ } else if (error.status.toString()[0] === '4' && specificOutput) {
145
+ throw new scrivito.ClientError(specificOutput, error.status, errorBody.code);
146
+ } else if (error.status === 500 && specificOutput) {
147
+ throw new scrivito.BackendError(specificOutput, error.status);
148
+ }
149
+ throw new scrivito.NetworkError(error.responseText, error.status);
150
+ }
151
+
152
+ function checkAuthorization(error) {
153
+ if (error.status === 401) {
154
+ var errorBody = parseError(error);
155
+ var specificOutput = errorBody.error;
156
+ throw new scrivito.UnauthorizedError(specificOutput, error.status, errorBody.code);
157
+ }
158
+ throw error;
159
+ }
160
+
161
+ function parseError(error) {
162
+ try {
163
+ return JSON.parse(error.responseText);
164
+ } catch (err) {
165
+ if (err instanceof SyntaxError) {
166
+ throw new scrivito.NetworkError(error.responseText, error.status);
167
+ }
168
+ throw err;
169
+ }
170
+ }
171
+
172
+ function prepareAjaxParams(method, path) {
173
+ var requestParams = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
174
+
175
+ var ajaxParams = {
176
+ path: path,
177
+ verb: method,
178
+ params: requestParams
179
+ };
180
+
181
+ return {
182
+ data: JSON.stringify(ajaxParams)
183
+ };
184
+ }
185
+
186
+ function ajax(method, path, requestParams, timeout, token) {
187
+ // -- PATCH BEGINS HERE --
188
+ if (ajaxWithFormDataRequired(requestParams) /* || true */) {
189
+ return ajaxWithFormData(method, path, requestParams, timeout, token);
190
+ }
191
+ // -- PATCH ENDS HERE --
192
+
193
+ var ajaxParams = prepareAjaxParams(method, path, requestParams);
194
+ var ajaxMethod = method === 'POST' ? 'POST' : 'PUT';
195
+ var url = '/_f7/tenants/' + tenant + '/perform'; // <-- PATCH HERE
196
+
197
+ return $.ajax(_.extend({
198
+ url: url,
199
+ method: ajaxMethod,
200
+ contentType: 'application/json; charset=utf-8',
201
+ dataType: 'json',
202
+ //headers: { Authorization: `Session ${token}` }, // <-- PATCH HERE
203
+ timeout: timeout,
204
+ cache: false, // Don't cache GET requests.
205
+ xhrFields: { withCredentials: true }
206
+ }, ajaxParams)).then(function (result, textStatus, xhr) {
207
+ return $.Deferred().resolve(result);
208
+ }, function (xhr, textStatus, xhrError) {
209
+ return $.Deferred().reject(xhr);
210
+ });
211
+ }
212
+
213
+ // -- PATCH BEGINS HERE --
214
+ function ajaxWithFormDataRequired(params) {
215
+ var objParams = params && params.obj;
216
+ var result = false;
217
+
218
+ if (!objParams) {
219
+ return result;
220
+ }
221
+
222
+ var _iteratorNormalCompletion = true;
223
+ var _didIteratorError = false;
224
+ var _iteratorError = undefined;
225
+
226
+ try {
227
+ for (var _iterator = Object.keys(objParams)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
228
+ var k = _step.value;
229
+
230
+ // if params[k] is an array
231
+ if (objParams[k].pop) {
232
+ // file uploads require form data
233
+ result = objParams[k][1] && (scrivito.BinaryUtils.isFile(objParams[k][1]) || scrivito.BinaryUtils.isBlob(objParams[k][1]) || scrivito.BinaryUtils.isBlobWithName(objParams[k][1]));
234
+ if (result) {
235
+ return result;
236
+ }
237
+ }
238
+ }
239
+ } catch (err) {
240
+ _didIteratorError = true;
241
+ _iteratorError = err;
242
+ } finally {
243
+ try {
244
+ if (!_iteratorNormalCompletion && _iterator['return']) {
245
+ _iterator['return']();
246
+ }
247
+ } finally {
248
+ if (_didIteratorError) {
249
+ throw _iteratorError;
250
+ }
251
+ }
252
+ }
253
+
254
+ return result;
255
+ }
256
+
257
+ function ajaxWithFormData(method, path, requestParams, timeout, token) {
258
+ var formData = paramsToFormData(method, path, requestParams);
259
+ var ajaxMethod = method === 'POST' ? 'POST' : 'PUT';
260
+ var url = '/_f7/tenants/' + tenant + '/perform';
261
+
262
+ return $.ajax(_.extend({
263
+ url: url,
264
+ method: ajaxMethod,
265
+ contentType: false,
266
+ processData: false,
267
+ data: formData,
268
+ timeout: timeout,
269
+ cache: false, // Don't cache GET requests.
270
+ xhrFields: { withCredentials: true }
271
+ })).then(function (result, textStatus, xhr) {
272
+ return $.Deferred().resolve(result);
273
+ }, function (xhr, textStatus, xhrError) {
274
+ return $.Deferred().reject(xhr);
275
+ });
276
+ }
277
+
278
+ function paramsToFormData(verb, path, params) {
279
+ var objParams = params && params.obj || {};
280
+ var fd = new FormData();
281
+ fd.append('verb', verb);
282
+ fd.append('path', path);
283
+
284
+ var _iteratorNormalCompletion2 = true;
285
+ var _didIteratorError2 = false;
286
+ var _iteratorError2 = undefined;
287
+
288
+ try {
289
+ for (var _iterator2 = Object.keys(objParams)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
290
+ var attr = _step2.value;
291
+
292
+ // attr is a [type, value] pair
293
+ if (objParams[attr] && typeof objParams[attr] === 'object' && objParams[attr].pop) {
294
+ var _objParams$attr = _slicedToArray(objParams[attr], 2);
295
+
296
+ var type = _objParams$attr[0];
297
+ var value = _objParams$attr[1];
298
+
299
+ if (value.pop) {
300
+ // multienum / stringlist / widgetlist
301
+ fd.append('params[obj][' + attr + '[]', type);
302
+ for (var i = 0; i < value.length; ++i) {
303
+ fd.append('params[obj][' + attr + '[][formdata$workaround][]', value[i]);
304
+ }
305
+ } else if (scrivito.BinaryUtils.isFile(value) || scrivito.BinaryUtils.isBlob(value)) {
306
+ // upload
307
+ fd.append('params[obj][' + attr + '][]', type);
308
+ fd.append('params[obj][' + attr + '][]', value);
309
+ } else if (scrivito.BinaryUtils.isBlobWithName(value)) {
310
+ fd.append('params[obj][' + attr + '][]', type);
311
+ fd.append('params[obj][' + attr + '][]', value.blob_to_upload, value.filename);
312
+ } else if (value && typeof value === 'object') {
313
+ // blob/copy rename
314
+ fd.append('params[obj][' + attr + '[]', type);
315
+ var _iteratorNormalCompletion3 = true;
316
+ var _didIteratorError3 = false;
317
+ var _iteratorError3 = undefined;
318
+
319
+ try {
320
+ for (var _iterator3 = Object.keys(value)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
321
+ var l = _step3.value;
322
+
323
+ fd.append('params[obj][' + attr + '][][' + l + ']', value[l]);
324
+ }
325
+ } catch (err) {
326
+ _didIteratorError3 = true;
327
+ _iteratorError3 = err;
328
+ } finally {
329
+ try {
330
+ if (!_iteratorNormalCompletion3 && _iterator3['return']) {
331
+ _iterator3['return']();
332
+ }
333
+ } finally {
334
+ if (_didIteratorError3) {
335
+ throw _iteratorError3;
336
+ }
337
+ }
338
+ }
339
+ } else if (typeof value !== 'undefined') {
340
+ fd.append('params[obj][' + attr + '][]', type);
341
+ fd.append('params[obj][' + attr + '][]', value);
342
+ }
343
+ // special handling for widget pool
344
+ } else if (attr === '_widget_pool') {
345
+ var value = objParams[attr];
346
+ var _iteratorNormalCompletion4 = true;
347
+ var _didIteratorError4 = false;
348
+ var _iteratorError4 = undefined;
349
+
350
+ try {
351
+ for (var _iterator4 = Object.keys(value)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
352
+ var widgetId = _step4.value;
353
+
354
+ var widget = value[widgetId];
355
+ var _iteratorNormalCompletion5 = true;
356
+ var _didIteratorError5 = false;
357
+ var _iteratorError5 = undefined;
358
+
359
+ try {
360
+ for (var _iterator5 = Object.keys(widget)[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
361
+ var widgetAttr = _step5.value;
362
+
363
+ if (widget[widgetAttr].pop) {
364
+ var _widget$widgetAttr = _slicedToArray(widget[widgetAttr], 2);
365
+
366
+ var widgetAttrType = _widget$widgetAttr[0];
367
+ var widgetValue = _widget$widgetAttr[1];
368
+
369
+ // FIXME: Duplication
370
+ if (widgetValue.pop) {
371
+ // multienum / stringlist / widgetlist
372
+ fd.append('params[obj][' + attr + '][' + widgetId + '][' + widgetAttr + '][]', widgetAttrType);
373
+ for (var i = 0; i < widgetValue.length; ++i) {
374
+ fd.append('params[obj][' + attr + '][' + widgetId + '][' + widgetAttr + '][][formdata$workaround][]', widgetValue[i]);
375
+ }
376
+ } else if (scrivito.BinaryUtils.isFile(widgetValue) || scrivito.BinaryUtils.isBlob(widgetValue)) {
377
+ // upload
378
+ fd.append('params[obj][' + attr + '][' + widgetId + '][' + widgetAttr + '][]', widgetAttrType);
379
+ fd.append('params[obj][' + attr + '][' + widgetId + '][' + widgetAttr + '][]', widgetValue);
380
+ } else if (scrivito.BinaryUtils.isBlobWithName(widgetValue)) {
381
+ fd.append('params[obj][' + attr + '][' + widgetId + '][' + widgetAttr + '][]', widgetAttrType);
382
+ fd.append('params[obj][' + attr + '][' + widgetId + '][' + widgetAttr + '][]', widgetValue.blob_to_upload, widgetValue.filename);
383
+ } else if (widgetValue && typeof widgetValue === 'object') {
384
+ // blob/copy rename
385
+ fd.append('params[obj][' + attr + '][' + widgetId + '][' + widgetAttr + '][]', widgetAttrType);
386
+ var _iteratorNormalCompletion6 = true;
387
+ var _didIteratorError6 = false;
388
+ var _iteratorError6 = undefined;
389
+
390
+ try {
391
+ for (var _iterator6 = Object.keys(widgetValue)[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
392
+ var l = _step6.value;
393
+
394
+ fd.append('params[obj][' + attr + '][' + widgetId + '][' + widgetAttr + '][][' + l + ']', widgetValue[l]);
395
+ }
396
+ } catch (err) {
397
+ _didIteratorError6 = true;
398
+ _iteratorError6 = err;
399
+ } finally {
400
+ try {
401
+ if (!_iteratorNormalCompletion6 && _iterator6['return']) {
402
+ _iterator6['return']();
403
+ }
404
+ } finally {
405
+ if (_didIteratorError6) {
406
+ throw _iteratorError6;
407
+ }
408
+ }
409
+ }
410
+ } else {
411
+ // normal value
412
+ fd.append('params[obj][' + attr + '][' + widgetId + '][' + widgetAttr + '][]', widgetAttrType);
413
+ fd.append('params[obj][' + attr + '][' + widgetId + '][' + widgetAttr + '][]', widgetValue);
414
+ }
415
+ } else {
416
+ // hopefully a built-in attribute :-)
417
+ fd.append('params[obj][' + attr + '][' + widgetId + '][' + widgetAttr + ']', widget[widgetAttr]);
418
+ }
419
+ }
420
+ } catch (err) {
421
+ _didIteratorError5 = true;
422
+ _iteratorError5 = err;
423
+ } finally {
424
+ try {
425
+ if (!_iteratorNormalCompletion5 && _iterator5['return']) {
426
+ _iterator5['return']();
427
+ }
428
+ } finally {
429
+ if (_didIteratorError5) {
430
+ throw _iteratorError5;
431
+ }
432
+ }
433
+ }
434
+ }
435
+ } catch (err) {
436
+ _didIteratorError4 = true;
437
+ _iteratorError4 = err;
438
+ } finally {
439
+ try {
440
+ if (!_iteratorNormalCompletion4 && _iterator4['return']) {
441
+ _iterator4['return']();
442
+ }
443
+ } finally {
444
+ if (_didIteratorError4) {
445
+ throw _iteratorError4;
446
+ }
447
+ }
448
+ }
449
+ } else {
450
+ // hopefully a built-in attribute :-)
451
+ fd.append('params[obj][' + attr + ']', objParams[attr]);
452
+ }
453
+ }
454
+ } catch (err) {
455
+ _didIteratorError2 = true;
456
+ _iteratorError2 = err;
457
+ } finally {
458
+ try {
459
+ if (!_iteratorNormalCompletion2 && _iterator2['return']) {
460
+ _iterator2['return']();
461
+ }
462
+ } finally {
463
+ if (_didIteratorError2) {
464
+ throw _iteratorError2;
465
+ }
466
+ }
467
+ }
468
+
469
+ return fd;
470
+ }
471
+
472
+ // -- PATCH ENDS HERE --
473
+
474
+ function handleTask(task) {
475
+ switch (task.status) {
476
+ case 'success':
477
+ return task.result;
478
+ case 'error':
479
+ throw new scrivito.ClientError(task.message, undefined, task.code);
480
+ case 'open':
481
+ return scrivito.wait(2).then(function () {
482
+ return request('GET', 'tasks/' + task.id).then(function (result) {
483
+ return handleTask(result);
484
+ });
485
+ });
486
+ default:
487
+ throw new scrivito.ScrivitoError('Invalid task response (unknown status)');
488
+ }
489
+ }
490
+ })();