Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Allow multiple autocompletes per page #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45,435 changes: 45,433 additions & 2 deletions dist/js/field.js

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions resources/js/components/AddressMetadata/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export default {
mixins: [FormField, HandlesValidationErrors],
props: ['resourceName', 'resourceId', 'field'],
mounted() {
Nova.$on('address-metadata-clear', () => {
Nova.$on('address-metadata-clear-' + this.groupId, () => {
this.value = '';
});

if (this.field.asJson) {
Nova.$on('address-metadata-update', locationObject => {
Nova.$on('address-metadata-update-' + this.groupId, locationObject => {
this.value = JSON.stringify(locationObject);
});
} else if (this.field.addressValue.indexOf('{{') >= 0) {
Expand All @@ -52,7 +52,7 @@ export default {
}
} while (match !== null);

Nova.$on('address-metadata-update', locationObject => {
Nova.$on('address-metadata-update-' + this.groupId, locationObject => {
if (this.checkIfFlexibleField(locationObject.attribute)) {
return;
}
Expand All @@ -72,7 +72,7 @@ export default {
this.value = addressValue;
});
} else {
Nova.$on('address-metadata-update', locationObject => {
Nova.$on('address-metadata-update-' + this.groupId, locationObject => {
if (this.checkIfFlexibleField(locationObject.attribute)) {
return;
}
Expand All @@ -81,6 +81,11 @@ export default {
});
}
},
computed: {
groupId () {
return this._.parent.uid
},
},
methods: {
setInitialValue() {
this.value = this.field.value || '';
Expand Down
7 changes: 5 additions & 2 deletions resources/js/components/GoogleAutocomplete/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ export default {

return this.__('nga_search');
},
groupId () {
return this._.parent.uid
},
},
methods: {
clear() {
this.$refs.searchField.$refs.autocomplete.value = '';
this.value = '';
Nova.$emit('address-metadata-clear');
Nova.$emit('address-metadata-clear-' + this.groupId);
},
getAddressData(addressData, placeResultData) {
// Save current data address as a string
Expand Down Expand Up @@ -91,7 +94,7 @@ export default {
}
});

Nova.$emit('address-metadata-update', {
Nova.$emit('address-metadata-update-' + this.groupId, {
attribute: this.field.attribute,
...retrievedAddress,
});
Expand Down