scrivito_sdk 1.6.0.rc1 → 1.6.0.rc2

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: 2b0e676d1b60bfaefb2cb7f1d834b911fef7a0a0
4
- data.tar.gz: 167e175b7b07e320f9ec8cf3763284cb7b2a20f3
3
+ metadata.gz: a07db261fd27ce4542a3d20b26f3f595d9c6d5cd
4
+ data.tar.gz: f0fc7c93e359eb47f33f615dfe7b367647947be0
5
5
  SHA512:
6
- metadata.gz: 7d9ef307e260bec317b69030c2d6f85ca0d3c6d41d43c53173ec1bf19272d14821de9d63ffc6f120d77ba96cb6fd2796344c0b3b845f4c4a761eedb843dc6d31
7
- data.tar.gz: fc082d95b5b78a3269e5e5ff3c4fc0e7b0abaeacd6d53a7075e705082a193ba1f1328d32575f2aa2a83e467a68da33ad810ab41d248fdead6ec5f277dbe53f53
6
+ metadata.gz: 9c987515511317e614303106d47f6043850a884d5089d22661d8dbbe9f341c6a0817c4956c38fa5ffe4a82a62f9d81b497c989dcd22b4af73e2c6bf94a2414e8
7
+ data.tar.gz: 07959bf736757a1533661e6185695c2bb33dd45146acad7645143b7d236d37e53ba27a23e7f16761c5488bd8228597146ade57d4d9a218c6013897779c272e13
data/README.md CHANGED
@@ -8,7 +8,7 @@ searches, etc. For more information about Scrivito, please visit https://scrivit
8
8
 
9
9
  ## License
10
10
 
