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

Implemented: centralized facility switcher to be used in all app (#138) #159

Closed
wants to merge 16 commits into from

Conversation

amansinghbais
Copy link
Contributor

@amansinghbais amansinghbais commented Sep 14, 2023

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

src/components/FacilitySwitcher.vue Outdated Show resolved Hide resolved
src/components/FacilitySwitcher.vue Outdated Show resolved Hide resolved
src/components/FacilitySwitcher.vue Outdated Show resolved Hide resolved
src/components/Login.ts Outdated Show resolved Hide resolved
src/components/FacilitySwitcher.vue Outdated Show resolved Hide resolved
src/components/FacilitySwitcher.vue Outdated Show resolved Hide resolved
src/components/FacilitySwitcher.vue Outdated Show resolved Hide resolved
src/components/FacilitySwitcher.vue Outdated Show resolved Hide resolved
src/components/FacilitySwitcher.vue Outdated Show resolved Hide resolved
src/components/FacilitySwitcher.vue Outdated Show resolved Hide resolved
@@ -8306,4 +8306,4 @@
"dev": true
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this change.


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 ) {
Copy link
Contributor

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.

@amansinghbais amansinghbais changed the title Implemented: centralized facility switcher to be used in all app (#138) [WIP] Implemented: centralized facility switcher to be used in all app (#138) Oct 4, 2023
@amansinghbais amansinghbais changed the title [WIP] Implemented: centralized facility switcher to be used in all app (#138) Implemented: centralized facility switcher to be used in all app (#138) Oct 6, 2023
@@ -0,0 +1,61 @@
<template>

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'])

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) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

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']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required now

Comment on lines 37 to 43
const userAppState = computed(() => {
return {
currentFacility: appState.getters['user/getCurrentFacility'],
userProfile: appState.getters['user/getUserProfile'],
uploadProducts: appState.getters['product/getUploadProducts']
}
});

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const selectedFacility = event.detail.value
const facilityId = event.detail.value

@ymaheshwari1
Copy link
Contributor

Closing as handled in #320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Centralized Facility Switcher
3 participants