-
Notifications
You must be signed in to change notification settings - Fork 6
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
Improved: facility display logic on Admin/Super user details page(#173) #271
Changes from 3 commits
2536bf0
38240b5
073a3ad
2319e03
076ca8f
576597e
5c6b86f
d8a18e1
a3bcc82
a22b395
f8fae48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -326,6 +326,34 @@ const getUserSecurityGroup = async (userLoginId: string): Promise<any> => { | |
|
||
return userSecurityGroup | ||
} | ||
const isUserFulfillmentAdmin = async (userLoginId: string): Promise<any> => { | ||
const payload = { | ||
inputFields: { | ||
userLoginId, | ||
permissionId: ['STOREFULFILLMENT_ADMIN'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we are passing list in permissionId here? |
||
}, | ||
entityName: "UserLoginSecurityGroupAndPermission", | ||
filterByDate: "Y", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also we will get expired permission in this case. As the UserLoginSecurityGroupAndPermission view has dates for managing UserLogin and Security Group association (fromDate, thruDate) as well as dates for managing SecurityGroup and SecurityGroupPermission associations (SGPFromDate, SGPThruDate). The filterByDate parameter in performFind service by default consider fromDate and thruDate for filtering active records. We need checks on both the dates which is not possible in performFind. You should use the getPermission api here which is used during login to fetch the user's permission. |
||
viewSize: 10, | ||
}; | ||
|
||
try { | ||
const resp: any = await api({ | ||
url: "performFind", | ||
method: "POST", | ||
data: payload, | ||
}); | ||
|
||
if (!hasError(resp)) { | ||
return resp.data.docs; | ||
} else { | ||
throw resp.data; | ||
} | ||
} catch (error) { | ||
logger.error(error); | ||
return []; | ||
} | ||
}; | ||
|
||
const removeUserSecurityGroup = async (payload: any): Promise <any> => { | ||
return api({ | ||
|
@@ -787,6 +815,7 @@ export const UserService = { | |
getUserFacilities, | ||
getUserProductStores, | ||
getUserSecurityGroup, | ||
isUserFulfillmentAdmin, | ||
isUserLoginIdAlreadyExists, | ||
isRoleTypeExists, | ||
login, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -322,8 +322,11 @@ | |
{{ translate("Show as picker") }} | ||
</ion-toggle> | ||
</ion-item> | ||
<ion-item lines="none" button detail :disabled="!hasPermission(Actions.APP_UPDT_FULFILLMENT_FACILITY) || selectedUser.securityGroup.groupId === 'INTEGRATION'" @click="selectFacility()"> | ||
<ion-label>{{ getUserFacilities().length === 1 ? translate('Added to 1 facility') : translate('Added to facilities', { count: getUserFacilities().length }) }}</ion-label> | ||
<ion-item lines="none" v-if="isUserFulfillmentAdmin.length"> | ||
<ion-label>{{ translate("This user has 'STOREFULFILLMENT_ADMIN' permission, enabling access to all facilities.") }}</ion-label> | ||
</ion-item> | ||
<ion-item lines="none" button detail v-else @click="selectFacility()" :disabled="selectedUser.securityGroup.groupId === 'INTEGRATION'"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the Actions.APP_UPDT_FULFILLMENT_FACILITY permission is removed? |
||
<ion-label>{{ getUserFacilities().length === 1 ? translate('Added to 1 facility') : translate('Added to facilities', { count: getUserFacilities().length }) }}</ion-label> | ||
</ion-item> | ||
</ion-list> | ||
</ion-card> | ||
|
@@ -520,6 +523,7 @@ export default defineComponent({ | |
isUserFetched: false, | ||
showPassword: false, | ||
shopifyShopsForProductStore: [] as any, | ||
isUserFulfillmentAdmin: [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isUserFulfillmentAdmin should be boolean. |
||
} | ||
}, | ||
|
||
|
@@ -533,7 +537,7 @@ export default defineComponent({ | |
if (productStoreId) { | ||
this.getShopifyShops(productStoreId); | ||
} | ||
|
||
this.isUserFulfillmentAdmin = await UserService.isUserFulfillmentAdmin(this.selectedUser.userLoginId) | ||
this.isUserFetched = true | ||
this.username = this.selectedUser.groupName ? (this.selectedUser.groupName)?.toLowerCase() : (`${this.selectedUser.firstName}.${this.selectedUser.lastName}`?.toLowerCase()) | ||
}, | ||
|
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.
The name of the service suggest that boolean value will be returned, but you are returning data. Either return boolean or change the name of the service.