Replace broken Location dropdown with Place (city) dropdown + Location Facility text input. Add /api/places endpoint. Add place/location_text filter params to /api/assets. Add functional_location to work orders API and frontend.
This commit is contained in:
@@ -930,6 +930,16 @@ def list_makes():
|
||||
return [r["manufacturer"] for r in rows]
|
||||
|
||||
|
||||
@app.get("/api/places")
|
||||
def list_places():
|
||||
conn = get_db()
|
||||
rows = conn.execute(
|
||||
"SELECT DISTINCT place FROM assets WHERE place IS NOT NULL AND place != '' ORDER BY place"
|
||||
).fetchall()
|
||||
conn.close()
|
||||
return [r["place"] for r in rows]
|
||||
|
||||
|
||||
# ─── Task 4: POST /api/assets ──────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -1067,6 +1077,8 @@ def list_assets(
|
||||
disney_filter: Optional[str] = Query(None),
|
||||
disney_group: Optional[str] = Query(None, description="Grouped park categories: park, resort, office, springs, other"),
|
||||
q: Optional[str] = Query(None),
|
||||
place: Optional[str] = Query(None, description="Filter by place/city"),
|
||||
location_text: Optional[str] = Query(None, description="Free-text location filter (building, facility)"),
|
||||
no_dex_days: Optional[int] = Query(None, ge=1),
|
||||
has_gps: Optional[bool] = Query(None),
|
||||
branch: Optional[str] = Query(None, description="Filter by branch/territory name"),
|
||||
@@ -1122,6 +1134,13 @@ def list_assets(
|
||||
conditions.append("(a.name LIKE ? OR a.machine_id LIKE ? OR a.serial_number LIKE ? OR a.description LIKE ? OR a.company LIKE ? OR a.place LIKE ? OR a.customer_name LIKE ? OR a.address LIKE ?)")
|
||||
like = f"%{q}%"
|
||||
params.extend([like, like, like, like, like, like, like, like])
|
||||
if place:
|
||||
conditions.append("a.place = ?")
|
||||
params.append(place)
|
||||
if location_text:
|
||||
conditions.append("(a.building_name LIKE ? OR a.address LIKE ? OR a.location_area LIKE ? OR a.place LIKE ? OR a.company LIKE ?)")
|
||||
lt = f"%{location_text}%"
|
||||
params.extend([lt, lt, lt, lt, lt])
|
||||
if no_dex_days is not None:
|
||||
conditions.append("(dex_report_date IS NULL OR REPLACE(dex_report_date, 'T', ' ') < datetime('now', '-' || ? || ' days'))")
|
||||
params.append(no_dex_days)
|
||||
@@ -3659,6 +3678,7 @@ async def workorders_list(
|
||||
w."msdyn_workordertype!name" AS work_type,
|
||||
w."msdyn_primaryincidenttype!name" AS incident_type,
|
||||
w."msdyn_serviceterritory!name" AS territory,
|
||||
w."msdyn_functionallocation!name" AS functional_location,
|
||||
w.msdyn_instructions,
|
||||
w.hsl_onsiteduration,
|
||||
w.msdyn_address1,
|
||||
@@ -3720,6 +3740,7 @@ async def workorders_list(
|
||||
"incident_type": r["incident_type"],
|
||||
"territory": r["territory"],
|
||||
"customer_asset_name": r["customer_asset_name"],
|
||||
"functional_location": r["functional_location"],
|
||||
"instructions": r["msdyn_instructions"],
|
||||
"onsite_duration": r["hsl_onsiteduration"],
|
||||
"datewindow_start": r["msdyn_datewindowstart"],
|
||||
|
||||
Reference in New Issue
Block a user