V1.4.3
This commit is contained in:
parent
a1559c3861
commit
f74316a661
@ -55,7 +55,7 @@ function scitemcustom_escape_like(string $value): string
|
||||
]);
|
||||
}
|
||||
|
||||
function scitemcustom_search_available_items(PDO $db, int $ownerAuthId, string $query, int $limit = 15): array
|
||||
function scitemcustom_search_available_items(PDO $db, int $ownerAuthId, string $query, ?int $limit = null): array
|
||||
{
|
||||
$query = trim($query);
|
||||
if ($query === '') {
|
||||
@ -66,7 +66,10 @@ function scitemcustom_search_available_items(PDO $db, int $ownerAuthId, string $
|
||||
$exact = $escapedQuery;
|
||||
$prefix = $escapedQuery . '%';
|
||||
$contains = '%' . $escapedQuery . '%';
|
||||
$limit = max(1, min(25, $limit));
|
||||
$limitClause = '';
|
||||
if ($limit !== null && $limit > 0) {
|
||||
$limitClause = ' LIMIT ' . (int) $limit;
|
||||
}
|
||||
|
||||
$sql = "SELECT cl_scobjs_id, cl_scobjs_name, cl_scobjs_uuid, cl_scobjs_type, cl_scobjs_subtype
|
||||
FROM tbl_scobjs
|
||||
@ -94,7 +97,7 @@ function scitemcustom_search_available_items(PDO $db, int $ownerAuthId, string $
|
||||
CHAR_LENGTH(cl_scobjs_name) ASC,
|
||||
cl_scobjs_name ASC,
|
||||
cl_scobjs_id ASC
|
||||
LIMIT {$limit}";
|
||||
{$limitClause}";
|
||||
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->execute([
|
||||
@ -374,7 +377,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET' && (string) ($_GET['ajax'] ?? '') === '
|
||||
$query = trim((string) ($_GET['q'] ?? ''));
|
||||
$items = [];
|
||||
|
||||
if ($query !== '') {
|
||||
if (mb_strlen($query) >= 3) {
|
||||
$items = array_map(static function (array $row): array {
|
||||
return [
|
||||
'id' => (int) $row['cl_scobjs_id'],
|
||||
@ -383,7 +386,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET' && (string) ($_GET['ajax'] ?? '') === '
|
||||
'type' => (string) $row['cl_scobjs_type'],
|
||||
'subtype' => (string) ($row['cl_scobjs_subtype'] ?? ''),
|
||||
];
|
||||
}, scitemcustom_search_available_items($db, $current_owner_auth_id, $query, 12));
|
||||
}, scitemcustom_search_available_items($db, $current_owner_auth_id, $query));
|
||||
}
|
||||
|
||||
echo json_encode(['items' => $items], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
@ -582,6 +585,7 @@ $current_session_user = $_SESSION['user'] ?? '';
|
||||
}
|
||||
|
||||
.glass-card {
|
||||
position: relative;
|
||||
background: var(--card-bg);
|
||||
backdrop-filter: blur(10px);
|
||||
border: 1px solid var(--border-glow);
|
||||
@ -590,6 +594,10 @@ $current_session_user = $_SESSION['user'] ?? '';
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.item-picker-card {
|
||||
z-index: 30;
|
||||
}
|
||||
|
||||
.glass-card h2,
|
||||
.glass-card h3 {
|
||||
margin-top: 0;
|
||||
@ -695,6 +703,8 @@ $current_session_user = $_SESSION['user'] ?? '';
|
||||
gap: 0.65rem;
|
||||
max-height: 360px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
box-sizing: border-box;
|
||||
padding: 0.75rem;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(162, 155, 120, 0.22);
|
||||
@ -708,6 +718,7 @@ $current_session_user = $_SESSION['user'] ?? '';
|
||||
gap: 0.85rem;
|
||||
align-items: flex-start;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid rgba(255, 255, 255, 0.07);
|
||||
border-radius: 10px;
|
||||
padding: 0.8rem;
|
||||
@ -834,6 +845,11 @@ $current_session_user = $_SESSION['user'] ?? '';
|
||||
display: block;
|
||||
}
|
||||
|
||||
.item-picker-dropdown .item-name,
|
||||
.search-result-list .item-name {
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
.item-submeta {
|
||||
color: #96a0b5;
|
||||
font-size: 0.78rem;
|
||||
@ -841,6 +857,12 @@ $current_session_user = $_SESSION['user'] ?? '';
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.item-picker-dropdown .item-submeta,
|
||||
.search-result-list .item-submeta {
|
||||
font-size: 0.71rem;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.custom-item-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -1139,7 +1161,7 @@ $current_session_user = $_SESSION['user'] ?? '';
|
||||
|
||||
<div class="admin-grid">
|
||||
<aside class="stack">
|
||||
<section class="glass-card">
|
||||
<section class="glass-card item-picker-card">
|
||||
<h2>Ajouter un objet</h2>
|
||||
<p class="count-note">Choisis un objet depuis la base, puis attribue-lui autant de stats que nécessaire.</p>
|
||||
|
||||
@ -1163,7 +1185,7 @@ $current_session_user = $_SESSION['user'] ?? '';
|
||||
<div class="item-picker-dropdown hidden-by-filter" id="item-add-suggestions" role="listbox" aria-label="Suggestions d'objets"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-help" id="item-add-help">Commence à taper le nom d'un objet. La liste juste en dessous se met à jour dynamiquement et tu peux cliquer sur l'objet voulu.</div>
|
||||
<div class="form-help" id="item-add-help">Commence à taper le nom d'un objet. La liste se déclenche à partir de 3 caractères saisis et affiche tous les objets correspondants.</div>
|
||||
|
||||
<div class="item-picker-selection hidden-by-filter" id="item-add-selection" aria-live="polite">
|
||||
<div class="item-picker-selection-main">
|
||||
@ -1208,8 +1230,7 @@ $current_session_user = $_SESSION['user'] ?? '';
|
||||
<strong class="item-name"><?php echo htmlspecialchars($result['cl_scobjs_name'], ENT_QUOTES, 'UTF-8'); ?></strong>
|
||||
<div class="item-submeta">
|
||||
<?php echo htmlspecialchars($result['cl_scobjs_type'], ENT_QUOTES, 'UTF-8'); ?>
|
||||
<?php if (!empty($result['cl_scobjs_subtype'])): ?> / <?php echo htmlspecialchars($result['cl_scobjs_subtype'], ENT_QUOTES, 'UTF-8'); ?><?php endif; ?><br>
|
||||
<?php echo htmlspecialchars($result['cl_scobjs_uuid'], ENT_QUOTES, 'UTF-8'); ?>
|
||||
<?php if (!empty($result['cl_scobjs_subtype'])): ?> / <?php echo htmlspecialchars($result['cl_scobjs_subtype'], ENT_QUOTES, 'UTF-8'); ?><?php endif; ?>
|
||||
</div>
|
||||
<form method="post" class="search-item-actions">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrf_token, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
@ -1563,13 +1584,9 @@ $current_session_user = $_SESSION['user'] ?? '';
|
||||
if (item.subtype) {
|
||||
meta += (meta ? ' / ' : '') + escapeHtml(item.subtype);
|
||||
}
|
||||
if (item.uuid) {
|
||||
meta += (meta ? '<br>' : '') + escapeHtml(item.uuid);
|
||||
}
|
||||
|
||||
return '' +
|
||||
'<button type="button" class="item-picker-option' + (index === 0 ? ' is-active' : '') + '" role="option" data-item-id="' + escapeHtml(item.id) + '" data-item-name="' + escapeHtml(item.name) + '" data-item-type="' + escapeHtml(item.type || '') + '" data-item-subtype="' + escapeHtml(item.subtype || '') + '" data-item-uuid="' + escapeHtml(item.uuid || '') + '">' +
|
||||
'<img src="https://cstone.space/uifimages/' + encodeURIComponent(item.uuid || '') + '.png" class="item-preview" alt="">' +
|
||||
'<div class="search-item-content">' +
|
||||
'<strong class="item-name">' + escapeHtml(item.name || '') + '</strong>' +
|
||||
'<div class="item-submeta">' + meta + '</div>' +
|
||||
@ -1586,7 +1603,7 @@ $current_session_user = $_SESSION['user'] ?? '';
|
||||
}
|
||||
|
||||
var trimmedQuery = (query || '').trim();
|
||||
if (trimmedQuery === '') {
|
||||
if (trimmedQuery.length < 3) {
|
||||
hidePickerDropdown();
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user