소스 검색

HUE-7040 [oozie] Pressing Esc on share popup throws JS error in Hue4

Enrico Berti 8 년 전
부모
커밋
cb5be91

+ 33 - 27
apps/oozie/src/oozie/templates/editor2/bundle_editor.mako

@@ -298,40 +298,46 @@ ${ utils.submit_popup_event() }
       show: false
     });
     $(window).bind("keydown", "esc", function () {
-      if ($(".demi-modal.fade.in").length > 0) {
-        $(".demi-modal.fade.in .demi-modal-chevron").click();
+      if (window.location.pathname.indexOf('/oozie/editor/bundle') > -1) {
+        if ($(".demi-modal.fade.in").length > 0) {
+          $(".demi-modal.fade.in .demi-modal-chevron").click();
+        }
       }
     });
 
-    $(document).on("click", ".now-link", function(){
-      $(this).parents(".controls").find("input[type='text']").val(moment().format("YYYY-MM-DD[T]HH:mm[Z]"));
+    $(document).on("click", ".now-link", function () {
+      if (window.location.pathname.indexOf('/oozie/editor/bundle') > -1) {
+        $(this).parents(".controls").find("input[type='text']").val(moment().format("YYYY-MM-DD[T]HH:mm[Z]"));
+      }
     });
 
     $(document).on("click", ".calendar-link", function () {
-      var DATE_FORMAT = "YYYY-MM-DD";
-      var _el = $(this).parents(".controls").find("input[type='text']");
-      _el.off("keyup");
-      _el.on("keyup", function () {
+      if (window.location.pathname.indexOf('/oozie/editor/bundle') > -1) {
+        var DATE_FORMAT = "YYYY-MM-DD";
+        var _el = $(this).parents(".controls").find("input[type='text']");
+        _el.off("keyup");
+        _el.on("keyup", function () {
+          _el.data("lastValue", _el.val());
+        });
         _el.data("lastValue", _el.val());
-      });
-      _el.data("lastValue", _el.val());
-      _el.datepicker({
-        format: DATE_FORMAT.toLowerCase()
-      }).on("changeDate", function () {
-        _el.datepicker("hide");
-      }).on("hide", function () {
-        var _val = _el.data("lastValue") ? _el.data("lastValue") : _el.val();
-        if (_val.indexOf("T") == -1) {
-          _el.val(_el.val() + "T00:00Z");
-        }
-        else if (_el.val().indexOf("T") == "-1") {
-          _el.val(_el.val() + "T" + _val.split("T")[1]);
-        }
-      });
-      _el.datepicker('show');
-      huePubSub.subscribeOnce('hide.datepicker', function () {
-        _el.datepicker('hide');
-      });
+        _el.datepicker({
+          format: DATE_FORMAT.toLowerCase()
+        }).on("changeDate", function () {
+          _el.datepicker("hide");
+        }).on("hide", function () {
+          var _val = _el.data("lastValue") ? _el.data("lastValue") : _el.val();
+          if (_val.indexOf("T") == -1) {
+            _el.val(_el.val() + "T00:00Z");
+          }
+          else if (_el.val().indexOf("T") == "-1") {
+            _el.val(_el.val() + "T" + _val.split("T")[1]);
+          }
+        });
+        _el.datepicker('show');
+        huePubSub.subscribeOnce('hide.datepicker', function () {
+          _el.datepicker('hide');
+        });
+      }
     });
 
     huePubSub.subscribe('submit.popup.return', function (data) {

+ 2 - 2
apps/oozie/src/oozie/templates/editor2/coordinator_editor.mako

@@ -148,8 +148,8 @@ ${ scheduler.import_sla_cron(coordinator_json) }
   }
 
   var firstToggled = true;
-  $(document).on("editingToggled", function(){
-    if (firstToggled){
+  $(document).on("editingToggled", function () {
+    if (firstToggled && window.location.pathname.indexOf('/oozie/editor/coordinator') > -1) {
       firstToggled = false;
       viewModel.coordinator.tracker().markCurrentStateAsClean();
     }

+ 29 - 21
apps/oozie/src/oozie/templates/editor2/workflow_editor.mako

@@ -810,33 +810,39 @@ ${ utils.submit_popup_event() }
     renderChangeables();
 
     $(document).on("editingToggled", function () {
-      $("canvas").remove();
-      exposeOverlayClickHandler();
-      if (viewModel.isEditing()) {
-        hueUtils.waitForRendered('#oozie_workflowComponents .card-toolbar-content', function (el) {
-          return el.height() > 40 && el.height() < 200
-        }, function () {
-          renderChangeables();
-        });
-      }
-      else {
-        hueUtils.waitForRendered('#oozie_workflowComponents .card-toolbar-content', function (el) {
-          return !el.is(':visible')
-        }, renderChangeables);
+      if (window.location.pathname.indexOf('/oozie/editor/workflow') > -1) {
+        $("canvas").remove();
+        exposeOverlayClickHandler();
+        if (viewModel.isEditing()) {
+          hueUtils.waitForRendered('#oozie_workflowComponents .card-toolbar-content', function (el) {
+            return el.height() > 40 && el.height() < 200
+          }, function () {
+            renderChangeables();
+          });
+        }
+        else {
+          hueUtils.waitForRendered('#oozie_workflowComponents .card-toolbar-content', function (el) {
+            return !el.is(':visible')
+          }, renderChangeables);
+        }
       }
     });
 
     $(document).on("blur", "[validate]", function() {
-      validateFields();
+      if (window.location.pathname.indexOf('/oozie/editor/workflow') > -1) {
+        validateFields();
+      }
     });
 
     $("#exposeOverlay").on("click", exposeOverlayClickHandler);
 
     $(document).keyup(function(e) {
-      if (e.keyCode == 27) {
-        exposeOverlayClickHandler();
-        addActionDemiModalFieldCancel();
-        $("#addActionDemiModal").modal("hide");
+      if (window.location.pathname.indexOf('/oozie/editor/workflow') > -1) {
+        if (e.keyCode == 27) {
+          exposeOverlayClickHandler();
+          addActionDemiModalFieldCancel();
+          $("#addActionDemiModal").modal("hide");
+        }
       }
     });
 
@@ -862,9 +868,11 @@ ${ utils.submit_popup_event() }
       apiHelper.setInTotalStorage('oozie', 'draggable_section', val);
     });
 
-    $(document).on("click", ".widget-main-section", function(e){
-      if (! $(e.target).is("a") && ! $(e.target).is("input") && ! $(e.target).is("i") && ! $(e.target).is("button")){
-        setLastExpandedWidget(ko.dataFor($(e.target).parents(".card-widget")[0]));
+    $(document).on("click", ".widget-main-section", function (e) {
+      if (window.location.pathname.indexOf('/oozie/editor/workflow') > -1) {
+        if (!$(e.target).is("a") && !$(e.target).is("input") && !$(e.target).is("i") && !$(e.target).is("button")) {
+          setLastExpandedWidget(ko.dataFor($(e.target).parents(".card-widget")[0]));
+        }
       }
     });