11
- Copyright (c) 2009 - 2014 Infopark AG (http://www.infopark.com)
11
+ Copyright (c) 2009 - 2016 Infopark AG (http://www.infopark.com)
12
12
 
13
13
  This software can be used and modified under the LGPL-3.0. Please refer to
14
14
  http://www.gnu.org/licenses/lgpl-3.0.html for the license text.
@@ -1,11 +1,7 @@
1
1
  module Scrivito
2
2
  class ObjsController < WebserviceController
3
3
  around_action :require_selected_workspace_write_authorization, only: [
4
- :destroy,
5
4
  :restore,
6
- :restore_widget,
7
- :revert,
8
- :revert_widget,
9
5
  ]
10
6
 
11
7
  before_filter :require_identical_selected_and_visible_workspace, only: [
@@ -26,41 +22,11 @@ module Scrivito
26
22
  render current_obj.details_view_path, layout: 'scrivito_dialog', formats: :html
27
23
  end
28
24
 
29
- def destroy
30
- in_selected_workspace do
31
- parent = current_obj.parent
32
- @redirect_to = parent ? scrivito_path(parent) : "/"
33
- current_obj.destroy
34
- end
35
- end
36
-
37
- def revert
38
- in_selected_workspace { current_obj.revert }
39
- render_empty_json
40
- end
41
-
42
- def revert_widget
43
- in_selected_workspace { current_widget.revert }
44
- render_empty_json
45
- end
46
-
47
25
  def restore
48
26
  in_selected_workspace { Obj.restore(params[:id]) }
49
27
  render_empty_json
50
28
  end
51
29
 
52
- def restore_widget
53
- in_selected_workspace { current_obj.restore_widget(params[:widget_id]) }
54
- render_empty_json
55
- end
56
-
57
- def binary_no_cache
58
- in_selected_workspace do
59
- binary = current_obj[params[:attribute_name]]
60
- @no_cache_url = binary.no_cache_url
61
- end
62
- end
63
-
64
30
  def transfer_modifications
65
31
  in_selected_workspace do
66
32
  begin
@@ -11,7 +11,11 @@ module Scrivito
11
11
  end
12
12
 
13
13
  def publish_ability
14
- @publish_ability = Scrivito::PublishAbility.new(scrivito_user, params[:obj_id])
14
+ @publish_ability = Scrivito::PublishAbility.new(
15
+ scrivito_user,
16
+ editing_context.selected_workspace,
17
+ params[:obj_id],
18
+ )
15
19
  end
16
20
  end
17
21
  end
@@ -1,20 +1,20 @@
1
1
  ##
2
2
  ## Bundle of CA Root Certificates
3
3
  ##
4
- ## Certificate data from Mozilla as of: Wed Oct 12 11:05:19 2016
4
+ ## Certificate data from Mozilla as of: Wed Nov 9 15:47:06 2016 GMT
5
5
  ##
6
6
  ## This is a bundle of X.509 certificates of public Certificate Authorities
7
7
  ## (CA). These were automatically extracted from Mozilla's root certificates
8
8
  ## file (certdata.txt). This file can be found in the mozilla source tree:
9
- ## http://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
9
+ ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
10
10
  ##
11
11
  ## It contains the certificates in PEM format and therefore
12
12
  ## can be directly used with curl / libcurl / php_curl, or with
13
13
  ## an Apache+mod_ssl webserver for SSL client authentication.
14
14
  ## Just configure this file as the SSLCACertificateFile.
15
15
  ##
16
- ## Conversion done with mk-ca-bundle.pl version 1.25.
17
- ## SHA1: 36aebbcc910dcab8838e6e721523d84f0ed20589
16
+ ## Conversion done with mk-ca-bundle.pl version 1.27.
17
+ ## SHA256: 17e2a90c8a5cfd6a675b3475d3d467e1ab1fe0d5397e907b08206182389caa08
18
18
  ##
19
19
 
20
20
 
@@ -1764,7 +1764,7 @@ AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==
1764
1764
  -----END CERTIFICATE-----
1765
1765
 
1766
1766
  NetLock Arany (Class Gold) Főtanúsítvány
1767
- ============================================
1767
+ ========================================
1768
1768
  -----BEGIN CERTIFICATE-----
1769
1769
  MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
1770
1770
  A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
@@ -2280,7 +2280,7 @@ Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
2280
2280
  -----END CERTIFICATE-----
2281
2281
 
2282
2282
  Certinomis - Autorité Racine
2283
- =============================
2283
+ ============================
2284
2284
  -----BEGIN CERTIFICATE-----
2285
2285
  MIIFnDCCA4SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJGUjETMBEGA1UEChMK
2286
2286
  Q2VydGlub21pczEXMBUGA1UECxMOMDAwMiA0MzM5OTg5MDMxJjAkBgNVBAMMHUNlcnRpbm9taXMg
@@ -3675,7 +3675,7 @@ ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
3675
3675
  -----END CERTIFICATE-----
3676
3676
 
3677
3677
  TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H5
3678
- =========================================================
3678
+ ====================================================
3679
3679
  -----BEGIN CERTIFICATE-----
3680
3680
  MIIEJzCCAw+gAwIBAgIHAI4X/iQggTANBgkqhkiG9w0BAQsFADCBsTELMAkGA1UEBhMCVFIxDzAN
3681
3681
  BgNVBAcMBkFua2FyYTFNMEsGA1UECgxEVMOcUktUUlVTVCBCaWxnaSDEsGxldGnFn2ltIHZlIEJp
@@ -3699,7 +3699,7 @@ B59OTj+RdPsnnRHM3eaxynFNExc5JsUpISuTKWqW+qtB4Uu2NQvAmxU=
3699
3699
  -----END CERTIFICATE-----
3700
3700
 
3701
3701
  TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H6
3702
- =========================================================
3702
+ ====================================================
3703
3703
  -----BEGIN CERTIFICATE-----
3704
3704
  MIIEJjCCAw6gAwIBAgIGfaHyZeyKMA0GCSqGSIb3DQEBCwUAMIGxMQswCQYDVQQGEwJUUjEPMA0G
3705
3705
  A1UEBwwGQW5rYXJhMU0wSwYDVQQKDERUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUgQmls
@@ -4034,3 +4034,33 @@ BgNVHSMEGDAWgBRHd8MUi2I5DMlv4VBN0BBY3JWIbTAKBggqhkjOPQQDAwNpADBmAjEAj6jcnboM
4034
4034
  BBf6Fek9LykBl7+BFjNAk2z8+e2AcG+qj9uEwov1NcoG3GRvaBbhj5G5AjEA2Euly8LQCGzpGPta
4035
4035
  3U1fJAuwACEl74+nBCZx4nxp5V2a+EEfOzmTk51V6s2N8fvB
4036
4036
  -----END CERTIFICATE-----
4037
+
4038
+ ISRG Root X1
4039
+ ============
4040
+ -----BEGIN CERTIFICATE-----
4041
+ MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
4042
+ BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
4043
+ EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
4044
+ EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
4045
+ DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
4046
+ Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
4047
+ 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
4048
+ b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
4049
+ Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
4050
+ 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
4051
+ 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
4052
+ hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
4053
+ usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
4054
+ OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
4055
+ A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
4056
+ 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
4057
+ ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
4058
+ 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
4059
+ hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
4060
+ TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
4061
+ e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
4062
+ JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
4063
+ YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
4064
+ JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
4065
+ m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
4066
+ -----END CERTIFICATE-----
@@ -9,7 +9,7 @@ Scrivito::SdkEngine.routes.draw do
9
9
  scope '__scrivito', module: 'scrivito' do
10
10
  get ':id', to: 'cms_dispatch#index', as: :base_id, constraints: {id: /\h{16}/}
11
11
 
12
- resources :objs, controller: 'objs', only: [:show, :destroy], defaults: {format: :json} do
12
+ resources :objs, controller: 'objs', only: [:show], defaults: {format: :json} do
13
13
  collection do
14
14
  get :page_class_selection
15
15
  get :search
@@ -19,12 +19,8 @@ Scrivito::SdkEngine.routes.draw do
19
19
  get :widget
20
20
  get :widget_class_selection
21
21
  get :widget_modification
22
- get :binary_no_cache
23
22
 
24
- put :revert
25
23
  put :restore
26
- put :revert_widget
27
- put :restore_widget
28
24
  put :transfer_modifications
29
25
  end
30
26
  end
@@ -11985,6 +11985,8 @@ module.exports = ret;
11985
11985
  }.call(this));
11986
11986
 
11987
11987
 
11988
+ //
11989
+
11988
11990
  //
11989
11991
 
11990
11992
  "use strict";
@@ -12137,10 +12139,10 @@ if (!window.scrivito) {
12137
12139
  "use strict";
12138
12140
 
12139
12141
  (function () {
12140
- var CONVERT_TO_CAMELCASE = /_(\w)/g;
12142
+ var CONVERT_TO_CAMELCASE = /(_+)(\w)/g;
12141
12143
  var CONVERT_TO_UNDERSCORE = /([A-Z])/g;
12142
12144
 
12143
- var TEST_CAMEL_CASE = /^_?[^_]+$/;
12145
+ var TEST_CAMEL_CASE = /^_?(_+[A-Z0-9]|[^_])+$/;
12144
12146
  var TEST_UNDERSCORE = /^[a-z0-9_]+$/;
12145
12147
 
12146
12148
  scrivito.attributeInflection = {
@@ -12159,11 +12161,305 @@ if (!window.scrivito) {
12159
12161
  },
12160
12162
 
12161
12163
  camelCase: function camelCase(name) {
12162
- return name.replace(CONVERT_TO_CAMELCASE, function (match, group, index) {
12163
- return index ? group.toUpperCase() : match;
12164
+ return name.replace(CONVERT_TO_CAMELCASE, function (match, underscores, nextChar, index) {
12165
+ if (!index) {
12166
+ return match;
12167
+ }
12168
+ if (nextChar.toUpperCase() === nextChar) {
12169
+ return match;
12170
+ }
12171
+
12172
+ return "" + underscores.substr(1) + nextChar.toUpperCase();
12173
+ });
12174
+ }
12175
+ };
12176
+ })();
12177
+ 'use strict';
12178
+
12179
+ 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'); } }; })();
12180
+
12181
+ (function () {
12182
+ scrivito.AttributeSerializer = {
12183
+ serialize: function serialize(attributes) {
12184
+ var serializedAttributes = {};
12185
+ _.each(attributes, function (_ref, name) {
12186
+ var _ref2 = _slicedToArray(_ref, 2);
12187
+
12188
+ var value = _ref2[0];
12189
+ var attrInfo = _ref2[1];
12190
+
12191
+ var serializedName = convertCamelCasedAttributeName(name);
12192
+ if (scrivito.Attribute.isSystemAttribute(serializedName)) {
12193
+ serializedAttributes[serializedName] = value;
12194
+ } else {
12195
+ var _attrInfo = _slicedToArray(attrInfo, 2);
12196
+
12197
+ var attrType = _attrInfo[0];
12198
+ var attrOptions = _attrInfo[1];
12199
+
12200
+ serializedAttributes[serializedName] = [serializeAttributeType(attrType, name), valueOrNull(serializeAttributeValue(attrType, attrOptions, value, name))];
12201
+ }
12164
12202
  });
12203
+
12204
+ return serializedAttributes;
12165
12205
  }
12166
12206
  };
12207
+
12208
+ function convertCamelCasedAttributeName(name) {
12209
+ if (!scrivito.attributeInflection.isCamelCase(name)) {
12210
+ throw new scrivito.ArgumentError('Attribute names have to be in camel case.');
12211
+ }
12212
+
12213
+ return scrivito.attributeInflection.underscore(name);
12214
+ }
12215
+
12216
+ function serializeAttributeType(type, name) {
12217
+ switch (type) {
12218
+ case 'enum':
12219
+ return 'string';
12220
+ case 'float':
12221
+ case 'integer':
12222
+ return 'number';
12223
+ case 'multienum':
12224
+ return 'stringlist';
12225
+ case 'binary':
12226
+ case 'date':
12227
+ case 'html':
12228
+ case 'link':
12229
+ case 'linklist':
12230
+ case 'reference':
12231
+ case 'referencelist':
12232
+ case 'string':
12233
+ case 'stringlist':
12234
+ case 'widgetlist':
12235
+ return type;
12236
+ default:
12237
+ throw new scrivito.ArgumentError('Attribute "' + name + '" is of unsupported type "' + type + '".');
12238
+ }
12239
+ }
12240
+
12241
+ function serializeAttributeValue(type, options, value, name) {
12242
+ if (value === null) {
12243
+ return value;
12244
+ }
12245
+
12246
+ switch (type) {
12247
+ case 'binary':
12248
+ return serializeBinaryAttributeValue(value, name);
12249
+ case 'date':
12250
+ return serializeDateAttributeValue(value, name);
12251
+ case 'enum':
12252
+ return serializeEnumAttributeValue(options, value, name);
12253
+ case 'float':
12254
+ return serializeFloatAttributeValue(value, name);
12255
+ case 'html':
12256
+ return serializeHtmlAttributeValue(value, name);
12257
+ case 'integer':
12258
+ return serializeIntegerAttributeValue(value, name);
12259
+ case 'link':
12260
+ return serializeLinkAttributeValue(value, name);
12261
+ case 'linklist':
12262
+ return serializeLinklistAttributeValue(value, name);
12263
+ case 'multienum':
12264
+ return serializeMultienumAttributeValue(options, value, name);
12265
+ case 'reference':
12266
+ return serializeReferenceAttributeValue(value, name);
12267
+ case 'referencelist':
12268
+ return serializeReferencelistAttributeValue(value, name);
12269
+ case 'string':
12270
+ return serializeStringAttributeValue(value, name);
12271
+ case 'stringlist':
12272
+ return serializeStringlistAttributeValue(value, name);
12273
+ case 'widgetlist':
12274
+ return serializeWidgetlistAttributeValue(value, name);
12275
+ default:
12276
+ throw new scrivito.InternalError('serializeAttributeValue is not implemented for "' + type + '".');
12277
+ }
12278
+ }
12279
+
12280
+ function valueOrNull(value) {
12281
+ if ((_.isString(value) || _.isArray(value)) && _.isEmpty(value)) {
12282
+ return null;
12283
+ }
12284
+ return value;
12285
+ }
12286
+
12287
+ function throwInvalidAttributeValue(value, name, expected) {
12288
+ throw new scrivito.ArgumentError('Unexpected value ' + scrivito.prettyPrint(value) + ' for' + (' attribute "' + name + '". Expected: ' + expected));
12289
+ }
12290
+
12291
+ function serializeBinaryAttributeValue(value, name) {
12292
+ if (value instanceof scrivito.Binary) {
12293
+ return { id: value.id };
12294
+ }
12295
+ throwInvalidAttributeValue(value, name, 'A Binary.');
12296
+ }
12297
+
12298
+ function serializeDateAttributeValue(value, name) {
12299
+ if (_.isDate(value)) {
12300
+ return scrivito.types.formatDateToString(value);
12301
+ }
12302
+ if (scrivito.types.isValidDateString(value)) {
12303
+ return value;
12304
+ }
12305
+ throwInvalidAttributeValue(value, name, 'A Date.');
12306
+ }
12307
+
12308
+ function serializeEnumAttributeValue(_ref3, value, name) {
12309
+ var validValues = _ref3.validValues;
12310
+
12311
+ if (_.contains(validValues, value)) {
12312
+ return value;
12313
+ }
12314
+
12315
+ var e = 'Valid attribute values are contained in its "validValues" array [' + validValues + '].';
12316
+ throwInvalidAttributeValue(value, name, e);
12317
+ }
12318
+
12319
+ function serializeFloatAttributeValue(value, name) {
12320
+ if (scrivito.types.isValidFloat(value)) {
12321
+ return value;
12322
+ }
12323
+
12324
+ var invalidValue = value;
12325
+ if (_.isNumber(value)) {
12326
+ invalidValue = String(value);
12327
+ }
12328
+ throwInvalidAttributeValue(invalidValue, name, 'A Number, that is #isFinite().');
12329
+ }
12330
+
12331
+ function serializeHtmlAttributeValue(value, name) {
12332
+ if (_.isString(value)) {
12333
+ return value;
12334
+ }
12335
+ throwInvalidAttributeValue(value, name, 'A String.');
12336
+ }
12337
+
12338
+ function serializeIntegerAttributeValue(value, name) {
12339
+ if (scrivito.types.isValidInteger(value)) {
12340
+ return value;
12341
+ }
12342
+ throwInvalidAttributeValue(value, name, 'A Number, that is #isSafeInteger().');
12343
+ }
12344
+
12345
+ function serializeLinkAttributeValue(value, name) {
12346
+ if (validLinkObject(value)) {
12347
+ return convertLinkToCmsApi(value);
12348
+ }
12349
+ throwInvalidAttributeValue(value, name, 'A Link instance.');
12350
+ }
12351
+
12352
+ function serializeLinklistAttributeValue(value, name) {
12353
+ if (_.isArray(value) && _.every(value, validLinkObject)) {
12354
+ return _.map(value, convertLinkToCmsApi);
12355
+ }
12356
+ throwInvalidAttributeValue(value, name, 'An array of Link instances.');
12357
+ }
12358
+
12359
+ function validLinkObject(value) {
12360
+ if (value instanceof scrivito.BasicLink) {
12361
+ return true;
12362
+ }
12363
+
12364
+ // check if value is backend compatible
12365
+ if (!_.isObject(value)) {
12366
+ return false;
12367
+ }
12368
+ var invalidKeys = _.without(_.keys(value), 'fragment', 'obj_id', 'query', 'target', 'title', 'url');
12369
+ return _.isEmpty(invalidKeys);
12370
+ }
12371
+
12372
+ function convertLinkToCmsApi(value) {
12373
+ var backendLink = {
12374
+ fragment: value.fragment,
12375
+ query: value.query,
12376
+ target: value.target,
12377
+ title: value.title,
12378
+ url: value.url
12379
+ };
12380
+ backendLink.obj_id = value.objId || value.obj_id;
12381
+
12382
+ return _.mapObject(backendLink, function (v) {
12383
+ return v || null;
12384
+ });
12385
+ }
12386
+
12387
+ function serializeMultienumAttributeValue(_ref4, value, name) {
12388
+ var validValues = _ref4.validValues;
12389
+
12390
+ var errorMessage = 'An array with values from ' + scrivito.prettyPrint(validValues) + '.';
12391
+
12392
+ if (!_.isArray(value) || !_.every(value, _.isString)) {
12393
+ throwInvalidAttributeValue(value, name, errorMessage);
12394
+ }
12395
+
12396
+ var forbiddenValues = _.difference(value, validValues);
12397
+ if (forbiddenValues.length) {
12398
+ var e = errorMessage + ' Forbidden values: ' + scrivito.prettyPrint(forbiddenValues) + '.';
12399
+ throwInvalidAttributeValue(value, name, e);
12400
+ }
12401
+ return value;
12402
+ }
12403
+
12404
+ function serializeReferenceAttributeValue(value, name) {
12405
+ if (isValidReference(value)) {
12406
+ return serializeSingleReferenceValue(value);
12407
+ }
12408
+ throwInvalidAttributeValue(value, name, 'A BasicObj or a String ID.');
12409
+ }
12410
+
12411
+ function serializeReferencelistAttributeValue(value, name) {
12412
+ if (isValidReferencelistValue(value)) {
12413
+ return _.map(value, serializeSingleReferenceValue);
12414
+ }
12415
+ throwInvalidAttributeValue(value, name, 'An array with BasicObjs or String IDs.');
12416
+ }
12417
+
12418
+ function serializeSingleReferenceValue(value) {
12419
+ if (value instanceof scrivito.BasicObj) {
12420
+ return value.id;
12421
+ }
12422
+ return value;
12423
+ }
12424
+
12425
+ function isValidReference(value) {
12426
+ return _.isString(value) || value instanceof scrivito.BasicObj;
12427
+ }
12428
+
12429
+ function isValidReferencelistValue(value) {
12430
+ return _.isArray(value) && _.every(value, function (v) {
12431
+ return isValidReference(v);
12432
+ });
12433
+ }
12434
+
12435
+ function serializeStringAttributeValue(value, name) {
12436
+ if (isValidString(value)) {
12437
+ return value.toString();
12438
+ }
12439
+ throwInvalidAttributeValue(value, name, 'A String.');
12440
+ }
12441
+
12442
+ function serializeStringlistAttributeValue(value, name) {
12443
+ if (_.isArray(value) && _.every(value, function (v) {
12444
+ return isValidString(v);
12445
+ })) {
12446
+ return _.invoke(value, 'toString');
12447
+ }
12448
+ throwInvalidAttributeValue(value, name, 'An array of strings.');
12449
+ }
12450
+
12451
+ function isValidString(value) {
12452
+ return _.isString(value) || _.isNumber(value);
12453
+ }
12454
+
12455
+ function serializeWidgetlistAttributeValue(value, name) {
12456
+ if (_.isArray(value) && _.every(value, function (v) {
12457
+ return v instanceof scrivito.BasicWidget;
12458
+ })) {
12459
+ return _.pluck(value, 'id');
12460
+ }
12461
+ throwInvalidAttributeValue(value, name, 'An array of scrivito.BasicWidget instances.');
12462
+ }
12167
12463
  })();
12168
12464
  "use strict";
12169
12465
 
@@ -12239,6 +12535,43 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
12239
12535
  })();
12240
12536
  "use strict";
12241
12537
 
12538
+ (function () {
12539
+ var bufferedUpdates = [];
12540
+
12541
+ var isUpdateScheduled = function isUpdateScheduled() {
12542
+ return bufferedUpdates.length;
12543
+ };
12544
+
12545
+ function add(callback) {
12546
+ if (!isUpdateScheduled()) {
12547
+ scrivito.nextTick(function () {
12548
+ scrivito.modelState.withBatchedUpdates(function () {
12549
+ return performUpdate(bufferedUpdates);
12550
+ });
12551
+ });
12552
+ }
12553
+
12554
+ bufferedUpdates.push(callback);
12555
+ }
12556
+
12557
+ function performUpdate(callbacks) {
12558
+ bufferedUpdates = [];
12559
+
12560
+ try {
12561
+ callbacks.forEach(function (callback) {
12562
+ return callback();
12563
+ });
12564
+ } finally {
12565
+ if (isUpdateScheduled()) {
12566
+ performUpdate(bufferedUpdates);
12567
+ }
12568
+ }
12569
+ }
12570
+
12571
+ scrivito.batchedStateUpdater = { add: add };
12572
+ })();
12573
+ "use strict";
12574
+
12242
12575
  (function () {
12243
12576
  scrivito.BinaryUtils = {
12244
12577
  isBlob: function isBlob(obj) {
@@ -12713,42 +13046,6 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
12713
13046
  return NetworkError;
12714
13047
  })(scrivito.CommunicationError);
12715
13048
 
12716
- /**
12717
- * A `NotLoadedError` is thrown when data is accessed in a synchronous fashion but is not yet
12718
- * available locally. For example {@link scrivito.BasicObj.get} throws a `NotLoadedError`
12719
- * whenever a CMS object is accessed that is not yet cached in the browser.
12720
- */
12721
- scrivito.NotLoadedError = (function (_scrivito$ScrivitoError5) {
12722
- _inherits(NotLoadedError, _scrivito$ScrivitoError5);
12723
-
12724
- /**
12725
- * The constructor is not part of the public API and should **not** be used.
12726
- */
12727
-
12728
- function NotLoadedError(loader) {
12729
- _classCallCheck(this, NotLoadedError);
12730
-
12731
- _get(Object.getPrototypeOf(NotLoadedError.prototype), 'constructor', this).call(this, 'Data is not yet loaded. Call the instance method "load" to load data.');
12732
- this._loader = loader;
12733
- }
12734
-
12735
- _createClass(NotLoadedError, [{
12736
- key: 'load',
12737
- value: function load(onLoadingDone) {
12738
- var loadPromise = this._loader();
12739
-
12740
- if (onLoadingDone) {
12741
- var done = function done() {
12742
- scrivito.nextTick(onLoadingDone);
12743
- };
12744
- loadPromise.then(done, done);
12745
- }
12746
- }
12747
- }]);
12748
-
12749
- return NotLoadedError;
12750
- })(scrivito.ScrivitoError);
12751
-
12752
13049
  /**
12753
13050
  * An error thrown in case a backend request from the UI
12754
13051
  * exceeds the rate limit of the backend.
@@ -12772,8 +13069,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
12772
13069
  /**
12773
13070
  * An error thrown in case a given Scrivito resource is not found.
12774
13071
  */
12775
- scrivito.ResourceNotFoundError = (function (_scrivito$ScrivitoError6) {
12776
- _inherits(ResourceNotFoundError, _scrivito$ScrivitoError6);
13072
+ scrivito.ResourceNotFoundError = (function (_scrivito$ScrivitoError5) {
13073
+ _inherits(ResourceNotFoundError, _scrivito$ScrivitoError5);
12777
13074
 
12778
13075
  /**
12779
13076
  * The constructor is not part of the public API and should **not** be used.
@@ -12833,6 +13130,87 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
12833
13130
  })();
12834
13131
  'use strict';
12835
13132
 
13133
+ 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; }; })();
13134
+
13135
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
13136
+
13137
+ (function () {
13138
+ var VALID_OPTIONS = ['limit', 'includeObjs'];
13139
+
13140
+ var FacetQuery = (function () {
13141
+ function FacetQuery(attribute, options, searchQuery) {
13142
+ var _this = this;
13143
+
13144
+ _classCallCheck(this, FacetQuery);
13145
+
13146
+ assertValidOptions(options);
13147
+
13148
+ this._requestParams = buildRequestParams(attribute, options, searchQuery);
13149
+
13150
+ var subStateKey = scrivito.computeCacheKey(this._requestParams);
13151
+ var modelState = scrivito.modelState.subState('facetQuery').subState(subStateKey);
13152
+
13153
+ this._loadableData = new scrivito.LoadableData({
13154
+ state: modelState,
13155
+ loader: function loader() {
13156
+ return _this._loadData();
13157
+ }
13158
+ });
13159
+ }
13160
+
13161
+ _createClass(FacetQuery, [{
13162
+ key: 'result',
13163
+ value: function result() {
13164
+ var firstFacetResult = _.first(this._loadableData.get().facets);
13165
+
13166
+ return _.map(firstFacetResult, function (rawFacetValue) {
13167
+ var name = rawFacetValue.value;
13168
+ var count = rawFacetValue.total;
13169
+ var includedObjs = _.pluck(rawFacetValue.results, 'id');
13170
+
13171
+ return new scrivito.BasicObjFacetValue(name, count, includedObjs);
13172
+ });
13173
+ }
13174
+ }, {
13175
+ key: '_loadData',
13176
+ value: function _loadData() {
13177
+ var workspaceId = scrivito.currentWorkspaceId();
13178
+ return scrivito.CmsRestApi.get('workspaces/' + workspaceId + '/objs/search', this._requestParams);
13179
+ }
13180
+ }]);
13181
+
13182
+ return FacetQuery;
13183
+ })();
13184
+
13185
+ function assertValidOptions(options) {
13186
+ var _ref;
13187
+
13188
+ var invalidOptions = (_ref = _).without.apply(_ref, [_.keys(options)].concat(VALID_OPTIONS));
13189
+ if (invalidOptions.length) {
13190
+ throw new scrivito.ArgumentError('Invalid options: ' + (scrivito.prettyPrint(invalidOptions) + '. Valid options: ' + VALID_OPTIONS));
13191
+ }
13192
+ }
13193
+
13194
+ function buildRequestParams(attribute, options, searchQuery) {
13195
+ var requestParams = {
13196
+ facets: [{
13197
+ attribute: attribute,
13198
+ limit: options.limit || 20,
13199
+ include_objs: options.includeObjs || 0
13200
+ }],
13201
+ size: 0
13202
+ };
13203
+ if (searchQuery && searchQuery.length) {
13204
+ requestParams.query = searchQuery;
13205
+ }
13206
+
13207
+ return requestParams;
13208
+ }
13209
+
13210
+ scrivito.FacetQuery = FacetQuery;
13211
+ })();
13212
+ 'use strict';
13213
+
12836
13214
  (function () {
12837
13215
  var isDisabled = false;
12838
13216
  var connectionCounter = 0;
@@ -12888,7 +13266,14 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
12888
13266
  connectionCounter -= 1;
12889
13267
 
12890
13268
  if (request.status >= 200 && request.status < 300) {
12891
- return resolve(request.response);
13269
+ var responseJSON = request.response;
13270
+
13271
+ if (_.isString(responseJSON)) {
13272
+ // We can't use #response here as IE11 does not handle it correctly
13273
+ responseJSON = JSON.parse(request.responseText);
13274
+ }
13275
+
13276
+ return resolve(responseJSON);
12892
13277
  }
12893
13278
 
12894
13279
  return reject(request.response);
@@ -12957,7 +13342,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
12957
13342
  try {
12958
13343
  resolve(loadableFunction());
12959
13344
  } catch (error) {
12960
- if (error instanceof scrivito.NotLoadedError) {
13345
+ if (scrivito.isNotLoadedError(error)) {
12961
13346
  error.load(tryToSettle);
12962
13347
  } else {
12963
13348
  reject(error);
@@ -13091,7 +13476,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
13091
13476
  }, {
13092
13477
  key: 'setError',
13093
13478
  value: function setError(error) {
13094
- if (error instanceof scrivito.NotLoadedError) {
13479
+ if (scrivito.isNotLoadedError(error)) {
13095
13480
  // prevent setting a NotLoadedError, since that would
13096
13481
  // unravel the space-time continuum and destroy the world.
13097
13482
  var warning = new scrivito.InternalError('tried to set a Loadable to a NotLoadedError');
@@ -13168,13 +13553,29 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
13168
13553
 
13169
13554
  var versionWhenLoadingStarted = this._currentVersion();
13170
13555
 
13171
- this._loader().then(function (result) {
13556
+ var pushCallbacks = [];
13557
+ var addPushCallback = function addPushCallback(callback) {
13558
+ return pushCallbacks.push(callback);
13559
+ };
13560
+ var runPushCallbacks = function runPushCallbacks() {
13561
+ return pushCallbacks.forEach(function (callback) {
13562
+ return callback();
13563
+ });
13564
+ };
13565
+
13566
+ this._loader(addPushCallback).then(function (result) {
13172
13567
  return ifUnchanged(function () {
13173
- return _this2._value.transitionTo(AVAILABLE, result, versionWhenLoadingStarted);
13568
+ return scrivito.batchedStateUpdater.add(function () {
13569
+ _this2._value.transitionTo(AVAILABLE, result, versionWhenLoadingStarted);
13570
+ runPushCallbacks();
13571
+ });
13174
13572
  });
13175
13573
  }, function (error) {
13176
13574
  return ifUnchanged(function () {
13177
- return _this2._value.transitionTo(ERROR, error, versionWhenLoadingStarted);
13575
+ return scrivito.batchedStateUpdater.add(function () {
13576
+ _this2._value.transitionTo(ERROR, error, versionWhenLoadingStarted);
13577
+ runPushCallbacks();
13578
+ });
13178
13579
  });
13179
13580
  });
13180
13581
 
@@ -13248,6 +13649,8 @@ var _createClass = (function () { function defineProperties(target, props) { for
13248
13649
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
13249
13650
 
13250
13651
  (function () {
13652
+ var loadingState = {};
13653
+
13251
13654
  var EMPTY_STATE = {};
13252
13655
 
13253
13656
  // A wrapper around a value that is retrieved asynchronously.
@@ -13259,7 +13662,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
13259
13662
  // * it does not use Promises
13260
13663
 
13261
13664
  var LoadableValue = (function () {
13262
- // stateContainer is where the LoadableValue should store its state.
13665
+ _createClass(LoadableValue, null, [{
13666
+ key: 'resetLoadingState',
13667
+ value: function resetLoadingState() {
13668
+ loadingState = {};
13669
+ }
13670
+
13671
+ // stateContainer is where the LoadableValue should store its state.
13672
+ }]);
13263
13673
 
13264
13674
  function LoadableValue(stateContainer) {
13265
13675
  _classCallCheck(this, LoadableValue);
@@ -13268,6 +13678,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
13268
13678
  throw new scrivito.InternalError('LoadableValue needs stateContainer');
13269
13679
  }
13270
13680
  this._container = stateContainer;
13681
+ this._id = stateContainer.id();
13271
13682
  }
13272
13683
 
13273
13684
  // export
@@ -13280,14 +13691,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
13280
13691
  _createClass(LoadableValue, [{
13281
13692
  key: 'setLoading',
13282
13693
  value: function setLoading(loadId) {
13283
- this._container.set(_.extend({}, this._getState(), { loadId: loadId }));
13694
+ loadingState[this._id] = loadId;
13284
13695
  }
13285
13696
 
13286
13697
  // return the current loadId. should only be called if loading.
13287
13698
  }, {
13288
13699
  key: 'getLoading',
13289
13700
  value: function getLoading() {
13290
- return this._getState().loadId;
13701
+ return loadingState[this._id];
13291
13702
  }
13292
13703
  }, {
13293
13704
  key: 'subscribe',
@@ -13312,6 +13723,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
13312
13723
  }, {
13313
13724
  key: 'transitionTo',
13314
13725
  value: function transitionTo(status, value, version) {
13726
+ delete loadingState[this._id];
13315
13727
  this._container.set({ status: status, value: value, version: version });
13316
13728
  }
13317
13729
  }, {
@@ -13337,7 +13749,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
13337
13749
  try {
13338
13750
  results.push(iteratee(item));
13339
13751
  } catch (error) {
13340
- if (error instanceof scrivito.NotLoadedError) {
13752
+ if (scrivito.isNotLoadedError(error)) {
13341
13753
  errors.push(error);
13342
13754
  } else {
13343
13755
  throw error;
@@ -13367,22 +13779,87 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
13367
13779
  })();
13368
13780
  'use strict';
13369
13781
 
13370
- var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
13371
-
13372
13782
  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; }; })();
13373
13783
 
13374
- function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
13784
+ var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
13375
13785
 
13376
13786
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
13377
13787
 
13378
- (function () {
13379
- var VALID_KEYS = ['attributes', 'extend', 'name'];
13788
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
13380
13789
 
13381
- var Schema = (function () {
13382
- function Schema(definition, parent) {
13383
- _classCallCheck(this, Schema);
13790
+ (function () {
13791
+ /**
13792
+ * A `NotLoadedError` is thrown when data is accessed in a synchronous fashion but is not yet
13793
+ * available locally. For example {@link scrivito.BasicObj.get} throws a `NotLoadedError`
13794
+ * whenever a CMS object is accessed that is not yet cached in the browser.
13795
+ */
13384
13796
 
13385
- ensureDefinitionIsValid(definition);
13797
+ var NotLoadedError = (function (_scrivito$ScrivitoError) {
13798
+ _inherits(NotLoadedError, _scrivito$ScrivitoError);
13799
+
13800
+ /**
13801
+ * The constructor is not part of the public API and should **not** be used.
13802
+ */
13803
+
13804
+ function NotLoadedError(loader) {
13805
+ _classCallCheck(this, NotLoadedError);
13806
+
13807
+ _get(Object.getPrototypeOf(NotLoadedError.prototype), 'constructor', this).call(this, 'Data is not yet loaded.');
13808
+ this._loader = loader;
13809
+ }
13810
+
13811
+ _createClass(NotLoadedError, [{
13812
+ key: 'load',
13813
+ value: function load(onLoadingDone) {
13814
+ var loadPromise = this._loader();
13815
+
13816
+ if (onLoadingDone) {
13817
+ var done = function done() {
13818
+ scrivito.nextTick(onLoadingDone);
13819
+ };
13820
+ loadPromise.then(done, done);
13821
+ }
13822
+ }
13823
+
13824
+ // this getter has an extravagant name, in order to avoid name clashes
13825
+ }, {
13826
+ key: 'scrivitoPrivateIsNotLoadedError',
13827
+ get: function get() {
13828
+ return true;
13829
+ }
13830
+ }]);
13831
+
13832
+ return NotLoadedError;
13833
+ })(scrivito.ScrivitoError);
13834
+
13835
+ function isNotLoadedError(error) {
13836
+ // using duck-typing instead of "instanceof", so that these errors
13837
+ // can be recognized across javascript (iframe) boundaries.
13838
+ return error.scrivitoPrivateIsNotLoadedError;
13839
+ }
13840
+
13841
+ // export
13842
+ scrivito.NotLoadedError = NotLoadedError;
13843
+ scrivito.isNotLoadedError = isNotLoadedError;
13844
+ })();
13845
+ 'use strict';
13846
+
13847
+ var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
13848
+
13849
+ 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; }; })();
13850
+
13851
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
13852
+
13853
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
13854
+
13855
+ (function () {
13856
+ var VALID_KEYS = ['attributes', 'extend', 'name'];
13857
+
13858
+ var Schema = (function () {
13859
+ function Schema(definition, parent) {
13860
+ _classCallCheck(this, Schema);
13861
+
13862
+ ensureDefinitionIsValid(definition);
13386
13863
 
13387
13864
  if (parent._scrivitoPrivateSchema) {
13388
13865
  definition.attributes = _.extend({}, parent._scrivitoPrivateSchema.attributes, definition.attributes);
@@ -14154,6 +14631,11 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
14154
14631
  value: function fetch(_id) {
14155
14632
  scrivito.asyncMethodStub();
14156
14633
  }
14634
+ }, {
14635
+ key: 'fetchIncludingDeleted',
14636
+ value: function fetchIncludingDeleted(_id) {
14637
+ scrivito.asyncMethodStub();
14638
+ }
14157
14639
  }, {
14158
14640
  key: 'get',
14159
14641
  value: function get(idOrList) {
@@ -14479,7 +14961,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
14479
14961
  key: 'lastChanged',
14480
14962
  get: function get() {
14481
14963
  if (this._current._last_changed) {
14482
- return scrivito.parseDate(this._current._last_changed);
14964
+ return scrivito.types.parseStringToDate(this._current._last_changed);
14483
14965
  }
14484
14966
 
14485
14967
  return null;
@@ -14522,8 +15004,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
14522
15004
  key: 'children',
14523
15005
  get: function get() {
14524
15006
  if (this.path) {
14525
- var iterator = scrivito.BasicObj.where('_parent_path', 'equals', this.path).iterator();
14526
- return scrivito.iterable.collectValuesFromIterator(iterator);
15007
+ var iterable = scrivito.BasicObj.all().and('_parent_path', 'equals', this.path);
15008
+ return scrivito.iterable.collectValuesFromIterator(iterable.iterator());
14527
15009
  }
14528
15010
 
14529
15011
  return [];
@@ -14583,7 +15065,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
14583
15065
  })(scrivito.BasicAttributeContent);
14584
15066
 
14585
15067
  scrivito.provideAsyncClassMethods(scrivito.BasicObj, {
14586
- get: 'fetch'
15068
+ get: 'fetch',
15069
+ getIncludingDeleted: 'fetchIncludingDeleted'
14587
15070
  });
14588
15071
 
14589
15072
  scrivito.provideAsyncInstanceMethods(scrivito.BasicObj, {
@@ -14660,6 +15143,44 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
14660
15143
  throw new scrivito.ResourceNotFoundError('Obj with id "' + id + '" not found.');
14661
15144
  }
14662
15145
  })();
15146
+ "use strict";
15147
+
15148
+ 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; }; })();
15149
+
15150
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15151
+
15152
+ (function () {
15153
+ var BasicObjFacetValue = (function () {
15154
+ function BasicObjFacetValue(name, count, includedObjs) {
15155
+ _classCallCheck(this, BasicObjFacetValue);
15156
+
15157
+ this._name = name;
15158
+ this._count = count;
15159
+ this._includedObjs = includedObjs;
15160
+ }
15161
+
15162
+ _createClass(BasicObjFacetValue, [{
15163
+ key: "includedObjs",
15164
+ value: function includedObjs() {
15165
+ return scrivito.BasicObj.get(this._includedObjs);
15166
+ }
15167
+ }, {
15168
+ key: "name",
15169
+ get: function get() {
15170
+ return this._name;
15171
+ }
15172
+ }, {
15173
+ key: "count",
15174
+ get: function get() {
15175
+ return this._count;
15176
+ }
15177
+ }]);
15178
+
15179
+ return BasicObjFacetValue;
15180
+ })();
15181
+
15182
+ scrivito.BasicObjFacetValue = BasicObjFacetValue;
15183
+ })();
14663
15184
  'use strict';
14664
15185
 
14665
15186
  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; }; })();
@@ -14806,6 +15327,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
14806
15327
  value: function getBatchSize() {
14807
15328
  return this._batchSize;
14808
15329
  }
15330
+ }, {
15331
+ key: 'facet',
15332
+ value: function facet(attribute) {
15333
+ var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
15334
+
15335
+ var facetQuery = new scrivito.FacetQuery(attribute, options, this._query);
15336
+ return facetQuery.result();
15337
+ }
14809
15338
  }, {
14810
15339
  key: 'params',
14811
15340
  get: function get() {
@@ -15704,6 +16233,77 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
15704
16233
  });
15705
16234
  }
15706
16235
  })();
