Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / quickedit / js / models / EntityModel.js
index cf84a515aa0f93678dec31a6a7455d4fec100580..3c55c6ab417dbe5e0d383000e4d7ef37498039f6 100644 (file)
           break;
 
         case 'committing':
-          var fields = this.get('fields');
+          {
+            var fields = this.get('fields');
 
-          fields.chain().filter(function (fieldModel) {
-            return _.intersection([fieldModel.get('state')], ['active']).length;
-          }).each(function (fieldModel) {
-            fieldModel.set('state', 'candidate');
-          });
+            fields.chain().filter(function (fieldModel) {
+              return _.intersection([fieldModel.get('state')], ['active']).length;
+            }).each(function (fieldModel) {
+              fieldModel.set('state', 'candidate');
+            });
 
-          fields.chain().filter(function (fieldModel) {
-            return _.intersection([fieldModel.get('state')], Drupal.quickedit.app.changedFieldStates).length;
-          }).each(function (fieldModel) {
-            fieldModel.set('state', 'saving');
-          });
-          break;
+            fields.chain().filter(function (fieldModel) {
+              return _.intersection([fieldModel.get('state')], Drupal.quickedit.app.changedFieldStates).length;
+            }).each(function (fieldModel) {
+              fieldModel.set('state', 'saving');
+            });
+            break;
+          }
 
         case 'deactivating':
-          var changedFields = this.get('fields').filter(function (fieldModel) {
-            return _.intersection([fieldModel.get('state')], ['changed', 'invalid']).length;
-          });
-
-          if ((changedFields.length || this.get('fieldsInTempStore').length) && !options.saved && !options.confirmed) {
-            this.set('state', 'opened', { confirming: true });
-
-            _.defer(function () {
-              Drupal.quickedit.app.confirmEntityDeactivation(entityModel);
+          {
+            var changedFields = this.get('fields').filter(function (fieldModel) {
+              return _.intersection([fieldModel.get('state')], ['changed', 'invalid']).length;
             });
-          } else {
-            var invalidFields = this.get('fields').filter(function (fieldModel) {
-              return _.intersection([fieldModel.get('state')], ['invalid']).length;
-            });
-
-            entityModel.set('reload', this.get('fieldsInTempStore').length || invalidFields.length);
 
-            entityModel.get('fields').each(function (fieldModel) {
-              if (_.intersection([fieldModel.get('state')], ['candidate', 'highlighted']).length) {
-                fieldModel.trigger('change:state', fieldModel, fieldModel.get('state'), options);
-              } else {
-                fieldModel.set('state', 'candidate', options);
-              }
-            });
+            if ((changedFields.length || this.get('fieldsInTempStore').length) && !options.saved && !options.confirmed) {
+              this.set('state', 'opened', { confirming: true });
+
+              _.defer(function () {
+                Drupal.quickedit.app.confirmEntityDeactivation(entityModel);
+              });
+            } else {
+              var invalidFields = this.get('fields').filter(function (fieldModel) {
+                return _.intersection([fieldModel.get('state')], ['invalid']).length;
+              });
+
+              entityModel.set('reload', this.get('fieldsInTempStore').length || invalidFields.length);
+
+              entityModel.get('fields').each(function (fieldModel) {
+                if (_.intersection([fieldModel.get('state')], ['candidate', 'highlighted']).length) {
+                  fieldModel.trigger('change:state', fieldModel, fieldModel.get('state'), options);
+                } else {
+                  fieldModel.set('state', 'candidate', options);
+                }
+              });
+            }
+            break;
           }
-          break;
 
         case 'closing':
           options.reason = 'stop';
           break;
 
         case 'committing':
-          if (fieldState === 'invalid') {
-            _.defer(function () {
-              entityModel.set('state', 'opened', { reason: 'invalid' });
-            });
-          } else {
-            this._updateInTempStoreAttributes(entityModel, fieldModel);
-          }
-
-          var options = {
-            'accept-field-states': Drupal.quickedit.app.readyFieldStates
-          };
-          if (entityModel.set('isCommitting', true, options)) {
-            entityModel.save({
-              success: function success() {
-                entityModel.set({
-                  state: 'deactivating',
-                  isCommitting: false
-                }, { saved: true });
-              },
-              error: function error() {
-                entityModel.set('isCommitting', false);
-
-                entityModel.set('state', 'opened', { reason: 'networkerror' });
-
-                var message = Drupal.t('Your changes to <q>@entity-title</q> could not be saved, either due to a website problem or a network connection problem.<br>Please try again.', { '@entity-title': entityModel.get('label') });
-                Drupal.quickedit.util.networkErrorModal(Drupal.t('Network problem!'), message);
-              }
-            });
+          {
+            if (fieldState === 'invalid') {
+              _.defer(function () {
+                entityModel.set('state', 'opened', { reason: 'invalid' });
+              });
+            } else {
+              this._updateInTempStoreAttributes(entityModel, fieldModel);
+            }
+
+            var options = {
+              'accept-field-states': Drupal.quickedit.app.readyFieldStates
+            };
+            if (entityModel.set('isCommitting', true, options)) {
+              entityModel.save({
+                success: function success() {
+                  entityModel.set({
+                    state: 'deactivating',
+                    isCommitting: false
+                  }, { saved: true });
+                },
+                error: function error() {
+                  entityModel.set('isCommitting', false);
+
+                  entityModel.set('state', 'opened', { reason: 'networkerror' });
+
+                  var message = Drupal.t('Your changes to <q>@entity-title</q> could not be saved, either due to a website problem or a network connection problem.<br>Please try again.', { '@entity-title': entityModel.get('label') });
+                  Drupal.quickedit.util.networkErrorModal(Drupal.t('Network problem!'), message);
+                }
+              });
+            }
+            break;
           }
-          break;
 
         case 'deactivating':
           _.defer(function () {