From 22f5275d383d420c2553056fb134b1f41a444e03 Mon Sep 17 00:00:00 2001 From: KrivovDE <208969570+kunzite16@users.noreply.github.com> Date: Wed, 9 Sep 2026 16:00:37 +0300 Subject: [PATCH] Disable appending to an empty result list --- assets/css/main.css | 10 ++++++++++ assets/js/app.js | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/assets/css/main.css b/assets/css/main.css index a0a05a6..3ad3fb1 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -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{ diff --git a/assets/js/app.js b/assets/js/app.js index 4396527..77efd1a 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -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);