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

Analyses sorted by priority in Add Analyses view and preserve AR order when adding into Worksheet #338

Merged
merged 3 commits into from
Oct 31, 2017

Conversation

xispa
Copy link
Member

@xispa xispa commented Oct 30, 2017

Fixes #303

IMPORTANT: Requires the execution of upgrade step v1.1.1

In Analyses Add View (when creating a Worksheet), the analyses were displayed randomly. After their selection (and addition into a new Worksheet), the position of the Analysis Requests in the Worksheet was the same as the Analyses Add view, random.

With this Pull Request, the Analyses in Add Analyses view are sorted by priority by default (from more priority to less priority), at the same time that preserves the correct order of analyses in accordance with the SortKey value as defined in the Analysis Service (#331):

add_analyses_1

When selected and submitted, the order of the Analysis Requests inside the Worksheet is corrected, so the ARs are sorted in natural order of creation, but again, keeping the Analyses' SortKey order:

ws

Note the priority of AP-0010-R01 was "High" and the priority of "AP-0005-R01" was medium, so:
a) In Add Analyses view, AP-0010-R01 is displayed before AP-0005-R01
b) In Worksheet manage results, AP-0010-R01 is displayed after AP-0005-R01
c) In both cases, analyses are sorted in accordance with their SortKey value (Iron = 20, Calcium = 50, Magnesium = 70, Copper and others = Not defined)

title = sortable_title(self)
if callable(title):
title = title()
return '{}.{}.{}'.format(ar_sort_key, ar_id, title)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a little style issue here to remove code complexity.

Better do something like this:

analysis_request = self.getRequest()
if analysis_request is None:
    return None
# continue with the rest of the code with a lower indendation level
ar_sort_key = analysis_request.getPrioritySortkey()
...

@ramonski ramonski merged commit f5138b8 into senaite:senaite-integration Oct 31, 2017
@xispa xispa deleted the sorted-ar-in-ws branch October 31, 2017 21:14
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.

2 participants