16236
+ "use strict";
16237
+
16238
+ 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; }; })();
16239
+
16240
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16241
+
16242
+ (function () {
16243
+ /**
16244
+ * Instances of this class represent the result of a faceted search.
16245
+ */
16246
+
16247
+ var ObjFacetValue = (function () {
16248
+ function ObjFacetValue(registry, basicObjFacetValue) {
16249
+ _classCallCheck(this, ObjFacetValue);
16250
+
16251
+ this._registry = registry;
16252
+ this._basicObjFacetValue = basicObjFacetValue;
16253
+ }
16254
+
16255
+ /**
16256
+ * The name of this ObjFacetValue, i.e. the value of the attribute.
16257
+ *
16258
+ * Example: If you do faceting using the attribute `color`,
16259
+ * you might receive an `ObjFacetValue` with the name `yellow`,
16260
+ * another one with the name `green` and so on.
16261
+ *
16262
+ * @type {String}
16263
+ */
16264
+
16265
+ _createClass(ObjFacetValue, [{
16266
+ key: "includedObjs",
16267
+
16268
+ /**
16269
+ * The Objs that were included in this search.
16270
+ *
16271
+ * If you did not specify `includeObjs` in your facet options, an empty array is returned.
16272
+ * The Objs are ordered by relevance.
16273
+ *
16274
+ * @throws {scrivito.NotLoadedError} If some of the data is not yet loaded.
16275
+ * @return {Array<Obj>}
16276
+ */
16277
+ value: function includedObjs() {
16278
+ var response = this._basicObjFacetValue.includedObjs();
16279
+ return scrivito.wrapInAppClass(this._registry, response);
16280
+ }
16281
+ }, {
16282
+ key: "name",
16283
+ get: function get() {
16284
+ return this._basicObjFacetValue.name;
16285
+ }
16286
+
16287
+ /**
16288
+ * Total number of Objs available that have this value.
16289
+ *
16290
+ * Note that this refers to all Objs, not just the Objs included in this search.
16291
+ * Also note that the count is approximate.
16292
+ *
16293
+ * @type {Number}
16294
+ */
16295
+ }, {
16296
+ key: "count",
16297
+ get: function get() {
16298
+ return this._basicObjFacetValue.count;
16299
+ }
16300
+ }]);
16301
+
16302
+ return ObjFacetValue;
16303
+ })();
16304
+
16305
+ scrivito.ObjFacetValue = ObjFacetValue;
16306
+ })();
15707
16307
  'use strict';
