浏览代码

HUE-8441 [report] Fix JS error on document picker statement chooser

Enrico Berti 7 年之前
父节点
当前提交
665da0844e
共有 1 个文件被更改,包括 9 次插入7 次删除
  1. 9 7
      desktop/libs/dashboard/src/dashboard/templates/common_search.mako

+ 9 - 7
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -4982,13 +4982,15 @@ $(document).ready(function () {
   huePubSub.subscribe('dashboard.confirm.document', function () {
     $('#addDocumentFacetDemiModal').modal('hide');
     if (selectedWidget != null) {
-      // there's no programmatic way to get the selected index from the Selectize API...
-      var $dropdown = $('.temp-document-statement')[0].selectize.$dropdown_content;
-      if ($dropdown.find('.selected').length > 1) {
-        searchViewModel.tempDocument.selectedStatementId($dropdown.find('.selected.active').index());
-      }
-      else {
-        searchViewModel.tempDocument.selectedStatementId($dropdown.find('.selected').index());
+      if (searchViewModel.tempDocument.parsedStatements().length > 1) {
+        // there's no programmatic way to get the selected index from the Selectize API...
+        var $dropdown = $('.temp-document-statement')[0].selectize.$dropdown_content;
+        if ($dropdown.find('.selected').length > 1) {
+          searchViewModel.tempDocument.selectedStatementId($dropdown.find('.selected.active').index());
+        }
+        else {
+          searchViewModel.tempDocument.selectedStatementId($dropdown.find('.selected').index());
+        }
       }
       searchViewModel.collection.selectedDocument({
         uuid: searchViewModel.tempDocument.uuid(),