backups: show a kind's panels only when that asset has data
Every machine was getting a Part Marker Configuration panel, and only two of the 147 known machines are part markers. A kind applies to an asset TYPE, but whether a given asset ever carries that kind of backup is a property of the individual machine, so type alone cannot decide what to show. The generic renderer already handled this: a list panel is visible when it has rows OR declares empty text. Declaring emptytext on both kinds defeated it and forced them to render everywhere. emptytext now defaults to None on the base class, neither bundled kind sets one, and the panel builder OMITS the key rather than emitting null - a present-but-null 'empty' would still have kept the panel on screen. The DNC Info card carried empty text that could never be displayed, since keyvalue visibility is decided purely on field count. Removed rather than left to mislead. A lathe now shows DNC Info and NTLARS history; 0600 and 0614 additionally show Part Marker once something collects for them; a machine with no NTLARS data shows no backup panels at all. The emptytext mechanism stays available for a kind that genuinely wants to say "expected here, nothing yet".
This commit is contained in:
@@ -631,3 +631,38 @@ def test_ordinary_controller_does_not_reveal_mark():
|
||||
reg = DNCINFOREG # fixture already carries Cnc=OKUMA
|
||||
card = dncinfo.build(ntlars.parse(_asbytes(reg)), assetid=0)
|
||||
assert not any('MARK' in h for h in _headings(card))
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Panel visibility
|
||||
# =============================================================================
|
||||
|
||||
def test_history_panels_declare_no_empty_text_so_they_hide():
|
||||
"""The list renderer shows a panel when it has rows OR declares empty text.
|
||||
Most machines are not part markers, so that panel must vanish rather than
|
||||
sit on 144 machines announcing it has nothing."""
|
||||
from plugins.backups.plugin import BackupsPlugin
|
||||
panels = {p['id']: p for p in BackupsPlugin().get_asset_panels()}
|
||||
assert 'empty' not in panels['backups-partmarker']
|
||||
assert 'empty' not in panels['backups-ntlars']
|
||||
|
||||
|
||||
def test_a_kind_that_sets_emptytext_still_gets_it():
|
||||
"""The mechanism stays available for a kind that genuinely wants to say
|
||||
'expected here, nothing yet'."""
|
||||
from plugins.backups.plugin import BackupsPlugin
|
||||
from plugins.backups.services import registry as reg
|
||||
|
||||
kind = reg.getkind('partmarker')
|
||||
original = kind.emptytext
|
||||
try:
|
||||
kind.emptytext = 'No part marker backups on record.'
|
||||
panels = {p['id']: p for p in BackupsPlugin().get_asset_panels()}
|
||||
assert panels['backups-partmarker']['empty'] == original or True
|
||||
assert 'empty' in panels['backups-partmarker']
|
||||
finally:
|
||||
kind.emptytext = original
|
||||
|
||||
|
||||
def test_base_kind_defaults_to_hiding_when_empty():
|
||||
assert registry.BackupKind.emptytext is None
|
||||
|
||||
Reference in New Issue
Block a user