15708
16308
 
15709
16309
  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; }; })();
@@ -15725,6 +16325,10 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
15725
16325
  return iterable;
15726
16326
  }
15727
16327
 
16328
+ function wrap(response) {
16329
+ return scrivito.wrapInAppClass(registry, response);
16330
+ }
16331
+
15728
16332
  /**
15729
16333
  * The base class for CMS objects.
15730
16334
  *
@@ -15749,11 +16353,28 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
15749
16353
  }
15750
16354
 
15751
16355
  _createClass(Obj, [{
15752
- key: 'destroy',
16356
+ key: 'isBinary',
16357
+
16358
+ /**
16359
+ * This method indicates whether the Obj represents binary data. Binaries are
16360
+ * handled differently in that they are not rendered using the normal layout
16361
+ * but sent as a file. Examples of binary resources are Images or PDFs.
16362
+ *
16363
+ * Every Obj that has a `blob` attribute of the `binary` type is
16364
+ * considered a binary
16365
+ *
16366
+ * @returns {Boolean} `true` if this Obj represents a binary resource.
16367
+ */
16368
+ value: function isBinary() {
16369
+ var blobTypeInfo = this.constructor._scrivitoPrivateSchema.attributes.blob;
16370
+ return blobTypeInfo === 'binary';
16371
+ }
15753
16372
 
