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
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
349c2ca
Implemented: centralized facility switcher to be used in all app (#138)
amansinghbais Sep 14, 2023
c2f0a98
Merge branch 'main' of https://github.com/hotwax/dxp-components into …
amansinghbais Sep 18, 2023
b9e5f52
Improved: updated to dxp version 1.6.0 (#138)
amansinghbais Sep 18, 2023
139c15b
Merge branch 'main' of https://github.com/hotwax/dxp-components into …
amansinghbais Sep 21, 2023
2ca991f
Merge branch 'main' of https://github.com/hotwax/dxp-components into …
amansinghbais Sep 25, 2023
10595c7
Improved: code to use deep-clone for the computed properties, method …
amansinghbais Sep 25, 2023
525f934
Improved: unwanted changes in package-lock.json
amansinghbais Sep 25, 2023
8437048
Improved: emitting methods from child modal without promise.all (#138)
amansinghbais Sep 26, 2023
37ab41b
Merge branch 'main' of https://github.com/hotwax/dxp-components into …
amansinghbais Oct 3, 2023
1534a58
Improved: facility switcher logic to use before/after emit for apps (…
amansinghbais Oct 4, 2023
902bf7c
Improved: calling normally without the help of finally (#138)
amansinghbais Oct 5, 2023
1c9bdcf
Improved: emitting function without catching them (#138)
amansinghbais Oct 6, 2023
1614a90
Improved: added Dxp prefix in component name (dxp/138)
amansinghbais Oct 9, 2023
40558c4
Improved: emits name and if condition code (#138)
amansinghbais Oct 10, 2023
d890841
Merge branch 'main' of https://github.com/hotwax/dxp-components into …
amansinghbais Oct 12, 2023
30c28d4
Improved: variable name and used arrow function in computed(#138)
amansinghbais Oct 12, 2023
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
49 changes: 49 additions & 0 deletions src/components/FacilitySwitcher.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<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

<ion-card>
<ion-card-header>
<ion-card-title>
{{ "Facility" }}
</ion-card-title>
</ion-card-header>
<ion-card-content>
{{ 'Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.' }}
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
</ion-card-content>
<ion-item lines="none">
<ion-label>{{ "Select facility" }}</ion-label>
<ion-select interface="popover" :value="appUserState.currentFacility.facilityId" @ionChange="setFacility($event)">
<ion-select-option v-for="facility in (appUserState.userProfile ? appUserState.userProfile.facilities : [])" :key="facility.facilityId" :value="facility.facilityId" >{{ facility.name }}</ion-select-option>
</ion-select>
</ion-item>
</ion-card>
</template>

<script setup lang="ts">
import { IonCard, IonCardContent, IonCardHeader, IonCardTitle, IonItem, IonLabel, IonSelect, IonSelectOption } from '@ionic/vue'
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
import { appContext } from '../index';
import { computed } from 'vue';

const emit = defineEmits(['facility-change-alert', 'get-facility-details' ,'update-facility-id'])
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
const store = appContext.config.globalProperties.$store;
const appUserState = computed(() => {
return {
currentFacility: store.getters['user/getCurrentFacility'],
userProfile: store.getters['user/getUserProfile'],
uploadProducts: store.getters['product/getUploadProducts']
}
});
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved

const setFacility = async (facility: any) => {
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
const currentAppUserState = appUserState.value
const selectedFacility = facility['detail'].value
if ( currentAppUserState.currentFacility.facilityId && currentAppUserState.currentFacility.facilityId != selectedFacility && currentAppUserState.userProfile?.facilities) {
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
if (store.uploadProducts && Object.keys(store.uploadProducts).length > 0 ) {
emit('facility-change-alert', selectedFacility)
} else {
await store.dispatch('user/setFacility', {
'facility': currentAppUserState.userProfile.facilities.find((fac: any) => fac.facilityId == selectedFacility)
});
Promise.all([emit('update-facility-id', currentAppUserState.currentFacility.facilityId), emit('get-facility-details')])
}
}
}
</script>
2 changes: 1 addition & 1 deletion src/components/Login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default defineComponent({
window.location.href = context.appLoginUrl
return
}

ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
const { token, oms, expirationTime } = this.route.query
this.handleUserFlow(token, oms, expirationTime)
},
Expand Down
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ import '@ionic/vue/css/text-transformation.css';
import '@ionic/vue/css/flex-utils.css';
import '@ionic/vue/css/display.css';

export { default as FacilitySwitcher } from './FacilitySwitcher.vue';
13 changes: 8 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createPinia } from "pinia";
import { useProductIdentificationStore } from "./store/productIdentification";
import { useAuthStore } from "./store/auth";
import Login from "./components/Login";
import { FacilitySwitcher } from "./components";
import ShopifyImg from "./components/ShopifyImg";
import { goToOms } from "./utils";
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
Expand All @@ -25,6 +26,7 @@ export let dxpComponents = {
app.use(pinia);

app.component('Login', Login)
app.component('FacilitySwitcher', FacilitySwitcher)
app.component('ShopifyImg', ShopifyImg)

loginContext.login = options.login
Expand All @@ -39,13 +41,14 @@ export let dxpComponents = {
}

export {
useProductIdentificationStore,
useAuthStore,
appContext,
FacilitySwitcher,
goToOms,
Login,
loginContext,
productIdentificationContext,
shopifyImgContext,
ShopifyImg,
goToOms,
appContext,
productIdentificationContext
useProductIdentificationStore,
useAuthStore,
}