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

Fixed: Added validation on Longitude/latitude(#255) #262

Open
wants to merge 4 commits 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
8 changes: 7 additions & 1 deletion src/components/FacilityAddressModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</ion-select>
</ion-item>
<ion-item>
<ion-input label-placement="floating" v-model="address.postalCode">
<ion-input label-placement="floating" v-model="address.postalCode" @keydown="validateZipCode($event)">
<div slot="label">{{ translate("Zipcode") }} <ion-text color="danger">*</ion-text></div>
</ion-input>
</ion-item>
Expand Down Expand Up @@ -149,6 +149,12 @@ export default defineComponent({
closeModal() {
modalController.dismiss()
},
validateZipCode(e: any) {
if(/[`!@#$%^&*()_+=\\|,.<>?~{};:'"/]/.test(e.key)){
e.preventDefault();
return false;
}
},
async saveContact() {
let resp, postalAddress = '';

Expand Down
20 changes: 17 additions & 3 deletions src/components/FacilityGeoPointModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@
<ion-content>
<form @keyup.enter="saveGeoPoint">
<ion-item class="ion-margin-bottom">
<ion-input aria-label="zipcode" :placeholder="translate('Zipcode')" v-model="geoPoint.postalCode" />
<ion-input aria-label="zipcode" :placeholder="translate('Zipcode')" v-model="geoPoint.postalCode" @keydown="validateZipCode($event)"/>
<ion-button slot="end" fill="outline" @click="generateLatLong">
{{ translate("Generate") }}
<ion-icon v-if="!isGeneratingLatLong" slot="end" :icon="colorWandOutline" />
<ion-spinner v-else data-spinner-size="small"/>
</ion-button>
</ion-item>
<ion-item>
<ion-input label-placement="floating" :label="translate('Latitude')" v-model="geoPoint.latitude" />
<ion-input label-placement="floating" type="number" v-model="geoPoint.latitude">
<div slot="label">{{ translate("Latitude")}}<ion-text color="danger">*</ion-text></div>
</ion-input>
</ion-item>
<ion-item>
<ion-input label-placement="floating" :label="translate('Longitude')" v-model="geoPoint.longitude" />
<ion-input label-placement="floating" type="number" v-model="geoPoint.longitude">
<div slot="label">{{ translate("Longitude")}}<ion-text color="danger">*</ion-text></div>
</ion-input>
</ion-item>
</form>
</ion-content>
Expand Down Expand Up @@ -98,7 +102,17 @@ export default defineComponent({
closeModal() {
modalController.dismiss()
},
validateZipCode(e: any) {
if(/[`!@#$%^&*()_+=\\|,.<>?~{};:'"/]/.test(e.key)){
e.preventDefault();
return false;
}
},
async generateLatLong() {
if(!this.geoPoint.postalCode) {
showToast("Please fill the required Zipcode")
return;
}
this.isGeneratingLatLong = true
const payload = {
json: {
Expand Down
3 changes: 1 addition & 2 deletions src/views/FacilityDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@
<ion-icon slot="end" :icon="addCircleOutline" />
</ion-button>
</ion-card>

<ion-card>
<ion-card-header>
<ion-card-title>
{{ translate("Latitude & Longitude") }}
</ion-card-title>
</ion-card-header>
<template v-if="postalAddress?.latitude">
<template v-if="postalAddress?.latitude || postalAddress.latitude == 0">
<ion-card-content>
{{ translate("These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.") }}
</ion-card-content>
Expand Down
Loading