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

Custom rate and named standard rate for units (Issue #1216) #1388

Open
wants to merge 38 commits into
base: development
Choose a base branch
from

Conversation

gyordong
Copy link
Contributor

@gyordong gyordong commented Nov 17, 2024

Description

(Please include a summary of the change and which issue is touched on. Please also include relevant motivation and context.)

Fixes #1216

Done in collaboration with @huss, @aduques, @AchsahJojo, @emilysarne.

Type of change

  • Note merging this changes the database configuration.
  • This change requires a documentation update

Checklist

  • I have followed the OED pull request ideas
  • I have removed text in ( ) from the issue request
  • You acknowledge that every person contributing to this work has signed the OED Contributing License Agreement and each author is listed in the Description section.

Limitations

gyordong and others added 26 commits July 11, 2024 11:00
…t value to custom input if nonstandard value
- Update unit edit logic for useEffect more
- Change custom sec in rate to require enter
- Disable save if not changed and incomplete custom input
- use setState and not directy set state
- consistently use === & !==
- Added SHL comments for original developers to look at and then remove
- Formatting
- Minor edit

Note create unit does not have new logic and bar may need
to be update to be similar
Note that @gyordong worked with me on these changes.

- Also has comments with ?? on items to do.
- Not carefully tested/completed.
…ts on customratevalid(), included customratevalid in editunit's canSave useEffect check to fix a bug with negative numbers.
@gyordong gyordong changed the title 1216 Custom rate and named standard rate for units (Issue #1216) Nov 17, 2024
Copy link
Member

@huss huss left a comment

Choose a reason for hiding this comment

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

I want to thank @gyordong, @aduques, @AchsahJojo & Emily Sarne for this contribution. Is Emily Sarne the GitHub user @emilysarne? I want to verify they have signed the CLA if they contributed to this work.

Testing found this works as desired. Most of my comments relate to differences between the code for edit and create for unit. I welcome your thoughts on my comments and you can address if you think a comment is fine. Please let me know if I can help in any way.

src/client/app/translations/data.ts Outdated Show resolved Hide resolved
if (state.typeOfUnit != UnitType.suffix && state.suffix != '') {
state.typeOfUnit = UnitType.suffix;
}
const submitState = {
Copy link
Member

Choose a reason for hiding this comment

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

While the change in how state is set here is nice, edit unit differs. This change should probably go there too. Note identifier is set here and done after save in edit so make consistent. I think I did this so it probably isn't your doing. If you prefer, I can make the change.

Copy link
Contributor

Choose a reason for hiding this comment

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

changed setting state in EditUnitModalComponent to be consistent with CreateUnitModalComponent

// - The rate is set so not the custom input value. This happens if select custom value but don't input with enter.
// - The custom rate is a positive integer
const validUnit = state.name !== '' &&
(state.typeOfUnit !== UnitType.suffix || state.suffix !== '') && state.secInRate !== Number(CUSTOM_INPUT)
Copy link
Member

Choose a reason for hiding this comment

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

This checks for not hitting enter on custom but create does not. This is kind to the user and nice to have.

Copy link
Contributor

Choose a reason for hiding this comment

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

After looking at comments on the CreateUnitModalComponent, I noticed that the design of the current implementation was to discard all values when leaving the page without saving. Given this, the custom rate would be discarded alongside the other values despite changing the similar line of code in CreateModalComponent. Should CreateUnitModalComponent be changed to still keep unsaved changes similarly to how it is implemented in EditUnitModalComponent?

Copy link
Member

Choose a reason for hiding this comment

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

I thought this test was to see if the user had started a custom input but not hit enter. This likely indicates they started to enter a value but never finalized it with an enter. This seems a potentially common mistake that OED is trying to catch to avoid. I didn't think it has to do with leaving the page and resetting state but maybe I'm missing something. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Steve, I changed the code to check for enter. The only caveat is that I made it purposely allow users to save without clicking enter if they didn't change the custom value from the standard values automatically inputted when clicked (ex. day to custom value, box shows 86400, create unit can be clicked). Let me know if this doesn't seem ideal and I'll change it to require enter to create a unit under all circumstances.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I missed this comment until now. I'm not sure which is best. It is unclear why the admin selected custom if they did not intend to change the value. However, I'm okay with this as long as both create and edit work the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the difference won't be noticeable for the user. Should I change it to require a change of value or is it fine as is?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if I understand but it is okay to use the value without enter if it is the standard value as long as both create and edit do the same thing. Is this what you were asking?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Do you have a preference between the two implementations?

Copy link
Member

Choose a reason for hiding this comment

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

I don't care too much but I might pick that if they do custom then they have to hit enter. One case I am thinking about is if they change the value away from a standard one and then put it back without hitting enter then would the code accept this second value because it is standard? This type of issue is why I'm leaning toward requiring enter for all custom values but maybe it isn't an issue.

src/client/app/components/unit/EditUnitModalComponent.tsx Outdated Show resolved Hide resolved
src/client/app/components/unit/EditUnitModalComponent.tsx Outdated Show resolved Hide resolved
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.

standard choices for sec. in rate
4 participants