diff --git a/static/v2/css/pages/p_search_route_results.css b/static/v2/css/pages/p_search_route_results.css index 94f29b2..0e52bc7 100644 --- a/static/v2/css/pages/p_search_route_results.css +++ b/static/v2/css/pages/p_search_route_results.css @@ -12,11 +12,14 @@ display: grid; grid-template-columns: 30% calc(100% - 30% - 41px); gap: 41px; - /*.routes_search_results{*/ - /* @media (max-width: 1160px) {*/ - /* width: calc(100dvw - 40px);*/ - /* }*/ - /*}*/ + .routes_search_results{ + .next_page{ + margin: 50px 0; + width: 100%; + background: #212121; + height: 1px; + } + } @media (max-width: 1440px) { margin-top: 40px; } diff --git a/static/v2/js/blocks/b_search_routes.js b/static/v2/js/blocks/b_search_routes.js index b152a60..ccedc5d 100644 --- a/static/v2/js/blocks/b_search_routes.js +++ b/static/v2/js/blocks/b_search_routes.js @@ -17,11 +17,48 @@ function searchRoutes (form=undefined) { data_type: 'formData', success: function (res) { if (!res.html) return; - let $parent = $('.routes_search_results .routes_cont')[0] + let $parent = $('.routes_search_results')[0]; $parent.innerHTML = res.html; } }) + request.ajaxRequest() +} + +function loadMoreRoutes (el) { + if (!el) return; + let from_el = parseInt(el.dataset.from_el); + let to_el = from_el + parseInt(el.dataset.more_count); + let $filter_form = $('.b_filter_routes form')[0]; + let $search_form = $('.b_search_routes form')[0]; + + let formData = getFormData($search_form); + formData = getFormData($filter_form, formData); + let owner_type = 'mover' + formData.append('owner_type', owner_type); + formData.append('from_el', from_el); + formData.append('to_el', to_el); + + let query = formDataToQueryString(formData, [$filter_form, $search_form]); + query+=`owner_type=${owner_type}` + window.history.pushState(null, null, `?${query}`); + let request = new api({ + url: '/routes/find_routes/', + data: formData, + data_type: 'formData', + success: function (res) { + if (!res.html) return; + let $parent = $('.routes_search_results')[0]; + let $next_page_btn = $parent.querySelector('.container_btns[data-next_page_btn]') + $next_page_btn.remove(); + + appendNodes($parent, templateStrToNode(` +
+ `)); + appendNodes($parent, templateStrToNode(res.html)); + } + }) + request.ajaxRequest() } \ No newline at end of file diff --git a/templates/v2/blocks/b_search_routes_result.html b/templates/v2/blocks/b_search_routes_result.html index 6b6eb45..c42898f 100644 --- a/templates/v2/blocks/b_search_routes_result.html +++ b/templates/v2/blocks/b_search_routes_result.html @@ -5,6 +5,14 @@ {% include "v2/widgets/w_route_card_for_search.html" %} {% endfor %} -
-
{% trans "Показать ещё 10" %}
-
\ No newline at end of file +{% if not last_block %} +
+
+ {% trans "Показать ещё" %} {{ next_page_els_count }} +
+
+{% endif %} \ No newline at end of file