Fix new bill search input (#11524)

* Work around select2 in a modal

* Update select2
This commit is contained in:
Tony Murray
2020-05-01 21:49:36 -05:00
committed by GitHub
parent d941fbe91b
commit 5ac05e9221
6 changed files with 24 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@@ -394,7 +394,7 @@ function http_fallback(link) {
return false;
}
function init_select2(selector, type, data, selected, placeholder) {
function init_select2(selector, type, data, selected, placeholder, config) {
var $select = $(selector);
// allow function to be assigned to pass data
@@ -407,7 +407,7 @@ function init_select2(selector, type, data, selected, placeholder) {
data_function = data;
}
$select.select2({
var init = {
theme: "bootstrap",
dropdownAutoWidth : true,
width: "auto",
@@ -418,7 +418,17 @@ function init_select2(selector, type, data, selected, placeholder) {
delay: 150,
data: data_function
}
});
};
// override init values
if (typeof config === 'object') {
const keys = Object.keys(config)
for (const key of keys) {
init[key] = config[key];
}
}
$select.select2(init);
if (selected) {
console.log(selected);

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,11 @@ var ajax = new Array();
function getInterfaceList(sel)
{
var deviceId = sel.options[sel.selectedIndex].value;
document.getElementById('port_id').options.length = 0; // Empty city select box
// Empty city select box
var el = document.getElementById('port_id');
if (el !== null) {
el.options.length = 0;
}
if (deviceId.length>0) {
var index = ajax.length;
ajax[index] = new sack();

View File

@@ -43,7 +43,7 @@ if (Auth::user()->hasGlobalAdmin()) {
<div class="col-sm-8">
<select class="form-control input-sm" id="device" name="device" onchange="getInterfaceList(this)"></select>
<script type="text/javascript">
init_select2('#device', 'device', {}, <?php echo "{id: $port_device_id, text: '" . format_hostname($device) . "'}"; ?>);
init_select2('#device', 'device', {}, <?php echo "{id: $port_device_id, text: '" . format_hostname($device) . "'}"; ?>, '', {dropdownParent: $('#create-bill .modal-content')});
</script>
</div>
</div>

View File

@@ -16,7 +16,7 @@
@else
<link rel="shortcut icon" href="{{ LibreNMS\Config::get('favicon') }}" />
@endif
<link rel="manifest" href="{{ asset('images/manifest.json') }}">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="msapplication-config" content="{{ asset('images/browserconfig.xml') }}">
@@ -79,7 +79,7 @@
});
var ajax_url = "{{ url('/ajax') }}";
</script>
<script src="{{ asset('js/librenms.js?ver=20191025') }}"></script>
<script src="{{ asset('js/librenms.js?ver=20200501') }}"></script>
<script type="text/javascript">
<!-- Begin
function popUp(URL)