fix: Обновление фильтрации и валидации в компонентах ASNsNewManager, AutoUrlManager, DomainsNewManager, IPRangesManager и FilterManager. Добавлена проверка на null для предотвращения ошибок и улучшения стабильности приложения.
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m40s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m40s
This commit is contained in:
@@ -129,7 +129,7 @@ export function useDataManager(config) {
|
||||
continue;
|
||||
}
|
||||
const prev = mapBefore.get(k);
|
||||
if (String(prev.community) !== String(v.community)) {
|
||||
if (prev && v && String(prev.community || '') !== String(v.community || '')) {
|
||||
changed.push({ from: prev, to: v });
|
||||
}
|
||||
}
|
||||
@@ -147,6 +147,7 @@ export function useDataManager(config) {
|
||||
try {
|
||||
// Валидируем и дедуплицируем
|
||||
const valid = items.filter(item => {
|
||||
if (!item) return false;
|
||||
const itemValid = validateItem ? validateItem(item[itemKey]) : true;
|
||||
const communityValid = validateCommunity ? validateCommunity(item.community) : true;
|
||||
return itemValid && communityValid;
|
||||
@@ -198,7 +199,8 @@ export function useDataManager(config) {
|
||||
};
|
||||
|
||||
// Сортировка
|
||||
const sortedItems = [...items].sort((a, b) => {
|
||||
const sortedItems = [...items].filter(item => item != null).sort((a, b) => {
|
||||
if (!a || !b) return 0;
|
||||
let valA = a[sortField] || '';
|
||||
let valB = b[sortField] || '';
|
||||
if (typeof valA === 'string') valA = valA.toLowerCase();
|
||||
@@ -210,9 +212,10 @@ export function useDataManager(config) {
|
||||
|
||||
// Фильтрация
|
||||
const filtered = sortedItems.filter(item => {
|
||||
if (!item) return false;
|
||||
const byCommunity = !filterCommunity || item.community === filterCommunity;
|
||||
const term = String(searchTerm || '').toLowerCase();
|
||||
const bySearch = !term || String(item[itemKey]).toLowerCase().includes(term);
|
||||
const bySearch = !term || String(item[itemKey] || '').toLowerCase().includes(term);
|
||||
return byCommunity && bySearch;
|
||||
});
|
||||
|
||||
@@ -221,7 +224,7 @@ export function useDataManager(config) {
|
||||
const paginatedItems = filtered.slice((currentPage - 1) * pageSize, currentPage * pageSize);
|
||||
|
||||
// Уникальные community для фильтра
|
||||
const allCommunities = Array.from(new Set(items.map(i => i.community)));
|
||||
const allCommunities = Array.from(new Set(items.filter(i => i != null).map(i => i.community).filter(c => c != null)));
|
||||
|
||||
// Управление сортировкой
|
||||
const handleSort = (field) => {
|
||||
|
||||
Reference in New Issue
Block a user