Skip to content

Allow manual selection of units on results entry#2201

Merged
xispa merged 18 commits into
senaite:2.xfrom
RML-IAEA:unitSelection
Feb 21, 2023
Merged

Allow manual selection of units on results entry#2201
xispa merged 18 commits into
senaite:2.xfrom
RML-IAEA:unitSelection

Conversation

@RML-IAEA
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread src/bika/lims/browser/analyses/view.py
Comment thread src/bika/lims/content/abstractbaseanalysis.py Outdated
Comment thread src/bika/lims/validators.py Outdated
Comment thread src/bika/lims/validators.py Outdated
Comment thread src/bika/lims/browser/analyses/view.py Outdated
Comment thread src/bika/lims/browser/analyses/view.py Outdated
Comment thread src/bika/lims/browser/analyses/view.py Outdated
Comment thread src/bika/lims/browser/analyses/view.py Outdated
Comment thread src/bika/lims/browser/analyses/view.py Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@ramonski ramonski added the Feature 🪚 New feature request label Jan 10, 2023
Implemented corrections from senaite#2201 (review)
@RML-IAEA
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/bika/lims/browser/analyses/view.py Outdated
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
Copy Markdown
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

Comment thread src/bika/lims/browser/analyses/view.py
@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
Copy Markdown
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

Labels

Feature 🪚 New feature request

Development

Successfully merging this pull request may close these issues.

4 participants