MDL-67827 behat: Pending JS improvements for dialogues
authorAndrew Nicols <andrew@nicols.co.uk>
Fri, 6 Mar 2020 04:27:51 +0000 (12:27 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Fri, 6 Mar 2020 04:59:38 +0000 (12:59 +0800)
enrol/manual/amd/build/quickenrolment.min.js
enrol/manual/amd/build/quickenrolment.min.js.map
enrol/manual/amd/src/quickenrolment.js
lib/amd/build/modal.min.js
lib/amd/build/modal.min.js.map
lib/amd/build/modal_factory.min.js
lib/amd/build/modal_factory.min.js.map
lib/amd/src/modal.js
lib/amd/src/modal_factory.js

index 1ae2fd7..a08ba79 100644 (file)
Binary files a/enrol/manual/amd/build/quickenrolment.min.js and b/enrol/manual/amd/build/quickenrolment.min.js differ
index b408f4b..d8e65c3 100644 (file)
Binary files a/enrol/manual/amd/build/quickenrolment.min.js.map and b/enrol/manual/amd/build/quickenrolment.min.js.map differ
index 980581a..74b9e21 100644 (file)
@@ -28,8 +28,9 @@ define(['core/templates',
          'core/modal_factory',
          'core/modal_events',
          'core/fragment',
+         'core/pending',
        ],
-       function(Template, $, Str, Config, Notification, ModalFactory, ModalEvents, Fragment) {
+       function(Template, $, Str, Config, Notification, ModalFactory, ModalEvents, Fragment, Pending) {
 
     /** @type {Object} The list of selectors for the quick enrolment modal. */
     var SELECTORS = {
@@ -91,6 +92,7 @@ define(['core/templates',
             });
 
             modal.getRoot().on(ModalEvents.shown, function() {
+                var pendingPromise = new Pending('enrol_manual/quickenrolment:initModal:shown');
                 var bodyPromise = this.getBody();
                 bodyPromise.then(function(html) {
                     var stringIndex = $(html).find(SELECTORS.COHORTSELECT).length ? 0 : 1;
@@ -98,7 +100,8 @@ define(['core/templates',
 
                     return;
                 })
-                .fail(Notification.exception);
+                .then(pendingPromise.resolve)
+                .catch(Notification.exception);
 
                 modal.setBody(bodyPromise);
             }.bind(this));
index e54631a..3269e6e 100644 (file)
Binary files a/lib/amd/build/modal.min.js and b/lib/amd/build/modal.min.js differ
index 0a501e5..5b24706 100644 (file)
Binary files a/lib/amd/build/modal.min.js.map and b/lib/amd/build/modal.min.js.map differ
index f38a752..2fa4d54 100644 (file)
Binary files a/lib/amd/build/modal_factory.min.js and b/lib/amd/build/modal_factory.min.js differ
index 32561b5..ff93873 100644 (file)
Binary files a/lib/amd/build/modal_factory.min.js.map and b/lib/amd/build/modal_factory.min.js.map differ
index 16469ae..aeefaed 100644 (file)
@@ -32,7 +32,8 @@ define([
     'core/event',
     'core/modal_events',
     'core/local/aria/focuslock',
-], function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents, FocusLock) {
+    'core/pending',
+], function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents, FocusLock, Pending) {
 
     var SELECTORS = {
         CONTAINER: '[data-region="modal-container"]',
@@ -615,6 +616,8 @@ define([
             return;
         }
 
+        var pendingPromise = new Pending('core/modal:show');
+
         if (this.hasFooterContent()) {
             this.showFooter();
         } else {
@@ -625,7 +628,8 @@ define([
             this.attachToDOM();
         }
 
-        this.getBackdrop().done(function(backdrop) {
+        this.getBackdrop()
+        .then(function(backdrop) {
             var currentIndex = this.calculateZIndex();
             var newIndex = currentIndex + 2;
             var newBackdropIndex = newIndex - 1;
@@ -638,7 +642,10 @@ define([
             this.getModal().focus();
             $('body').addClass('modal-open');
             this.root.trigger(ModalEvents.shown, this);
-        }.bind(this));
+
+            return;
+        }.bind(this))
+        .then(pendingPromise.resolve);
     };
 
     /**
index 4e9381e..2b304bc 100644 (file)
  */
 define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
         'core/modal_save_cancel', 'core/modal_cancel',
-        'core/templates', 'core/notification', 'core/custom_interaction_events'],
+        'core/templates', 'core/notification', 'core/custom_interaction_events',
+        'core/pending'],
     function($, ModalEvents, ModalRegistry, Modal, ModalSaveCancel,
-        ModalCancel, Templates, Notification, CustomEvents) {
+        ModalCancel, Templates, Notification, CustomEvents, Pending) {
 
     // The templates for each type of modal.
     var TEMPLATES = {
@@ -64,6 +65,7 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
         var hasPreShowCallback = (typeof modalConfig.preShowCallback == 'function');
         // Function to handle the trigger element being activated.
         var triggeredCallback = function(e, data) {
+            var pendingPromise = new Pending('core/modal_factory:setUpTrigger:triggeredCallback');
             actualTriggerElement = $(e.currentTarget);
             modalPromise.then(function(modal) {
                 if (hasPreShowCallback) {
@@ -75,7 +77,8 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
                 modal.show();
 
                 return modal;
-            });
+            })
+            .then(pendingPromise.resolve);
             data.originalEvent.preventDefault();
         };