test/public/js/buttonActions.js
2024-02-01 11:22:12 +01:00

27 lines
1.3 KiB
JavaScript

function setEditButtonOnClick(editButton, printer) {
editButton.onclick = function () {
document.getElementById('editInputName').value = printer.name;
document.getElementById('editInputPrice').value = printer.price;
document.getElementById('editInputBuildVolume').value = printer.build_volume;
document.getElementById('editInputMaxSpeed').value = printer.max_speed;
document.getElementById('editModalConfirm').setAttribute('onclick', `editPrinter(${printer.id})`);
}
}
function setButtonAttributes(buttonType, modal) {
const button = document.createElement('button');
button.setAttribute('data-bs-target', modal);
button.setAttribute('data-bs-toggle', 'modal');
button.setAttribute('class', `btn ${buttonType}`);
return button;
}
function setViewButtonOnClick(viewButton, printer) {
viewButton.onclick = function () {
document.getElementById('viewModalName').textContent = `Name: ${printer.name}`;
document.getElementById('viewModalPrice').textContent = `Price: ${printer.price.toFixed(2)}$`;
document.getElementById('viewModalBuildVolume').textContent = `Build Volume: ${printer.build_volume}`;
document.getElementById('viewModalMaxSpeed').textContent = `Max Speed: ${printer.max_speed}mm/s`;
}
}