NA's CAMPUS page always shows a campus, and says which
Opened directly (nothing tapped), page 99 was all purple: no campus chosen. It now shows the first other campus until one is tapped, and the back key reads WS / ALL SITES. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+12
-4
@@ -118,14 +118,18 @@ def build_view(local_cfg, page, overview_page):
|
|||||||
"options": {"stepProgression": "auto", "stepExpression": "", "rotaryActions": False, "canModifyStyleInApis": True,
|
"options": {"stepProgression": "auto", "stepExpression": "", "rotaryActions": False, "canModifyStyleInApis": True,
|
||||||
"notes": "STATUS tile 'campus view %d/%d' - the tapped campus's key here, view only (hold it on that campus's own deck)." % (r, c)},
|
"notes": "STATUS tile 'campus view %d/%d' - the tapped campus's key here, view only (hold it on that campus's own deck)." % (r, c)},
|
||||||
"feedbacks": [], "steps": {"0": {"action_sets": {"down": [], "up": []}, "options": {"runWhileHeld": []}}}, "localVariables": []})
|
"feedbacks": [], "steps": {"0": {"action_sets": {"down": [], "up": []}, "options": {"runWhileHeld": []}}}, "localVariables": []})
|
||||||
make_page.place(controls, (3, 0), make_page.static_button("campus_back", "ALL\\nCAMPUSES", 0x37474F, 0xFFFFFF, overview_page,
|
back = make_page.static_button("campus_back", "ALL\\nSITES", 0x37474F, 0xFFFFFF, overview_page,
|
||||||
"Tap: back to the CAMPUSES page (page %d)." % overview_page, "STATUS jump key"))
|
"Tap: back to the CAMPUSES page (page %d)." % overview_page, "STATUS jump key")
|
||||||
|
for layer in back["style"]["layers"]:
|
||||||
|
if layer["type"] == "text": # which campus this page shows, then the way back
|
||||||
|
layer["text"] = make_page.prop("`${$(custom:%s)}\\nALL SITES`" % SELECT, True)
|
||||||
|
make_page.place(controls, (3, 0), back)
|
||||||
return make_page.page_export("%d\\nCampus" % page, page, controls, local_cfg)
|
return make_page.page_export("%d\\nCampus" % page, page, controls, local_cfg)
|
||||||
|
|
||||||
|
|
||||||
def select_action(cid):
|
def select_action(cid):
|
||||||
return {"type": "action", "id": make_page.stable_id("campus_" + cid, "select"), "definitionId": "custom_variable_set_value",
|
return {"type": "action", "id": make_page.stable_id("campus_" + cid, "select"), "definitionId": "custom_variable_set_value",
|
||||||
"connectionId": "internal", "options": {"name": make_page.prop(SELECT), "value": make_page.prop(cid)}, "children": {}}
|
"connectionId": "internal", "options": {"name": make_page.prop(SELECT), "value": make_page.prop(cid.upper())}, "children": {}}
|
||||||
|
|
||||||
|
|
||||||
def campus_key(cid, name, names, actions, note, local_cfg):
|
def campus_key(cid, name, names, actions, note, local_cfg):
|
||||||
@@ -325,7 +329,11 @@ class Mirror:
|
|||||||
for t in threads:
|
for t in threads:
|
||||||
t.join(2)
|
t.join(2)
|
||||||
# The CAMPUS page shows the tapped campus: its keys moved onto their cells.
|
# The CAMPUS page shows the tapped campus: its keys moved onto their cells.
|
||||||
pick = (self.site.comp.get_custom(SELECT) or "").strip()
|
pick = (self.site.comp.get_custom(SELECT) or "").strip().lower() # held as "WS": the back key shows it
|
||||||
|
if pick not in others and others:
|
||||||
|
# Nothing tapped yet (or a campus that left): show the first one rather than a purple page.
|
||||||
|
pick = sorted(others)[0]
|
||||||
|
self.site.comp.set_custom(SELECT, pick.upper())
|
||||||
st = self.remote.get(pick)
|
st = self.remote.get(pick)
|
||||||
if st and pick in self.keys and (data.get("pages") or {}).get("view"):
|
if st and pick in self.keys and (data.get("pages") or {}).get("view"):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -258,6 +258,7 @@ class TestCampusesView(unittest.TestCase):
|
|||||||
ctrls = export["page"]["controls"]
|
ctrls = export["page"]["controls"]
|
||||||
self.assertEqual(export["page"]["name"], "99\\nCampus")
|
self.assertEqual(export["page"]["name"], "99\\nCampus")
|
||||||
self.assertIn("CAMPUSES", json.dumps(ctrls["3"]["0"])) # where ALARMS sits on every status page
|
self.assertIn("CAMPUSES", json.dumps(ctrls["3"]["0"])) # where ALARMS sits on every status page
|
||||||
|
self.assertIn("$(custom:sp_view)", json.dumps(ctrls["3"]["0"]["style"])) # it says which campus is shown
|
||||||
cells = [ctl for row in ctrls.values() for ctl in row.values() if "campus view" in (ctl.get("options") or {}).get("notes", "")]
|
cells = [ctl for row in ctrls.values() for ctl in row.values() if "campus view" in (ctl.get("options") or {}).get("notes", "")]
|
||||||
self.assertEqual(len(cells), 28)
|
self.assertEqual(len(cells), 28)
|
||||||
self.assertTrue(all(c["steps"]["0"]["action_sets"] == {"down": [], "up": []} for c in cells)) # no press, no hold
|
self.assertTrue(all(c["steps"]["0"]["action_sets"] == {"down": [], "up": []} for c in cells)) # no press, no hold
|
||||||
@@ -286,7 +287,7 @@ class TestCampusesView(unittest.TestCase):
|
|||||||
ws_key = next(k for _, _, k in keys if "'campus ws'" in k["options"]["notes"])
|
ws_key = next(k for _, _, k in keys if "'campus ws'" in k["options"]["notes"])
|
||||||
acts = ws_key["steps"]["0"]["action_sets"]["up"]
|
acts = ws_key["steps"]["0"]["action_sets"]["up"]
|
||||||
self.assertEqual([a["definitionId"] for a in acts], ["custom_variable_set_value", "set_page"])
|
self.assertEqual([a["definitionId"] for a in acts], ["custom_variable_set_value", "set_page"])
|
||||||
self.assertEqual((acts[0]["options"]["value"]["value"], acts[1]["options"]["page"]["value"]), ("ws", 99))
|
self.assertEqual((acts[0]["options"]["value"]["value"], acts[1]["options"]["page"]["value"]), ("WS", 99))
|
||||||
|
|
||||||
def test_a_campus_tells_the_hub_and_learns_nothing_back(self):
|
def test_a_campus_tells_the_hub_and_learns_nothing_back(self):
|
||||||
from settings import campuses as cv
|
from settings import campuses as cv
|
||||||
|
|||||||
Reference in New Issue
Block a user