From a5731a5452751c77ef3e3aedbc0bb409a3616400 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Tue, 1 Sep 2015 17:49:23 -0700 Subject: [PATCH 1/3] Removing search field on select2 fields used in inventory sources tab. This also fixes the behavior when the user hits escape while the select2 drop down menu is visible. --- awx/ui/client/src/shared/Utilities.js | 28 ++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/awx/ui/client/src/shared/Utilities.js b/awx/ui/client/src/shared/Utilities.js index d8233a316c..6d05ed7933 100644 --- a/awx/ui/client/src/shared/Utilities.js +++ b/awx/ui/client/src/shared/Utilities.js @@ -695,25 +695,27 @@ angular.module('Utilities', ['RestServices', 'Utilities', 'sanitizeFilter']) options = params.opts; $.fn.select2.amd.require([ - "select2/utils", - "select2/dropdown", - "select2/dropdown/attachContainer", - "select2/dropdown/search", - ], function (Utils, DropdownAdapter, AttachContainer, DropdownSearch) { + 'select2/utils', + 'select2/dropdown', + 'select2/dropdown/search', + 'select2/dropdown/attachContainer', + 'select2/dropdown/closeOnSelect', + 'select2/dropdown/minimumResultsForSearch' + ], function (Utils, Dropdown, Search, AttachContainer, CloseOnSelect, MinimumResultsForSearch) { - var CustomAdapter = Utils.Decorate( - Utils.Decorate( - DropdownAdapter, - DropdownSearch - ), - AttachContainer - ); + var CustomAdapter = + _.reduce([Search, AttachContainer, CloseOnSelect, MinimumResultsForSearch], + function(Adapter, Decorator) { + return Utils.Decorate(Adapter, Decorator); + }, Dropdown); $(element).select2({ dropdownAdapter: CustomAdapter, multiple: 'true', theme: "bootstrap", - width: '100%' + width: '100%', + minimumResultsForSearch: Infinity, + dropdownAdapter: CustomAdapter }); if(options){ for (var d = 0; d < $(element + " option").length; d++) { From b5392316c9ccb852605b92c70618feea014fcca0 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Wed, 2 Sep 2015 10:53:13 -0700 Subject: [PATCH 2/3] removing dropDownAdapter --- awx/ui/client/src/shared/Utilities.js | 1 - 1 file changed, 1 deletion(-) diff --git a/awx/ui/client/src/shared/Utilities.js b/awx/ui/client/src/shared/Utilities.js index 6d05ed7933..d51045be78 100644 --- a/awx/ui/client/src/shared/Utilities.js +++ b/awx/ui/client/src/shared/Utilities.js @@ -710,7 +710,6 @@ angular.module('Utilities', ['RestServices', 'Utilities', 'sanitizeFilter']) }, Dropdown); $(element).select2({ - dropdownAdapter: CustomAdapter, multiple: 'true', theme: "bootstrap", width: '100%', From 8aa9325e43e8fc6e40654e68e6ef40065912ae22 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Thu, 3 Sep 2015 09:35:49 -0700 Subject: [PATCH 3/3] removing "Choose a..." option for select2 fields in form generator --- awx/ui/client/src/shared/form-generator.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index 9c2a9aea69..f0709c63fa 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -1117,15 +1117,18 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += buildId(field, fld, this.form); html += (options.mode === 'edit' && field.editRequired) ? "required " : ""; html += (options.mode === 'add' && field.addRequired) ? "required " : ""; + //used for select2 combo boxes html += (field.multiSelect) ? "multiple " : ""; html += (field.readonly) ? "disabled " : ""; html += (field.awRequiredWhen) ? "data-awrequired-init=\"" + field.awRequiredWhen.init + "\" aw-required-when=\"" + field.awRequiredWhen.variable + "\" " : ""; html += ">\n"; - html += "\n"; + if(!field.multiSelect){ + html += "\n"; + } html += "\n"; // Add error messages if ((options.mode === 'add' && field.addRequired) || (options.mode === 'edit' && field.editRequired) ||