Skip to content

Commit

Permalink
Implemented: support to fetch all facilities for admin, updated local…
Browse files Browse the repository at this point in the history
…es for missing static text(#232)
  • Loading branch information
ymaheshwari1 committed Dec 19, 2023
1 parent fa84b66 commit ccb60a0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/adapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { api, client, getConfig, initialise, logout, resetConfig, updateInstanceUrl, updateToken } from '@hotwax/oms-api'
import { api, client, getConfig, getUserFacilities, initialise, logout, resetConfig, updateInstanceUrl, updateToken } from '@hotwax/oms-api'

export {
api,
client,
getConfig,
getUserFacilities,
initialise,
logout,
resetConfig,
Expand Down
1 change: 1 addition & 0 deletions src/authorization/Rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export default {
"APP_VARIANCE_LOG": "FULFILL_INVCUNT_ADMIN OR INV_COUNT_ADMIN",
"APP_INVNTRY_CNT_IMPORT": "",
"APP_QOH_STNG_UPDATE": "COMMON_ADMIN",
"APP_INVCUNT_ADMIN": "COMMON_ADMIN",
"INVENTORY_APP_VIEW": "INVENTORY_APP_VIEW"
} as any
4 changes: 4 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"App": "App",
"Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to {timeZoneId}?",
"Authenticating": "Authenticating",
"Back to Launchpad": "Back to Launchpad",
"Camera permission denied.": "Camera permission denied.",
"Cancel": "Cancel",
"Change": "Change",
Expand All @@ -28,6 +29,7 @@
"Location": "Location",
"Log variance": "Log variance",
"Login": "Login",
"Login failed": "Login failed",
"Logging in": "Logging in",
"Logging out": "Logging out",
"Logout": "Logout",
Expand All @@ -38,6 +40,7 @@
"OMS": "OMS",
"OMS instance": "OMS instance",
"Password": "Password",
"Please contact the administrator.": "Please contact the administrator.",
"Quantity": "Quantity",
"Quantity on hand": "Quantity on hand",
"Remove": "Remove",
Expand Down Expand Up @@ -74,5 +77,6 @@
"Variance reason": "Variance reason",
"Variance updated successfully": "Variance updated successfully",
"View": "View",
"You do not have permission to access the app.": "You do not have permission to access the app.",
"You do not have permission to access this page": "You do not have permission to access this page"
}
9 changes: 8 additions & 1 deletion src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { translate } from '@/i18n'
import { Settings } from 'luxon';
import { logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter'
import { getUserFacilities, logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter'
import {
getServerPermissionsFromRules,
prepareAppPermissions,
Expand All @@ -15,6 +15,7 @@ import {
} from '@/authorization'
import { useAuthStore } from '@hotwax/dxp-components'
import emitter from '@/event-bus'
import store from '@/store'

const actions: ActionTree<UserState, RootState> = {

Expand Down Expand Up @@ -55,6 +56,12 @@ const actions: ActionTree<UserState, RootState> = {

const userProfile = await UserService.getUserProfile(token);

//fetching user facilities
const isAdminUser = appPermissions.some((appPermission: any) => appPermission?.action === "APP_INVCUNT_ADMIN" );
const baseURL = store.getters['user/getBaseUrl'];
const facilities = await getUserFacilities(token, baseURL, userProfile?.partyId, "", isAdminUser);
userProfile.facilities = facilities;

// removing duplicate records as a single user can be associated with a facility by multiple roles.
userProfile.facilities.reduce((uniqueFacilities: any, facility: any, index: number) => {
if(uniqueFacilities.includes(facility.facilityId)) userProfile.facilities.splice(index, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<ion-item lines="none">
<ion-label>{{ $t("Select facility") }}</ion-label>
<ion-select interface="popover" v-model="currentFacilityId" @ionChange="setFacility($event)">
<ion-select-option v-for="facility in (userProfile ? userProfile.facilities : [])" :key="facility.facilityId" :value="facility.facilityId" >{{ facility.name }}</ion-select-option>
<ion-select-option v-for="facility in (userProfile ? userProfile.facilities : [])" :key="facility.facilityId" :value="facility.facilityId" >{{ facility.facilityName }}</ion-select-option>
</ion-select>
</ion-item>
</ion-card>
Expand Down

0 comments on commit ccb60a0

Please sign in to comment.