Buildings and levels for the floor map, and make every identifier searchable
This commit is contained in:
@@ -117,9 +117,24 @@ class Asset(BaseModel, SoftDeleteMixin, AuditMixin):
|
||||
nullable=True
|
||||
)
|
||||
|
||||
# Floor map position (ADR-001: asset-specific override; nullable)
|
||||
mapx = db.Column(db.Integer, comment='X coordinate on floor map (ADR-001)')
|
||||
mapy = db.Column(db.Integer, comment='Y coordinate on floor map (ADR-001)')
|
||||
# Floor map position (ADR-001: asset-specific override; nullable).
|
||||
#
|
||||
# Absolute pixels in the NATIVE COORDINATE SPACE OF ITS LEVEL, not of the
|
||||
# site (ADR-017). levelid says which drawing they are pixels of, and without
|
||||
# it a position cannot be rendered - a marker drawn on the wrong level's
|
||||
# blueprint looks perfectly correct and points at the wrong place, so the UI
|
||||
# shows "level unknown" rather than assuming the default.
|
||||
mapx = db.Column(db.Integer, comment='X coordinate on this level (ADR-017)')
|
||||
mapy = db.Column(db.Integer, comment='Y coordinate on this level (ADR-017)')
|
||||
levelid = db.Column(
|
||||
db.Integer, db.ForeignKey('maplevels.levelid'), nullable=True,
|
||||
index=True,
|
||||
comment='Which drawing mapx/mapy are pixels of (ADR-017)')
|
||||
# When the position was last CONFIRMED against the current drawing. A bulk
|
||||
# transform clears it, because a transform is a starting guess: the levels
|
||||
# were redrawn and machines moved, and nothing in the coordinates says which
|
||||
# markers are now stale. Null means "not yet reviewed on this drawing".
|
||||
mapverifiedat = db.Column(db.DateTime, nullable=True)
|
||||
|
||||
# Notes
|
||||
notes = db.Column(db.Text, nullable=True)
|
||||
@@ -198,6 +213,10 @@ class Asset(BaseModel, SoftDeleteMixin, AuditMixin):
|
||||
'locationname': related.location.locationname if related.location else None,
|
||||
'mapx': related.mapx,
|
||||
'mapy': related.mapy,
|
||||
# The level belongs to whichever asset supplied the
|
||||
# coordinates (ADR-017). Inheriting a position without its
|
||||
# level draws it on the borrower's drawing instead.
|
||||
'levelid': related.levelid,
|
||||
'inheritedfrom': related.assetnumber
|
||||
}
|
||||
|
||||
@@ -250,6 +269,11 @@ class Asset(BaseModel, SoftDeleteMixin, AuditMixin):
|
||||
result['mapx'] = inherited['mapx']
|
||||
if result.get('mapy') is None:
|
||||
result['mapy'] = inherited['mapy']
|
||||
# Coordinates and their level move together, always. Copying the
|
||||
# position while leaving levelid as this asset's own is how an
|
||||
# inherited marker lands on the wrong drawing.
|
||||
if result.get('levelid') is None:
|
||||
result['levelid'] = inherited.get('levelid')
|
||||
|
||||
# Operation/short code of the resolved location (own or inherited).
|
||||
# Derived from the location name's leading token; labels can encode a
|
||||
|
||||
Reference in New Issue
Block a user