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 product identifier using dxp-component #247

Closed
wants to merge 12 commits into from
Closed
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
492 changes: 288 additions & 204 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@casl/ability": "^6.0.0",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.1.0",
"@hotwax/dxp-components": "^1.3.2",
"@hotwax/oms-api": "^1.6.0",
"@ionic/core": "6.7.5",
"@ionic/vue": "6.7.5",
Expand Down
32 changes: 27 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
<script lang="ts">
import { IonApp, IonRouterOutlet, IonSplitPane } from '@ionic/vue';
import Menu from '@/components/Menu.vue';
import { defineComponent } from 'vue';
import { defineComponent, provide, ref } from 'vue';
import { loadingController } from '@ionic/vue';
import emitter from "@/event-bus"
import { mapGetters, useStore } from "vuex";
import { Settings } from 'luxon';
import { initialise, resetConfig } from '@/adapter'
import { useRouter } from 'vue-router';
import { useProductIdentificationStore } from '@hotwax/dxp-components';

export default defineComponent({
name: 'App',
Expand Down Expand Up @@ -94,15 +95,17 @@ export default defineComponent({
// TODO: fetch product identifications from enumeration instead of storing it in env
this.store.dispatch('util/setProductIdentifications', process.env.VUE_APP_PRDT_IDENT ? JSON.parse(process.env.VUE_APP_PRDT_IDENT) : [])
}

if(this.userProfile) {
this.store.dispatch('user/getProductIdentificationPref', this.currentEComStore.productStoreId);
}
// Handles case when user resumes or reloads the app
// Luxon timezzone should be set with the user's selected timezone
if (this.userProfile && this.userProfile.userTimeZone) {
Settings.defaultZone = this.userProfile.userTimeZone;
}

// Get product identification from api using dxp-component and set the state if eComStore is defined
if (this.currentEComStore.productStoreId) {
await useProductIdentificationStore().getIdentificationPref(this.currentEComStore.productStoreId)
.catch((error) => console.error(error));
}
},
unmounted() {
emitter.off('presentLoader', this.presentLoader);
Expand All @@ -113,6 +116,25 @@ export default defineComponent({
const store = useStore();
const router = useRouter();

/* Start Product Identifier */

const productIdentificationStore = useProductIdentificationStore();

// Reactive state for productIdentificationPref
let productIdentificationPref = ref(
productIdentificationStore.$state.productIdentificationPref
);

// Providing productIdentificationPref to child components
provide('productIdentificationPref', productIdentificationPref);

// Subscribing to productIdentificationStore state change and changing value productIdentificationPref
productIdentificationStore.$subscribe((mutation: any, state) => {
productIdentificationPref.value = state.productIdentificationPref;
});

/* End Product Identifier */

return {
router,
store
Expand Down
11 changes: 9 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import store from './store'
import permissionPlugin from '@/authorization';
import permissionRules from '@/authorization/Rules';
import permissionActions from '@/authorization/Actions';
import { dxpComponents } from '@hotwax/dxp-components';
import { setProductIdentificationPref, getProductIdentificationPref } from '@hotwax/oms-api';

const app = createApp(App)
.use(IonicVue, {
Expand All @@ -43,12 +45,17 @@ const app = createApp(App)
.use(permissionPlugin, {
rules: permissionRules,
actions: permissionActions
})
.use(dxpComponents, {
defaultImgUrl: require("@/assets/images/defaultImage.png"),
setProductIdentificationPref,
getProductIdentificationPref
});

// Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters
app.config.globalProperties.$filters = {
formatDate(value: any, inFormat?: string, outFormat?: string) {
if(inFormat){
if (inFormat) {
return DateTime.fromFormat(value, inFormat).toFormat(outFormat ? outFormat : 'MM-DD-YYYY');
}
return DateTime.fromISO(value).toFormat(outFormat ? outFormat : 'MM-DD-YYYY');
Expand All @@ -61,7 +68,7 @@ app.config.globalProperties.$filters = {
return DateTime.fromISO(value, { zone: "utc" }).setZone(userProfile.userTimeZone).toFormat(outFormat ? outFormat : 'MM-dd-yyyy')
},
getFeature(featureHierarchy: any, featureKey: string) {
let featureValue = ''
let featureValue = ''
if (featureHierarchy) {
const feature = featureHierarchy.find((featureItem: any) => featureItem.startsWith(featureKey))
const featureSplit = feature ? feature.split('/') : [];
Expand Down
29 changes: 0 additions & 29 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,32 +132,6 @@ const getPreferredStore = async (token: any): Promise<any> => {
}
}

const updateProductIdentificationPref = async (payload: any): Promise<any> => {
return api({
url: "service/updateProductStoreSetting",
method: "post",
data: payload
});
}

const createProductIdentificationPref = async (payload: any): Promise<any> => {
return api({
url: "service/createProductStoreSetting",
method: "post",
data: payload
});
}

const getProductIdentificationPref = async (payload: any): Promise<any> => {
return api({
url: "performFind",
//TODO Due to security reasons service model OMS 1.0 does not support sending parameters in get request that's why we use post here
method: "post",
data: payload,
cache: true
});
}

const getUserPermissions = async (payload: any, token: any): Promise<any> => {
const baseURL = store.getters['user/getBaseUrl'];
let serverPermissions = [] as any;
Expand Down Expand Up @@ -255,9 +229,6 @@ export const UserService = {
setUserTimeZone,
getFacilityLocations,
getEComStores,
getProductIdentificationPref,
createProductIdentificationPref,
updateProductIdentificationPref,
setUserPreference,
getPreferredStore,
checkPermission
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ export default interface UserState {
currentEComStore: object;
instanceUrl: string;
facilityLocationsByFacilityId: any;
productIdentificationPref: any;
permissions: any;
}
Loading
Loading