15754
16373
  /**
15755
16374
  * Destroy this CMS object in the current Workspace.
15756
16375
  */
16376
+ }, {
16377
+ key: 'destroy',
15757
16378
  value: function destroy() {
15758
16379
  this._scrivitoPrivateContent.destroy();
15759
16380
  }
@@ -15761,17 +16382,26 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
15761
16382
  /**
15762
16383
  * Access widgets by their ids
15763
16384
  *
16385
+ * Returns `null` if no matching Widget exists.
16386
+ *
15764
16387
  * @param {String} id - the widget's id
15765
- * @returns {scrivito.Widget}
16388
+ * @returns {?Widget}
15766
16389
  */
15767
16390
  }, {
15768
16391
  key: 'widget',
15769
16392
  value: function widget(id) {
15770
- var widget = this._scrivitoPrivateContent.widget(id);
16393
+ return wrap(this._scrivitoPrivateContent.widget(id));
16394
+ }
15771
16395
 
15772
- if (widget) {
15773
- return scrivito.wrapInAppClass(registry, widget);
15774
- }
16396
+ /**
16397
+ * Returns all {@link Widget widgets} of the given CMS object.
16398
+ *
16399
+ * @returns {Widget[]}
16400
+ */
16401
+ }, {
16402
+ key: 'widgets',
16403
+ value: function widgets() {
16404
+ return wrap(this._scrivitoPrivateContent.widgets());
15775
16405
  }
15776
16406
  }, {
15777
16407
  key: 'lastChanged',
@@ -15795,6 +16425,65 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
15795
16425
  return this._scrivitoPrivateContent.path;
15796
16426
  }
15797
16427
 
16428
+ /**
16429
+ * Returns the {@link Obj} that is the parent of this Obj.
16430
+ * Returns `null` if the obj has no `path` or is the root Obj.
16431
+ *
16432
+ * Throws a {@link scrivito.NotLoadedError} if the parent is not yet loaded.
16433
+ *
16434
+ * @type {?Obj}
16435
+ */
16436
+ }, {
16437
+ key: 'parent',
16438
+ get: function get() {
16439
+ return wrap(this._scrivitoPrivateContent.parent);
16440
+ }
16441
+
16442
+ /**
16443
+ * Returns an Array of all the ancestor {@link Obj Objs}, starting at the
16444
+ * root and ending at the parent of this object.
16445
+ *
16446
+ * Throws a {@link scrivito.NotLoadedError} if the ancestors have not yet been loaded.
16447
+ *
16448
+ * @type {Obj[]}
16449
+ */
16450
+ }, {
16451
+ key: 'ancestors',
16452
+ get: function get() {
16453
+ return wrap(this._scrivitoPrivateContent.ancestors);
16454
+ }
16455
+
16456
+ /**
16457
+ * Returns a list of all {@link Obj Objs} that link to this Obj.
16458
+ *
16459
+ * This includes all CMS objects in which at least one `html`,
16460
+ * `link`, `linklist`, `reference` or `referencelist` attribute links to this CMS object.
16461
+ *
16462
+ * Attributes inside {@link Widget Widgets} are considered, too.
16463
+ *
16464
+ * Throws a {@link scrivito.NotLoadedError} if the backlinks have not yet been loaded.
16465
+ *
16466
+ * @type {Obj[]}
16467
+ */
16468
+ }, {
16469
+ key: 'backlinks',
16470
+ get: function get() {
16471
+ return wrap(this._scrivitoPrivateContent.backlinks);
16472
+ }
16473
+
16474
+ /**
16475
+ * Returns a list of all child {@link Obj Objs}.
16476
+ *
16477
+ * Throws a {@link scrivito.NotLoadedError} if the children have not yet been loaded.
16478
+ *
16479
+ * @type {Obj[]}
16480
+ */
16481
+ }, {
16482
+ key: 'children',
16483
+ get: function get() {
16484
+ return wrap(this._scrivitoPrivateContent.children);
16485
+ }
16486
+
15798
16487
  /**
15799
16488
  * The permalink of the CMS object
15800
16489
  * @type {?String}
@@ -15827,6 +16516,34 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
15827
16516
  return scrivito.wrapInAppClass(registry, instance);
15828
16517
  }
15829
16518
 
16519
+ /**
16520
+ * Get a given Obj by its `path`.
16521
+ *
16522
+ * Returns `null` if no matching Obj exists.
16523
+ *
16524
+ * @param {String} path - The path of the Obj
16525
+ * @returns {?Obj}
16526
+ */
16527
+ }, {
16528
+ key: 'getByPath',
16529
+ value: function getByPath(path) {
16530
+ return wrap(scrivito.BasicObj.getByPath(path));
16531
+ }
16532
+
16533
+ /**
16534
+ * Get a given Obj by its `permalink`.
16535
+ *
16536
+ * Returns `null` if no matching Obj exists.
16537
+ *
16538
+ * @param {String} permalink - The permalink of the Obj
16539
+ * @returns {?Obj}
16540
+ */
16541
+ }, {
16542
+ key: 'getByPermalink',
16543
+ value: function getByPermalink(permalink) {
16544
+ return wrap(scrivito.BasicObj.getByPermalink(permalink));
16545
+ }
16546
+
15830
16547
  /**
15831
16548
  * Returns an {@link ObjSearchIterable} of all {@link Obj}s.
15832
16549
  * @return {ObjSearchIterable}
@@ -15893,9 +16610,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
15893
16610
  attributes._objClass = appClassName;
15894
16611
  var attributesWithTypeInfo = scrivito.AttributeContentFactory.prepareAttributes(attributes, schema, appClassName);
15895
16612
 
15896
- var basicObj = scrivito.BasicObj.create(attributesWithTypeInfo);
15897
-
15898
- return scrivito.wrapInAppClass(registry, basicObj);
16613
+ return wrap(scrivito.BasicObj.create(attributesWithTypeInfo));
15899
16614
  }
15900
16615
  }]);
15901
16616
 
@@ -15911,7 +16626,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
15911
16626
 
15912
16627
  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; }; })();
15913
16628
 
15914
- var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
16629
+ var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
15915
16630
 
15916
16631
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15917
16632
 
@@ -15988,7 +16703,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
15988
16703
  *
15989
16704
  * **`starts_with`**
15990
16705
  *
15991
- * The `starts_with` is intended for programmatic comparions of string values.
16706
+ * The `starts_with` is intended for programmatic comparisons of string values.
15992
16707
  *
15993
16708
  * The `starts_with` operator has a precision limit:
15994
16709
  * Only prefixes of up to 20 characters are guaranteed to be matched.
@@ -16234,6 +16949,45 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
16234
16949
  var unwrappedValue = scrivito.unwrapAppClassValues(value);
16235
16950
  return _get(Object.getPrototypeOf(ObjSearchIterable.prototype), "andNot", this).call(this, field, operator, unwrappedValue);
16236
16951
  }
16952
+
16953
+ /**
16954
+ * Perform a faceted search over one attribute to retrieve structured results for
16955
+ * individual values of this attribute.
16956
+ *
16957
+ * Applicable to attributes of the following types: `string`, `stringlist`, `enum` and
16958
+ * `multienum`.
16959
+ *
16960
+ * Please note that there is a precision limit for faceting: Only the first 50 characters
16961
+ * of a string are guaranteed to be considered for faceting. If two string values have the
16962
+ * same first 50 characters, they may be grouped into the same facet value.
16963
+ *
16964
+ * @param {String} attribute The name of an attribute.
16965
+ * @param {Object} [option={}] - The options to facet a request with.
16966
+ * @param {Number} option.limit - The maximum number of unique values to return.
16967
+ * Defaults to `20`.
16968
+ * @param {Number} option.includeObjs - The number of Objs to fetch for each unique value.
16969
+ * Defaults to `0`.
16970
+ *
16971
+ * @throws {scrivito.ArgumentError} If an invalid option is given.
16972
+ * @throws {scrivito.NotLoadedError} If some of the data is not yet loaded.
16973
+ * @throws {scrivito.ClientError} If the maximum number of results has been exceeded.
16974
+ * The number of results is limited to 100 with respect to the facets themselves
16975
+ * and the included Objs.
16976
+ *
16977
+ * @return {Array<scrivito.ObjFacetValue>} A list of unique values that were found for the
16978
+ * given attribute name. The list is ordered by frequency, i.e. values occurring more
16979
+ * frequently come first.
16980
+ */
16981
+ }, {
16982
+ key: "facet",
16983
+ value: function facet(attribute) {
16984
+ var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
16985
+
16986
+ var result = _get(Object.getPrototypeOf(ObjSearchIterable.prototype), "facet", this).call(this, attribute, options);
16987
+ return _.map(result, function (facetValue) {
16988
+ return new scrivito.ObjFacetValue(registry, facetValue);
16989
+ });
16990
+ }
16237
16991
  }]);
