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: miscellaneous fixes related to new facility group UI. #313

Merged
merged 4 commits into from
Sep 10, 2024
Merged
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
72 changes: 35 additions & 37 deletions src/views/CreateFacilityGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,43 @@
<ion-card-header>
<ion-card-title>{{ translate('Create a new group') }}</ion-card-title>
</ion-card-header>
<form @keyup.enter="createFacilityGroup">
<ion-list>
<ion-item>
<ion-input label-placement="floating" @ionBlur="setFacilityGroupId($event)" v-model="formData.facilityGroupName">
<div slot="label">{{ translate("Name") }} <ion-text color="danger">*</ion-text></div>
</ion-input>
</ion-item>
<ion-item lines="none">
<ion-input label-placement="floating" :label="translate('Internal ID')" ref="facilityGroupId" v-model="formData.facilityGroupId" @ionInput="validateFacilityGroupId" @ionBlur="markFacilityGroupIdTouched" :error-text="translate('Internal ID cannot be more than 20 characters.')" />
</ion-item>
<ion-item>
<ion-select :label="translate('Group type')" :disabled="isFacilityGroupTypeDisabled" :placeholder="translate('Select')" interface="popover" v-model="formData.facilityGroupTypeId">
<ion-select-option :value="facilityGroupType.facilityGroupTypeId" :key="facilityGroupType.facilityGroupTypeId" v-for="facilityGroupType in facilityGroupTypes">
{{ facilityGroupType.description ? facilityGroupType.description : facilityGroupType.facilityGroupTypeId }}
</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-select v-if="productStores.length" :label="translate('Product store')" :placeholder="translate('Select')" :selectedText="selectedProductStoreIds.length > 1 ? translate('product stores', { count: selectedProductStoreIds.length }) : selectedProductStoreIds.map[0]" :value="selectedProductStoreIds" @ionChange="updateFacilityGroupProductStores($event)" :multiple="true">
<ion-select-option :value="productStore.productStoreId" :key="productStore.productStoreId" v-for="productStore in productStores">
{{ productStore.storeName ? productStore.storeName : productStore.productStoreId }}
</ion-select-option>
</ion-select>
</ion-item>
<ion-item lines="none">
<ion-textarea :label="translate('Description')" label-placement="floating"
:placeholder="translate('group description')"
:auto-grow="true"
:counter="true"
:maxlength="255"
v-model="formData.description"
>
</ion-textarea>
</ion-item>
</ion-list>
</form>
<ion-list>
<ion-item>
<ion-input label-placement="floating" @ionBlur="setFacilityGroupId($event)" v-model="formData.facilityGroupName">
<div slot="label">{{ translate("Name") }} <ion-text color="danger">*</ion-text></div>
</ion-input>
</ion-item>
<ion-item lines="none">
<ion-input label-placement="floating" :label="translate('Internal ID')" ref="facilityGroupId" v-model="formData.facilityGroupId" @ionInput="validateFacilityGroupId" @ionBlur="markFacilityGroupIdTouched" :error-text="translate('Internal ID cannot be more than 20 characters.')" />
</ion-item>
<ion-item>
<ion-select :label="translate('Group type')" :disabled="isFacilityGroupTypeDisabled" :placeholder="translate('Select')" interface="popover" v-model="formData.facilityGroupTypeId">
<ion-select-option :value="facilityGroupType.facilityGroupTypeId" :key="facilityGroupType.facilityGroupTypeId" v-for="facilityGroupType in facilityGroupTypes">
{{ facilityGroupType.description ? facilityGroupType.description : facilityGroupType.facilityGroupTypeId }}
</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-select v-if="productStores.length" :label="translate('Product store')" :placeholder="translate('Select')" :selectedText="selectedProductStoreIds.length > 1 ? translate('product stores', { count: selectedProductStoreIds.length }) : selectedProductStoreIds.map[0]" :value="selectedProductStoreIds" @ionChange="updateFacilityGroupProductStores($event)" :multiple="true">
<ion-select-option :value="productStore.productStoreId" :key="productStore.productStoreId" v-for="productStore in productStores">
{{ productStore.storeName ? productStore.storeName : productStore.productStoreId }}
</ion-select-option>
</ion-select>
</ion-item>
<ion-item lines="none">
<ion-textarea :label="translate('Description')" label-placement="floating"
:placeholder="translate('group description')"
:auto-grow="true"
:counter="true"
:maxlength="255"
v-model="formData.description"
>
</ion-textarea>
</ion-item>
</ion-list>
</ion-card>
<div class="ion-text-center ion-margin">
<ion-button @click="createFacilityGroup()" @keyup.enter.stop>
<ion-button @click="createFacilityGroup()">
{{ translate("Create group") }}
<ion-icon slot="end" :icon="arrowForwardOutline"/>
</ion-button>
Expand Down Expand Up @@ -199,7 +197,7 @@
)
const hasFailedResponse = responses.some((response: any) => response.status === 'rejected')
if (hasFailedResponse) {
console.log("Error in associating group to some of the product stores")

Check warning on line 200 in src/views/CreateFacilityGroup.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

Unexpected console statement

Check warning on line 200 in src/views/CreateFacilityGroup.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

Unexpected console statement
}
} catch (error) {
logger.error(error)
Expand All @@ -214,13 +212,13 @@
buttons: [
{
text: translate("Skip"),
handler: async (data: any) => {

Check warning on line 215 in src/views/CreateFacilityGroup.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'data' is defined but never used

Check warning on line 215 in src/views/CreateFacilityGroup.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'data' is defined but never used
this.router.replace({ path: `/tabs/find-groups`})
}
},
{
text: translate("Add"),
handler: async (data: any) => {

Check warning on line 221 in src/views/CreateFacilityGroup.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'data' is defined but never used

Check warning on line 221 in src/views/CreateFacilityGroup.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'data' is defined but never used
this.router.replace({ path: `/manage-facilities/${facilityGroupId}`})
}
}
Expand Down
1 change: 1 addition & 0 deletions src/views/FindGroups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export default defineComponent({
async ionViewWillEnter() {
this.segment = "facility-groups"
await this.fetchGroups();
await this.resetParentGroupPage()
},
methods: {
async resetParentGroupPage() {
Expand Down
22 changes: 15 additions & 7 deletions src/views/ManageFacilities.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
async ionViewWillEnter() {
emitter.emit('presentLoader')
this.isSavingDetail = false
this.queryString = ''
await Promise.all([this.fetchFacilities(), this.fetchFacilityGroup()])
await this.fetchMemberFacilities();
await this.getFilteredFacilities();
Expand Down Expand Up @@ -310,12 +311,13 @@
},
async save () {
this.isSavingDetail = true
const facilitiesToAdd = this.selectedFacilities.filter((facility: any) => !facility.fromDate)
const memberFacilityIds = this.memberFacilities?.map((facility: any) => facility.facilityId)
const facilitiesToAdd = this.selectedFacilities.filter((facility: any) => !memberFacilityIds.includes(facility.facilityId))
const selectedFacilityIds = this.selectedFacilities ? new Set(this.selectedFacilities.map((facility:any) => facility.facilityId)) as any : [];
const facilitiesToRemove = this.memberFacilities.filter((facility: any) => !selectedFacilityIds.has(facility.facilityId))

const removeResponses = await Promise.allSettled(facilitiesToRemove
.map(async (facility: any) => await FacilityService.updateFacilityToGroup({
.map((facility: any) => FacilityService.updateFacilityToGroup({
"facilityId": facility.facilityId,
"facilityGroupId": facility.facilityGroupId,
"fromDate": facility.fromDate,
Expand All @@ -324,7 +326,7 @@
)

const addResponses = await Promise.allSettled(facilitiesToAdd
.map(async (facility: any) => await FacilityService.addFacilityToGroup({
.map((facility: any) => FacilityService.addFacilityToGroup({
"facilityId": facility.facilityId,
"facilityGroupId": this.facilityGroupId,
"sequenceNum": facility.sequenceNum
Expand All @@ -334,11 +336,17 @@
const facilityIdsToAdd = facilitiesToAdd ? new Set(facilitiesToAdd.map((facility:any) => facility.facilityId)) as any : [];
const existingFacilityMembers = this.selectedFacilities.filter((facility:any) => !facilityIdsToAdd.has(facility.facilityId))
const diffMemberFacilitySequencing = existingFacilityMembers.filter((facility: any) => this.memberFacilities.some((memberFacility: any) => memberFacility.facilityId === facility.facilityId && memberFacility.sequenceNum !== facility.sequenceNum))
const sequenceUpdateResponses = await Promise.allSettled(diffMemberFacilitySequencing.map(async (memberFacility: any) => {
await FacilityService.updateFacilityToGroup({

const memberFacilityDetail = this.memberFacilities.reduce((memberInfo:any, facility:any) => {
memberInfo[facility.facilityId] = facility;
return memberInfo;
}, {});

const sequenceUpdateResponses = await Promise.allSettled(diffMemberFacilitySequencing.map((memberFacility: any) => {
FacilityService.updateFacilityToGroup({
"facilityId": memberFacility.facilityId,
"facilityGroupId": memberFacility.facilityGroupId,
"fromDate": memberFacility.fromDate,
"facilityGroupId": this.facilityGroupId,
"fromDate": memberFacilityDetail[memberFacility.facilityId].fromDate,
"sequenceNum": memberFacility.sequenceNum
});
}))
Expand Down
Loading