You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2019/12/15 04:47:33 UTC
[sling-org-apache-sling-app-cms] branch SLING-8919-fix-error-dialog
updated: Cleaning up fetch handling in SLING-8919
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
The following commit(s) were added to refs/heads/SLING-8919-fix-error-dialog by this push:
new e615716 Cleaning up fetch handling in SLING-8919
e615716 is described below
commit e6157166db3994648c89e90e69462dce0ab70748
Author: Dan Klco <dk...@apache.org>
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