fix limit dropdown

This commit is contained in:
2026-05-19 16:20:55 +02:00
parent 3e69e3c322
commit e42d1b9c51
2 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -349,7 +349,7 @@
return {
field_id: fieldId,
q: params.term || "",
limit: 10,
limit: 0, // 0 = no limit for custom field values
};
},
processResults: function (data) {
@@ -2,7 +2,11 @@
require_once dirname(__DIR__, 2) . '/vendor/autoload.php';
require_once __DIR__ . '/class/db-functions.php';
include dirname(__DIR__) . '/../extra/auth.php';
if (!Auth::check()) { http_response_code(401); echo json_encode(['error' => 'Unauthorized']); exit; }
if (!Auth::check()) {
http_response_code(401);
echo json_encode(['error' => 'Unauthorized']);
exit;
}
require_once __DIR__ . '/class/VisualLimsApiClient.class.php';
@@ -13,7 +17,8 @@ error_reporting(E_ALL);
$fieldId = intval($_GET['field_id'] ?? 0);
$q = mb_strtolower(trim($_GET['q'] ?? ''));
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
$limit = max(1, min(50, intval($_GET['limit'] ?? 20)));
$rawLimit = intval($_GET['limit'] ?? 20);
$limit = $rawLimit <= 0 ? 0 : max(1, min(500, $rawLimit));
if (!$fieldId) {
echo json_encode(['results' => []]);
@@ -52,7 +57,7 @@ try {
$text = $v['Valore'] ?? '';
if ($q === '' || mb_strpos(mb_strtolower($text), $q) !== false) {
$results[] = ['id' => $v['IdCustomFieldsValue'], 'text' => $text];
if (count($results) >= $limit) break;
if ($limit > 0 && count($results) >= $limit) break;
}
}