Prevent primary allocation from being an additional allocation at the same time when creating a server

This commit is contained in:
Matthew Penner 2020-04-11 12:35:27 -06:00
parent 25f18dccdc
commit fb96d9468e

View file

@ -21,18 +21,23 @@ $(document).ready(function() {
$('#pNestId').select2({
placeholder: 'Select a Nest',
}).change();
$('#pEggId').select2({
placeholder: 'Select a Nest Egg',
});
$('#pPackId').select2({
placeholder: 'Select a Service Pack',
});
$('#pNodeId').select2({
placeholder: 'Select a Node',
}).change();
$('#pAllocation').select2({
placeholder: 'Select a Default Allocation',
});
$('#pAllocationAdditional').select2({
placeholder: 'Select Additional Allocations',
});
@ -97,10 +102,8 @@ $('#pNodeId').on('change', function () {
data: v.allocations,
placeholder: 'Select a Default Allocation',
});
$('#pAllocationAdditional').html('').select2({
data: v.allocations,
placeholder: 'Select Additional Allocations',
})
updateAdditionalAllocations();
}
});
});
@ -154,3 +157,31 @@ $('#pEggId').on('change', function (event) {
$('#appendVariablesTo').append(dataAppend);
});
});
$('#pAllocation').on('change', function () {
updateAdditionalAllocations();
});
function updateAdditionalAllocations() {
let currentAllocation = $('#pAllocation').val();
let currentNode = $('#pNodeId').val();
$.each(Pterodactyl.nodeData, function (i, v) {
if (v.id == currentNode) {
let allocations = [];
for (let i = 0; i < v.allocations.length; i++) {
const allocation = v.allocations[i];
if (allocation.id != currentAllocation) {
allocations.push(allocation);
}
}
$('#pAllocationAdditional').html('').select2({
data: allocations,
placeholder: 'Select Additional Allocations',
});
}
});
}