Add save button above payments table in luz_camara
This commit is contained in:
@@ -103,6 +103,13 @@ endif; ?>
|
||||
<!-- Tabla de Pagos -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body p-0">
|
||||
<?php if (Auth::isCapturist()): ?>
|
||||
<div class="p-3 pb-0 no-print">
|
||||
<button onclick="saveChanges()" id="btnSaveTable" class="btn btn-warning" disabled>
|
||||
<i class="bi bi-save"></i> Guardar Cambios
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover mb-0" id="electricityTable">
|
||||
<thead class="table-dark text-center sticky-top">
|
||||
@@ -428,6 +435,7 @@ endforeach; ?>
|
||||
function updateSaveButton() {
|
||||
const count = Object.keys(pendingChanges).length;
|
||||
const btnTop = document.getElementById('btnSaveTop');
|
||||
const btnTable = document.getElementById('btnSaveTable');
|
||||
const btnBottom = document.getElementById('btnSaveBottom');
|
||||
const badge = document.getElementById('changesBadge');
|
||||
|
||||
@@ -443,6 +451,11 @@ endforeach; ?>
|
||||
}
|
||||
}
|
||||
|
||||
if (btnTable) {
|
||||
btnTable.disabled = count === 0;
|
||||
btnTable.innerHTML = `<i class="bi bi-save"></i> Guardar ${count > 0 ? count + ' ' : ''}Cambios`;
|
||||
}
|
||||
|
||||
if (btnBottom) {
|
||||
btnBottom.disabled = count === 0;
|
||||
btnBottom.innerHTML = `<i class="bi bi-save"></i> Guardar ${count} Cambios`;
|
||||
@@ -461,15 +474,21 @@ endforeach; ?>
|
||||
|
||||
const changes = Object.values(pendingChanges);
|
||||
const btnTop = document.getElementById('btnSaveTop');
|
||||
const btnTable = document.getElementById('btnSaveTable');
|
||||
const btnBottom = document.getElementById('btnSaveBottom');
|
||||
|
||||
const originalTextTop = btnTop ? btnTop.innerHTML : '';
|
||||
const originalTextTable = btnTable ? btnTable.innerHTML : '';
|
||||
const originalTextBottom = btnBottom ? btnBottom.innerHTML : '';
|
||||
|
||||
if (btnTop) {
|
||||
btnTop.disabled = true;
|
||||
btnTop.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Guardando...';
|
||||
}
|
||||
if (btnTable) {
|
||||
btnTable.disabled = true;
|
||||
btnTable.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Guardando...';
|
||||
}
|
||||
if (btnBottom) {
|
||||
btnBottom.disabled = true;
|
||||
btnBottom.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Guardando...';
|
||||
@@ -494,6 +513,10 @@ endforeach; ?>
|
||||
btnTop.disabled = false;
|
||||
btnTop.innerHTML = originalTextTop;
|
||||
}
|
||||
if (btnTable) {
|
||||
btnTable.disabled = false;
|
||||
btnTable.innerHTML = originalTextTable;
|
||||
}
|
||||
if (btnBottom) {
|
||||
btnBottom.disabled = false;
|
||||
btnBottom.innerHTML = originalTextBottom;
|
||||
|
||||
Reference in New Issue
Block a user