-
-
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-5768 Add request approval supported activity to the Location do… #4277
Conversation
// Don't allow to set REQUEST_APPROVAL activity if there are not any users that | ||
// have Request Approver location role for this location | ||
// TODO: Replace ROLE_APPROVER with the ROLE_REQUEST_APPROVER when OBPIH-5799 is done | ||
if (activities?.contains(ActivityCode.REQUEST_APPROVAL.id) |
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.
Was it meant to be a validator? I thought it was a message to inform the user that he has to do this after adding this supported activity to the location
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 apologize, I was confused because of many different versions that we were speaking about, but I've consulted with Katarzyna and she confirmed this could be just a message, not a validation.
I fixed that part.
@@ -64,7 +64,9 @@ enum ActivityCode { | |||
|
|||
AUTOSAVE('AUTOSAVE'), | |||
|
|||
NONE('NONE') | |||
NONE('NONE'), |
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 you put it at the end?
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
… and instead return an information message
2e184ac
to
91837b6
Compare
@@ -114,6 +114,10 @@ class LocationController { | |||
} | |||
flash.message = "${warehouse.message(code: 'default.updated.message', args: [warehouse.message(code: 'location.label', default: 'Location'), locationInstance.id])}" | |||
|
|||
if (locationInstance.supportedActivities.contains(ActivityCode.REQUEST_APPROVAL.id)) { | |||
flash.message += " ${g.message(code: 'location.supportedActivities.noRequestApprovers', default: 'You must add one or several Approvers to the location to support the requests approval workflow. Go to users list to add an Approver.')}" |
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 you confirm that the component where flash.message
is rendered does not render HTML?
Because my first thought was to have a messages.properties
label
location.supportedActivities.noRequestApprovers=You must add one or several Approvers to the location to support the requests approval workflow. Go to <a href="{0}">users list</a> to add an Approver.
and inject the link with an argument
flash.message += " ${g.message(code: 'location.supportedActivities.noRequestApprovers', default: 'You must add one or several Approvers to the location to support the requests approval workflow. Go to users list to add an Approver.', args: ["https://somelink...."])}"
flash.message = [] | ||
flash.message.add([code: 'default.updated.message', args: [warehouse.message(code: 'location.label', default: 'Location'), locationInstance.id]]) |
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 it be done without initializing empty array? I mean merging those two lines into one:
flash.message = [[code: 'default.updated.message', args: [warehouse.message(code: 'location.label', default: 'Location'), locationInstance.id]]]
grails-app/views/location/edit.gsp
Outdated
<g:if test="${flash.message}"> | ||
<div class="message">${flash.message}</div> | ||
</g:if> | ||
<g:renderMessage /> |
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 like this solution since rendering messages with HTML tags doesn't work well in Grails 1. The first situation that came to my mind was the message after logging in with incorrect credentials. (This message works on Grails 3 - the same code, without any changes) 👍👍
…ages passed by flash.message
d9256ca
to
d442c4d
Compare
* by default takes the value stored in flash.message. | ||
* accepts data like: String, List<String>, Map<code: string, args: obj>, List<Map<code: string, args: obj>> | ||
*/ | ||
class RenderMessageTagLib { |
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.
@drodzewicz I am not sure if this is a good place for this tag lib (if there is need for a new tag lib). I wonder if this rather should be in the MessageTagLib
.
grails-app/i18n/messages.properties
Outdated
@@ -1456,6 +1457,7 @@ location.bgColor.label=Background color | |||
location.fgColor.label=Foreground color | |||
location.bgColor.invalid.matchingcolor=Colors cannot be the same | |||
location.supportedActivities.invalid.supportedActivities=You cannot set supported activity NONE in combination with other supported activities | |||
location.supportedActivities.noRequestApprovers=You must add one or several Approvers to the location to support the requests approval workflow. Go to <a href="{0}">users list</a> to add an Approver. |
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.
"one or more approvers to the location to support the requisition approval workflow."
<g:if test="${flash.message}"> | ||
<div class="message">${flash.message}</div> | ||
</g:if> | ||
<warehouse:renderMessage /> |
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 you explain the reason for this?
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.
Using a join(".") in the controller might allow us to avoid this.
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 you explain the reason for this?
The reason for that was to be able to include a link inside the message. This has nothing to do with the dot.
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 reason behind creating this taglib util function for rendering messages is because when translating labels in the controller and passing them using flash.messages
it would either escape the HTML or render the HTML as a string.
So as a solution we want to pass to the flash.message
all of the arguments needed for rendering the translated label and let the g.message
handle the rendering.
I implemented this <warehouse:renderMessage />
taglib function in a way so it would be possible to render either a single message or a list of messages.
We can also both pass a normal string or, as I mentioned before, all of the arguments for rendering message.properties labels like code, args, default
grails-app/i18n/messages.properties
Outdated
@@ -589,7 +589,7 @@ default.qtyPerUom.label=Qty per UoM | |||
default.pricePerUom.label=Price per UoM | |||
default.upload.label=Upload {0} | |||
default.uploaded.message={0} uploaded | |||
default.updated.message={0} updated | |||
default.updated.message={0} updated. |
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 (locationInstance.supportedActivities.contains(ActivityCode.REQUEST_APPROVAL.id)) { | ||
flash.message.add([code: 'location.supportedActivities.noRequestApprovers', args: [g.createLink(controller: "user", action: "list")]]) | ||
} |
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.
Instead of adding a period to the message, just add a join(".") 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 comma isn't necessary anymore since the message is rendered in the new line like
Previously @kchelstowski must have added the comma to separate both messages since they were rendered in the same line.
@@ -64,6 +64,8 @@ enum ActivityCode { | |||
|
|||
AUTOSAVE('AUTOSAVE'), | |||
|
|||
REQUEST_APPROVAL('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.
Why can't we use APPROVE_REQUEST above?
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.
Honestly I have not seen this before. I checked it and it seems to be existing, but not having any effect 🤔 so we could potentially use it.
It's also displayed as Approve requisition
- I saw your comments in @alannadolny 's ticket and I am a bit confused. In tickets it was supposed to be named with "Request" and you suggest that it should be "Requisition" instead of "Request".
So would it mean this activity code should be also renamed from APPROVE_REQUEST
to APPROVE_REQUISITION
?
I think we should not mix "Requisition" and "Request", so the question is, what is the path we want to follow?
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.
@drodzewicz There are still some pending requests (If everything is fixed, @kchelstowski you have green light to merge this one)
750f91a
to
4ef6883
Compare
#4277) * OBPIH-5768 Add request approval supported activity to the Location domain * OBPIH-5798 Remove validation for request approval supported activity, and instead return an information message * OBPIH-5798 Render list of messages using flash.messages * OBPIH-5798 Create RenderMessageTagLib which handles rendering of messages passed by flash.message * OBPIH-5798 Move renderMessage to MessageTagLib * OBPIH-5798 Use APPROVE_REQUEST Activity code instead of REQUEST_APPROVAL --------- Co-authored-by: Darek Rodzewicz <DRodzewicz@gmail.com> (cherry picked from commit 19bf7ec)
…APPROVE_REQUEST activity (#4364) * OBPIH-5768 Add request approval supported activity to the Location do… (#4277) * OBPIH-5768 Add request approval supported activity to the Location domain * OBPIH-5798 Remove validation for request approval supported activity, and instead return an information message * OBPIH-5798 Render list of messages using flash.messages * OBPIH-5798 Create RenderMessageTagLib which handles rendering of messages passed by flash.message * OBPIH-5798 Move renderMessage to MessageTagLib * OBPIH-5798 Use APPROVE_REQUEST Activity code instead of REQUEST_APPROVAL --------- Co-authored-by: Darek Rodzewicz <DRodzewicz@gmail.com> (cherry picked from commit 19bf7ec) * OBGM-714 Fixed i18n code used to alert user to add approvers (cherry-picked re: OBPIH-5768) * OBGM-714 Removed unnecessary newline --------- Co-authored-by: jmiranda <jcm62@columbia.edu>
…main
Either can be merged and for now use ROLE_APPOVER for user to check if it works fine, or do not merge and wait for the OBPIH-5799 to replace the role with REQUEST_APPROVER or whatever it will be.