ui: selectpicker issue with ipv4v6net after version update - fix for https://github.com/opnsense/core/issues/6849

Handling is a bit different since the latest selectpicker doesn't select the top item in the list anymore, we need to choose an item to make it look less odd.
This commit is contained in:
Ad Schellevis 2023-09-18 20:28:07 +02:00
parent 6d5ca5da1a
commit 445a81d73b

View File

@ -46,7 +46,7 @@ function hook_ipv4v6(classname, data_id, prefixlen)
let val = $(this).val();
if (val.indexOf(":") != -1) {
for (let i = 33; i <= 128; ++i) {
$("#"+selectlist_id+' option[value=' + i + ']').show()
$("#"+selectlist_id+' option[value=' + i + ']').attr('disabled', null);
}
if ((type === undefined && val == '') || type === '4') {
net = prefixlen == undefined ? '64' : prefixlen;
@ -58,12 +58,16 @@ function hook_ipv4v6(classname, data_id, prefixlen)
}
type = '4';
for (let i = 33; i <= 128; ++i) {
$("#"+selectlist_id+' option[value=' + i + ']').hide()
$("#"+selectlist_id+' option[value=' + i + ']').attr('disabled', 'disabled');
}
}
$("#"+selectlist_id).val(net);
$(this).data('ipv4v6', type);
/* when select list uses selectpicker, refresh */
$("#"+selectlist_id).data('hideDisabled', true);
if ($("#"+selectlist_id).val() === null) {
$("#"+selectlist_id).val(type === '6' ? '64' : '24');
}
if ($("#"+selectlist_id).hasClass('selectpicker')) {
$("#"+selectlist_id).selectpicker('refresh');
}