Disable appending to an empty result list
This commit is contained in:
@@ -3391,6 +3391,16 @@ body.organization-view:not(.expanded) #content>#stability>.bankruptcy-timeline{
|
|||||||
border-color:#727a80;
|
border-color:#727a80;
|
||||||
color:#d5dadd;
|
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{
|
.search-view .results-table-wrap{
|
||||||
|
|||||||
@@ -1250,6 +1250,15 @@ const searchPagination=document.querySelector('#searchPagination');
|
|||||||
let displayedSearchRows=[];
|
let displayedSearchRows=[];
|
||||||
let searchResultGroups=[];
|
let searchResultGroups=[];
|
||||||
const searchResultsByPanel=new Map();
|
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 getSearchRows=panel=>{
|
||||||
const registryChecked=[...panel.querySelectorAll('.filter-check')].some(label=>label.textContent.includes('Входящие в Реестр ОПК')&&label.querySelector('input')?.checked);
|
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);
|
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]}];
|
searchResultGroups=[{action:'replace',filters,rows:[...rows]}];
|
||||||
}
|
}
|
||||||
searchResultsByPanel.set(panel.id,{rows:displayedSearchRows,groups:searchResultGroups});
|
searchResultsByPanel.set(panel.id,{rows:displayedSearchRows,groups:searchResultGroups});
|
||||||
|
syncSearchAddButton(panel);
|
||||||
renderSearchResults();
|
renderSearchResults();
|
||||||
resetSearchPanel(panel);
|
resetSearchPanel(panel);
|
||||||
};
|
};
|
||||||
@@ -1517,7 +1527,10 @@ searchResults.addEventListener('click',event=>{
|
|||||||
searchResultGroups.splice(groupIndex,1);
|
searchResultGroups.splice(groupIndex,1);
|
||||||
displayedSearchRows=searchResultGroups.flatMap(item=>item.rows);
|
displayedSearchRows=searchResultGroups.flatMap(item=>item.rows);
|
||||||
const activePanel=document.querySelector('.filter-panel:not([hidden])');
|
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();
|
renderSearchResults();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1544,6 +1557,7 @@ const setFilterPanel=panelName=>{
|
|||||||
const panelState=searchResultsByPanel.get(panelId);
|
const panelState=searchResultsByPanel.get(panelId);
|
||||||
displayedSearchRows=panelState?.rows||[];
|
displayedSearchRows=panelState?.rows||[];
|
||||||
searchResultGroups=panelState?.groups||[];
|
searchResultGroups=panelState?.groups||[];
|
||||||
|
syncSearchAddButton(document.getElementById(panelId));
|
||||||
renderSearchResults();
|
renderSearchResults();
|
||||||
};
|
};
|
||||||
const createFilterTab=panelName=>{
|
const createFilterTab=panelName=>{
|
||||||
@@ -1696,6 +1710,7 @@ const initializeFilterSelect=select=>{
|
|||||||
sync();
|
sync();
|
||||||
};
|
};
|
||||||
const initializeFilterPanel=panel=>{
|
const initializeFilterPanel=panel=>{
|
||||||
|
syncSearchAddButton(panel);
|
||||||
panel.querySelectorAll('select').forEach(initializeFilterSelect);
|
panel.querySelectorAll('select').forEach(initializeFilterSelect);
|
||||||
panel.querySelectorAll('.search-field').forEach(field=>{
|
panel.querySelectorAll('.search-field').forEach(field=>{
|
||||||
updateFilterFieldState(field);
|
updateFilterFieldState(field);
|
||||||
|
|||||||
Reference in New Issue
Block a user