Skip to content

Commit

Permalink
Merge pull request #6 from theideabureau/main
Browse files Browse the repository at this point in the history
Added compatibility with whitecube/nova-flexible-content
  • Loading branch information
JamesHemery committed Jul 9, 2023
2 parents 03970f8 + 26c1ed6 commit 242c06e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/js/field.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vuex v4.0.2
* (c) 2021 Evan You
* vuex v4.1.0
* (c) 2022 Evan You
* @license MIT
*/
15 changes: 15 additions & 0 deletions resources/js/components/AddressMetadata/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export default {
} while (match !== null);
Nova.$on('address-metadata-update', locationObject => {
if (this.checkIfFlexibleField(locationObject.attribute)) {
return;
}
let addressValue = this.field.addressValue;
for (let i = 0; i < addressParts.length; i++) {
Expand All @@ -64,6 +68,10 @@ export default {
});
} else {
Nova.$on('address-metadata-update', locationObject => {
if (this.checkIfFlexibleField(locationObject.attribute)) {
return;
}
this.value = locationObject[this.field.addressValue];
});
}
Expand All @@ -78,6 +86,13 @@ export default {
handleChange(value) {
this.value = value;
},
checkIfFlexibleField(attributeName) {
const flexibleFieldKey = this.field.attribute.match(/((.{16})__)/);
// if the flexible field key exists but doesn't match the first 16 characters
// of the location object attribute, return to not set the value on this field
return flexibleFieldKey && attributeName.indexOf(flexibleFieldKey[0]) === -1;
},
},
};
</script>
Expand Down
5 changes: 4 additions & 1 deletion resources/js/components/GoogleAutocomplete/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export default {
}
});
Nova.$emit('address-metadata-update', { ...retrievedAddress });
Nova.$emit('address-metadata-update', {
attribute: this.field.attribute,
...retrievedAddress
});
},
setInitialValue() {
this.value = this.field.value || '';
Expand Down

0 comments on commit 242c06e

Please sign in to comment.