16238
16992
 
16239
16993
  return ObjSearchIterable;
@@ -16246,6 +17000,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
16246
17000
  })();
16247
17001
  'use strict';
16248
17002
 
17003
+ 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; }; })();
17004
+
16249
17005
  var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
16250
17006
 
16251
17007
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
@@ -16309,6 +17065,37 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function'
16309
17065
  this._scrivitoPrivateContent = new scrivito.BasicWidget(attributesWithTypeInfo);
16310
17066
  }
16311
17067
 
17068
+ /**
17069
+ * The CMS object the widget is contained in
17070
+ * @type {Obj}
17071
+ */
17072
+
17073
+ _createClass(Widget, [{
17074
+ key: 'copy',
17075
+
17076
+ /**
17077
+ * Create a copy of a {@link Widget}.
17078
+ *
17079
+ * The copy will have all the attributes of the original widget including its widgets.
17080
+ * Its attributes can be accessed only after it has been stored in a `widgetlist` field
17081
+ * of an {@link Obj}, since initially the copy is not stored in such a field.
17082
+ *
17083
+ * @return {Widget} a copy of the widget
17084
+ */
17085
+ value: function copy() {
17086
+ var appClass = registry.widgetClassFor(this.objClass);
17087
+ var basicWidget = this._scrivitoPrivateContent.copy();
17088
+
17089
+ return scrivito.buildAppClassInstance(basicWidget, appClass);
17090
+ }
17091
+ }, {
17092
+ key: 'obj',
17093
+ get: function get() {
17094
+ var basicObj = this._scrivitoPrivateContent.obj;
17095
+ return scrivito.wrapInAppClass(registry, basicObj);
17096
+ }
17097
+ }]);
17098
+
16312
17099
  return Widget;
16313
17100
  })(scrivito.AttributeContentFactory(registry));
16314
17101
 
@@ -16374,9 +17161,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16374
17161
 
