diff --git a/db/scmanutention.php b/db/scmanutention.php index e0ce0a9..eff255b 100644 --- a/db/scmanutention.php +++ b/db/scmanutention.php @@ -537,7 +537,7 @@ function scmanutention_validate_item_reference(PDO $db, int $owner_auth_id, stri ]; } -function scmanutention_search_available_items(PDO $db, int $owner_auth_id, string $query, int $limit = 12): array +function scmanutention_search_available_items(PDO $db, int $owner_auth_id, string $query, ?int $limit = 25, int $offset = 0): array { $query = trim($query); if ($query === '') { @@ -548,7 +548,12 @@ function scmanutention_search_available_items(PDO $db, int $owner_auth_id, strin $exact = $escaped; $prefix = $escaped . '%'; $contains = '%' . $escaped . '%'; - $limit = max(1, min(30, $limit)); + $limit_clause = ''; + $offset = max(0, $offset); + if ($limit !== null && $limit > 0) { + $limit = max(1, min(100, $limit)); + $limit_clause = ' LIMIT ' . (int) $limit . ' OFFSET ' . (int) $offset; + } $sql = " SELECT * @@ -607,7 +612,7 @@ function scmanutention_search_available_items(PDO $db, int $owner_auth_id, strin CHAR_LENGTH(result_name) ASC, result_name ASC, result_key ASC - LIMIT {$limit}"; + {$limit_clause}"; $stmt = $db->prepare($sql); $stmt->execute([ diff --git a/scmanutention.php b/scmanutention.php index bce7c27..d0bb067 100644 --- a/scmanutention.php +++ b/scmanutention.php @@ -133,7 +133,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET' && (string) ($_GET['ajax'] ?? '') === ' header('Content-Type: application/json; charset=utf-8'); $query = trim((string) ($_GET['q'] ?? '')); - $suggestion_rows = scmanutention_search_available_items($db, $current_owner_auth_id, $query, 14); + $offset = max(0, (int) ($_GET['offset'] ?? 0)); + $limit = max(1, min(50, (int) ($_GET['limit'] ?? 25))); + $suggestion_rows = scmanutention_search_available_items($db, $current_owner_auth_id, $query, $limit + 1, $offset); + $has_more = count($suggestion_rows) > $limit; + if ($has_more) { + array_pop($suggestion_rows); + } + $suggestion_custom_ids = []; foreach ($suggestion_rows as $row) { @@ -165,7 +172,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET' && (string) ($_GET['ajax'] ?? '') === ' ]; }, $suggestion_rows); - echo json_encode(['items' => $items], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + echo json_encode([ + 'items' => $items, + 'hasMore' => $has_more, + 'nextOffset' => $offset + count($items), + ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); exit; } @@ -809,6 +820,7 @@ $page_access_widget = auth_render_page_access_widget('scmanutention.php', 'Manut z-index: 9999; max-height: 320px; overflow-y: auto; + overscroll-behavior: contain; box-shadow: 0 22px 40px rgba(0, 0, 0, 0.38); } @@ -885,6 +897,13 @@ $page_access_widget = auth_render_page_access_widget('scmanutention.php', 'Manut background: rgba(255, 255, 255, 0.07); } + .picker-status { + padding: 0.65rem 0.8rem 0.45rem; + color: var(--text-soft); + font-size: 0.78rem; + text-align: center; + } + .picker-selection { display: flex; justify-content: space-between; @@ -1347,7 +1366,7 @@ $page_access_widget = auth_render_page_access_widget('scmanutention.php', 'Manut -
+
@@ -1365,7 +1384,7 @@ $page_access_widget = auth_render_page_access_widget('scmanutention.php', 'Manut
-
La recherche démarre à partir de 2 caractères et distingue les objets de base des objets persos.
+
La recherche démarre à partir de 2 caractères, distingue les objets de base des objets persos, et charge la suite au scroll pour accéder à tous les résultats sans agrandir le panneau.