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",
|
||||
"valid-jsdoc": ["error", {"requireReturn": false, "requireParamDescription": false, "requireReturnDescription": false}],
|
||||
"vars-on-top": "off",
|
||||
"operator_assignment": "off",
|
||||
"operator-assignment": "off",
|
||||
"no-else-return": "off",
|
||||
|
||||
// Node.js and CommonJS
|
||||
"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 (
|
||||
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 &&
|
||||
beestat.address.is_valid(address.address_id) === true &&
|
||||
beestat.setting('comparison_region') !== 'global'
|
||||
) {
|
||||
attributes.radius = {
|
||||
|
@ -102,10 +102,7 @@ beestat.component.card.my_home.prototype.decorate_region_ = function(parent) {
|
||||
(new beestat.component.title('Region')).render(parent);
|
||||
|
||||
var region;
|
||||
if (
|
||||
address.normalized !== null &&
|
||||
address.normalized.components !== undefined
|
||||
) {
|
||||
if (beestat.address.is_valid(address.address_id) === true) {
|
||||
region =
|
||||
address.normalized.components.state_abbreviation ||
|
||||
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 addresses = Object.values(beestat.cache.address);
|
||||
addresses.forEach(function(address) {
|
||||
if (
|
||||
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
|
||||
];
|
||||
|
||||
if (beestat.address.is_valid(address.address_id) === true) {
|
||||
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);
|
||||
|
||||
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 addresses = Object.values(beestat.cache.address);
|
||||
addresses.forEach(function(address) {
|
||||
if (
|
||||
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
|
||||
];
|
||||
|
||||
if (beestat.address.is_valid(address.address_id) === true) {
|
||||
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);
|
||||
|
||||
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/crypto.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
|
||||
echo '<script src="/js/layer.js"></script>' . PHP_EOL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user