Ensure that addons cannot be added in edit on devices that do not have addons

This commit is contained in:
steve-lad 2021-07-30 07:27:31 +02:00
parent 472d73489e
commit d432ff7a05
2 changed files with 23 additions and 6 deletions

View file

@ -287,12 +287,12 @@ $(document).ready(function () {
}); });
}); });
// Form.adddevice // Form.adddevice
$('.hw_select').change(function (e) { $('.hw_select').mouseover(function (e) {
// data-val contains the number of buttons for this type
// data-id contains the max number of addons (1 = 0, 3 = 2)
var type_id = $('#sccp_hw_type').find(':selected').data('id'); var type_id = $('#sccp_hw_type').find(':selected').data('id');
var btn_dev = $('#sccp_hw_type').find(':selected').data('val'); if (type_id == null) {
if (type_id === 1) { var type_id = $('#addonCnt').val();
}
if (type_id == 1) {
if ($('#sccp_hw_addon').val() !== 'NONE') { if ($('#sccp_hw_addon').val() !== 'NONE') {
$('#sccp_hw_addon').val('NONE').change(); $('#sccp_hw_addon').val('NONE').change();
} }
@ -300,9 +300,25 @@ $(document).ready(function () {
} else { } else {
$('#sccp_hw_addon').prop('disabled',false); $('#sccp_hw_addon').prop('disabled',false);
} }
// when edit, btn_dev is undefined as no select, so send btn_dev with page });
$('.hw_select').change(function (e) {
// data-val contains the number of buttons for this type
// data-id contains the max number of addons (1 = 0, 3 = 2)
var type_id = $('#sccp_hw_type').find(':selected').data('id');
var btn_dev = $('#sccp_hw_type').find(':selected').data('val');
// when edit, btn_dev is undefined as no select, so send btn_dev and type_id with page
if (btn_dev == null) { if (btn_dev == null) {
var btn_dev = $('#devButtonCnt').val(); var btn_dev = $('#devButtonCnt').val();
var type_id = $('#addonCnt').val();
}
if (type_id == 1) {
if ($('#sccp_hw_addon').val() !== 'NONE') {
$('#sccp_hw_addon').val('NONE').change();
}
$('#sccp_hw_addon').attr("disabled", "disabled");
} else {
$('#sccp_hw_addon').prop('disabled',false);
} }
var btn_add = $('#sccp_hw_addon').find(':selected').data('val'); var btn_add = $('#sccp_hw_addon').find(':selected').data('val');
// btn_add is empty if none selected // btn_add is empty if none selected

View file

@ -69,6 +69,7 @@ if (!empty($_REQUEST['ru_id'])) {
<input type="hidden" name="Submit" value="Submit"> <input type="hidden" name="Submit" value="Submit">
<input type="hidden" name="buttonscount" id="buttonscount" value="<?php echo $show_buttons;?>"> <input type="hidden" name="buttonscount" id="buttonscount" value="<?php echo $show_buttons;?>">
<input type="hidden" name="devButtonCnt" id="devButtonCnt" value="<?php echo (!empty($db_device['buttons']))?$db_device['buttons']:0;?>"> <input type="hidden" name="devButtonCnt" id="devButtonCnt" value="<?php echo (!empty($db_device['buttons']))?$db_device['buttons']:0;?>">
<input type="hidden" name="addonCnt" id="addonCnt" value="<?php echo (!empty($db_device['dns']))?$db_device['dns']:0;?>">
<div class="section-title" data-for="<?php echo $forminfo[0]['name'];?>"> <div class="section-title" data-for="<?php echo $forminfo[0]['name'];?>">
<h3><i class="fa fa-minus"></i><?php echo _($forminfo[0]['label']) ?></h3> <h3><i class="fa fa-minus"></i><?php echo _($forminfo[0]['label']) ?></h3>
</div> </div>