refactor: Remove debug logging and normalize community values in CommunityAutocomplete, ensuring consistent handling of baseAS and improving display logic for selected communities.
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m51s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m51s
This commit is contained in:
@@ -82,9 +82,6 @@ function CommunityAutocomplete({ label, value, onChange, communities = [], requi
|
||||
setInputValue(value || '');
|
||||
}, [value]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log('[CommunityAutocomplete] baseAS:', baseAS, 'communities:', communities.length);
|
||||
}, [baseAS, communities]);
|
||||
|
||||
// Фильтруем communities по введённому тексту
|
||||
const filteredCommunities = communities.filter(c => {
|
||||
@@ -93,11 +90,6 @@ function CommunityAutocomplete({ label, value, onChange, communities = [], requi
|
||||
|
||||
const cValue = (c.value || '').toLowerCase();
|
||||
|
||||
// Отладка первых 3 элементов
|
||||
if (communities.indexOf(c) < 3 && inputValue) {
|
||||
console.log(`[Filter] search="${search}", cValue="${cValue}", baseAS="${baseAS}"`);
|
||||
}
|
||||
|
||||
// 1. Поиск по названию и описанию
|
||||
if (c.name && c.name.toLowerCase().includes(search)) return true;
|
||||
if (c.description && c.description.toLowerCase().includes(search)) return true;
|
||||
@@ -162,8 +154,10 @@ function CommunityAutocomplete({ label, value, onChange, communities = [], requi
|
||||
};
|
||||
|
||||
const handleSelect = (c) => {
|
||||
setInputValue(c.value);
|
||||
onChange(c.value);
|
||||
// Нормализуем значение: если в справочнике просто число, добавляем baseAS
|
||||
const normalizedValue = c.value.includes(':') ? c.value : `${baseAS}:${c.value}`;
|
||||
setInputValue(normalizedValue);
|
||||
onChange(normalizedValue);
|
||||
setIsOpen(false);
|
||||
setHighlightedIndex(-1);
|
||||
};
|
||||
@@ -199,7 +193,13 @@ function CommunityAutocomplete({ label, value, onChange, communities = [], requi
|
||||
}
|
||||
};
|
||||
|
||||
const selectedCommunity = communities.find(c => c.value === value);
|
||||
// Находим выбранный community с учётом нормализации
|
||||
const selectedCommunity = communities.find(c => {
|
||||
if (c.value === value) return true;
|
||||
// Если в справочнике просто число, проверяем с baseAS
|
||||
const normalizedCValue = c.value.includes(':') ? c.value : `${baseAS}:${c.value}`;
|
||||
return normalizedCValue === value;
|
||||
});
|
||||
|
||||
// Группируем по категориям
|
||||
const groupedCommunities = filteredCommunities.reduce((acc, c) => {
|
||||
@@ -283,7 +283,9 @@ function CommunityAutocomplete({ label, value, onChange, communities = [], requi
|
||||
</span>
|
||||
<div className="flex-grow-1 min-w-0">
|
||||
<div className="d-flex align-items-center gap-2">
|
||||
<code className="fw-bold text-blue">{c.value}</code>
|
||||
<code className="fw-bold text-blue">
|
||||
{c.value.includes(':') ? c.value : `${baseAS}:${c.value}`}
|
||||
</code>
|
||||
{c.name && <span className="text-muted">— {c.name}</span>}
|
||||
</div>
|
||||
{c.description && (
|
||||
@@ -312,7 +314,7 @@ function CommunityAutocomplete({ label, value, onChange, communities = [], requi
|
||||
</span>
|
||||
<div className="flex-grow-1">
|
||||
<div className="d-flex align-items-center gap-2">
|
||||
<code className="fw-bold text-blue">{selectedCommunity.value}</code>
|
||||
<code className="fw-bold text-blue">{value}</code>
|
||||
{selectedCommunity.name && <span className="text-muted">— {selectedCommunity.name}</span>}
|
||||
</div>
|
||||
{selectedCommunity.description && (
|
||||
@@ -683,10 +685,8 @@ function FilterManager() {
|
||||
const res = await api.get('/ui-settings');
|
||||
const data = res?.data || {};
|
||||
const loadedBaseAS = String(data?.baseAS || '65001');
|
||||
console.log('[FilterManager] Загружена baseAS:', loadedBaseAS);
|
||||
setBaseAS(loadedBaseAS);
|
||||
} catch (e) {
|
||||
console.warn('[FilterManager] Не удалось загрузить baseAS, используем 65001');
|
||||
// мягко игнорируем, используем значение по умолчанию
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user