search_list show rules
This commit is contained in:
SDE
2023-07-21 17:28:25 +03:00
parent 9a92cdc64f
commit e377eecacf
2 changed files with 20 additions and 15 deletions

View File

@@ -24,7 +24,7 @@ def get_address_point_ajax(request):
data = json.loads(request.body)
if not 'search_str' in data or not 'type_transport' in data:
if not 'search_str' in data or not 'type_transport' in data or not 'ctrl_name' in data:
errors_Dict = {
'errors': {
'all__': f'ошибка в запросе = недостаточно данных'
@@ -32,7 +32,7 @@ def get_address_point_ajax(request):
}
return JsonResponse(errors_Dict, status=400)
if len(data['search_str'].strip()) < 0:
if len(data['search_str'].strip()) < 3:
res_data = []
else:
if data['type_transport'] == 'avia':

View File

@@ -33,18 +33,18 @@ function searchTown(el){
function selectItemAddrPoint(id, name, ctrl_name){
//reset value
if (ctrl_name.startsWith("from")){
let fap_txt_cont = document.querySelector("#id_" + ctrl_name);
let fap_cont = document.querySelector("#id_" + ctrl_name.slice(0, -4));
fap_txt_cont.value = name;
fap_cont.value = id;
}
else if (ctrl_name.startsWith("to")) {
// if (ctrl_name.startsWith("from")){
// let fap_txt_cont = document.querySelector("#id_" + ctrl_name);
// let fap_cont = document.querySelector("#id_" + ctrl_name.slice(0, -4));
// fap_txt_cont.value = name;
// fap_cont.value = id;
// }
// else if (ctrl_name.startsWith("to")) {
let tap_txt_cont = document.querySelector("#id_" + ctrl_name);
tap_txt_cont.value = name;
let tap_cont = document.querySelector("#id_" + ctrl_name.slice(0, -4));
tap_cont.value = id;
}
// }
@@ -67,11 +67,16 @@ function selectItemAddrPoint(id, name, ctrl_name){
function insertSearchList(data, ctrl_name) {
// let ac = document.querySelector("#id_from_address_point_txt");
let divs = data.res_search_list;
let input_list = document.getElementsByName(ctrl_name)[0];
let divs = data.res_search_list;
if (divs.length > 0) {
// let ac = document.querySelector("#id_from_address_point_txt");
input_list.classList.add("show");
input_list.innerHTML = divs;
} else {
input_list.classList.remove("show");
}
//
// if (ac.value.length > 2) {
// //