1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add select2-bootstrap for consistent widget styling

This commit is contained in:
Jeremy Stretch
2019-01-23 10:18:44 -05:00
parent 14695037da
commit 4227c6b806
3 changed files with 17 additions and 7 deletions

View File

@ -99,15 +99,17 @@ $(document).ready(function() {
$('.netbox-select2-color-picker').select2({
allowClear: true,
placeholder: "---------",
theme: "bootstrap",
templateResult: colorPickerClassCopy,
templateSelection: colorPickerClassCopy,
})
templateSelection: colorPickerClassCopy
});
// Static choice selection
$('.netbox-select2-static').select2({
allowClear: true,
placeholder: "---------",
})
theme: "bootstrap"
});
// API backed selection
// Includes live search and chained fields
@ -115,7 +117,7 @@ $(document).ready(function() {
$('.netbox-select2-api').select2({
allowClear: true,
placeholder: "---------",
theme: "bootstrap",
ajax: {
delay: 500,
@ -162,13 +164,13 @@ $(document).ready(function() {
var conditional = attr.name.split("data-conditional-query-param-")[1].split("__");
var field = $("#id_" + conditional[0]);
var field_value = conditional[1];
if ($('option:selected', field).attr('api-value') === field_value){
var _val = attr.value.split("=");
parameters[_val[0]] = _val[1];
}
}
})
});
// Additional query params
$.each(element.attributes, function(index, attr){
@ -176,7 +178,7 @@ $(document).ready(function() {
var param_name = attr.name.split("data-additional-query-param-")[1]
parameters[param_name] = attr.value;
}
})
});
// This will handle params with multiple values (i.e. for list filter forms)
return $.param(parameters, true);