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-5120 Show that loading is in progress on substitution window #3723

Merged
merged 6 commits into from
Dec 21, 2022

Conversation

alannadolny
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@kchelstowski kchelstowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover I think you should avoid reformatting the code everywhere, because if there are bigger changes, it might be difficult to follow where you provided a change and where it is only a code reformatting

@@ -3036,6 +3036,7 @@ react.stockMovement.edit.label=Edit
react.stockMovement.pick.label=Pick
react.stockMovement.pack.label=Pack
react.stockMovement.send.label=Send
react.stockMovement.noSubstitutionsAvailable.message=There are no substitutions available
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it won't work if it doesn't have .label at the end

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? Do you mean crowding will not detect this label ?
I am pretty sure there are many labels that end with .message that we have in the project and it looks like all of them have translations

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember not a long time ago I didn't add .label and the translation did not work, but I do not rememeber if it was on gsp pages or react

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it could be a random case that it didn't want to work for me, so if you are confident that it should work, I'm fine with it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave it as it is and if after merge it turns out that it doesn't work then we will know for sure :D

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked locally this branch and the translation seems to be working fine even if removing .message etc, so my case when it did not work without .label was probably a random one. I apologize for confusion

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I meant at the beginning is that the label won't even be recognized, so that it'd take the defaultMessage, not that it will work, but will not be translatable with crowdin, but never mind, everything is fine

const {
emptySubstitutions,
loadingSubstitutions,
} = properties;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should add a comment about usage of those properties and also about the two ifs below, as TableBody is a component we use in many places and this particular case will only be used for substitution modal

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think that such a request might come in some other places/modals, so maybe we could think about some "generic" naming here? @awalkowiak what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kchelstowski @alannadolny yes, this definitely has to be generic

return (<Spinner />);
}

if (emptySubstitutions && !fields.length) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is that fields.length responsible for here? fields is probably an object, so I do not understand the usage of that? Isn't checking emptySubstitutions good enough?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fields is an object, but it has its length as a property. Checking emptySubstitutions isn't enough, because when you are clicking 'add custom substitution' emptySubsitutions is still 0, but fields.length will be > 0, so message with 'There are no substitutions available' will disappear. When it will be only emptySubstitutions there will be displayed this message and added substitution.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I see, I forgot about adding a custom one, then I'm fine with it - it was rather a question, not a request change

} = props;
const dynamicAttr = getDynamicAttr ? getDynamicAttr(props) : {};
const attr = { ...attributes, ...dynamicAttr };

this.state = {
loadingSubstitutions: false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see emptySubstitutions being initialized here?

formValues: {
substitutions,
},
originalItem,
});
}).catch(err => err);
})
.catch(err => err);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we want to mark loadingSubstitutions as true if we get an error also? In my opinion if any error occurs, the spinner will still be visible.
You could use .finally in the end, so you don't have to hide the spinner twice (you would avoid setting the loading to false twice - once in .then and once in .catch)

@alannadolny
Copy link
Collaborator Author

Yes, I know that code formatting can be problematic and I am trying to avoid it, but this is my habit, so I forget about it sometimes. I will pay more attention to code formatting.

// fields.length is checked due to possibility of adding custom substitution
if (emptySubstitutions && !fields.length) {
return (translate(
'react.stockMovement.noSubstitutionsAvailable.message',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be passed from the modal component (or other component using the TableBody)

@awalkowiak awalkowiak merged commit 1a90fb9 into develop Dec 21, 2022
@awalkowiak awalkowiak deleted the OBPIH-5120 branch December 21, 2022 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants