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({ $('#pNestId').select2({
placeholder: 'Select a Nest', placeholder: 'Select a Nest',
}).change(); }).change();
$('#pEggId').select2({ $('#pEggId').select2({
placeholder: 'Select a Nest Egg', placeholder: 'Select a Nest Egg',
}); });
$('#pPackId').select2({ $('#pPackId').select2({
placeholder: 'Select a Service Pack', placeholder: 'Select a Service Pack',
}); });
$('#pNodeId').select2({ $('#pNodeId').select2({
placeholder: 'Select a Node', placeholder: 'Select a Node',
}).change(); }).change();
$('#pAllocation').select2({ $('#pAllocation').select2({
placeholder: 'Select a Default Allocation', placeholder: 'Select a Default Allocation',
}); });
$('#pAllocationAdditional').select2({ $('#pAllocationAdditional').select2({
placeholder: 'Select Additional Allocations', placeholder: 'Select Additional Allocations',
}); });
@ -97,10 +102,8 @@ $('#pNodeId').on('change', function () {
data: v.allocations, data: v.allocations,
placeholder: 'Select a Default Allocation', placeholder: 'Select a Default Allocation',
}); });
$('#pAllocationAdditional').html('').select2({
data: v.allocations, updateAdditionalAllocations();
placeholder: 'Select Additional Allocations',
})
} }
}); });
}); });
@ -154,3 +157,31 @@ $('#pEggId').on('change', function (event) {
$('#appendVariablesTo').append(dataAppend); $('#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',
});
}
});
}