-
Notifications
You must be signed in to change notification settings - Fork 16
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
Implemented: support to add,update and display an address and latitude, longitude for a facility (#20) #22
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
24dbbf3
Implemented: action, service and state for fetching facility contact …
amansinghbais 12ee9f7
Improved: added support to fetch and display facility contact informa…
amansinghbais 7915e74
Implemented: services for adding and updating address, generating lat…
amansinghbais b0a41c6
Improved: code for generating geopoints, methods name (#20)
amansinghbais 1c9a328
Improved: code syntax, removed unused mutations, alphabetical entries…
amansinghbais 6196d88
Implemented: logic to add/update geoPoints, disable lat&long buttons …
amansinghbais f229af1
Merge branch 'main' of https://github.com/hotwax/facilities into faci…
amansinghbais ce5af3d
Improved: code for unused getter, error message, rendering postalCode…
amansinghbais aa9bf61
Merge branch 'main' of https://github.com/hotwax/facilities into faci…
amansinghbais abf6695
Implemented: state & countries dropdown accessibility and lat-long up…
amansinghbais bb7d313
Implemented: cacheing for states to avoid multiple api calls (#20)
amansinghbais eb5aaa3
Improved: code to add keyboard accessibility to form modals (#20)
amansinghbais 77733d7
Improved: code to fetch only required fields from api (#20)
amansinghbais bf87bfe
Improved: geoPoint modal variable name (#20)
amansinghbais 3935f50
Improved: ion-select looping logic, states type, payload entries (#20)
amansinghbais cf64836
Merge branch 'main' of https://github.com/hotwax/facilities into faci…
amansinghbais 58d7029
Improved: code to showToast and return when we save modal without cha…
amansinghbais 348fa5a
Improved: payload mapping reduced for optimized code(#20)
amansinghbais 6a351ef
Improved: added translation to placeholder (#20)
amansinghbais e47b178
Merge branch 'main' of https://github.com/hotwax/facilities into faci…
amansinghbais 125231e
Improved: added facilityId in payload for updating lat-long (#20)
amansinghbais File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
<template> | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-buttons slot="start"> | ||
<ion-button @click="closeModal()"> | ||
<ion-icon slot="icon-only" :icon="closeOutline" /> | ||
</ion-button> | ||
</ion-buttons> | ||
<ion-title>{{ translate("Address") }}</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content> | ||
<form @keyup.enter="saveAddress"> | ||
<ion-item> | ||
<ion-label>{{ translate("Address line 1") }} <ion-text color="danger">*</ion-text></ion-label> | ||
<ion-input v-model="address.address1" slot="end" /> | ||
</ion-item> | ||
<ion-item class="ion-margin-bottom"> | ||
<ion-label>{{ translate("Address line 2") }}</ion-label> | ||
<ion-input v-model="address.address2" slot="end" /> | ||
</ion-item> | ||
<ion-item> | ||
<ion-label>{{ translate("City") }} <ion-text color="danger">*</ion-text></ion-label> | ||
<ion-input v-model="address.city" slot="end" /> | ||
</ion-item> | ||
<ion-item @keyup.enter.stop> | ||
<ion-label>{{ translate("Country") }}</ion-label> | ||
<ion-select interface="popover" :placeholder="translate('Select')" @ionChange="updateState($event)" v-model="address.countryGeoId"> | ||
<ion-select-option v-for="country in countries" :key="country.geoId" :value="country.geoId">{{ country.geoName }}</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
<ion-item @keyup.enter.stop> | ||
<ion-label>{{ translate("State") }}</ion-label> | ||
<ion-select interface="popover" :placeholder="translate('Select')" v-model="address.stateProvinceGeoId"> | ||
<ion-select-option v-for="state in states[address.countryGeoId]" :key="state.geoId" :value="state.geoId">{{ state.geoName }}</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
<ion-item> | ||
<ion-label>{{ translate("Zipcode") }}</ion-label> | ||
<ion-input v-model="address.postalCode" slot="end" /> | ||
</ion-item> | ||
</form> | ||
</ion-content> | ||
|
||
<ion-fab vertical="bottom" horizontal="end" slot="fixed"> | ||
<ion-fab-button @click="saveAddress"> | ||
<ion-icon :icon="saveOutline" /> | ||
</ion-fab-button> | ||
</ion-fab> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { | ||
IonButton, | ||
IonButtons, | ||
IonContent, | ||
IonFab, | ||
IonFabButton, | ||
IonHeader, | ||
IonIcon, | ||
IonInput, | ||
IonItem, | ||
IonLabel, | ||
IonSelect, | ||
IonSelectOption, | ||
IonText, | ||
IonTitle, | ||
IonToolbar, | ||
modalController | ||
} from "@ionic/vue"; | ||
import { defineComponent } from "vue"; | ||
import { mapGetters, useStore } from "vuex"; | ||
import { closeOutline, saveOutline } from "ionicons/icons"; | ||
import { translate } from '@hotwax/dxp-components' | ||
import { FacilityService } from '@/services/FacilityService'; | ||
import { hasError } from "@/adapter"; | ||
import logger from "@/logger"; | ||
import { showToast } from "@/utils"; | ||
|
||
export default defineComponent({ | ||
name: "FacilityAddressModal", | ||
components: { | ||
IonButton, | ||
IonButtons, | ||
IonContent, | ||
IonFab, | ||
IonFabButton, | ||
IonHeader, | ||
IonIcon, | ||
IonInput, | ||
IonItem, | ||
IonLabel, | ||
IonSelect, | ||
IonSelectOption, | ||
IonText, | ||
IonTitle, | ||
IonToolbar | ||
}, | ||
computed: { | ||
...mapGetters({ | ||
postalAddress: 'facility/getPostalAddress', | ||
countries: 'util/getCountries', | ||
states: 'util/getStates' | ||
}) | ||
}, | ||
data() { | ||
return { | ||
address: {} as any | ||
} | ||
}, | ||
props: ['facilityId'], | ||
async mounted() { | ||
this.address = JSON.parse(JSON.stringify(this.postalAddress)) | ||
await this.store.dispatch('util/fetchCountries', { countryGeoId: this.address?.countryGeoId }) | ||
}, | ||
methods: { | ||
closeModal() { | ||
modalController.dismiss() | ||
}, | ||
async saveAddress() { | ||
const isAddressUpdated = Object.entries(this.postalAddress).filter(([addressKey, addressValue]) => this.address[addressKey] !== addressValue).length | ||
if(!isAddressUpdated) { | ||
showToast(translate("Please fill all the required fields")) | ||
return; | ||
} | ||
|
||
let resp; | ||
|
||
if(!this.address?.address1 || !this.address?.city) { | ||
showToast("Please fill all the required fields.") | ||
return | ||
} | ||
|
||
try { | ||
if(this.address.contactMechId) { | ||
resp = await FacilityService.updateFacilityPostalAddress({...this.address, facilityId: this.facilityId }) | ||
} else { | ||
resp = await FacilityService.createFacilityPostalAddress(this.address) | ||
} | ||
|
||
if(!hasError(resp)) { | ||
showToast(translate("Facility address updated successfully.")) | ||
await this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }) | ||
} else { | ||
throw resp.data | ||
} | ||
} catch(err) { | ||
showToast(translate("Failed to update facility address.")) | ||
logger.error(err) | ||
} | ||
modalController.dismiss() | ||
}, | ||
updateState(ev: CustomEvent) { | ||
this.store.dispatch('util/fetchStates', { geoId: ev.detail.value }) | ||
} | ||
}, | ||
setup() { | ||
const store = useStore() | ||
|
||
return { | ||
closeOutline, | ||
saveOutline, | ||
store, | ||
translate | ||
}; | ||
}, | ||
}); | ||
</script> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only call saveAddress if there are changes in the address