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

Allow manual selection of units on results entry #2201

Merged
merged 18 commits into from
Feb 21, 2023

Conversation

RML-IAEA
Copy link
Contributor

  • A list of units can be defined for an analysis service
  • The user can select the units when submitting data.

Description of the issue/feature this PR addresses

Linked issue: https://github.com/senaite/senaite.core/issues/

Current behavior before PR

Desired behavior after PR is merged

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

+ A list of units can be defined for an analysis service
+ The user can select the units when submitting data.
update the code so that the default value is always listed first.
update the code so that the units rendered beside the result do not wrap.
Copy link
Member

@xispa xispa left a comment

Choose a reason for hiding this comment

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

Thanks for your efforts!

Seems the unit is not store properly

  1. Type result:

Captura de 2022-12-20 13-41-00

  1. Select a unit from the selection list:

Captura de 2022-12-20 13-41-15

  1. On save, the unit next to the result changes to default, different from the selected one:

Captura de 2022-12-20 13-41-28

  1. On submit, the unit has not changed, although the selected one was different from default:

Captura de 2022-12-20 13-41-39

src/bika/lims/browser/analyses/view.py Show resolved Hide resolved
src/bika/lims/content/abstractbaseanalysis.py Outdated Show resolved Hide resolved
src/bika/lims/validators.py Outdated Show resolved Hide resolved
src/bika/lims/validators.py Outdated Show resolved Hide resolved
src/bika/lims/browser/analyses/view.py Outdated Show resolved Hide resolved
src/bika/lims/browser/analyses/view.py Outdated Show resolved Hide resolved
src/bika/lims/browser/analyses/view.py Outdated Show resolved Hide resolved
src/bika/lims/browser/analyses/view.py Outdated Show resolved Hide resolved
@@ -1065,7 +1112,18 @@ def _folder_item_method(self, analysis_brain, item):
item["Method"] = api.get_title(method)
item["replace"]["Method"] = get_link_for(method, tabindex="-1")

def _on_unit_choice_change(self, uid=None, value=None, item=None, **kw):
Copy link
Member

Choose a reason for hiding this comment

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

You don't need this if you do it differently. Hint: You don't need a "UnitChoices" column, but a "Unit" column that becomes editable (with a choices list) when the analysis have multiple units set. Otherwise, the column "Unit" is not rendered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed UnitChoice column. Unit it column is only rendered when needed.

Copy link
Member

Choose a reason for hiding this comment

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

I think you can remove this function _on_unit_choice_change, cause on_unit_change is used instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, removed.

Implemented corrections from senaite#2201 (review)
@RML-IAEA
Copy link
Contributor Author

RML-IAEA commented Jan 13, 2023

Thank you @xispa for all your comments. I have implemented your comments (ac745f9).
A default unit can be provided here:
image

A list of units for selection can be provided here:
image

The unit column will only render if a selection of units is provided.
image

I have also updated the code so that the units render after the uncertainty.
image

and for the selection list;
image

The units change is now stored properly:

image

On submit:
image

Improvement:
I wanted to include the unitchoice object with the unit object. I tried to implement this by updating the unit object to be a RecordsField. I was unable to set the selected value properly. I notice that for UIDReferenceField this works well. Do you have any suggestions on how the unitchoice object could be merged with the unit object?

@RML-IAEA RML-IAEA marked this pull request as ready for review January 13, 2023 16:49
Copy link
Member

@xispa xispa left a comment

Choose a reason for hiding this comment

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

Thanks, you are almost there!. Just two minor changes (see comments) and please add an entry at CHANGES.rst. Also, do a pull first, cause I've merged 2.x into your branch and done some commits to make Flake8 happy.

@@ -1065,7 +1112,18 @@ def _folder_item_method(self, analysis_brain, item):
item["Method"] = api.get_title(method)
item["replace"]["Method"] = get_link_for(method, tabindex="-1")

def _on_unit_choice_change(self, uid=None, value=None, item=None, **kw):
Copy link
Member

Choose a reason for hiding this comment

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

I think you can remove this function _on_unit_choice_change, cause on_unit_change is used instead

src/bika/lims/browser/analyses/view.py Show resolved Hide resolved
@xispa xispa changed the title Unit selection Manual selection of units on results introduction Feb 7, 2023
@xispa xispa changed the title Manual selection of units on results introduction Manual selection of units on results entry Feb 7, 2023
Implemented xispa requested changes on Jan 19. see senaite#2201
@RML-IAEA
Copy link
Contributor Author

Hi @xispa,
Thank you for al your help. I have implemented all changes.

@RML-IAEA RML-IAEA requested a review from xispa February 21, 2023 13:52
@xispa xispa changed the title Manual selection of units on results entry Allow manual selection of units on results entry Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants