Merge pull request #399 from jaredevantabor/inventory-source-select2-fix

Removing search field on select2 fields used in inventory sources tab.
This commit is contained in:
jaredevantabor
2015-09-03 11:47:46 -07:00
2 changed files with 22 additions and 18 deletions

View File

@@ -695,25 +695,26 @@ 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++) {

View File

@@ -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 += "<option value=\"\">";
// Add a custom default select 'value' (default text)
html += (field.defaultText) ? field.defaultText : "Choose a " + field.label.toLowerCase();
html += "</option>\n";
if(!field.multiSelect){
html += "<option value=\"\">";
// Add a custom default select 'value' (default text)
html += (field.defaultText) ? field.defaultText : "Choose a " + field.label.toLowerCase();
html += "</option>\n";
}
html += "</select>\n";
// Add error messages
if ((options.mode === 'add' && field.addRequired) || (options.mode === 'edit' && field.editRequired) ||