mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-07-11 07:26:18 -04:00
Fix nominatim address lookup with jquery ui autcomplete (#328)
Add dblclick event handler to item + customer autocomplete in register
This commit is contained in:
@@ -65,11 +65,11 @@
|
||||
<!-- start mincss template tags -->
|
||||
<link rel="stylesheet" type="text/css" href="dist/bootstrap.min.css?rel=9ed20b1ee8"/>
|
||||
<link rel="stylesheet" type="text/css" href="dist/jquery-ui.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=a5e6ea4b25"/>
|
||||
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=fab2796a66"/>
|
||||
<link rel="stylesheet" type="text/css" href="dist/opensourcepos_bower.css"/>
|
||||
<!-- end mincss template tags -->
|
||||
<!-- start minjs template tags -->
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=3fc124cd56" language="javascript"></script>
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=0bc5d892d3" language="javascript"></script>
|
||||
<!-- end minjs template tags -->
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -466,8 +466,6 @@ $(document).ready(function()
|
||||
}
|
||||
};
|
||||
|
||||
$('#item, #customer').click(clear_fields);
|
||||
|
||||
$("#customer").autocomplete(
|
||||
{
|
||||
source: '<?php echo site_url("customers/suggest"); ?>',
|
||||
@@ -479,7 +477,12 @@ $(document).ready(function()
|
||||
}
|
||||
});
|
||||
|
||||
$('#customer').blur(function()
|
||||
$('#item, #customer').click(clear_fields).dblclick(function(event) {
|
||||
$(this).autocomplete("search");
|
||||
});
|
||||
|
||||
|
||||
$('#customer').blur(function()
|
||||
{
|
||||
$(this).val("<?php echo $this->lang->line('sales_start_typing_customer_name'); ?>");
|
||||
});
|
||||
|
||||
117
dist/opensourcepos.js
vendored
117
dist/opensourcepos.js
vendored
@@ -51606,7 +51606,8 @@ dialog_support = (function() {
|
||||
var url = http_s('nominatim.openstreetmap.org/search');
|
||||
|
||||
var handle_auto_completion = function(fields) {
|
||||
return function(event, results, formatted) {
|
||||
return function(event, ui) {
|
||||
var results = ui.item.results;
|
||||
if (results != null && results.length > 0) {
|
||||
// handle auto completion
|
||||
for(var i in fields) {
|
||||
@@ -51618,10 +51619,6 @@ dialog_support = (function() {
|
||||
};
|
||||
};
|
||||
|
||||
var set_field_values = function(results) {
|
||||
return results[0] + ' - ' + results[1];
|
||||
};
|
||||
|
||||
var create_parser = function(field_name, parse_format)
|
||||
{
|
||||
var parse_field = function(format, address)
|
||||
@@ -51642,78 +51639,76 @@ dialog_support = (function() {
|
||||
var parsed = [];
|
||||
$.each(data, function(index, value)
|
||||
{
|
||||
var address = value.address;
|
||||
var row = [];
|
||||
var row = [];
|
||||
var address = value.address;
|
||||
$.each(parse_format, function(key, format)
|
||||
{
|
||||
row.push(parse_field(format, address));
|
||||
});
|
||||
parsed[index] = {
|
||||
data: row,
|
||||
value: address[field_name],
|
||||
result: address[field_name]
|
||||
label: row.join(", "),
|
||||
results: row,
|
||||
value: address[field_name]
|
||||
};
|
||||
});
|
||||
return parsed;
|
||||
};
|
||||
};
|
||||
|
||||
var request_params = function(id, key, language)
|
||||
{
|
||||
return function() {
|
||||
var result = {
|
||||
format: 'json',
|
||||
limit: 5,
|
||||
addressdetails: 1,
|
||||
country: window['sessionStorage'] ? sessionStorage['country'] : 'be',
|
||||
'accept-language' : language || navigator.language
|
||||
};
|
||||
result[key || id] = $("#"+id).val();
|
||||
return result;
|
||||
}
|
||||
var init = function(options) {
|
||||
|
||||
var default_params = function(id, key, language)
|
||||
{
|
||||
return function() {
|
||||
var result = {
|
||||
format: 'json',
|
||||
limit: 5,
|
||||
addressdetails: 1,
|
||||
countrycodes: window['sessionStorage'] ? sessionStorage['country'] : 'be',
|
||||
'accept-language' : language || navigator.language
|
||||
};
|
||||
result[key || id] = $("#"+id).val();
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$.each(options.fields, function(key, value)
|
||||
{
|
||||
var handle_field_completion = handle_auto_completion(value.dependencies);
|
||||
|
||||
$("#" + key).autocomplete({
|
||||
source: function (request, response) {
|
||||
var params = default_params(key, value.response && value.response.field, options.language);
|
||||
var request_params = {q: request.term};
|
||||
$.each(options.extra_params, function(key, param) {
|
||||
request_params[key] = typeof param == "function" ? param() : param;
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "json",
|
||||
data: $.extend(request_params, params()),
|
||||
success: function(data) {
|
||||
response($.map(data, function(item) {
|
||||
return (create_parser(key, (value.response && value.response.format) || value.dependencies))(data)
|
||||
}))
|
||||
}
|
||||
});
|
||||
},
|
||||
minChars:3,
|
||||
delay:500,
|
||||
appendTo: '.modal-content',
|
||||
select: handle_field_completion
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
var nominatim = {
|
||||
|
||||
init : function(options) {
|
||||
|
||||
$.each(options.fields, function(key, value)
|
||||
{
|
||||
var handle_field_completion = handle_auto_completion(value.dependencies);
|
||||
|
||||
$("#" + key).autocomplete({
|
||||
source: function (request, response) {
|
||||
var extra_params = request_params(key, value.response && value.response.field, options.language);
|
||||
$.each(options.extra_params, function(key, param) {
|
||||
extra_params[key] = typeof param == "function" ? param() : param;
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "json",
|
||||
data: $.extend(request, extra_params),
|
||||
success: function(data) {
|
||||
response($.map(data, function(item) {
|
||||
return {
|
||||
value: item.label
|
||||
};
|
||||
}))
|
||||
}
|
||||
});
|
||||
},
|
||||
minChars:3,
|
||||
delay:500,
|
||||
formatItem: set_field_values,
|
||||
parse: create_parser(key, (value.response && value.response.format) || value.dependencies),
|
||||
result: function(a, ui) {
|
||||
$("#" + ui.item.value).result(handle_field_completion);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
init : init
|
||||
|
||||
};
|
||||
|
||||
|
||||
19
dist/opensourcepos.min.css
vendored
19
dist/opensourcepos.min.css
vendored
File diff suppressed because one or more lines are too long
2
dist/opensourcepos.min.js
vendored
2
dist/opensourcepos.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -19,7 +19,8 @@
|
||||
var url = http_s('nominatim.openstreetmap.org/search');
|
||||
|
||||
var handle_auto_completion = function(fields) {
|
||||
return function(event, results, formatted) {
|
||||
return function(event, ui) {
|
||||
var results = ui.item.results;
|
||||
if (results != null && results.length > 0) {
|
||||
// handle auto completion
|
||||
for(var i in fields) {
|
||||
@@ -31,10 +32,6 @@
|
||||
};
|
||||
};
|
||||
|
||||
var set_field_values = function(results) {
|
||||
return results[0] + ' - ' + results[1];
|
||||
};
|
||||
|
||||
var create_parser = function(field_name, parse_format)
|
||||
{
|
||||
var parse_field = function(format, address)
|
||||
@@ -55,78 +52,76 @@
|
||||
var parsed = [];
|
||||
$.each(data, function(index, value)
|
||||
{
|
||||
var address = value.address;
|
||||
var row = [];
|
||||
var row = [];
|
||||
var address = value.address;
|
||||
$.each(parse_format, function(key, format)
|
||||
{
|
||||
row.push(parse_field(format, address));
|
||||
});
|
||||
parsed[index] = {
|
||||
data: row,
|
||||
value: address[field_name],
|
||||
result: address[field_name]
|
||||
label: row.join(", "),
|
||||
results: row,
|
||||
value: address[field_name]
|
||||
};
|
||||
});
|
||||
return parsed;
|
||||
};
|
||||
};
|
||||
|
||||
var request_params = function(id, key, language)
|
||||
{
|
||||
return function() {
|
||||
var result = {
|
||||
format: 'json',
|
||||
limit: 5,
|
||||
addressdetails: 1,
|
||||
country: window['sessionStorage'] ? sessionStorage['country'] : 'be',
|
||||
'accept-language' : language || navigator.language
|
||||
};
|
||||
result[key || id] = $("#"+id).val();
|
||||
return result;
|
||||
}
|
||||
var init = function(options) {
|
||||
|
||||
var default_params = function(id, key, language)
|
||||
{
|
||||
return function() {
|
||||
var result = {
|
||||
format: 'json',
|
||||
limit: 5,
|
||||
addressdetails: 1,
|
||||
countrycodes: window['sessionStorage'] ? sessionStorage['country'] : 'be',
|
||||
'accept-language' : language || navigator.language
|
||||
};
|
||||
result[key || id] = $("#"+id).val();
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$.each(options.fields, function(key, value)
|
||||
{
|
||||
var handle_field_completion = handle_auto_completion(value.dependencies);
|
||||
|
||||
$("#" + key).autocomplete({
|
||||
source: function (request, response) {
|
||||
var params = default_params(key, value.response && value.response.field, options.language);
|
||||
var request_params = {q: request.term};
|
||||
$.each(options.extra_params, function(key, param) {
|
||||
request_params[key] = typeof param == "function" ? param() : param;
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "json",
|
||||
data: $.extend(request_params, params()),
|
||||
success: function(data) {
|
||||
response($.map(data, function(item) {
|
||||
return (create_parser(key, (value.response && value.response.format) || value.dependencies))(data)
|
||||
}))
|
||||
}
|
||||
});
|
||||
},
|
||||
minChars:3,
|
||||
delay:500,
|
||||
appendTo: '.modal-content',
|
||||
select: handle_field_completion
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
var nominatim = {
|
||||
|
||||
init : function(options) {
|
||||
|
||||
$.each(options.fields, function(key, value)
|
||||
{
|
||||
var handle_field_completion = handle_auto_completion(value.dependencies);
|
||||
|
||||
$("#" + key).autocomplete({
|
||||
source: function (request, response) {
|
||||
var extra_params = request_params(key, value.response && value.response.field, options.language);
|
||||
$.each(options.extra_params, function(key, param) {
|
||||
extra_params[key] = typeof param == "function" ? param() : param;
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "json",
|
||||
data: $.extend(request, extra_params),
|
||||
success: function(data) {
|
||||
response($.map(data, function(item) {
|
||||
return {
|
||||
value: item.label
|
||||
};
|
||||
}))
|
||||
}
|
||||
});
|
||||
},
|
||||
minChars:3,
|
||||
delay:500,
|
||||
formatItem: set_field_values,
|
||||
parse: create_parser(key, (value.response && value.response.format) || value.dependencies),
|
||||
result: function(a, ui) {
|
||||
$("#" + ui.item.value).result(handle_field_completion);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
init : init
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -65,11 +65,11 @@
|
||||
<![endif]-->
|
||||
<link rel="stylesheet" type="text/css" href="templates/spacelab/css/bootstrap.min.css?rel=9ed20b1ee8"/>
|
||||
<!-- start mincss template tags -->
|
||||
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=a5e6ea4b25"/>
|
||||
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=fab2796a66"/>
|
||||
<!-- end mincss template tags -->
|
||||
<link rel="stylesheet" type="text/css" href="templates/spacelab/css/style.css"/>
|
||||
<!-- start minjs template tags -->
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=3fc124cd56" language="javascript"></script>
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=0bc5d892d3" language="javascript"></script>
|
||||
<!-- end minjs template tags -->
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user