-
Notifications
You must be signed in to change notification settings - Fork 17
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: latitude and longitude regenration, remove functionality. (#37) #43
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
267ff78
Implemented: lat-long regenration functionality, removing functionali…
amansinghbais 6b73039
Improved: toast message, and payload syntax (#37)
amansinghbais 5c19d59
Merge branch 'main' of https://github.com/hotwax/facilities into faci…
amansinghbais 6f73afb
Improve: added conditional check for rendering (#37)
amansinghbais 6df1ce5
Improved: code to close popover in case action failed (#37)
amansinghbais 72bb6ce
Improved: code for unused arguments, and typo in toast message (#37)
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 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
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,118 @@ | ||
<template> | ||
<ion-content> | ||
<ion-list> | ||
<ion-item button :disabled="!isRegenerationRequired" @click="regenerateLatitudeAndLongitude"> | ||
{{ translate("Regenerate") }} | ||
</ion-item> | ||
<ion-item button lines="none" @click="removeLatitudeAndLongitude"> | ||
{{ translate("Remove") }} | ||
</ion-item> | ||
</ion-list> | ||
</ion-content> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { | ||
IonContent, | ||
IonItem, | ||
IonList, | ||
popoverController | ||
} from "@ionic/vue"; | ||
import { defineComponent } from "vue"; | ||
import { translate } from "@hotwax/dxp-components"; | ||
import { mapGetters, useStore } from "vuex"; | ||
import { FacilityService } from "@/services/FacilityService"; | ||
import { hasError } from "@/adapter"; | ||
import { showToast } from "@/utils"; | ||
import logger from "@/logger"; | ||
import { UtilService } from '@/services/UtilService'; | ||
|
||
export default defineComponent({ | ||
name: "LocationDetailsPopover", | ||
components: { | ||
IonContent, | ||
IonItem, | ||
IonList | ||
}, | ||
computed: { | ||
...mapGetters({ | ||
postalAddress: 'facility/getPostalAddress', | ||
}) | ||
}, | ||
props: ['facilityId', 'isRegenerationRequired'], | ||
methods: { | ||
async regenerateLatitudeAndLongitude() { | ||
let resp; | ||
|
||
try { | ||
resp = await UtilService.generateLatLong({ | ||
json: { | ||
params: { | ||
q: `postcode: ${this.postalAddress.postalCode}` | ||
} | ||
} | ||
}) | ||
|
||
if(!hasError(resp)) { | ||
const generatedLatLong = resp.data.response.docs[0] | ||
|
||
if(generatedLatLong.latitude && generatedLatLong.longitude) { | ||
resp = await FacilityService.updateFacilityPostalAddress({ | ||
...this.postalAddress, | ||
facilityId: this.facilityId, | ||
latitude: generatedLatLong.latitude, | ||
longitude: generatedLatLong.longitude | ||
}) | ||
|
||
if(!hasError(resp)) { | ||
showToast(translate("Successfully regenerated latitude and longitude for the facility.")) | ||
await this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }) | ||
} else { | ||
throw resp.data | ||
} | ||
} | ||
} else { | ||
throw resp.data | ||
} | ||
} catch(err) { | ||
showToast(translate("Failed to regenerate latitude and longitude for the facility.")) | ||
logger.error(err); | ||
} | ||
|
||
popoverController.dismiss() | ||
}, | ||
async removeLatitudeAndLongitude() { | ||
let resp; | ||
|
||
try { | ||
resp = await FacilityService.updateFacilityPostalAddress({ | ||
...this.postalAddress, | ||
facilityId: this.facilityId, | ||
latitude: '', | ||
longitude: '' | ||
}) | ||
|
||
if(!hasError(resp)) { | ||
showToast(translate("Facility latitude and longitude removed successfully.")) | ||
await this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }) | ||
} else { | ||
throw resp.data | ||
} | ||
} catch(err) { | ||
showToast(translate("Failed to remove facility latitude and longitude.")) | ||
logger.error(err) | ||
} | ||
|
||
popoverController.dismiss() | ||
} | ||
}, | ||
setup() { | ||
const store = useStore(); | ||
|
||
return { | ||
store, | ||
translate | ||
}; | ||
} | ||
}); | ||
</script> |
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
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
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
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.
Rename this to openGeoPointPopover.