json bindings filter && order
This commit is contained in:
@@ -52,7 +52,7 @@ $bindings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
<title>Gestione Binding JSON -> LIMS - <?= htmlspecialchars($titlewebsite ?? '', ENT_QUOTES, 'UTF-8'); ?></title>
|
||||
<title>Gestione Binding JSON → LIMS - <?= htmlspecialchars($titlewebsite ?? '', ENT_QUOTES, 'UTF-8'); ?></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -65,18 +65,22 @@ $bindings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
<div class="card radius-10">
|
||||
<div class="card-header">
|
||||
<div class="d-flex align-items-center justify-content-between flex-wrap gap-2">
|
||||
<h6 class="mb-0">Gestione Binding JSON -> LIMS</h6>
|
||||
<form method="GET" class="d-flex align-items-center gap-2">
|
||||
<label class="small text-muted mb-0">Template</label>
|
||||
<select name="template_id" class="form-select form-select-sm" onchange="this.form.submit()">
|
||||
<option value="0">Tutti</option>
|
||||
<?php foreach ($templates as $t): ?>
|
||||
<option value="<?= (int) $t['id'] ?>" <?= $templateFilter === (int) $t['id'] ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($t['name']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</form>
|
||||
<h6 class="mb-0">Gestione Binding JSON → LIMS</h6>
|
||||
<div class="d-flex align-items-center gap-2 flex-wrap">
|
||||
<input type="text" id="bindingSearch" class="form-control form-control-sm" style="width:220px;"
|
||||
placeholder="Cerca (campo, valore...)">
|
||||
<form method="GET" class="d-flex align-items-center gap-2 mb-0">
|
||||
<label class="small text-muted mb-0">Template</label>
|
||||
<select name="template_id" class="form-select form-select-sm" onchange="this.form.submit()">
|
||||
<option value="0">Tutti</option>
|
||||
<?php foreach ($templates as $t): ?>
|
||||
<option value="<?= (int) $t['id'] ?>" <?= $templateFilter === (int) $t['id'] ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($t['name']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -85,23 +89,23 @@ $bindings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
<div class="alert alert-secondary small">
|
||||
Le modifiche ai binding si applicano alle <strong>importazioni future</strong>.
|
||||
I record gia' importati non vengono ricalcolati.
|
||||
I record già importati non vengono ricalcolati.
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered align-middle">
|
||||
<table class="table table-striped table-bordered align-middle" id="bindingsTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Template</th>
|
||||
<th>Campo (template_mapping)</th>
|
||||
<th>Valore JSON</th>
|
||||
<th>Valore LIMS</th>
|
||||
<th class="sortable" data-col="0" style="cursor:pointer;">Template <span class="sort-caret"></span></th>
|
||||
<th class="sortable" data-col="1" style="cursor:pointer;">Campo (template_mapping) <span class="sort-caret"></span></th>
|
||||
<th class="sortable" data-col="2" style="cursor:pointer;">Valore JSON <span class="sort-caret"></span></th>
|
||||
<th class="sortable" data-col="3" style="cursor:pointer;">Valore LIMS <span class="sort-caret"></span></th>
|
||||
<th style="width:170px;">Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($bindings)): ?>
|
||||
<tr>
|
||||
<tr class="no-data-row">
|
||||
<td colspan="5" class="text-center text-muted">Nessun binding presente.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
@@ -155,6 +159,33 @@ $bindings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$(function() {
|
||||
const $globalError = $('#globalError');
|
||||
|
||||
// Filtro testuale generale su tutte le colonne.
|
||||
const $rows = () => $('#bindingsTable tbody tr').not('.no-data-row');
|
||||
$('#bindingSearch').on('input', function() {
|
||||
const q = $(this).val().toLowerCase().trim();
|
||||
$rows().each(function() {
|
||||
const text = $(this).text().toLowerCase();
|
||||
$(this).toggle(q === '' || text.indexOf(q) !== -1);
|
||||
});
|
||||
});
|
||||
|
||||
// Ordinamento per colonna (click sull'intestazione).
|
||||
$('#bindingsTable thead .sortable').on('click', function() {
|
||||
const col = +$(this).data('col');
|
||||
const asc = !($(this).data('asc'));
|
||||
$('#bindingsTable thead .sortable').data('asc', null).find('.sort-caret').html('');
|
||||
$(this).data('asc', asc).find('.sort-caret').html(asc ? ' ▲' : ' ▼');
|
||||
|
||||
const $tbody = $('#bindingsTable tbody');
|
||||
const rows = $tbody.find('tr').not('.no-data-row').get();
|
||||
rows.sort((a, b) => {
|
||||
const x = $(a).find('td').eq(col).text().trim().toLowerCase();
|
||||
const y = $(b).find('td').eq(col).text().trim().toLowerCase();
|
||||
return asc ? x.localeCompare(y) : y.localeCompare(x);
|
||||
});
|
||||
rows.forEach(r => $tbody.append(r));
|
||||
});
|
||||
|
||||
$('.binding-select').each(function() {
|
||||
const fieldId = $(this).data('field-id');
|
||||
const initialVal = $(this).val();
|
||||
|
||||
Reference in New Issue
Block a user