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

OBPIH-4584 Fix reason code for revising items on the outbound request #3333

Merged
merged 2 commits into from
Jul 1, 2022
Merged
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
11 changes: 0 additions & 11 deletions grails-app/domain/org/pih/warehouse/core/User.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package org.pih.warehouse.core

import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH
import org.pih.warehouse.auth.AuthService
import util.StringUtil
import grails.converters.JSON

Expand Down Expand Up @@ -99,16 +98,6 @@ class User extends Person {
return roles.roleType.find { RoleType.listPrimaryRoleTypes().contains(it) }
}

boolean hasHigherRoleThanAuthenticated() {
Location currentLocation = AuthService.currentLocation.get()
return getHighestRole(currentLocation)?.roleType == RoleType.ROLE_AUTHENTICATED
}

boolean hasHighestRoleAuthenticated() {
Location currentLocation = AuthService.currentLocation.get()
return getHighestRole(currentLocation)?.roleType != RoleType.ROLE_AUTHENTICATED
}

/**
* @return all location role pairs for this user
*/
Expand Down
6 changes: 2 additions & 4 deletions grails-app/taglib/org/pih/warehouse/AuthTagLib.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,12 @@ class AuthTagLib {
}

def hasHighestRoleAuthenticated = { attrs, body ->
if (User.get(session?.user?.id)?.hasHighestRoleAuthenticated()) {
if (User.get(session?.user?.id)?.getHighestRole(session.warehouse).roleType == RoleType.ROLE_AUTHENTICATED)
out << body()
}
}

def hasHigherRoleThanAuthenticated = { attrs, body ->
if (User.get(session?.user?.id)?.hasHigherRoleThanAuthenticated()) {
if (User.get(session?.user?.id)?.getHighestRole(session.warehouse).roleType != RoleType.ROLE_AUTHENTICATED)
out << body()
}
}
}
8 changes: 4 additions & 4 deletions grails-app/views/taglib/_displayLogo.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<%@ page import="org.pih.warehouse.core.User" %>
<div class="logo">
<g:if test="${attrs.includeLink}">
<g:if test="${session?.user?.hasHighestRoleAuthenticated()}">
<g:hasHighestRoleAuthenticated>
<a href="${createLink(uri: '/stockMovement/list?direction=INBOUND')}">
<img src="${attrs?.logoUrl}" />
</a>
</g:if>
<g:else>
</g:hasHighestRoleAuthenticated>
<g:hasHigherRoleThanAuthenticated>
<a href="${createLink(uri: '/')}">
<img src="${attrs?.logoUrl}" />
</a>
</g:else>
</g:hasHigherRoleThanAuthenticated>
</g:if>
<g:else>
<img src="${attrs?.logoUrl}" />
Expand Down
8 changes: 8 additions & 0 deletions src/js/components/stock-movement-wizard/request/EditPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1025,13 +1025,17 @@ class EditItemsPage extends Component {
...val.product,
label: `${val.productCode} ${val.productName}`,
},
// eslint-disable-next-line max-len
reasonCode: _.find(this.props.reasonCodes, ({ value }) => _.includes(val.reasonCode, value)),
substitutionItems: _.map(val.substitutionItems, sub => ({
...sub,
requisitionItemId: val.requisitionItemId,
product: {
...sub.product,
label: `${sub.productCode} ${sub.productName}`,
},
// eslint-disable-next-line max-len
reasonCode: _.find(this.props.reasonCodes, ({ value }) => _.includes(val.reasonCode, value)),
})),
}),
);
Expand Down Expand Up @@ -1153,9 +1157,13 @@ class EditItemsPage extends Component {
editPageItems: _.map(data, item => ({
...item,
quantityOnHand: item.quantityOnHand || 0,
// eslint-disable-next-line max-len
reasonCode: _.find(this.props.reasonCodes, ({ value }) => _.includes(item.reasonCode, value)),
substitutionItems: _.map(item.substitutionItems, sub => ({
...sub,
requisitionItemId: item.requisitionItemId,
// eslint-disable-next-line max-len
reasonCode: _.find(this.props.reasonCodes, ({ value }) => _.includes(item.reasonCode, value)),
})),
})),
},
Expand Down