This commit is contained in:
2023-08-29 17:05:10 +03:00
parent 59fb628ced
commit fdeb2a4ae1
2 changed files with 51 additions and 15 deletions

View File

@@ -2,6 +2,41 @@ let page_iterator = 2
function load_routes (el) {
let number_last_route = el.id
let data = {
'from_el':parseInt(number_last_route) + 1,
'to_el':parseInt(number_last_route) + 11
}
let list_of_elements_form = document.querySelectorAll(".el_form_find_route");
for (let i = 0;i < list_of_elements_form.length;i++) {
// let id_el = list_of_elements_form[i].id
// if (id_el){
// if (id_el === "")
// }
let name_attr = list_of_elements_form[i].attributes["name"]
let value_el = list_of_elements_form[i].value
if (name_attr) {
if (list_of_elements_form[i].tagName === "INPUT" && list_of_elements_form[i].type === "checkbox"){
let name_el = name_attr.value
data[name_el] = ""
if (list_of_elements_form[i].checked){
if (name_el === "type_transport"){
let old_val = data["type_transport"]
if (old_val){
data["type_transport"] = `${data["type_transport"]},${value_el}`
}
}
data[name_el] = value_el
}
} else {
let name_el = name_attr.value
data[name_el] = value_el
}
}
}
let loader = document.querySelector(".loader_f_loading_routes")
loader.classList.toggle("show")
el.classList.toggle("hide")
@@ -12,11 +47,8 @@ function load_routes (el) {
// if (new_el_dataset){
// let number_last_route = new_el_dataset['numberOfRoute']
// let number_last_route = el.dataset['lastRoute']
let number_last_route = el.id
let data = {
'from_el':parseInt(number_last_route) + 1,
'to_el':parseInt(number_last_route) + 11
}
$.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: '/ru/routes/find_routes/',
@@ -36,7 +68,9 @@ function load_routes (el) {
let old_page_iterator = page_iterator
page_iterator++
loader.classList.toggle("show")
el.classList.toggle("hide")
if (!data.last_block_routes){
el.classList.toggle("hide")
}
let el_scroll = place_ins.firstElementChild
el_scroll.scrollIntoView(
{

View File

@@ -39,6 +39,7 @@
type="number"
name="from_address_point"
id="id_from_address_point"
class="el_form_find_route"
hidden
class="disp-none"
{% if form.initial.from_address_point %}value="{{ form.initial.from_address_point }}"{% endif %}
@@ -77,6 +78,7 @@
type="number"
name="to_address_point"
id="id_to_address_point"
class="el_form_find_route"
hidden
class="disp-none"
{% if form.initial.to_address_point %}value="{{ form.initial.to_address_point}}"{% endif %}/>
@@ -101,15 +103,15 @@
</div>
<div class="cont-el-form-search-carrier">
<label for="id_departure_DT">Дата отправки</label>
<input name="departure_DT" id="id_departure_DT" type="date" {% if form.fields.departure_DT.required %} {% endif %}>
<input class="el_form_find_route" name="departure_DT" id="id_departure_DT" type="date" {% if form.fields.departure_DT.required %} {% endif %}>
</div>
<div class="cont-el-form-search-carrier">
<label for="id_arrival_DT">Дата прибытия</label>
<input name="arrival_DT" id="id_arrival_DT" type="date" {% if form.fields.arrival_DT.required %} {% endif %}>
<input class="el_form_find_route" name="arrival_DT" id="id_arrival_DT" type="date" {% if form.fields.arrival_DT.required %} {% endif %}>
</div>
<div class="cont-el-form-search-carrier last">
<label>test</label>
<select name="cargo_type" id="id_cargo_type" {% if form.fields.cargo_type.required %} {% endif %}>
<select class="el_form_find_route" name="cargo_type" id="id_cargo_type" {% if form.fields.cargo_type.required %} {% endif %}>
<option value="" selected="selected">--не имеет значения--</option>
{% for item in form.fields.cargo_type.choices %}
<option value="{{ item.0 }}">{{ item.1 }}</option>
@@ -118,7 +120,7 @@
</select>
</div>
<div class="cont-el-form-search-carrier">
<div class="cont-el-form-search-carrier el_form_find_route">
<label style="opacity: 0">test</label>
<button onclick="filters_func_find_route_main(this)">Найти</button>
</div>
@@ -142,7 +144,7 @@
{% if forloop.counter0 > 0 %}
<div>
<input
class="custom-checkbox"
class="custom-checkbox el_form_find_route"
type="checkbox"
name="type_transport"
id="id_cargo_type_car_{{ forloop.counter }}"
@@ -171,7 +173,7 @@
</div>
<div class="methods_transportation_form_filters">
<div class="title_el_methods_transportation">Откуда забрать посылку</div>
<select class="select_form_filters_find_route" name="from_place">
<select class="select_form_filters_find_route el_form_find_route" name="from_place">
<option value="" selected="selected">--не имеет значения--</option>
{% for item in form.fields.from_place.choices %}
<option value="{{ item.0 }}">{{ item.1 }}</option>
@@ -183,7 +185,7 @@
</div>
<div class="methods_transportation_form_filters">
<div class="title_el_methods_transportation">Куда доставить посылку</div>
<select class="select_form_filters_find_route" name="to_place">
<select class="select_form_filters_find_route el_form_find_route" name="to_place">
<option value="" selected="selected">--не имеет значения--</option>
{% for item in form.fields.to_place.choices %}
<option value="{{ item.0 }}">{{ item.1 }}</option>
@@ -193,7 +195,7 @@
<div class="methods_transportation_form_filters">
<label for="weight">Вес посылки (кг)</label>
<div class="range-slider">
<input type="text" class="range_slider_form_filters" name="weight" value="{{ form.fields.weight.initial }}" />
<input type="text" class="range_slider_form_filters el_form_find_route" name="weight" value="{{ form.fields.weight.initial }}" />
</div>
<div class="inputs_for_slider_cont">
<input type="text" class="input_f_slider_start" value="100" />
@@ -204,7 +206,7 @@
</div>
<div class="methods_transportation_form_filters">
<div class="title_el_methods_transportation">Сортировать по:</div>
<select name="sort" class="select_form_filters_find_route">
<select name="sort" class="select_form_filters_find_route el_form_find_route">
<option value="last">По последним</option>
</select>
</div>