This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch SLING-8919-fix-error-dialog
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git

commit e6157166db3994648c89e90e69462dce0ab70748
Author: Dan Klco <[email protected]>
AuthorDate: Sat Dec 14 23:47:25 2019 -0500

    Cleaning up fetch handling in SLING-8919
---
 ui/src/main/frontend/js/cms.job.js | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/ui/src/main/frontend/js/cms.job.js 
b/ui/src/main/frontend/js/cms.job.js
index 0988e9d..72e4aa4 100644
--- a/ui/src/main/frontend/js/cms.job.js
+++ b/ui/src/main/frontend/js/cms.job.js
@@ -17,26 +17,30 @@
  * under the License.
  */
 /* eslint-env browser, es6 */
-(function (rava) {
+(function (rava, Sling) {
     'use strict';
     
     rava.bind('.job-properties-container', {
         callbacks : {
             created :  function () {
-                var container = this;
-                
document.querySelector(container.dataset.source).addEventListener('change', 
function () {
-                    var sourceSelect = this,
-                        config = this.value;
+                const container = this;
+                
document.querySelector(container.dataset.source).addEventListener('change', 
async function () {
+                    const sourceSelect = this;
+                    const config = this.value;
                     sourceSelect.disabled = true;
                     container.innerHTML = '';
-                    fetch(container.dataset.path + config).then(function 
(response) {
-                        return response.text();
-                    }).then(function (formHtml) {
+                    
+                    const response = await fetch(container.dataset.path + 
config);
+                    if(response.ok){
+                        const formHtml = await response.text();
                         container.innerHTML = formHtml;
                         sourceSelect.disabled = false;
-                    });
+                    } else {
+                        Sling.CMS.ui.confirmMessage(response.status, 
response.statusText, function () {});
+                    }
+                    
                 });
             }
         }
     });
-}(window.rava = window.rava || {}));
\ No newline at end of file
+}(window.rava = window.rava || {}, window.Sling = window.Sling || {}));
\ No newline at end of file

Reply via email to