Skip to content

Commit

Permalink
Change worksheet analysis column order for better results capturing (#…
Browse files Browse the repository at this point in the history
…2266)

* Upgrade step

* Added registry panel for worksheets view

* Changed default columns order

* Changelog updated

* Removed memoize

* Fix empty columns_order
  • Loading branch information
ramonski authored Mar 6, 2023
1 parent cfc7188 commit bf0229e
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
2.4.0 (unreleased)
------------------

- #2266 Change worksheet analysis column order for better results capturing
- #2265 Change sample analysis column order for better results capturing
- #2264 Collapsible analyses listings in sample view
- #2262 Simplify attachment render in report options to single checkbox
Expand Down
3 changes: 2 additions & 1 deletion src/bika/lims/browser/analyses/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ def get_default_columns_order(self):
:returns: List of column keys
"""
name = "sampleview_analysis_columns_order"
return get_registry_record(name, default=[])
columns_order = get_registry_record(name, default=[]) or []
return columns_order

def reorder_analysis_columns(self):
"""Reorder analysis columns based on registry configuration
Expand Down
55 changes: 38 additions & 17 deletions src/bika/lims/browser/worksheet/views/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from bika.lims.utils import to_int
from plone.memoize import view
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from senaite.core.registry import get_registry_record


class AnalysesView(BaseView):
Expand Down Expand Up @@ -76,15 +77,6 @@ def __init__(self, context, request):
("Service", {
"sortable": False,
"title": _("Analysis")}),
("Method", {
"sortable": False,
"ajax": True,
"on_change": "_on_method_change",
"title": _("Method")}),
("Instrument", {
"sortable": False,
"ajax": True,
"title": _("Instrument")}),
("DetectionLimitOperand", {
"title": _("DL"),
"sortable": False,
Expand All @@ -95,25 +87,34 @@ def __init__(self, context, request):
"title": _("Result"),
"ajax": True,
"sortable": False}),
("Uncertainty", {
"sortable": False,
"title": _("+-")}),
("Specification", {
"title": _("Specification"),
"sortable": False}),
("retested", {
"title": get_image("retested.png", title=t(_("Retested"))),
"toggle": False,
"type": "boolean"}),
("Specification", {
"title": _("Specification"),
"sortable": False}),
("Uncertainty", {
("Method", {
"sortable": False,
"title": _("+-")}),
"ajax": True,
"on_change": "_on_method_change",
"title": _("Method")}),
("Instrument", {
"sortable": False,
"ajax": True,
"title": _("Instrument")}),
("Attachments", {
"sortable": False,
"title": _("Attachments")}),
("DueDate", {
"sortable": False,
"title": _("Due Date")}),
("state_title", {
"sortable": False,
"title": _("State")}),
("Attachments", {
"sortable": False,
"title": _("Attachments")}),
))

# Inject Remarks column for listing
Expand Down Expand Up @@ -151,13 +152,33 @@ def __init__(self, context, request):
},
]

def update(self):
super(AnalysesView, self).update()
self.reorder_analysis_columns()

def before_render(self):
super(AnalysesView, self).before_render()

if self.show_analysis_remarks_transition():
for state in self.review_states:
state["custom_transitions"] = [self.set_analysis_remarks_modal]

@view.memoize
def get_default_columns_order(self):
"""Return the default column order from the registry
:returns: List of column keys
"""
name = "worksheetview_analysis_columns_order"
columns_order = get_registry_record(name, default=[]) or []
# Always put `Pos` column first
try:
columns_order.remove("Pos")
except ValueError:
pass
columns_order.insert(0, "Pos")
return columns_order

def show_analysis_remarks_transition(self):
"""Check if the analysis remarks transitions should be rendered
Expand Down
2 changes: 1 addition & 1 deletion src/senaite/core/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
<version>2422</version>
<version>2423</version>
<dependencies>
<dependency>profile-Products.ATContentTypes:base</dependency>
<dependency>profile-Products.CMFEditions:CMFEditions</dependency>
Expand Down
3 changes: 3 additions & 0 deletions src/senaite/core/profiles/default/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<!-- SENAITE Registry -->
<records interface="senaite.core.registry.schema.ISenaiteRegistry" />

<!-- Registry for worksheet view configuration -->
<records interface="senaite.core.registry.schema.IWorksheetViewRegistry" />

<!-- Registry for sample view configuration -->
<records interface="senaite.core.registry.schema.ISampleViewRegistry" />

Expand Down
40 changes: 38 additions & 2 deletions src/senaite/core/registry/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,49 @@ class ISenaiteRegistry(model.Schema):
"""


class IWorksheetViewRegistry(ISenaiteRegistry):
"""View settings for worksheets
"""
model.fieldset(
"worksheet_view",
label=_(u"Worksheet View"),
description=_("Worksheet view configuration"),
fields=[
"worksheetview_analysis_columns_order",
],
)

worksheetview_analysis_columns_order = schema.List(
title=_(u"Analysis columns order"),
description=_(
u"Default column order for worksheet analysis listings"
),
value_type=schema.ASCIILine(title=u"Column"),
required=False,
default=[
"Pos",
"Service",
"DetectionLimitOperand",
"Result",
"Uncertainty",
"Specification",
"retested",
"Method",
"Instrument",
"Attachments",
"DueDate",
"state_title",
]
)


class ISampleViewRegistry(ISenaiteRegistry):
"""Registry settings for sample settings
"""View settings for samples
"""
model.fieldset(
"sample_view",
label=_(u"Sample View"),
description=_("Configuration for the sample view"),
description=_("Sample view configuration"),
fields=[
"sampleview_collapse_field_analysis_table",
"sampleview_collapse_lab_analysis_table",
Expand Down
8 changes: 8 additions & 0 deletions src/senaite/core/upgrade/v02_04_000.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,12 @@
handler="senaite.core.upgrade.v02_04_000.import_registry"
profile="senaite.core:default"/>

<genericsetup:upgradeStep
title="SENAITE CORE 2.4.0: Update configuration registry"
description="Update configuration registry for worksheet analyses columns config"
source="2422"
destination="2423"
handler="senaite.core.upgrade.v02_04_000.import_registry"
profile="senaite.core:default"/>

</configure>

0 comments on commit bf0229e

Please sign in to comment.