Selaa lähdekoodia

HUE-3906 [sentry] Offer role name autocomplete by just clicking in name field of add or select role popup

Enrico Berti 9 vuotta sitten
vanhempi
commit
38f2af9b8a

+ 5 - 0
apps/security/src/security/static/security/css/security.css

@@ -323,3 +323,8 @@ h1.emptyMessage {
   margin-right: 6px;
   margin-top: 7px;
 }
+
+.typeahead.dropdown-menu {
+  max-height: 300px;
+  overflow-y: auto;
+}

+ 24 - 15
apps/security/src/security/templates/hive.mako

@@ -705,16 +705,19 @@ ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assi
         show: false
       });
 
-      $("#createRoleModal").on("hidden", function () {
+      $("#createRoleModal").on("show", function () {
+        $(document).trigger("create.typeahead");
+      });
+
+      $("#createRoleModal").on("hide", function () {
         $('#jHueGenericAutocomplete').hide();
         viewModel.resetCreateRole();
       });
 
-      $("#grantPrivilegeModal").on("hidden", function () {
+      $("#grantPrivilegeModal").on("hide", function () {
         viewModel.clearTempRoles();
       });
 
-
       $("#deleteRoleModal").modal({
         show: false
       });
@@ -750,20 +753,26 @@ ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assi
 
       $(document).on("create.typeahead", function(){
         $("#createRoleName").typeahead({
-            source: function (query) {
-              var _options = [];
-              viewModel.selectableRoles().forEach(function(item){
-                if (item.toLowerCase().indexOf(query.toLowerCase()) > -1){
-                  _options.push(item);
-                }
-              });
-              return _options;
-            },
-            'updater': function(item) {
-                return item;
-            }
+          source: function (query) {
+            var _options = [];
+            viewModel.selectableRoles().forEach(function (item) {
+              if (item.toLowerCase().indexOf(query.toLowerCase()) > -1) {
+                _options.push(item);
+              }
+            });
+            return _options;
+          },
+          minLength: 0,
+          'updater': function (item) {
+            return item;
+          }
         });
       });
+      $(document).on('focus', '#createRoleName', function () {
+        if ($("#createRoleName").data('typeahead')){
+          $("#createRoleName").data('typeahead').lookup();
+        }
+      });
       $(document).on("destroy.typeahead", function(){
         $('.typeahead').unbind();
         $("ul.typeahead").hide();

+ 25 - 15
apps/security/src/security/templates/sentry.mako

@@ -747,12 +747,16 @@ ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assi
         show: false
       });
 
-      $("#createRoleModal").on("hidden", function () {
+      $("#createRoleModal").on("show", function () {
+        $(document).trigger("create.typeahead");
+      });
+
+      $("#createRoleModal").on("hide", function () {
         $('#jHueGenericAutocomplete').hide();
         viewModel.resetCreateRole();
       });
 
-      $("#grantPrivilegeModal").on("hidden", function () {
+      $("#grantPrivilegeModal").on("hide", function () {
         viewModel.clearTempRoles();
       });
 
@@ -790,22 +794,28 @@ ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assi
         viewModel.isApplyingBulk(false);
       });
 
-      $(document).on("create.typeahead", function(){
+      $(document).on("create.typeahead", function () {
         $("#createRoleName").typeahead({
-            source: function (query) {
-              var _options = [];
-              viewModel.selectableRoles().forEach(function(item){
-                if (item.toLowerCase().indexOf(query.toLowerCase()) > -1){
-                  _options.push(item);
-                }
-              });
-              return _options;
-            },
-            'updater': function(item) {
-                return item;
-            }
+          source: function (query) {
+            var _options = [];
+            viewModel.selectableRoles().forEach(function (item) {
+              if (item.toLowerCase().indexOf(query.toLowerCase()) > -1) {
+                _options.push(item);
+              }
+            });
+            return _options;
+          },
+          minLength: 0,
+          'updater': function (item) {
+            return item;
+          }
         });
       });
+      $(document).on('focus', '#createRoleName', function () {
+        if ($("#createRoleName").data('typeahead')){
+          $("#createRoleName").data('typeahead').lookup();
+        }
+      });
       $(document).on("destroy.typeahead", function(){
         $('.typeahead').unbind();
         $("ul.typeahead").hide();