0.0.29 add widjet
This commit is contained in:
@@ -1005,7 +1005,6 @@ form.new_route{
|
|||||||
|
|
||||||
.input_list.show{
|
.input_list.show{
|
||||||
display:block;
|
display:block;
|
||||||
height: 300px;
|
|
||||||
width: 50%;
|
width: 50%;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
@@ -19,49 +19,58 @@ function searchTown(el){
|
|||||||
return search(data)
|
return search(data)
|
||||||
},
|
},
|
||||||
error: function (data){
|
error: function (data){
|
||||||
console.log('++')
|
console.log('Error')
|
||||||
// document.querySelector(".button_register").innerHTML = data.responseJSON.html
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectItemAddrPoint(id, name){
|
function selectItemAddrPoint(id, name){
|
||||||
let ap_txt_cont = document.querySelector("#id_from_address_point_txt");
|
// from_address_point
|
||||||
let ap_cont = document.querySelector("#id_from_address_point");
|
let fap_txt_cont = document.querySelector("#id_from_address_point_txt");
|
||||||
ap_txt_cont.value = name;
|
let fap_cont = document.querySelector("#id_from_address_point");
|
||||||
ap_cont.value = id;
|
fap_txt_cont.value = name;
|
||||||
|
fap_cont.value = id;
|
||||||
|
|
||||||
|
//to_address_point
|
||||||
|
let tap_txt_cont = document.querySelector("#id_to_address_point_txt");
|
||||||
|
let tap_cont = document.querySelector("#id_to_address_point");
|
||||||
|
|
||||||
|
tap_txt_cont.value = name;
|
||||||
|
tap_cont.value = id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function search(data) {
|
|
||||||
|
|
||||||
let ac = document.querySelector("#id_from_address_point_txt");
|
// function search(data) {
|
||||||
|
//
|
||||||
if (ac.value.length > 2) {
|
// let ac = document.querySelector("#id_from_address_point_txt");
|
||||||
|
//
|
||||||
let res_data = data.data
|
// if (ac.value.length > 2) {
|
||||||
|
//
|
||||||
var divs = res_data.map(function(r, i) {
|
// let res_data = data.data
|
||||||
airport_name = "'"+r.iata_code + " - " + r.name+"'";
|
//
|
||||||
|
// var divs = res_data.map(function(r, i) {
|
||||||
return '<div onclick="selectItemAddrPoint('+ r.id+', '+ airport_name +')" class="autocomplete-result" data-index="'+ i +'" data-id="'+ r.id + '">'
|
// airport_name = "'"+r.iata_code + " - " + r.name+"'";
|
||||||
+ '<div><b>'+ r.iata_code +'</b> - '+ r.name +'</div>'
|
//
|
||||||
+ '<div class="autocomplete-location">'+ r.city__name +', '+ r.city__country__name +'</div>'
|
// return '<div onclick="selectItemAddrPoint('+ r.id+', '+ airport_name +')" class="autocomplete-result" data-index="'+ i +'" data-id="'+ r.id + '">'
|
||||||
+ '</div>';
|
// + '<div><b>'+ r.iata_code +'</b> - '+ r.name +'</div>'
|
||||||
});
|
// + '<div class="autocomplete-location">'+ r.city__name +', '+ r.city__country__name +'</div>'
|
||||||
|
// + '</div>';
|
||||||
|
// });
|
||||||
let input_list = document.querySelector(".input_list");
|
//
|
||||||
input_list.classList.toggle("show")
|
//
|
||||||
input_list.innerHTML = divs
|
// let input_list = document.querySelector(".input_list");
|
||||||
|
// input_list.classList.toggle("show")
|
||||||
|
// input_list.innerHTML = divs
|
||||||
// .html(divs.join(''))
|
//
|
||||||
// .attr('data-highlight', selectedIndex);
|
//
|
||||||
|
// // .html(divs.join(''))
|
||||||
} else {
|
// // .attr('data-highlight', selectedIndex);
|
||||||
numResults = 0;
|
//
|
||||||
let divs = [];
|
// } else {
|
||||||
|
// numResults = 0;
|
||||||
}
|
// let divs = [];
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
@@ -42,17 +42,23 @@
|
|||||||
<label for="id_from_address_point">{{ form.fields.from_address_point.label }}</label>
|
<label for="id_from_address_point">{{ form.fields.from_address_point.label }}</label>
|
||||||
<input type="number" name="from_address_point" id="id_from_address_point" hidden />
|
<input type="number" name="from_address_point" id="id_from_address_point" hidden />
|
||||||
<input oninput="searchTown(this)" type="text" name="from_address_point_txt"{% if form.fields.from_address_point.required %} required{% endif %} id="id_from_address_point_txt">
|
<input oninput="searchTown(this)" type="text" name="from_address_point_txt"{% if form.fields.from_address_point.required %} required{% endif %} id="id_from_address_point_txt">
|
||||||
<div class="input_list" name="from_address_point_txt"></div>
|
<div class="input_list" name="from_address_point_txt">
|
||||||
|
{% include 'widgets/w_autocomplete_input.html' %}
|
||||||
|
</div>
|
||||||
{% if form.errors and form.errors.from_address_point %}
|
{% if form.errors and form.errors.from_address_point %}
|
||||||
<span>{{ form.errors.from_address_point}}</span>
|
<span>{{ form.errors.from_address_point}}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="id_to_address_point">{{ form.fields.to_address_point.label }}</label>
|
<label for="id_to_address_point">{{ form.fields.to_address_point.label }}</label>
|
||||||
<input type="text" name="to_address_point"{% if form.fields.to_address_point.required %} required{% endif %} id="id_to_address_point">
|
<input type="number" name="to_address_point" id="id_to_address_point" hidden />
|
||||||
|
<input oninput="searchTown(this)" type="text" name="to_address_point_txt"{% if form.fields.to_address_point.required %} required{% endif %} id="id_to_address_point"/>
|
||||||
|
<div class="input_list" name="from_address_point_txt">
|
||||||
|
{% include 'widgets/w_autocomplete_input.html' %}
|
||||||
|
</div>
|
||||||
{% if form.errors and form.errors.to_address_point %}
|
{% if form.errors and form.errors.to_address_point %}
|
||||||
<span>{{ form.errors.to_address_point }}</span>
|
<span>{{ form.errors.to_address_point }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{# <div>#}
|
{# <div>#}
|
||||||
|
|||||||
6
templates/widgets/w_autocomplete_input.html
Normal file
6
templates/widgets/w_autocomplete_input.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<div onclick="selectItemAddrPoint('+ r.id+', '+ airport_name +')" class="autocomplete-result" data-index="'+ i +'" data-id="'+ r.id + '">
|
||||||
|
<div>
|
||||||
|
<b></b>
|
||||||
|
</div>
|
||||||
|
<div class="autocomplete-location"></div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user