feat: Añadir funcionalidad de filtrado en la búsqueda de elementos y actualizar etiquetas en la página de pagos
This commit is contained in:
@@ -1213,6 +1213,7 @@ function TS_IndexElement(
|
||||
var searchKeyInput = safeuuid();
|
||||
var debounce_search = safeuuid();
|
||||
var debounce_load = safeuuid();
|
||||
var filter_tr = safeuuid();
|
||||
|
||||
// Create the container with search bar and table
|
||||
container.innerHTML = html`
|
||||
@@ -1230,6 +1231,7 @@ function TS_IndexElement(
|
||||
/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr id="${filter_tr}"></tr>
|
||||
<tr id="${tablehead}"></tr>
|
||||
</thead>
|
||||
<tbody id="${tablebody}"></tbody>
|
||||
@@ -1251,7 +1253,24 @@ function TS_IndexElement(
|
||||
if (hashQuery.has('search')) {
|
||||
searchKeyEl.value = hashQuery.get('search');
|
||||
}
|
||||
var filters = {};
|
||||
if (hashQuery.has('filter')) {
|
||||
hashQuery.getAll('filter').forEach((filter) => {
|
||||
var [key, value] = filter.split(":");
|
||||
filters[key] = value;
|
||||
});
|
||||
document.getElementById(filter_tr).innerHTML = '<th colspan="100%" style="color: #000; background: #fff;">Filtrando por: ' + Object.entries(filters)
|
||||
.map(([key, value]) => `${key}`)
|
||||
.join(', ') + ' - <a href="' + window.location.hash.split('?')[0] + '">Limpiar filtros</a></th>';
|
||||
}
|
||||
function searchInData(data, searchValue, config) {
|
||||
if (filters) {
|
||||
for (var fkey in filters) {
|
||||
if (data[fkey] != filters[fkey]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!searchValue) return true;
|
||||
|
||||
// Search in ID
|
||||
|
||||
@@ -1030,7 +1030,7 @@ PAGES.pagos = {
|
||||
<div
|
||||
style="background: linear-gradient(135deg, #ff4757, #ff3838); padding: 20px; border-radius: 10px; text-align: center; color: white; box-shadow: 0 4px 6px rgba(0,0,0,0.1);"
|
||||
>
|
||||
<h3 style="margin: 0;">Total Ganancias</h3>
|
||||
<h3 style="margin: 0;">Total Gastos</h3>
|
||||
<div id="${total_gastos}" style="font-size: 32px; font-weight: bold; margin-top: 10px;">
|
||||
0.00€
|
||||
</div>
|
||||
|
||||
@@ -66,7 +66,7 @@ PAGES.personas = {
|
||||
Notas del Monedero<br>
|
||||
<textarea id="${field_monedero_notas}" rows="3" placeholder="Notas adicionales sobre el monedero..."></textarea><br><br>
|
||||
</label>
|
||||
<button type="button" id="${btn_ver_monedero}" class="btn5">Ver Transacciones del Monedero</button>
|
||||
<button type="button" id="${btn_ver_monedero}" class="btn5">Ver movimientos</button>
|
||||
</div>
|
||||
</details>
|
||||
<details style="background: #e3fde3ff; border: 2px solid #21f328ff; border-radius: 8px; padding: 10px; margin: 15px 0; display: none;">
|
||||
@@ -209,7 +209,7 @@ PAGES.personas = {
|
||||
});
|
||||
};
|
||||
document.getElementById(btn_ver_monedero).onclick = () => {
|
||||
setUrlHash('pagos?search=' + encodeURIComponent(document.getElementById(field_nombre).value)); // Navigate to pagos and show transactions for this person
|
||||
setUrlHash('pagos?filter=Persona:' + encodeURIComponent(mid)); // Navigate to pagos and show transactions for this person
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm('¿Quieres borrar esta persona?') == true) {
|
||||
|
||||
Reference in New Issue
Block a user