-
Notifications
You must be signed in to change notification settings - Fork 19
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: centralized facility switcher to be used in all app (#138) #159
Conversation
package-lock.json
Outdated
@@ -8306,4 +8306,4 @@ | |||
"dev": true | |||
} | |||
} | |||
} | |||
} |
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.
Revert this change.
src/components/FacilitySwitcher.vue
Outdated
|
||
if(currentUserAppState.currentFacility.facilityId && currentUserAppState.currentFacility.facilityId != selectedFacility && currentUserAppState.userProfile?.facilities) { | ||
// Below check is a handle case for the inventory-count app. | ||
if(appState.uploadProducts && Object.keys(appState.uploadProducts).length > 0 ) { |
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.
We should remove the app specific support from dxp.
src/components/FacilitySwitcher.vue
Outdated
@@ -0,0 +1,61 @@ | |||
<template> |
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 the component to DxpFacilitySwticher
import { appContext } from '../index'; | ||
import { computed } from 'vue'; | ||
|
||
const emit = defineEmits(['check-facility', 'update-facility']) |
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.
We can update the emit names to before-set-facility and after-set-facility for more readability.
} | ||
}); | ||
|
||
const setFacility = async (event: any) => { |
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.
const setFacility = async (event: any) => { | |
const setFacility = async (event: CustomEvent) => { |
const currentUserAppState = JSON.parse(JSON.stringify(userAppState.value)) | ||
const selectedFacility = event['detail'].value | ||
|
||
if(currentUserAppState.currentFacility.facilityId && currentUserAppState.currentFacility.facilityId != selectedFacility && currentUserAppState.userProfile?.facilities) { |
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.
if(currentUserAppState.currentFacility.facilityId && currentUserAppState.currentFacility.facilityId != selectedFacility && currentUserAppState.userProfile?.facilities) { | |
if(currentUserAppState.currentFacility.facilityId !== selectedFacility && currentUserAppState.userProfile?.facilities) { |
emit('check-facility', selectedFacility) | ||
|
||
await appState.dispatch('user/setFacility', { | ||
'facility': currentUserAppState.userProfile.facilities.find((facility: any) => facility.facilityId == selectedFacility) |
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.
While implementing in apps, check if this is done in the actions already, and remove it if so.
return { | ||
currentFacility: appState.getters['user/getCurrentFacility'], | ||
userProfile: appState.getters['user/getUserProfile'], | ||
uploadProducts: appState.getters['product/getUploadProducts'] |
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.
Not required now
const userAppState = computed(() => { | ||
return { | ||
currentFacility: appState.getters['user/getCurrentFacility'], | ||
userProfile: appState.getters['user/getUserProfile'], | ||
uploadProducts: appState.getters['product/getUploadProducts'] | ||
} | ||
}); |
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.
Use arrow function syntax
|
||
const setFacility = async (event: CustomEvent) => { | ||
const currentUserAppState = JSON.parse(JSON.stringify(userAppState.value)) | ||
const selectedFacility = event.detail.value |
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.
const selectedFacility = event.detail.value | |
const facilityId = event.detail.value |
Closing as handled in #320 |
Related Issues
Closes: #138
Short Description and Why It's Useful
Implemented centralized facility switcher component of the settings app in dxp-components so that it can be used in any of the app.
Steps to verify
Screenshots of Visual Changes before/after (If There Are Any)
IMPORTANT NOTICE - Remember to add changelog entry
Contribution and Currently Important Rules Acceptance