-
-
Notifications
You must be signed in to change notification settings - Fork 392
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-5854 New approval statuses in SM list pages - Approvals lists pages #4290
Conversation
List<RequisitionStatus> getRequisitionStatusCodesList(boolean hasRequestApprovalActivity, boolean isRequestsList) { | ||
if (isRequestsList) { | ||
return hasRequestApprovalActivity ? RequisitionStatus.listRequisitionOptions() : RequisitionStatus.listOutboundOptions() | ||
} | ||
|
||
return hasRequestApprovalActivity ? RequisitionStatus.listOutboundOptionsWhenSupportingRequestApproval() : RequisitionStatus.listOutboundOptions() | ||
} |
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 idea of this function is to use an appropriate list based on the list page that we are currently working on:
- If we are on the requests list:
a) If our location supports request approval activity - add waiting for approval and approved
b) If our location doesn't support request approval - the options should be the same as we had before - If we are on the outbound list:
a) If our location supports request approval activity - add the approved status
b) If our location doesn't support request approval - the options should be the same as we had before
List options = statuses?.collect(mapStatusCodes) | ||
List availableStatuses = RequisitionStatus.listAll().collect(mapStatusCodes) |
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.
I had to split options on the dropdown from statuses that we can have on the list page. In the frontend part, we used fetched statuses from the dropdown to display their names on the list, but when we removed the verified status we still had at least one stock movement with this status, and the error was thrown. So I split those two cases (We were trying to show the status that we didn't fetch). Regarding the validation with visible requests in "approved"/"waiting for approval" status - we have a ticket for this and I think this should be improved/resolved here
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.
if options
are still based on what getRequisitionStatusCodesList
returns, can't we still run into this problem, since this method can filter out some of the statuses?
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.
btw if I understand correctly - on the list we want to display SMs with some statuses that we can't filter by? E.g. On the list we'll have a SM with status "Verifying", but we would not be able to filter by this status?
If so, isn't it weird? Will it be handled in some other ticket or what?
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.
Yup, you understand this correctly, the only ticket I can see is that one with validation https://pihemr.atlassian.net/browse/OBPIH-5857?atlOrigin=eyJpIjoiNjE4OTJhMzFmNTUwNDUzMzg2YWMxN2FiZmQwZWQ1MDUiLCJwIjoiamlyYS1zbGFjay1pbnQifQ
But I don't know if we have a ticket to handle the situation when we have a verifying status on the list when supporting request approval.
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.
I think I understand the problem but not fully. To me, this approach doesn't seem right but maybe I am missing some context.
Anyway, we will probably need to discuss this part further.
useEffect(() => { | ||
dispatch(fetchRequisitionStatusCodes(currentLocation?.id, isRequestsList)); | ||
}, [currentLocale, currentLocation, isRequestsList]); |
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.
When we have different statuses on the dropdown, we should fetch them when:
- We are changing location (second location can not support requests approval, so this options should not be visible)
- We are changing locale (different translations)
- Changing list pages
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.
A general comment is that we probably need some comments for the RequisitionStatus methods.
In one place you use listRequisitionOptions
, in other place listOutboundOptions
, in other place listOutboundOptionsWhenSupportingRequestApproval
, in other place listAll()
- it's easy to get a headache while reading that and we should make sure to at least add comments above them to know, what they are supposed to exclude etc.
I agree the naming of them might say that, but for example - I don't know what we mean by listRequisitionOptions
here, and what's the difference between this and listOutboundOptions
since outbound is a requisition based SM 🤷♂️
boolean isRequestsList = params.getBoolean("isRequestsList") | ||
if (params.location) { | ||
Location location = Location.get(params.location) | ||
hasRequestApprovalActivity = location.supports(ActivityCode.APPROVE_REQUEST) |
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.
ideally, you could remove this hasRequestApprovalActivity
flag and base it on what I've done in the draft PR #4288 - so to use location.approvalRequired
transient.
[CREATED, EDITING, APPROVED, PICKING, PICKED, CHECKING, ISSUED, CANCELED, PENDING, REQUESTED, DISPATCHED] | ||
} | ||
|
||
static listRequisitionOptions() { |
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.
I don't know if it's a good naming here - what do you mean by "Requisition" here?
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.
I changed the naming here, but I am still open to better propositions
src/js/actions/index.js
Outdated
@@ -531,13 +531,13 @@ export function fetchShipmentStatusCodes() { | |||
} | |||
|
|||
|
|||
export function fetchRequisitionStatusCodes() { | |||
export function fetchRequisitionStatusCodes(locationId = null, isRequestsList = false) { |
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.
I don't mind the naming, but we used to distinguish outbound vs electronic request by using something connected to electronicType
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.
never mind - I see that it is also used in the useOutboundFilters
hook, but anyway, I'll leave this comment here
List options = statuses?.collect(mapStatusCodes) | ||
List availableStatuses = RequisitionStatus.listAll().collect(mapStatusCodes) |
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.
if options
are still based on what getRequisitionStatusCodesList
returns, can't we still run into this problem, since this method can filter out some of the statuses?
src/js/actions/index.js
Outdated
return (dispatch) => { | ||
apiClient.get('/openboxes/api/stockMovements/requisitionsStatusCodes') | ||
apiClient.get(`/openboxes/api/stockMovements/requisitionsStatusCodes?location=${locationId}&isRequestsList=${isRequestsList}`) |
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.
I'm also wondering if the location property here should not be handled by the backend.
Since anyway it is always supposed to be a currentLocation
static listOutboundOptionsWhenSupportingRequestApproval() { | ||
[CREATED, EDITING, APPROVED, PICKING, PICKED, CHECKING, ISSUED, CANCELED, PENDING, REQUESTED, DISPATCHED] | ||
} | ||
|
||
static listRequisitionOptions() { | ||
// Options for request list when we are supporting request approval (Added approved and waiting for approval) |
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.
"we" => current location
static listOutboundOptionsWhenSupportingRequestApproval() { | ||
[CREATED, EDITING, APPROVED, PICKING, PICKED, CHECKING, ISSUED, CANCELED, PENDING, REQUESTED, DISPATCHED] | ||
} | ||
|
||
static listRequisitionOptions() { | ||
// Options for request list when we are supporting request approval (Added approved and waiting for approval) | ||
static listRequestOptionsWhenSupportingRequestApproval() { | ||
[CREATED, EDITING, APPROVED, WAITING_FOR_APPROVAL, PICKING, PICKED, CHECKING, ISSUED, CANCELED, PENDING, REQUESTED, DISPATCHED] |
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.
looking at this stuff, I've now started to think if we should not refactor those statuses methods to:
- create a common list method that would contain the intersection of all the methods
- for particular methods just concat it with the statuses that we are adding, e.g:
listCommon().concat([APPROVED])
- or filter it if we want to exclude something
don't know if it should be part of this ticket, but I think it would improve the readability of those methods.
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.
Good point, I think we can even implement some kind of a RequisitionStatusFactory
to generate a list of the statuses based on some given parameters.
But for now, unless anyone disagrees I think we can proceed with the individual lists
static listOutboundOptionsWhenSupportingRequestApproval() { | ||
[CREATED, EDITING, APPROVED, PICKING, PICKED, CHECKING, ISSUED, CANCELED, PENDING, REQUESTED, DISPATCHED] | ||
} | ||
|
||
static listRequisitionOptions() { | ||
// Options for request list when we are supporting request approval (Added approved and waiting for approval) | ||
static listRequestOptionsWhenSupportingRequestApproval() { |
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.
I'm stlil not sure about the naming for this one, but I don't have any suggestion so I'll leave it for others maybe
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.
Yeah this is something that we could think about a bit
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.
I assume we don't want to spend time thinking about naming this one? @awalkowiak ?
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.
I do think we want to spend time thinking about naming.
@@ -18,8 +18,10 @@ enum StockMovementStatusCode { | |||
CREATED(0), | |||
REQUESTING(1, PENDING), | |||
REQUESTED(2, PENDING), | |||
WAITING_FOR_APPROVAL(2), |
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.
Shouldn't this be PENDING_APPROVAL
?
I saw Kacper has implemented these enums in #4288 so lets stick to the same name
VALIDATING(2, PENDING), | ||
VALIDATED(3, PENDING), | ||
APPROVED(3), |
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.
REJECTED
is probably missing right?
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.
I don't need this status here
static listOutboundOptionsWhenSupportingRequestApproval() { | ||
[CREATED, EDITING, APPROVED, PICKING, PICKED, CHECKING, ISSUED, CANCELED, PENDING, REQUESTED, DISPATCHED] | ||
} | ||
|
||
static listRequisitionOptions() { | ||
// Options for request list when we are supporting request approval (Added approved and waiting for approval) | ||
static listRequestOptionsWhenSupportingRequestApproval() { | ||
[CREATED, EDITING, APPROVED, WAITING_FOR_APPROVAL, PICKING, PICKED, CHECKING, ISSUED, CANCELED, PENDING, REQUESTED, DISPATCHED] |
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.
Good point, I think we can even implement some kind of a RequisitionStatusFactory
to generate a list of the statuses based on some given parameters.
But for now, unless anyone disagrees I think we can proceed with the individual lists
src/js/actions/index.js
Outdated
return (dispatch) => { | ||
apiClient.get('/openboxes/api/stockMovements/requisitionsStatusCodes') | ||
apiClient.get(`/openboxes/api/stockMovements/requisitionsStatusCodes?isRequestsList=${isRequestsList}`) |
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.
let's use params
attribute to pass parameters instead of template literals
apiClient.get(`/openboxes/api/stockMovements/requisitionsStatusCodes?isRequestsList=${isRequestsList}`) | |
apiClient.get('/openboxes/api/stockMovements/requisitionsStatusCodes', { | |
params: { isRequestsList }, | |
}) |
@@ -128,6 +139,8 @@ enum RequisitionStatus { | |||
return "(case status " + | |||
"when '${CREATED}' then ${CREATED.sortOrder} " + | |||
"when '${EDITING}' then ${EDITING.sortOrder} " + | |||
"when '${PENDING_APPROVAL}' then ${PENDING_APPROVAL.sortOrder} " + |
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.
Kacper's PR might add the same thing, watch out for conflicts.
render([data: options, allStatuses: allStatuses] as JSON) | ||
} | ||
|
||
List<RequisitionStatus> getRequisitionStatusCodesList(Boolean hasRequestApprovalActivity, Boolean isRequestsList) { |
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.
Would it be cleaner if it was one if + else if block in the action above? Is this used anywhere else? Plus you bring another confusion with hasRequestApprovalActivity
for a moment I was wondering how this differs from isApprovalRequired
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.
Yes, thank you. Please never name a variable after what it does. Always name the variable as close to the encapsulated behavior you're trying to capture. That way, if the behavior gets more complicated you don't rename hasRequestApprovalActivityAndHasSomeOtherActivity
.
Instead, the variable should be isRequisitionApprovalEnabled
or isApprovalRequired
and if the logic of that becomes more complicated, we still really only care about whether we've enabled approvals. I might like @awalkowiak suggestion even more than mine.
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.
Oh if "isRequestsList" is telling me where you are ("on the request list page") when you are making this request, then that's gotta go. There must be a better way of passing state than differentiating what page we're on. What if I needed these statuses on another page or the mobile app. Does that become "isRequestsListOrSomeOtherPageOrOnMobileApp"? What is the differentiating factor?
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.
I might think about adding another enum RequisitionStatusWorkflow
(??) to represent the different sub-workflows: RequestWorkflow, ApprovalWorkflow, PickPackWorkflow. Each status could have a workflow associated with it
CREATED(1, null, StatusType.SUCCESS, Workflow.REQUEST),
EDITING(2, PENDING, StatusType.PRIMARY, Workflow.REQUEST),
PENDING_APPROVAL(3, null, StatusType.WARNING, Workflow.APPROVAL),
APPROVED(4, null, StatusType.SUCCESS, Workflow.APPROVAL),
REJECTED(5, null, StatusType.DANGER, Workflow.APPROVAL),
VERIFYING(6, PENDING, StatusType.WARNING, Workflow.REQUEST),
and you could pass a single workflow or a list of workflows to get the appropriate list back.
RequisitionStatus.listOptions(Workflow.ALL)
RequisitionStatus.listOptions(Workflow.REQUEST)
RequisitionStatus.listOptions([Workflow.REQUEST, Workflow.REQUEST_APPROVAL])
NOTE: I don't understand the need for listOutboundOptions. Could someone explain that to me?
Aside: This is one of the reasons I dislike the Stock Movement workflow so much. It's not just one workflow, it's anywhere from 3-5 different workflows, each with its own complex set of steps, that are being squashed into a single, barely usable flow.
List options = statuses?.collect(mapStatusCodes) | ||
List allStatuses = RequisitionStatus.listAll().collect(mapStatusCodes) | ||
|
||
render([data: options, allStatuses: allStatuses] as JSON) |
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.
Why you can't just return [data: options]
based on the case?
static listOutboundOptionsWhenSupportingRequestApproval() { | ||
[CREATED, EDITING, APPROVED, PICKING, PICKED, CHECKING, ISSUED, CANCELED, PENDING, REQUESTED, DISPATCHED] | ||
} | ||
|
||
static listRequisitionOptions() { | ||
// Options for request list when we are supporting request approval (Added approved and waiting for approval) | ||
static listRequestOptionsWhenSupportingRequestApproval() { |
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.
Yeah this is something that we could think about a bit
7c45247
to
4cb466d
Compare
} | ||
render([data: options] as JSON) | ||
|
||
return hasRequestApprovalActivity ? RequisitionStatus.listOutboundOptionsWhenSupportingRequestApproval() : RequisitionStatus.listOutboundOptions() |
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.
it'd be cleaner if you reverted the statement, so:
// If a location doesn't support the request approval, return listOutboundOptions no matter what list is displayed
if (!hasRequestApprovalActivity) {
return RequisitionStatus.listOutboundOptions()
}
// If supports request approval, check what type of list page it is and return appropriate statuses
if (isRequestList) {
return RequisitionStatus.listRequestOptionsWhenSupportingRequestApproval()
}
return RequisitionStatus.listOutboundOptionsWhenSupportingRequestApproval()
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.
I prefer this version + changes in naming that @jmiranda suggested, than moving to the function higher + using if/else. So, I am leaving this part of the code in the version that you suggested, unless there is a strong opinion against it.
static listOutboundOptionsWhenSupportingRequestApproval() { | ||
[CREATED, EDITING, APPROVED, PICKING, PICKED, CHECKING, ISSUED, CANCELED, PENDING, REQUESTED, DISPATCHED] | ||
} | ||
|
||
static listRequisitionOptions() { | ||
// Options for request list when we are supporting request approval (Added approved and waiting for approval) | ||
static listRequestOptionsWhenSupportingRequestApproval() { |
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.
I assume we don't want to spend time thinking about naming this one? @awalkowiak ?
@@ -43,6 +43,8 @@ const StockMovementOutboundTable = ({ | |||
deleteConfirmAlert, | |||
} = useOutboundListTableData(filterParams); | |||
|
|||
useTranslation('requisitionStatus'); |
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.
nitpicky: I think this call should be placed in the useOutboundListTableData
hook, but no need to change.
> | ||
<StatusIndicator | ||
variant={row?.original?.statusVariant} | ||
status={translate(`react.requisitionStatus.enum.${row?.original?.status}`, row?.original?.status)} |
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.
please make sure that the label will change when you change the language - I remember having difficult times with translate
behavior when changing the language on list pages - most of the times I was just deciding to translate what I needed on the backend.
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.
Eh, you're right, it doesn't work
render([data: options, allStatuses: allStatuses] as JSON) | ||
} | ||
|
||
List<RequisitionStatus> getRequisitionStatusCodesList(Boolean hasRequestApprovalActivity, Boolean isRequestsList) { |
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.
Yes, thank you. Please never name a variable after what it does. Always name the variable as close to the encapsulated behavior you're trying to capture. That way, if the behavior gets more complicated you don't rename hasRequestApprovalActivityAndHasSomeOtherActivity
.
Instead, the variable should be isRequisitionApprovalEnabled
or isApprovalRequired
and if the logic of that becomes more complicated, we still really only care about whether we've enabled approvals. I might like @awalkowiak suggestion even more than mine.
variant: it.variant.name | ||
] | ||
Location currentLocation = Location.get(session.warehouse.id) | ||
Boolean isRequestsList = params.getBoolean("isRequestsList") |
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.
If something isn't self-explanatory, let's add comments for all of the changes. For example, what is "isRequestsList" for?
Pretend I'm not reading the requirements in the tickets. Because I'm not.
Location currentLocation = Location.get(session.warehouse.id) | ||
Boolean isRequestsList = params.getBoolean("isRequestsList") | ||
|
||
List<String> statuses = getRequisitionStatusCodesList(currentLocation.isApprovalRequired(), isRequestsList).collect(mapStatusCodes) |
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.
I don't think we need "List" here. Feels like getOutboundRequisitionStatuses() or getOutboundRequisitionStatusCodes() might be enough. Although I honestly don't know what this code is trying to accomplish (even with the comment below).
render([data: options, allStatuses: allStatuses] as JSON) | ||
} | ||
|
||
List<RequisitionStatus> getRequisitionStatusCodesList(Boolean hasRequestApprovalActivity, Boolean isRequestsList) { |
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.
Oh if "isRequestsList" is telling me where you are ("on the request list page") when you are making this request, then that's gotta go. There must be a better way of passing state than differentiating what page we're on. What if I needed these statuses on another page or the mobile app. Does that become "isRequestsListOrSomeOtherPageOrOnMobileApp"? What is the differentiating factor?
return hasRequestApprovalActivity ? RequisitionStatus.listOutboundOptionsWhenSupportingRequestApproval() : RequisitionStatus.listOutboundOptions() | ||
} | ||
|
||
Closure mapStatusCodes = { RequisitionStatus status -> |
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.
Any chance we could move this as a static method on the enum?
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.
moved
@@ -108,6 +108,7 @@ class OutboundStockMovementListItem implements Serializable { | |||
name : name, | |||
description : description, | |||
statusCode : statusCode?.toString(), | |||
statusVariant : status?.variant?.name, |
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.
Can someone explain what variant is here?
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 variant here is an indicator that can be as an example: "warning", "success", etc. It is represented as a colorful dot on our list pages:
I had to move it here, because of the implementation that we had. This implementation doesn't allow us to have different options on the filtering dropdown, than the statuses on the stock movement list. In this ticket I have to remove "Verified" from the filtering when the location supports "request approval", but on the current list we can have "verified" status
static listOutboundOptionsWhenSupportingRequestApproval() { | ||
[CREATED, EDITING, APPROVED, PICKING, PICKED, CHECKING, ISSUED, CANCELED, PENDING, REQUESTED, DISPATCHED] | ||
} | ||
|
||
static listRequisitionOptions() { | ||
// Options for request list when we are supporting request approval (Added approved and waiting for approval) | ||
static listRequestOptionsWhenSupportingRequestApproval() { |
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.
I do think we want to spend time thinking about naming.
render([data: options, allStatuses: allStatuses] as JSON) | ||
} | ||
|
||
List<RequisitionStatus> getRequisitionStatusCodesList(Boolean hasRequestApprovalActivity, Boolean isRequestsList) { |
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.
I might think about adding another enum RequisitionStatusWorkflow
(??) to represent the different sub-workflows: RequestWorkflow, ApprovalWorkflow, PickPackWorkflow. Each status could have a workflow associated with it
CREATED(1, null, StatusType.SUCCESS, Workflow.REQUEST),
EDITING(2, PENDING, StatusType.PRIMARY, Workflow.REQUEST),
PENDING_APPROVAL(3, null, StatusType.WARNING, Workflow.APPROVAL),
APPROVED(4, null, StatusType.SUCCESS, Workflow.APPROVAL),
REJECTED(5, null, StatusType.DANGER, Workflow.APPROVAL),
VERIFYING(6, PENDING, StatusType.WARNING, Workflow.REQUEST),
and you could pass a single workflow or a list of workflows to get the appropriate list back.
RequisitionStatus.listOptions(Workflow.ALL)
RequisitionStatus.listOptions(Workflow.REQUEST)
RequisitionStatus.listOptions([Workflow.REQUEST, Workflow.REQUEST_APPROVAL])
NOTE: I don't understand the need for listOutboundOptions. Could someone explain that to me?
Aside: This is one of the reasons I dislike the Stock Movement workflow so much. It's not just one workflow, it's anywhere from 3-5 different workflows, each with its own complex set of steps, that are being squashed into a single, barely usable flow.
grails-app/i18n/messages.properties
Outdated
@@ -3481,6 +3484,22 @@ react.stockMovement.enum.AvailableItemStatus.PICKED=Picked | |||
react.stockMovement.enum.AvailableItemStatus.RECALLED=Recalled | |||
react.stockMovement.enum.AvailableItemStatus.HOLD=Hold | |||
react.stockMovement.enum.AvailableItemStatus.NOT_AVAILABLE=Not Available | |||
react.requisitionStatus.enum.CREATED=Created |
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.
Can we stop duplicating these? I don't understand why the react app can just use the existing key
enum.RequisitionStatus.STATUS
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.
As I know we were using only those labels starting with "react" on the react side. For now, when I use our function for fetching translations, I have to pass "requisitionStatus" as an argument to fetch all of the translations that start with "react.requistionStatus...".
I am moving the translation to the backend because those translations don't work as @kchelstowski suggested in a comment. So, I am removing those duplications.
@@ -157,6 +158,15 @@ enum RequisitionStatus { | |||
"end)" | |||
} | |||
|
|||
static Closure mapStatusCodes = { RequisitionStatus status -> |
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.
I am wondering if we should specify what we are mapping to exactly.
Since we are mapping it to options maybe this should be called something like mapToOption
or toOption
and we can omit the "StatusCode" in the name since we are going to be calling it on RequisitionStatus so saying that we are mapping it to StatusCodes seems redundant, but that just my take.
To me this felts similar to what we are doing when mapping to JSON .toJson()
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.
Good idea, thanks
return [ | ||
id : id, | ||
name : name, | ||
description : description, | ||
statusCode : statusCode?.toString(), | ||
statusVariant : status?.variant?.name, | ||
statusLabel : "${g.message(code: 'enum.RequisitionStatus.' + status.name())}", |
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.
Since status
on OutboundStockMovementListItem
is a RequisitionStatus, I feel like we can use the mapStatusCodes()
or whatever the name for it will be, to extract the label from it.
I am not sure if it is going to work but lets try doing something like
statusLabel : "${g.message(code: 'enum.RequisitionStatus.' + status.name())}", | |
statusLabel : status.mapStatusCodes()?.label, |
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.
Yup, it works
dispatch(fetchShipmentTypes()); | ||
}, [currentLocale]); | ||
|
||
useEffect(() => { | ||
dispatch(fetchRequisitionStatusCodes(isRequestsList)); | ||
}, [currentLocale, currentLocation, isRequestsList]); |
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.
Should pass source type? Maybe not.
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.
Minor changes if necessary otherwise LGTM
b869d4b
to
5a87c7b
Compare
render([data: options] as JSON) | ||
// If request approval is required, check what type of list it is and return appropriate statuses | ||
if (isElectronicType) { | ||
return RequisitionStatus.listRequestOptionsWhenSupportingRequestApproval() |
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.
Let's follow other namings and do it as listRequestOptionsWhenApprovalRequired
and listOutboundOptionsWhenApprovalRequired
…ages (#4290) * OBPIH-5854 Add waiting for approval and approved statuses * OBPIH-5854 Add translations for new statuses * OBPIH-5854 Add fetching all available statuses and change sending dropdown options * OBPIH-5854 Make status colum wider and add fetching statuses when changing location * OBPIH-5854 Fixes after review * OBPIH-5854 Change comment in RequisitionStatus * OBPIH-5854 Fixes after review * OBPIH-5854 Remove fetching all statuses and add handling them on frontend * OBPIH-5854 Remove variant from mapping status codes * OBPIH-5854 Fix rejected status * OBPIH-5854 Fixes after review * OBPIH-5854 Rename static method in RequisitionStatus * OBPIH-5854 Change mapping status label in OutboundStockMovementListItem * OBPIH-5854 Change isElectronicType to sourceType * OBPIH-5854 Change naming of list methods in RequisitionStatus
No description provided.