This commit is contained in:
2023-08-28 18:05:53 +03:00
parent 4354d1369d
commit ec8fded136
6 changed files with 45 additions and 22 deletions

View File

@@ -14,6 +14,11 @@ function filters_func_find_route_main (el){
data: formData, data: formData,
success: function(data){ success: function(data){
document.querySelector(".block-finded-routes").innerHTML = data.html document.querySelector(".block-finded-routes").innerHTML = data.html
if (data.html === "\n\n\n\n\n"){
document.querySelector(".block-finded-routes").innerHTML = "<span style='color: #ff0000;font-weight: 800;font-size: 18px;padding: 10px;'>Нечего не найдено!</span>"
} else {
document.querySelector(".block-finded-routes").innerHTML = data.html
}
}, },
errors: function (data){ errors: function (data){

View File

@@ -56,6 +56,7 @@ function restart_ws (){
console.log("open") console.log("open")
} else { } else {
console.log("connecting...") console.log("connecting...")
} }

View File

@@ -345,28 +345,31 @@ function sliderInit() {
} }
function sendRoute(el, routeID = null){ function sendRoute(el, routeID = null){
let obj ={} event.preventDefault()
let list_of_elements_form = document.querySelectorAll(".el_form_b_new_route");
let obj_w_el_form = {}
for (let i = 0;i < list_of_elements_form.length;i++) {
let name_attr = list_of_elements_form[i].attributes["name"]
if (name_attr) {
let name_el = name_attr.value
let value_el = list_of_elements_form[i].value
obj_w_el_form[name_el] = value_el
}
}
let selected_owner_type = document.querySelectorAll("#customer, #mover") let selected_owner_type = document.querySelectorAll("#customer, #mover")
selected_owner_type.forEach(function(item) { selected_owner_type.forEach(function(item) {
if (item.classList.contains('selected')) { if (item.classList.contains('selected')) {
let { id, innerText } = item let { id, innerText } = item
obj['owner_type'] = id obj_w_el_form['owner_type'] = id
} }
}); });
if (selected_owner_type[0].classList.contains('selected')){ if (selected_owner_type[0].classList.contains('selected')){
}else }else{}
event.preventDefault()
let form = el.form;
let formData = new FormData(form);
let data = {
formData,
obj
}
let url = '/ru/routes/create_or_change_route/' let url = '/ru/routes/create_or_change_route/'
if (routeID !== null){ if (routeID !== null){
url = '/ru/routes/change_route/' + routeID + '/' url = '/ru/routes/change_route/' + routeID + '/'
@@ -381,7 +384,7 @@ function sendRoute(el, routeID = null){
processData: false, processData: false,
contentType: false, contentType: false,
// enctype: 'json', // enctype: 'json',
data: JSON.stringify(data), data: JSON.stringify(obj_w_el_form),
success: function(data){ success: function(data){
if (data.user_alerts) { if (data.user_alerts) {
getNewMessageSession() getNewMessageSession()

View File

@@ -33,7 +33,8 @@
<select <select
onchange="OnSelectionChange(this)" onchange="OnSelectionChange(this)"
name="type_transport" name="type_transport"
id="id_type_transport"> id="id_type_transport"
class="el_form_b_new_route">
{% for item in form.fields.type_transport.choices %} {% for item in form.fields.type_transport.choices %}
<option <option
@@ -63,6 +64,7 @@
name="departure_DT" name="departure_DT"
{% if form.fields.departure_DT.required %} required{% endif %} {% if form.fields.departure_DT.required %} required{% endif %}
id="id_departure_DT" id="id_departure_DT"
class="el_form_b_new_route"
{% if form.initial.departure_DT %}value="{{ form.initial.departure_DT.date|date:"Y-m-d" }}T{{ form.initial.departure_DT.time|date:"H:i" }}"{% endif %} {% if form.initial.departure_DT %}value="{{ form.initial.departure_DT.date|date:"Y-m-d" }}T{{ form.initial.departure_DT.time|date:"H:i" }}"{% endif %}
/> />
@@ -78,6 +80,7 @@
name="arrival_DT" name="arrival_DT"
{% if form.fields.arrival_DT.required %} required{% endif %} {% if form.fields.arrival_DT.required %} required{% endif %}
id="id_arrival_DT" id="id_arrival_DT"
class="el_form_b_new_route"
{% if form.initial.arrival_DT %}value="{{ form.initial.arrival_DT.date|date:"Y-m-d" }}T{{ form.initial.arrival_DT.time|date:"H:i" }}"{% endif %} {% if form.initial.arrival_DT %}value="{{ form.initial.arrival_DT.date|date:"Y-m-d" }}T{{ form.initial.arrival_DT.time|date:"H:i" }}"{% endif %}
/> />
{% if not errors_off and form.errors and form.errors.arrival_DT %} {% if not errors_off and form.errors and form.errors.arrival_DT %}
@@ -94,6 +97,7 @@
type="number" type="number"
name="from_address_point" name="from_address_point"
id="id_from_address_point" id="id_from_address_point"
class="el_form_b_new_route"
hidden hidden
{% if form.initial.from_address_point %}value="{{ form.initial.from_address_point }}"{% endif %} {% if form.initial.from_address_point %}value="{{ form.initial.from_address_point }}"{% endif %}
/> />
@@ -106,7 +110,7 @@
type="text" type="text"
minlength="3" minlength="3"
name="from_address_point_txt" name="from_address_point_txt"
class="from_address_point_txt post_route" class="from_address_point_txt post_route el_form_b_new_route"
{% if form.fields.from_address_point.required %} required{% endif %} {% if form.fields.from_address_point.required %} required{% endif %}
id="id_from_address_point_txt" id="id_from_address_point_txt"
{% if form.initial.from_address_point_txt %}value="{{ form.initial.from_address_point_txt }}"{% endif %} {% if form.initial.from_address_point_txt %}value="{{ form.initial.from_address_point_txt }}"{% endif %}
@@ -128,6 +132,7 @@
type="number" type="number"
name="to_address_point" name="to_address_point"
id="id_to_address_point" id="id_to_address_point"
class="el_form_b_new_route"
hidden hidden
{% if form.initial.to_address_point %}value="{{ form.initial.to_address_point}}"{% endif %} {% if form.initial.to_address_point %}value="{{ form.initial.to_address_point}}"{% endif %}
/> />
@@ -142,7 +147,7 @@
name="to_address_point_txt" name="to_address_point_txt"
{% if form.fields.to_address_point.required %} required{% endif %} {% if form.fields.to_address_point.required %} required{% endif %}
id="id_to_address_point_txt" id="id_to_address_point_txt"
class="to_address_point_txt post_route" class="to_address_point_txt post_route el_form_b_new_route"
{% if form.initial.to_address_point_txt %}value="{{ form.initial.to_address_point_txt}}"{% endif %} {% if form.initial.to_address_point_txt %}value="{{ form.initial.to_address_point_txt}}"{% endif %}
/> />
@@ -166,6 +171,7 @@
<div> <div>
<label for="id_from_place">{{ form.fields.from_place.label }}</label> <label for="id_from_place">{{ form.fields.from_place.label }}</label>
<select <select
class="el_form_b_new_route"
name="from_place" name="from_place"
{# onchange="hideErrorMsg(this)"#} {# onchange="hideErrorMsg(this)"#}
id="id_from_place" id="id_from_place"
@@ -186,6 +192,7 @@
<select <select
name="to_place" name="to_place"
id="id_to_place" id="id_to_place"
class="el_form_b_new_route"
{% if form.fields.to_place.required %} required{% endif %}> {% if form.fields.to_place.required %} required{% endif %}>
{% for item in form.fields.to_place.choices %} {% for item in form.fields.to_place.choices %}
<option <option
@@ -216,7 +223,8 @@
<input <input
class="custom-checkbox" class="custom-checkbox"
type="checkbox" type="checkbox"
name="cargo_type" name="cargo_type"
class="el_form_b_new_route"
id="id_cargo_type_{{ forloop.counter }}" id="id_cargo_type_{{ forloop.counter }}"
{% if form.fields.cargo_type.required %} required{% endif %} {% if form.fields.cargo_type.required %} required{% endif %}
value="{{ item.0 }}" value="{{ item.0 }}"
@@ -248,6 +256,7 @@
maxlength="4" maxlength="4"
class="js-input" class="js-input"
placeholder="Укажите вес" placeholder="Укажите вес"
class="el_form_b_new_route"
{% if form.fields.weight.required %} required{% endif %} {% if form.fields.weight.required %} required{% endif %}
/> />
@@ -260,7 +269,8 @@
<input <input
type="text" type="text"
id="id_weight"id="id_weight" id="id_weight" id="id_weight"
class="el_form_b_new_route"
name="weight" name="weight"
{% if form.initial.weight %} {% if form.initial.weight %}
value="{{ form.initial.weight }}" value="{{ form.initial.weight }}"
@@ -284,6 +294,7 @@
autocomplete="off" autocomplete="off"
maxlength="13" maxlength="13"
minlength="11" minlength="11"
class="el_form_b_new_route"
placeholder="{{ form.fields.phone.label }}" placeholder="{{ form.fields.phone.label }}"
{% if form.fields.phone.required %} required{% endif %} {% if form.fields.phone.required %} required{% endif %}
id="id_phone" id="id_phone"
@@ -302,6 +313,7 @@
type="phone" type="phone"
name="extra_phone" name="extra_phone"
id="id_extra_phone" id="id_extra_phone"
class="el_form_b_new_route"
autocomplete="off" autocomplete="off"
maxlength="13" maxlength="13"
minlength="11" minlength="11"

View File

@@ -1,4 +1,5 @@
{% load static %} {% load static %}
{% load i18n %}
<div class="title-profile-cont"> <div class="title-profile-cont">
Подписка Подписка
@@ -7,7 +8,7 @@
<div> <div>
<div class="state_subscribe"> <div class="state_subscribe">
У вас <a>не оформлена подписка</a> {% translate "У вас" %} <a>{% translate "не оформлена подписка" %}</a>
</div> </div>
<div class="state_subscribe"> <div class="state_subscribe">

View File

@@ -108,6 +108,7 @@
<div class="cont-el-form-search-carrier last"> <div class="cont-el-form-search-carrier last">
<label>test</label> <label>test</label>
<select name="cargo_type" id="id_cargo_type" {% if form.fields.cargo_type.required %} required{% endif %}> <select name="cargo_type" id="id_cargo_type" {% if form.fields.cargo_type.required %} required{% endif %}>
<option value="" selected="selected">--не имеет значения--</option>
{% for item in form.fields.cargo_type.choices %} {% for item in form.fields.cargo_type.choices %}
<option value="{{ item.0 }}">{{ item.1 }}</option> <option value="{{ item.0 }}">{{ item.1 }}</option>
{% endfor %} {% endfor %}