mirror of
https://github.com/beestat/app.git
synced 2025-07-09 03:04:07 -04:00
Fixed international addresses not showing up correctly
This commit is contained in:
parent
6736326f20
commit
f59621fb6c
@ -61,7 +61,8 @@
|
|||||||
"strict": "off",
|
"strict": "off",
|
||||||
"valid-jsdoc": ["error", {"requireReturn": false, "requireParamDescription": false, "requireReturnDescription": false}],
|
"valid-jsdoc": ["error", {"requireReturn": false, "requireParamDescription": false, "requireReturnDescription": false}],
|
||||||
"vars-on-top": "off",
|
"vars-on-top": "off",
|
||||||
"operator_assignment": "off",
|
"operator-assignment": "off",
|
||||||
|
"no-else-return": "off",
|
||||||
|
|
||||||
// Node.js and CommonJS
|
// Node.js and CommonJS
|
||||||
"callback-return": "off",
|
"callback-return": "off",
|
||||||
|
47
js/beestat/address.js
Normal file
47
js/beestat/address.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
beestat.address = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the parts of an address in two separate lines.
|
||||||
|
*
|
||||||
|
* @param {number} address_id
|
||||||
|
*
|
||||||
|
* @return {array}
|
||||||
|
*/
|
||||||
|
beestat.address.get_lines = function(address_id) {
|
||||||
|
const address = beestat.cache.address[address_id];
|
||||||
|
|
||||||
|
if (address.normalized === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(address);
|
||||||
|
|
||||||
|
// US Address
|
||||||
|
if (address.normalized.components.country_iso_3 === 'USA') {
|
||||||
|
return [
|
||||||
|
address.normalized.delivery_line_1,
|
||||||
|
[
|
||||||
|
address.normalized.components.city_name,
|
||||||
|
address.normalized.components.state_abbreviation + ',',
|
||||||
|
address.normalized.components.zipcode
|
||||||
|
].join(' ')
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
address.normalized.address1,
|
||||||
|
address.normalized.address2
|
||||||
|
];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether or not this address was validated and thus has address components/metadata, is geocoded, etc.
|
||||||
|
*
|
||||||
|
* @param {number} address_id
|
||||||
|
*
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
beestat.address.is_valid = function(address_id) {
|
||||||
|
const address = beestat.cache.address[address_id];
|
||||||
|
return address.normalized !== null;
|
||||||
|
};
|
@ -81,12 +81,7 @@ beestat.comparisons.get_attributes = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
address.normalized !== null &&
|
beestat.address.is_valid(address.address_id) === true &&
|
||||||
address.normalized.metadata !== undefined &&
|
|
||||||
address.normalized.metadata.latitude !== undefined &&
|
|
||||||
address.normalized.metadata.latitude !== null &&
|
|
||||||
address.normalized.metadata.longitude !== undefined &&
|
|
||||||
address.normalized.metadata.longitude !== null &&
|
|
||||||
beestat.setting('comparison_region') !== 'global'
|
beestat.setting('comparison_region') !== 'global'
|
||||||
) {
|
) {
|
||||||
attributes.radius = {
|
attributes.radius = {
|
||||||
|
@ -102,10 +102,7 @@ beestat.component.card.my_home.prototype.decorate_region_ = function(parent) {
|
|||||||
(new beestat.component.title('Region')).render(parent);
|
(new beestat.component.title('Region')).render(parent);
|
||||||
|
|
||||||
var region;
|
var region;
|
||||||
if (
|
if (beestat.address.is_valid(address.address_id) === true) {
|
||||||
address.normalized !== null &&
|
|
||||||
address.normalized.components !== undefined
|
|
||||||
) {
|
|
||||||
region =
|
region =
|
||||||
address.normalized.components.state_abbreviation ||
|
address.normalized.components.state_abbreviation ||
|
||||||
address.normalized.components.locality ||
|
address.normalized.components.locality ||
|
||||||
|
@ -122,26 +122,9 @@ beestat.component.modal.create_floor_plan.prototype.decorate_contents_ = functio
|
|||||||
const radio_group = new beestat.component.radio_group();
|
const radio_group = new beestat.component.radio_group();
|
||||||
const addresses = Object.values(beestat.cache.address);
|
const addresses = Object.values(beestat.cache.address);
|
||||||
addresses.forEach(function(address) {
|
addresses.forEach(function(address) {
|
||||||
if (
|
if (beestat.address.is_valid(address.address_id) === true) {
|
||||||
address.normalized !== null &&
|
|
||||||
address.normalized.metadata !== undefined &&
|
|
||||||
address.normalized.metadata.latitude !== undefined &&
|
|
||||||
address.normalized.metadata.latitude !== null &&
|
|
||||||
address.normalized.metadata.longitude !== undefined &&
|
|
||||||
address.normalized.metadata.longitude !== null
|
|
||||||
) {
|
|
||||||
const address_parts = [
|
|
||||||
address.normalized.components.primary_number,
|
|
||||||
address.normalized.components.street_predirection,
|
|
||||||
address.normalized.components.street_name,
|
|
||||||
address.normalized.components.street_suffix,
|
|
||||||
address.normalized.components.city_name + ',',
|
|
||||||
address.normalized.components.state_abbreviation,
|
|
||||||
address.normalized.components.zipcode
|
|
||||||
];
|
|
||||||
|
|
||||||
let radio = new beestat.component.input.radio()
|
let radio = new beestat.component.input.radio()
|
||||||
.set_label(address_parts.join(' '))
|
.set_label(beestat.address.get_lines(address.address_id)[0])
|
||||||
.set_value(address.address_id);
|
.set_value(address.address_id);
|
||||||
|
|
||||||
if (addresses.length === 1) {
|
if (addresses.length === 1) {
|
||||||
|
@ -82,26 +82,9 @@ beestat.component.modal.update_floor_plan.prototype.decorate_contents_ = functio
|
|||||||
const radio_group = new beestat.component.radio_group();
|
const radio_group = new beestat.component.radio_group();
|
||||||
const addresses = Object.values(beestat.cache.address);
|
const addresses = Object.values(beestat.cache.address);
|
||||||
addresses.forEach(function(address) {
|
addresses.forEach(function(address) {
|
||||||
if (
|
if (beestat.address.is_valid(address.address_id) === true) {
|
||||||
address.normalized !== null &&
|
|
||||||
address.normalized.metadata !== undefined &&
|
|
||||||
address.normalized.metadata.latitude !== undefined &&
|
|
||||||
address.normalized.metadata.latitude !== null &&
|
|
||||||
address.normalized.metadata.longitude !== undefined &&
|
|
||||||
address.normalized.metadata.longitude !== null
|
|
||||||
) {
|
|
||||||
const address_parts = [
|
|
||||||
address.normalized.components.primary_number,
|
|
||||||
address.normalized.components.street_predirection,
|
|
||||||
address.normalized.components.street_name,
|
|
||||||
address.normalized.components.street_suffix,
|
|
||||||
address.normalized.components.city_name + ',',
|
|
||||||
address.normalized.components.state_abbreviation,
|
|
||||||
address.normalized.components.zipcode
|
|
||||||
];
|
|
||||||
|
|
||||||
let radio = new beestat.component.input.radio()
|
let radio = new beestat.component.input.radio()
|
||||||
.set_label(address_parts.join(' '))
|
.set_label(beestat.address.get_lines(address.address_id)[0])
|
||||||
.set_value(address.address_id);
|
.set_value(address.address_id);
|
||||||
|
|
||||||
if (address.address_id === floor_plan.address_id) {
|
if (address.address_id === floor_plan.address_id) {
|
||||||
|
@ -43,6 +43,7 @@ if($setting->get('environment') === 'dev' || $setting->get('environment') === 'd
|
|||||||
echo '<script src="/js/beestat/touch.js"></script>' . PHP_EOL;
|
echo '<script src="/js/beestat/touch.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/beestat/crypto.js"></script>' . PHP_EOL;
|
echo '<script src="/js/beestat/crypto.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/beestat/floor_plan.js"></script>' . PHP_EOL;
|
echo '<script src="/js/beestat/floor_plan.js"></script>' . PHP_EOL;
|
||||||
|
echo '<script src="/js/beestat/address.js"></script>' . PHP_EOL;
|
||||||
|
|
||||||
// Layer
|
// Layer
|
||||||
echo '<script src="/js/layer.js"></script>' . PHP_EOL;
|
echo '<script src="/js/layer.js"></script>' . PHP_EOL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user