Disable appending to an empty result list

This commit is contained in:
KrivovDE
2026-09-09 16:00:37 +03:00
parent 8d45c74c66
commit 22f5275d38
2 changed files with 26 additions and 1 deletions

View File

@@ -3391,6 +3391,16 @@ body.organization-view:not(.expanded) #content>#stability>.bankruptcy-timeline{
border-color:#727a80;
color:#d5dadd;
}
.search-view .search-submit:disabled,
.search-view .search-submit:disabled:hover,
.search-view .search-submit:disabled:focus-visible{
border-color:#4d5356;
color:#747c80;
background:#303334;
opacity:.58;
cursor:not-allowed;
outline:none;
}
/* Геометрия выдачи не меняется при появлении новых строк и скроллбара. */
.search-view .results-table-wrap{

View File

@@ -1250,6 +1250,15 @@ const searchPagination=document.querySelector('#searchPagination');
let displayedSearchRows=[];
let searchResultGroups=[];
const searchResultsByPanel=new Map();
const syncSearchAddButton=panel=>{
if(!panel)return;
const addButton=panel.querySelector('[data-search-action="append"]');
if(!addButton)return;
const hasResults=Boolean(searchResultsByPanel.get(panel.id)?.rows.length);
addButton.disabled=!hasResults;
addButton.setAttribute('aria-disabled',String(!hasResults));
addButton.title=hasResults?'Добавить результаты к текущему списку':'Сначала выполните поиск';
};
const getSearchRows=panel=>{
const registryChecked=[...panel.querySelectorAll('.filter-check')].some(label=>label.textContent.includes('Входящие в Реестр ОПК')&&label.querySelector('input')?.checked);
const systemformingChecked=[...panel.querySelectorAll('.filter-check')].some(label=>label.textContent.includes('Системообразующие организации')&&label.querySelector('input')?.checked);
@@ -1490,6 +1499,7 @@ const updateSearchResults=(panel,action='replace')=>{
searchResultGroups=[{action:'replace',filters,rows:[...rows]}];
}
searchResultsByPanel.set(panel.id,{rows:displayedSearchRows,groups:searchResultGroups});
syncSearchAddButton(panel);
renderSearchResults();
resetSearchPanel(panel);
};
@@ -1517,7 +1527,10 @@ searchResults.addEventListener('click',event=>{
searchResultGroups.splice(groupIndex,1);
displayedSearchRows=searchResultGroups.flatMap(item=>item.rows);
const activePanel=document.querySelector('.filter-panel:not([hidden])');
if(activePanel)searchResultsByPanel.set(activePanel.id,{rows:displayedSearchRows,groups:searchResultGroups});
if(activePanel){
searchResultsByPanel.set(activePanel.id,{rows:displayedSearchRows,groups:searchResultGroups});
syncSearchAddButton(activePanel);
}
renderSearchResults();
}
});
@@ -1544,6 +1557,7 @@ const setFilterPanel=panelName=>{
const panelState=searchResultsByPanel.get(panelId);
displayedSearchRows=panelState?.rows||[];
searchResultGroups=panelState?.groups||[];
syncSearchAddButton(document.getElementById(panelId));
renderSearchResults();
};
const createFilterTab=panelName=>{
@@ -1696,6 +1710,7 @@ const initializeFilterSelect=select=>{
sync();
};
const initializeFilterPanel=panel=>{
syncSearchAddButton(panel);
panel.querySelectorAll('select').forEach(initializeFilterSelect);
panel.querySelectorAll('.search-field').forEach(field=>{
updateFilterFieldState(field);