Skip to content

Commit

Permalink
Merge pull request #27 from ymaheshwari1/#24
Browse files Browse the repository at this point in the history
Implemented: support to display external mappings for facility, create, edit and remove already existing mappings(#24)
  • Loading branch information
ravilodhi authored Nov 23, 2023
2 parents 8d686cc + 9fb59cc commit 8dccf28
Show file tree
Hide file tree
Showing 25 changed files with 839 additions and 152 deletions.
53 changes: 0 additions & 53 deletions src/components/AddExternalMappingPopover.vue

This file was deleted.

7 changes: 5 additions & 2 deletions src/components/AddStaffMemberModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,16 @@ export default defineComponent({
}
const payload = {
inputFields,
inputFields: {
...inputFields,
roleTypeId: 'APPLICATION_USER'
},
viewSize: 10,
entityName: 'PartyRoleAndPartyDetail',
noConditionFind: 'Y',
distinct: 'Y',
orderBy: "firstName ASC",
fieldList: ['firstName', 'groupName', 'lastName', 'partyId']
fieldList: ['partyId', 'firstName', 'groupName', 'lastName']
}
try {
Expand Down
72 changes: 66 additions & 6 deletions src/components/CustomMappingModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@
<ion-list-header>{{ translate("Facility details") }}</ion-list-header>
<ion-item>
<ion-label>{{ translate("Facility ID") }}</ion-label>
<p>{{ "<facility-id>" }}</p>
<p>{{ currentFacility.facilityId }}</p>
</ion-item>
<ion-item lines="none">
<ion-label>{{ translate("Facility name") }}</ion-label>
<p>{{ "<facility-name>" }}</p>
<p>{{ currentFacility.facilityName }}</p>
</ion-item>
</ion-list>

<ion-list>
<ion-list-header>{{ translate("Custom mapping") }}</ion-list-header>
<ion-item>
<ion-label>{{ translate("Mapping ID") }}</ion-label>
<ion-input placeholder="Mapping ID" />
<ion-input v-model="mappingId" placeholder="Mapping ID" />
</ion-item>
<ion-item>
<ion-label>{{ translate("Mapping Name") }}</ion-label>
<ion-input placeholder="Mapping name" />
<ion-input v-model="mappingName" placeholder="Mapping name" />
</ion-item>
<ion-item>
<ion-label>{{ translate("Identification") }}</ion-label>
<ion-input placeholder="Mapping Value" />
<ion-input v-model="mappingValue" placeholder="Mapping Value" />
</ion-item>
</ion-list>
</ion-content>
<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button>
<ion-fab-button @click="saveMapping">
<ion-icon :icon="saveOutline" />
</ion-fab-button>
</ion-fab>
Expand All @@ -67,6 +67,11 @@ import {
import { defineComponent } from "vue";
import { closeOutline, saveOutline } from "ionicons/icons";
import { translate } from '@hotwax/dxp-components'
import { mapGetters, useStore } from 'vuex'
import { showToast } from "@/utils";
import { FacilityService } from "@/services/FacilityService";
import { hasError } from "@/adapter";
import logger from "@/logger";
export default defineComponent({
name: "CustomMappingModal",
Expand All @@ -86,15 +91,70 @@ export default defineComponent({
IonTitle,
IonToolbar
},
data() {
return {
mappingId: '',
mappingName: '',
mappingValue: ''
}
},
computed: {
...mapGetters({
currentFacility: 'facility/getCurrent'
})
},
methods: {
closeModal() {
modalController.dismiss()
},
async saveMapping() {
if(!this.mappingId.trim() || !this.mappingName.trim() || !this.mappingValue.trim()) {
showToast(translate('Please fill all the required fields'))
return;
}
let resp;
try {
resp = await FacilityService.createEnumeration({
"enumId": this.mappingId,
"enumTypeId": "FACILITY_IDENTITY",
"description": this.mappingName
})
if(!hasError(resp) && resp.data.enumId) {
resp = await FacilityService.createFacilityIdentification({
"facilityId": this.currentFacility.facilityId,
"facilityIdenTypeId": resp.data.enumId,
"idValue": this.mappingValue
})
if(!hasError(resp)) {
showToast(translate('External mapping created successfully'))
// fetching external mapping types again, as we have created a new mapping type that needs to be included in popover
// added skipState property to not check for cached type and always make an api call
await this.store.dispatch('util/fetchExternalMappingTypes', { skipState: true })
this.store.dispatch('facility/fetchFacilityMappings', { facilityId: this.currentFacility.facilityId })
this.closeModal();
} else {
throw resp.data
}
} else {
throw resp.data
}
} catch(err) {
showToast(translate('Failed to create external mapping'))
logger.error('Failed to create external mapping', err)
}
}
},
setup() {
const store = useStore()
return {
closeOutline,
saveOutline,
store,
translate
};
},
Expand Down
177 changes: 177 additions & 0 deletions src/components/FacilityMappingModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<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>{{ externalMappingTypes[mappingId] }}</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<form @keyup.enter="saveMapping">
<ion-list>
<ion-list-header>{{ translate("Facility details") }}</ion-list-header>
<ion-item>
<ion-label>{{ translate("Facility ID") }}</ion-label>
<ion-label slot="end">{{ currentFacility.facilityId }}</ion-label>
</ion-item>
<ion-item lines="none">
<ion-label>{{ translate("Facility name") }}</ion-label>
<ion-label slot="end">{{ currentFacility.facilityName }}</ion-label>
</ion-item>
</ion-list>

<ion-list>
<ion-list-header>{{ externalMappingTypes[mappingId] }}</ion-list-header>
<ion-item>
<ion-label>{{ translate("Identification") }}</ion-label>
<ion-input v-model="mappingValue" placeholder="Mapping Value" />
</ion-item>
</ion-list>

<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button @click="type && type === 'update' ? updateMapping() : saveMapping()" @keyup.enter.stop>
<ion-icon :icon="saveOutline" />
</ion-fab-button>
</ion-fab>
</form>
</ion-content>
</template>

<script lang="ts">
import {
IonButton,
IonButtons,
IonContent,
IonFab,
IonFabButton,
IonHeader,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonTitle,
IonToolbar,
modalController
} from "@ionic/vue";
import { defineComponent } from "vue";
import { closeOutline, saveOutline } from "ionicons/icons";
import { translate } from '@hotwax/dxp-components'
import { mapGetters, useStore } from 'vuex'
import { FacilityService } from '@/services/FacilityService'
import { showToast } from "@/utils";
import { hasError } from "@/adapter";
import logger from "@/logger";
export default defineComponent({
name: "FacilityMappingModal",
components: {
IonButton,
IonButtons,
IonContent,
IonFab,
IonFabButton,
IonHeader,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonTitle,
IonToolbar
},
computed: {
...mapGetters({
currentFacility: 'facility/getCurrent',
externalMappingTypes: 'util/getExternalMappingTypes'
})
},
data() {
return {
mappingValue: ''
}
},
props: ["mappingId", "mapping", "type"],
mounted() {
if(this.type) {
this.mappingValue = this.mapping?.idValue
}
},
methods: {
closeModal() {
modalController.dismiss()
},
async saveMapping() {
if(!this.mappingValue.trim()) {
showToast(translate('Please enter a valid value'))
return;
}
let resp;
try {
resp = await FacilityService.createFacilityIdentification({
"facilityId": this.currentFacility.facilityId,
"facilityIdenTypeId": this.mappingId,
"idValue": this.mappingValue
})
if(!hasError(resp)) {
showToast(translate('External mapping created successfully'))
this.store.dispatch('facility/fetchFacilityMappings', { facilityId: this.currentFacility.facilityId })
this.closeModal();
} else {
throw resp.data
}
} catch(err) {
showToast(translate('Failed to create external mapping'))
logger.error('Failed to create external mapping', err)
}
},
async updateMapping() {
if(!this.mappingValue.trim()) {
showToast(translate('Please enter a valid value'))
return;
}
let resp;
try {
resp = await FacilityService.updateFacilityIdentification({
"facilityId": this.currentFacility.facilityId,
"facilityIdenTypeId": this.mappingId,
"fromDate": this.mapping.fromDate,
"idValue": this.mappingValue
})
if(!hasError(resp)) {
showToast(translate('External mapping updated successfully'))
this.store.dispatch('facility/fetchFacilityMappings', { facilityId: this.currentFacility.facilityId })
this.closeModal();
} else {
throw resp.data
}
} catch(err) {
showToast(translate('Failed to update external mapping'))
logger.error('Failed to update external mapping', err)
}
}
},
setup() {
const store = useStore();
return {
closeOutline,
saveOutline,
store,
translate
};
},
});
</script>
Loading

0 comments on commit 8dccf28

Please sign in to comment.