-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Always allow interim fields to be added to Analysis Services #820
Conversation
Welcome to the Jungle 🌴 🙈 🌴This PR refactors the whole JS logic in Analysis Services. The following functionality is given on the Analysis Service Edit View Analysis Tab:
The following functionality is given on the Analysis Service Edit View Container and Preservation Tab:N.B.: Only the working code was ported (not too much)...
The following functionality is given on the Analysis Service Edit View Methods Tab:
Additional NotesAll methods that are available in the Example: asv.is_instrument_assignment_allowed()
asv.get_methods()
asv.get_default_instrument() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, thank you for dealing with this thing. This is one of the craziest and cumbersome js logic in core.
I've added some bits with comments and suggestions, feel free to decide if you want to apply them or not.
Apart from the code review, I've done functional testing for Analysis Service edit view and seems to work just fine. I've noticed the hide/display dance when method/instrument entry settings are changed are not performed as used to, but the lists are populated correctly. No worries is fine as it is. After playing a bit around, I created ARs, added results and did not have any problem. Anyhow, is quite difficult to test results entry view taking into consideration all possible options available for Analysis Services, so... you never know.
Haven't test the container/preservation logic tough... (in fact, not sure if that thing was working before).
I'd recommend to change the title "Calculation Interim Fields" by "Interim fields" ("Additional values" might be better - I always found "Interim" too cryptic).
Good exhausting work!.
data: | ||
catalog_name: "bika_setup_catalog" | ||
page_size: 0 | ||
portal_type: "Instrument" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instrument
content type has theinactive_workflow
assigned, so I suggest to load only those with inactive_state='active'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort_on='sortable_title
would be nice too, as you did for Methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking now what would happen if you have an Analysis Service with an instrument associated and someone inactivates the instrument afterwards... the Analysis Service will remain in inconsistent status. Would be nice to think about a guard
for that transition that would return True
only if the instrument is not assigned to any AS. Another option is to not filter by inactivate_state
here, but in that case, the instrument should be added in the invalid_instruments
dict on L#29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I added issue #829 to not forget about this
notification = $("<dl/>") | ||
$.each invalid_instruments, (index, instrument) -> | ||
notification.append "<dd>⚠ #{instrument.Title}</dd>" | ||
title = @_ "Some of the selected instruments are out-of-date or with failed calibration tests" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind to change this message by something like "Some of the selected instruments are out-of-date, with failed calibration tests or under maintenance".
Note that as per L#29:
`if instrument.Valid isnt "1"
Valid
ComputedField delegates to isValid
, that does the following:
def isValid(self):
""" Returns if the current instrument is not out for verification, calibration,
out-of-date regards to its certificates and if the latest QC succeed
"""
return self.isOutOfDate() is False \
and self.isQCValid() is True \
and self.getDisposeUntilNextCalibrationTest() is False \
and self.isValidationInProgress() is False \
and self.isCalibrationInProgress() is False
The conditions "DisposedUntilNextCalibrationTest", "ValidationInProgress" and "CalibrationInProgress" are temporary situations, so the suggested message would be more informative.
page_size: 0 | ||
portal_type: "Method" | ||
inactive_state: "active" | ||
sort_on: "sortable_title" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same reasoning here about a guard for inactivate
transition as explained for Instrument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was not used, so I removed it from the JS
# load the calculation now, to set the interims | ||
@load_calculation uid | ||
.done (calculation) -> | ||
@set_interims calculation.InterimFields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not critical, thinking loud. If the user has entered manual interims previously, all them are replaced by the ones that comes with the Calculation. Would be nice if system could keep the ones entered manually. A function like purge_interims
could be in charge to remove only those interims that belong to the previous calculation (if any), and leave the rest. Then, using purge_interims
together with a function add_interims
(instead of set_interims
) would do the job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual interims are always preserved, see set_interims
.
However, I fixed a small issue, where "overwritten" interims, e.g. manual interims with the same keyword as the calculation interim, had different values, e.g. value
or unit
etc.
These interims are now merged on calculation change and preserved as "manual" interim
|
||
if not @is_uid method_uid | ||
# remove all calculation interims | ||
@set_interims null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my previous comment about keeping the interims manually set by using a purge_interims
function or something.
deferred = $.Deferred() | ||
|
||
options = | ||
url: @get_portal_url() + "/get_available_calculations" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we use /get_available_calculations
here? you could use the @@API/read
as you do below, for Methods
(L#778) and Instruments
(L#753). get_available_calculations
is only used here, so as a bonus, you'll be able to remove the class bika.lims.browser.calcs.ajaxGetAvailableCalculations
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change this, remember that Calculation
also uses inactive_workflow
, so you should query only for those that are active.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. This method is a relict that remained from refactoring and nowhere used. I'm removing it...
# {uid: "488400e9f5e24a4cbd214056e6b5e2aa", title: "My Calculation"} | ||
if not @is_uid data.uid | ||
return deferred.resolveWith this, [{}] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "Instrument assignment is not required"/"Manual entry of results" thing is totally weird. It shouldn't rely on the assignment/unassignment of methods, rather with instruments (if no instrument assigned, then there is no choice, the user must set the result manually)... but in turn, Method content type has the option "Manual entry" True/False, at the same time that can have none or multiple instruments associated.... so well, kind of an hydra we'll have to deal with in future.
Hi Jordi, thanks for your review and feedback. Could you please functional check the following:
Expected: Interim |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done the functional test you mentioned regarding Calculations A + B and works as expected.
Nevertheless, I noticed that when you create an Analysis Service, the option "Use the Default Calculation of Method" is checked by default, so "None" option appears selected in the list for "Calculation" field. This is correct. If then I unselect "Use the Default Calculation of Method", the first available calculation appears selected in the list of calculations, but interims are not populated accordingly.
Hi Jordi, good catch. I added this functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very good one!
Description of the issue/feature this PR addresses
Interim fields in Analysis Services are the only way, how to capture multiple results for one Analysis, e.g. 5 different areas in the sample like middle , right , left etc.
Linked issue: #751
Current behavior before PR
Interim fields are not visible when no calculation was selected
Desired behavior after PR is merged
Interim fields are always visible
--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.