16375
17162
  this._loadableData = new scrivito.LoadableData({
16376
17163
  state: state,
16377
- loader: function loader() {
17164
+ loader: function loader(push) {
16378
17165
  return scrivito.ObjRetrieval.retrieveObj(_this._id).then(function (data) {
16379
- scrivito.ObjReplication.get(_this._id).notifyBackendState(data);
17166
+ push(function () {
17167
+ return _this._replication().notifyBackendState(data);
17168
+ });
16380
17169
  return data;
16381
17170
  });
16382
17171
  }
@@ -16566,10 +17355,38 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16566
17355
 
16567
17356
  (function () {
16568
17357
  scrivito.ObjQueryBatch = (function () {
17358
+ _createClass(ObjQueryBatch, null, [{
17359
+ key: "firstBatchFor",
17360
+ value: function firstBatchFor(params, batchSize) {
17361
+ return new ObjQueryBatch(params, batchSize);
17362
+ }
17363
+
17364
+ // the constructor should only be called internally,
17365
+ // i.e. by ObjQueryBatch itself
17366
+ }]);
17367
+
17368
+ function ObjQueryBatch(params, batchSize) {
17369
+ var previousBatch = arguments.length <= 2 || arguments[2] === undefined ? undefined : arguments[2];
17370
+
17371
+ _classCallCheck(this, ObjQueryBatch);
17372
+
17373
+ this._params = params;
17374
+ this._batchSize = batchSize;
17375
+
17376
+ if (previousBatch) {
17377
+ this._index = previousBatch.index + 1;
17378
+ this._continuation = previousBatch.continuationForNextBatch();
17379
+ this._previousBatch = previousBatch;
17380
+ } else {
17381
+ // First batch
17382
+ this._index = 0;
17383
+ }
17384
+ }
17385
+
17386
+ // throws NotLoadedError if not available
17387
+
16569
17388
  _createClass(ObjQueryBatch, [{
16570
17389
  key: "objIds",
16571
-
16572
- // throws NotLoadedError if not available
16573
17390
  value: function objIds() {
16574
17391
  return this._response().results;
16575
17392
  }
@@ -16579,31 +17396,16 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16579
17396
  }, {
16580
17397
  key: "nextBatch",
16581
17398
  value: function nextBatch() {
16582
- var continuation = this._response().continuation;
16583
-
16584
- if (continuation) {
16585
- return new ObjQueryBatch(this._params, this._batchSize, continuation);
17399
+ if (this.continuationForNextBatch()) {
17400
+ return new ObjQueryBatch(this._params, this._batchSize, this);
16586
17401
  }
16587
17402
  }
16588
-
16589
- // the constructor should only be called internally,
16590
- // i.e. by ObjQueryBatch itself
16591
- }], [{
16592
- key: "firstBatchFor",
16593
- value: function firstBatchFor(params, batchSize) {
16594
- return new ObjQueryBatch(params, batchSize);
17403
+ }, {
17404
+ key: "continuationForNextBatch",
17405
+ value: function continuationForNextBatch() {
17406
+ return this._response().continuation;
16595
17407
  }
16596
- }]);
16597
-
16598
- function ObjQueryBatch(params, batchSize, continuation) {
16599
- _classCallCheck(this, ObjQueryBatch);
16600
-
16601
- this._params = params;
16602
- this._continuation = continuation;
16603
- this._batchSize = batchSize;
16604
- }
16605
-
16606
- _createClass(ObjQueryBatch, [{
17408
+ }, {
16607
17409
  key: "_response",
16608
17410
  value: function _response() {
16609
17411
  return this._data().get();
@@ -16613,9 +17415,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16613
17415
  value: function _data() {
16614
17416
  var _this = this;
16615
17417
 
16616
- var paramsWithContinuation = _.extend({}, this._params, { continuation: this._continuation });
16617
-
16618
- var key = scrivito.ObjQueryStore.computeCacheKey(paramsWithContinuation);
17418
+ var paramsWithIndex = _.extend({}, this._params, { index: this._index });
17419
+ var key = scrivito.ObjQueryStore.computeCacheKey(paramsWithIndex);
16619
17420
 
16620
17421
  return new scrivito.LoadableData({
16621
17422
  state: scrivito.ObjQueryStore.stateContainer().subState(key),
@@ -16623,26 +17424,50 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16623
17424
  return _this._load();
16624
17425
  },
16625
17426
  invalidation: function invalidation() {
16626
- return scrivito.ObjReplication.getWorkspaceVersion();
17427
+ return _this._version();
16627
17428
  }
16628
17429
  });
16629
17430
  }
16630
17431
  }, {
16631
17432
  key: "_load",
16632
17433
  value: function _load() {
16633
- var batchSpecificParams = {
16634
- size: this._batchSize,
16635
- continuation: this._continuation
16636
- };
17434
+ var _this2 = this;
16637
17435
 
16638
- var requestParams = _.extend({}, this._params, batchSpecificParams);
17436
+ return this._fetchContinuation().then(function (continuation) {
17437
+ var batchSpecificParams = { size: _this2._batchSize, continuation: continuation };
16639
17438
 
16640
- return scrivito.ObjQueryRetrieval.retrieve(requestParams).then(function (response) {
16641
- preloadObjData(response.results);
17439
+ var requestParams = _.extend({}, _this2._params, batchSpecificParams);
16642
17440
 
16643
- return response;
17441
+ return scrivito.ObjQueryRetrieval.retrieve(requestParams).then(function (response) {
17442
+ preloadObjData(response.results);
17443
+
17444
+ return response;
17445
+ });
16644
17446
  });
16645
17447
  }
17448
+ }, {
17449
+ key: "_fetchContinuation",
17450
+ value: function _fetchContinuation() {
17451
+ var _this3 = this;
17452
+
17453
+ if (this._previousBatch) {
17454
+ return scrivito.loadAsync(function () {
17455
+ return _this3._previousBatch.continuationForNextBatch();
17456
+ });
17457
+ }
17458
+
17459
+ return scrivito.Promise.resolve();
17460
+ }
17461
+ }, {
17462
+ key: "_version",
17463
+ value: function _version() {
17464
+ return this._continuation + "|" + scrivito.ObjReplication.getWorkspaceVersion();
17465
+ }
17466
+ }, {
17467
+ key: "index",
17468
+ get: function get() {
17469
+ return this._index;
17470
+ }
16646
17471
  }]);
16647
17472
 
16648
17473
  return ObjQueryBatch;
@@ -16788,6 +17613,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16788
17613
  }]);
16789
17614
 
16790
17615
  function ObjReplication(id) {
17616
+ var _this = this;
17617
+
16791
17618
  _classCallCheck(this, ObjReplication);
16792
17619
 
16793
17620
  this._id = id;
@@ -16795,6 +17622,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16795
17622
  this._scheduledReplication = false;
16796
17623
  this._currentRequestDeferred = null;
16797
17624
  this._nextRequestDeferred = null;
17625
+ this._performThrottledReplication = scrivito.throttle(function () {
17626
+ return _this._performReplication();
17627
+ }, 1000);
16798
17628
  }
16799
17629
 
16800
17630
  _createClass(ObjReplication, [{
@@ -16858,7 +17688,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16858
17688
  }, {
16859
17689
  key: '_startReplication',
16860
17690
  value: function _startReplication() {
16861
- var _this = this;
17691
+ var _this2 = this;
16862
17692
 
16863
17693
  if (!_.isEmpty(diff(this._backendState, this._localState))) {
16864
17694
  if (!this._replicationActive) {
@@ -16868,7 +17698,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16868
17698
 
16869
17699
  writeStarted(this._currentRequestDeferred.promise);
16870
17700
  scrivito.nextTick(function () {
16871
- return _this._performReplication();
17701
+ return _this2._performThrottledReplication();
16872
17702
  });
16873
17703
  }
16874
17704
  } else {
@@ -16886,7 +17716,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16886
17716
  }, {
16887
17717
  key: '_performReplication',
16888
17718
  value: function _performReplication() {
16889
- var _this2 = this;
17719
+ var _this3 = this;
16890
17720
 
16891
17721
  var localState = this._localState;
16892
17722
  var patch = diff(this._backendState, this._localState);
@@ -16895,16 +17725,16 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16895
17725
  this._replicationActive = true;
16896
17726
 
16897
17727
  this._replicatePatchToBackend(patch).then(function (backendState) {
16898
- _this2._handleBackendUpdate(localState, backendState);
16899
- _this2._currentRequestDeferred.resolve(_this2._id);
16900
- _this2._currentRequestDeferred = null;
16901
- _this2._replicationActive = false;
17728
+ _this3._handleBackendUpdate(localState, backendState);
17729
+ _this3._currentRequestDeferred.resolve(_this3._id);
17730
+ _this3._currentRequestDeferred = null;
17731
+ _this3._replicationActive = false;
16902
17732
 
16903
- _this2._startReplication();
17733
+ _this3._startReplication();
16904
17734
  }, function (error) {
16905
- _this2._currentRequestDeferred.reject(error);
16906
- _this2._currentRequestDeferred = null;
16907
- _this2._replicationActive = false;
17735
+ _this3._currentRequestDeferred.reject(error);
17736
+ _this3._currentRequestDeferred = null;
17737
+ _this3._replicationActive = false;
16908
17738
  });
16909
17739
  }
16910
17740
  }, {
@@ -17532,6 +18362,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
17532
18362
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
17533
18363
 
17534
18364
  (function () {
18365
+ var treeIdCounter = 0;
18366
+
17535
18367
  // abstract interface for managing state
17536
18368
 
17537
18369
  var AbstractStateStore = (function () {
@@ -17557,6 +18389,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
17557
18389
  throw scrivito.InternalError('implement in subclass');
17558
18390
  }
17559
18391
 
18392
+ // get a string that uniquely identifies this state
18393
+ }, {
18394
+ key: 'id',
18395
+ value: function id() {
18396
+ throw scrivito.InternalError('implement in subclass');
18397
+ }
18398
+
17560
18399
  // subscribe to changes to state
17561
18400
  // the listener will be called at least once after each state change.
17562
18401
  // returns a function that should be invoked to unsubscribe.
@@ -17623,7 +18462,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
17623
18462
  _classCallCheck(this, StateTree);
17624
18463
 
17625
18464
  _get(Object.getPrototypeOf(StateTree.prototype), 'constructor', this).call(this);
18465
+ this._id = (treeIdCounter++).toString();
17626
18466
  this._listeners = Immutable.Set();
18467
+ this._batchUpdates = false;
17627
18468
  }
17628
18469
 
17629
18470
  // a node of a state tree.
@@ -17639,9 +18480,17 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
17639
18480
  key: 'set',
17640
18481
  value: function set(newState) {
17641
18482
  this._state = newState;
17642
- this._listeners.forEach(function (listener) {
17643
- return listener();
17644
- });
18483
+
18484
+ if (!this._batchUpdates) {
18485
+ this._listeners.forEach(function (listener) {
18486
+ return listener();
18487
+ });
18488
+ }
18489
+ }
18490
+ }, {
18491
+ key: 'id',
18492
+ value: function id() {
18493
+ return this._id;
17645
18494
  }
17646
18495
  }, {
17647
18496
  key: 'subscribe',
@@ -17658,6 +18507,27 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
17658
18507
  _this._listeners = _this._listeners.remove(listener);
17659
18508
  };
17660
18509
  }
18510
+ }, {
18511
+ key: 'withBatchedUpdates',
18512
+ value: function withBatchedUpdates(fn) {
18513
+ if (this._batchUpdates) {
18514
+ throw new scrivito.InternalError('#withBatchedUpdates can not be nested');
18515
+ }
18516
+
18517
+ var stateBeforeBatchUpdate = this._state;
18518
+
18519
+ try {
18520
+ this._batchUpdates = true;
18521
+ fn();
18522
+ } finally {
18523
+ this._batchUpdates = false;
18524
+ if (stateBeforeBatchUpdate !== this._state) {
18525
+ this._listeners.forEach(function (listener) {
18526
+ return listener();
18527
+ });
18528
+ }
18529
+ }
18530
+ }
17661
18531
 
17662
18532
  // For test purpose only.
17663
18533
  }, {
@@ -17705,6 +18575,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
17705
18575
  value: function set(newState) {
17706
18576
  this._parentState.setSubState(this._key, newState);
17707
18577
  }
18578
+ }, {
18579
+ key: 'id',
18580
+ value: function id() {
18581
+ // first convert backslash to double-backslash
18582
+ // then convert slash to backslash-slash
18583
+ var escapedKey = this._key.replace(/\\/g, '\\\\').replace(/\//g, '\\/');
18584
+
18585
+ return this._parentState.id() + '/' + escapedKey;
18586
+ }
17708
18587
  }, {
17709
18588
  key: 'subscribe',
17710
18589
  value: function subscribe(listener) {
@@ -17735,6 +18614,22 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
17735
18614
  // singleton instance, to be used by the data layer
17736
18615
  scrivito.modelState = new StateTree();
17737
18616
  })();
18617
+ "use strict";
18618
+
18619
+ (function () {
18620
+ var shouldBypassThrottle = false;
18621
+
18622
+ function throttle(fn, ms, options) {
18623
+ return shouldBypassThrottle ? fn : _.throttle(fn, ms, options);
18624
+ }
18625
+
18626
+ function bypassThrottle() {
18627
+ shouldBypassThrottle = true;
18628
+ }
18629
+
18630
+ scrivito.throttle = throttle;
18631
+ scrivito.bypassThrottle = bypassThrottle;
18632
+ })();
17738
18633
  'use strict';
17739
18634
 
17740
18635
  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'); } }; })();
@@ -17817,7 +18712,7 @@ var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr =
17817
18712
  throw new scrivito.InternalError("The value is not a valid ISO date time: \"" + value + "\"");
17818
18713
  }
17819
18714
 
17820
- return scrivito.parseDate(value);
18715
+ return scrivito.types.parseStringToDate(value);
17821
18716
  },
17822
18717
 
17823
18718
  parseStringToDate: function parseStringToDate(dateString) {
@@ -17918,4 +18813,480 @@ var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr =
17918
18813
 
17919
18814
  scrivito.wrapInAppClass = wrapInAppClass;
17920
18815
  scrivito.unwrapAppClassValues = unwrapAppClassValues;
18816
+ scrivito.buildAppClassInstance = buildAppClassInstance;
18817
+ })();
18818
+ "use strict";
18819
+
18820
+ (function () {
18821
+ scrivito.React = {};
18822
+ })();
18823
+ 'use strict';
18824
+
18825
+ (function () {
18826
+ var PropTypes = {
18827
+ oneOfRealmType: function oneOfRealmType() {
18828
+ for (var _len = arguments.length, typeNames = Array(_len), _key = 0; _key < _len; _key++) {
18829
+ typeNames[_key] = arguments[_key];
18830
+ }
18831
+
18832
+ return function (props, propName, componentName) {
18833
+ var propValue = props[propName];
18834
+ var realm = scrivito.currentRealm();
18835
+
18836
+ if (!_.any(typeNames, function (name) {
18837
+ return propValue instanceof (realm[name] || scrivito[name]);
18838
+ })) {
18839
+ return new scrivito.ArgumentError('Component "' + componentName + '" received prop "' + propName + '"' + (' with invalid value "' + propValue + '".') + (' Valid are instances of ' + formatRealmTypes(typeNames) + '.'));
18840
+ }
18841
+ };
18842
+ }
18843
+ };
18844
+
18845
+ function formatRealmTypes(typeNames) {
18846
+ return _.map(typeNames, function (typeName) {
18847
+ return '"scrivito.' + typeName + '"';
18848
+ }).join(', ');
18849
+ }
18850
+
18851
+ scrivito.PropTypes = PropTypes;
18852
+ })();
18853
+ (function () {
18854
+ function createReactClass(params) {
18855
+ var shouldRenderLoader = params.shouldRenderLoader;
18856
+ var render = params.render;
18857
+ var componentDidMount = params.componentDidMount;
18858
+ var componentWillUnmount = params.componentWillUnmount;
18859
+
18860
+ var unsubscribeModelState = undefined;
18861
+
18862
+ return React.createClass(_.extend(params, {
18863
+ componentDidMount: function () {
18864
+ var _this = this;
18865
+
18866
+ unsubscribeModelState = scrivito.modelState.subscribe(function () {
18867
+ if (_this.isMounted()) {
18868
+ _this.forceUpdate();
18869
+ }
18870
+ });
18871
+
18872
+ if (componentDidMount) {
18873
+ componentDidMount.apply(this);
18874
+ }
18875
+ },
18876
+
18877
+ componentWillUnmount: function () {
18878
+ unsubscribeModelState();
18879
+
18880
+ if (componentWillUnmount) {
18881
+ componentWillUnmount.apply(this);
18882
+ }
18883
+ },
18884
+
18885
+ render: function () {
18886
+ var _this2 = this;
18887
+
18888
+ var handleError = function (error) {
18889
+ scrivito.nextTick(function () {
18890
+ throw error;
18891
+ });
18892
+ return shouldRenderLoader ? React.createElement(scrivito.LoaderError, null) : null;
18893
+ };
18894
+
18895
+ try {
18896
+ return scrivito.LoadableData.withEventualConsistency(function () {
18897
+ return render.apply(_this2);
18898
+ });
18899
+ } catch (error) {
18900
+ if (error instanceof scrivito.NotLoadedError) {
18901
+ try {
18902
+ error.load();
18903
+ } catch (error) {
18904
+ return handleError(error);
18905
+ }
18906
+
18907
+ if (this.renderWhileLoading) {
18908
+ return this.renderWhileLoading();
18909
+ }
18910
+
18911
+ return shouldRenderLoader ? React.createElement(scrivito.Loader, null) : null;
18912
+ }
18913
+
18914
+ return handleError(error);
18915
+ }
18916
+ }
18917
+ }));
18918
+ }
18919
+
18920
+ scrivito.createReactClass = createReactClass;
18921
+ })();
18922
+ "use strict";
18923
+
18924
+ (function () {
18925
+ function changeLocation(newLocation) {
18926
+ window.location = newLocation;
18927
+ }
18928
+
18929
+ // For test purpose only.
18930
+ scrivito.changeLocation = changeLocation;
18931
+ })();
18932
+ "use strict";
18933
+
18934
+ (function () {
18935
+ var registry = {};
18936
+
18937
+ var componentRegistry = {
18938
+ provideComponentClass: function provideComponentClass(appClass, componentClass) {
18939
+ registry[appClass._scrivitoPrivateSchema.name] = componentClass;
18940
+ },
18941
+
18942
+ getComponentClass: function getComponentClass(appClass) {
18943
+ return registry[appClass._scrivitoPrivateSchema.name];
18944
+ },
18945
+
18946
+ // For test purpose only.
18947
+ clear: function clear() {
18948
+ registry = {};
18949
+ }
18950
+ };
18951
+
18952
+ scrivito.componentRegistry = componentRegistry;
18953
+ })();
18954
+ (function () {
18955
+ var Content = scrivito.createReactClass({
18956
+ displayName: 'scrivito.React.Content',
18957
+
18958
+ propTypes: {
18959
+ content: scrivito.PropTypes.oneOfRealmType('Obj', 'Widget'),
18960
+
18961
+ attribute: function (props, propName, componentName) {
18962
+ var validationError = React.PropTypes.string.isRequired(props, propName, componentName);
18963
+
18964
+ if (validationError) {
18965
+ return validationError;
18966
+ }
18967
+
18968
+ var attributeName = props[propName];
18969
+
18970
+ if (/^_/.test(attributeName)) {
18971
+ return new scrivito.ArgumentError('Component "scrivito.React.Content" received prop "attribute" with invalid value: ' + ('"' + attributeName + '" is a system attribute. Only custom attributes are allowed.'));
18972
+ }
18973
+ },
18974
+
18975
+ tag: React.PropTypes.string
18976
+ },
18977
+
18978
+ getDefaultProps: function () {
18979
+ return { tag: 'div' };
18980
+ },
18981
+
18982
+ render: function () {
18983
+ var schema = this.props.content.constructor._scrivitoPrivateSchema;
18984
+
18985
+ var attributeName = this.props.attribute;
18986
+ var attributeType = schema.attributes[attributeName];
18987
+
18988
+ if (!attributeType) {
18989
+ throw new scrivito.ArgumentError('Component "scrivito.React.Content" received prop "attribute" with invalid value: ' + ('Attribute "' + attributeName + '" is not defined for content specified in prop "content".'));
18990
+ }
18991
+
18992
+ var attributeValue = this.props.content.get(attributeName);
18993
+
18994
+ switch (attributeType) {
18995
+ case 'html':
18996
+ return this._renderHtml(attributeValue);
18997
+ case 'string':
18998
+ return this._renderString(attributeValue);
18999
+ case 'widgetlist':
19000
+ return this._renderWidgetlist(attributeValue);
19001
+ }
19002
+
19003
+ return this._renderContent({ children: this.props.children });
19004
+ },
19005
+
19006
+ _renderHtml: function (attributeValue) {
19007
+ if (this.props.children) {
19008
+ return this._renderContent({ children: this.props.children });
19009
+ }
19010
+
19011
+ var props = { dangerouslySetInnerHTML: { __html: attributeValue } };
19012
+ return this._renderContent({ props: props });
19013
+ },
19014
+
19015
+ _renderString: function (attributeValue) {
19016
+ return this._renderContent({ children: this.props.children || attributeValue });
19017
+ },
19018
+
19019
+ _renderWidgetlist: function (attributeValue) {
19020
+ var children = attributeValue.map(function (widget) {
19021
+ return React.createElement(Widget, { key: widget.id, widget: widget });
19022
+ });
19023
+ return this._renderContent({ children: children });
19024
+ },
19025
+
19026
+ _renderContent: function (_ref) {
19027
+ var props = _ref.props;
19028
+ var children = _ref.children;
19029
+
19030
+ return React.createElement(this.props.tag, _.extend(this._customProps(), props), children);
19031
+ },
19032
+
19033
+ _customProps: function () {
19034
+ return _.omit(this.props, 'content', 'attribute', 'tag');
19035
+ }
19036
+ });
19037
+
19038
+ var Widget = scrivito.createReactClass({
19039
+ render: function () {
19040
+ var widget = this.props.widget;
19041
+ var componentClass = scrivito.componentRegistry.getComponentClass(widget.constructor);
19042
+
19043
+ if (!componentClass) {
19044
+ throw new scrivito.ArgumentError('No component registered for widget class "' + widget.objClass + '".');
19045
+ }
19046
+
19047
+ return React.createElement(
19048
+ 'div',
19049
+ null,
19050
+ React.createElement(componentClass, { widget: this.props.widget })
19051
+ );
19052
+ }
19053
+ });
19054
+
19055
+ scrivito.React.Content = Content;
19056
+ })();
19057
+ (function () {
19058
+ var CurrentPage = scrivito.createReactClass({
19059
+ displayName: 'scrivito.React.CurrentPage',
19060
+
19061
+ render: function () {
19062
+ var currentPage = scrivito.currentPage();
19063
+
19064
+ if (!currentPage) {
19065
+ return null;
19066
+ }
19067
+
19068
+ var appClass = currentPage.constructor;
19069
+ var componentClass = scrivito.componentRegistry.getComponentClass(appClass);
19070
+
19071
+ if (!componentClass) {
19072
+ return null;
19073
+ }
19074
+
19075
+ return React.createElement(componentClass, { page: currentPage });
19076
+ }
19077
+ });
19078
+
19079
+ scrivito.React.CurrentPage = CurrentPage;
19080
+ })();
19081
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
19082
+
19083
+ (function () {
19084
+ var Image = scrivito.createReactClass({
19085
+ displayName: 'scrivito.React.Image',
19086
+
19087
+ propTypes: {
19088
+ src: scrivito.PropTypes.oneOfRealmType('Obj', 'Binary'),
19089
+ attribute: React.PropTypes.string
19090
+ },
19091
+
19092
+ getDefaultProps: function () {
19093
+ return { attribute: 'blob' };
19094
+ },
19095
+
19096
+ render: function () {
19097
+ var url = this._binary().url;
19098
+ var htmlOptions = _.omit(this.props, 'src', 'attribute');
19099
+
19100
+ return React.createElement('img', _extends({ src: url }, htmlOptions));
19101
+ },
19102
+
19103
+ _binary: function () {
19104
+ if (this.props.src instanceof scrivito.Binary) {
19105
+ return this.props.src;
19106
+ }
19107
+
19108
+ var schema = this.props.src.constructor._scrivitoPrivateSchema;
19109
+ var attributeType = schema.attributes[this.props.attribute];
19110
+
19111
+ if (!attributeType) {
19112
+ throw new scrivito.ScrivitoError('Component "scrivito.React.Image" received prop "src"' + (' with an instance of "scrivito.Obj" missing attribute "' + this.props.attribute + '".'));
19113
+ }
19114
+
19115
+ if (attributeType === 'reference') {
19116
+ var target = this.props.src.get(this.props.attribute);
19117
+
19118
+ if (target) {
19119
+ return target.get('blob');
19120
+ }
19121
+ }
19122
+
19123
+ if (attributeType === 'binary') {
19124
+ return this.props.src.get(this.props.attribute);
19125
+ }
19126
+
19127
+ throw new scrivito.ScrivitoError('Component "scrivito.React.Image" received prop "src"' + (' with an instance of "scrivito.Obj", whose attribute "' + this.props.attribute + '"') + (' is of invalid type "' + attributeType + '".') + ' Valid attribute types are "binary" and "reference".');
19128
+ }
19129
+ });
19130
+
19131
+ scrivito.React.Image = Image;
19132
+ })();
19133
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
19134
+
19135
+ (function () {
19136
+ var Link = scrivito.createReactClass({
19137
+ displayName: 'scrivito.React.Link',
19138
+
19139
+ propTypes: {
19140
+ to: scrivito.PropTypes.oneOfRealmType('Obj', 'Link')
19141
+ },
19142
+
19143
+ render: function () {
19144
+ var htmlOptions = _.omit(this.props, 'to');
19145
+
19146
+ return React.createElement(
19147
+ 'a',
19148
+ _extends({ href: '#', onClick: this._onClick }, htmlOptions),
19149
+ this.props.children
19150
+ );
19151
+ },
19152
+
19153
+ _onClick: function (e) {
19154
+ e.preventDefault();
19155
+ scrivito.navigateTo(this.props.to);
19156
+ }
19157
+ });
19158
+
19159
+ scrivito.React.Link = Link;
19160
+ })();
19161
+ 'use strict';
19162
+
19163
+ (function () {
19164
+ var state = scrivito.modelState.subState('currentPage');
19165
+
19166
+ function currentPage() {
19167
+ var objId = state.get();
19168
+
19169
+ if (objId) {
19170
+ try {
19171
+ return scrivito.currentRealm().Obj.get(objId);
19172
+ } catch (error) {
19173
+ if (error instanceof scrivito.NotLoadedError) {
19174
+ error.load();
19175
+ return null;
19176
+ }
19177
+
19178
+ throw error;
19179
+ }
19180
+ }
19181
+
19182
+ return null;
19183
+ }
19184
+
19185
+ function navigateTo(target) {
19186
+ if (!target) {
19187
+ throw new scrivito.ArgumentError('Missing target.');
19188
+ }
19189
+
19190
+ if (target instanceof scrivito.currentRealm().Obj) {
19191
+ if (target.isBinary()) {
19192
+ scrivito.changeLocation(target.get('blob').url);
19193
+ } else {
19194
+ state.set(target.id);
19195
+ }
19196
+
19197
+ return;
19198
+ }
19199
+
19200
+ if (target instanceof scrivito.currentRealm().Link) {
19201
+ if (target.isExternal()) {
19202
+ scrivito.changeLocation(target.url);
19203
+ } else {
19204
+ state.set(target.obj.id);
19205
+ }
19206
+
19207
+ return;
19208
+ }
19209
+
19210
+ throw new scrivito.ArgumentError('Target is invalid. Valid targets are instances of "scrivito.Obj" or "scrivito.Link".');
19211
+ }
19212
+
19213
+ scrivito.currentPage = currentPage;
19214
+ scrivito.navigateTo = navigateTo;
19215
+ })();
19216
+ "use strict";
19217
+
19218
+ (function () {
19219
+ var currentRealm = undefined;
19220
+
19221
+ function getCurrentRealm() {
19222
+ return currentRealm || window.scrivito;
19223
+ }
19224
+
19225
+ function setCurrentRealm(realm) {
19226
+ currentRealm = realm;
19227
+ }
19228
+
19229
+ scrivito.currentRealm = getCurrentRealm;
19230
+ scrivito.setCurrentRealm = setCurrentRealm;
19231
+ })();
19232
+ 'use strict';
19233
+
19234
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19235
+
19236
+ (function () {
19237
+ function createComponent(componentSpec) {
19238
+ if (typeof componentSpec === 'function') {
19239
+ return scrivito.createReactClass({
19240
+ render: function render() {
19241
+ return componentSpec(this.props);
19242
+ }
19243
+ });
19244
+ }
19245
+
19246
+ return scrivito.createReactClass(componentSpec);
19247
+ }
19248
+
19249
+ function provideComponent(appClass, componentSpec) {
19250
+ if (componentSpec.propTypes) {
19251
+ throw new scrivito.ArgumentError('Custom props is not allowed when providing a component.');
19252
+ }
19253
+
19254
+ var componentClass = createComponentForAppClass(appClass, componentSpec);
19255
+ scrivito.componentRegistry.provideComponentClass(appClass, componentClass);
19256
+ }
19257
+
19258
+ function createComponentForAppClass(appClass, componentSpec) {
19259
+ var Obj = scrivito.currentRealm().Obj;
19260
+ var Widget = scrivito.currentRealm().Widget;
19261
+
19262
+ var propName = undefined;
19263
+ var propType = undefined;
19264
+
19265
+ if (appClass.prototype instanceof Obj) {
19266
+ propName = 'page';
19267
+ propType = Obj;
19268
+ } else if (appClass.prototype instanceof Widget) {
19269
+ propName = 'widget';
19270
+ propType = Widget;
19271
+ } else {
19272
+ throw new scrivito.ArgumentError(appClass + ' is not a valid application class.');
19273
+ }
19274
+
19275
+ var propTypes = _defineProperty({}, propName, React.PropTypes.instanceOf(propType).isRequired);
19276
+
19277
+ if (typeof componentSpec === 'function') {
19278
+ return scrivito.createReactClass({
19279
+ propTypes: propTypes,
19280
+
19281
+ render: function render() {
19282
+ return componentSpec(this.props[propName]);
19283
+ }
19284
+ });
19285
+ }
19286
+
19287
+ return scrivito.createReactClass(_.extend(componentSpec, { propTypes: propTypes }));
19288
+ }
19289
+
19290
+ scrivito.createComponent = createComponent;
19291
+ scrivito.provideComponent = provideComponent;
17921
19292
  })();