WIP on getting work_log support on inventory page.
This commit is contained in:
parent
7935b5b57d
commit
57104824a1
5 changed files with 117 additions and 68 deletions
|
|
@ -4,7 +4,7 @@ from sqlalchemy.inspection import inspect
|
|||
from typing import Any, Dict, List, Tuple, Callable, Optional
|
||||
|
||||
import crudkit
|
||||
from crudkit.ui.fragments import render_form
|
||||
from crudkit.ui.fragments import render_form, register_template_globals
|
||||
from crudkit.core import normalize_payload
|
||||
|
||||
bp_entry = Blueprint("entry", __name__)
|
||||
|
|
@ -17,7 +17,8 @@ def _fields_for_model(model: str):
|
|||
if model == "inventory":
|
||||
fields = ["label", "name", "serial", "barcode", "brand", "model",
|
||||
"device_type", "owner", "location", "condition", "image",
|
||||
"notes", "work_logs"]
|
||||
"notes", "work_logs.start_time", "work_logs.work_item.label",
|
||||
"work_logs.contact.label", "work_logs.complete"]
|
||||
fields_spec = [
|
||||
{"name": "label", "type": "display", "label": "", "row": "label",
|
||||
"attrs": {"class": "display-6 mb-3"}, "wrap": {"class": "col"}},
|
||||
|
|
@ -57,6 +58,7 @@ def _fields_for_model(model: str):
|
|||
"wrap": {"class": "h-100 w-100"}},
|
||||
{"name": "notes", "type": "template", "label": "Notes", "row": "notes", "wrap": {"class": "col"},
|
||||
"template": "inventory_note.html"},
|
||||
{"name": "work_logs", "type": "template", "row": "notes", "wrap": {"class": "col"}, "template": "inventory_logs.html"},
|
||||
]
|
||||
layout = [
|
||||
{"name": "label", "order": 5, "attrs": {"class": "row align-items-center"}},
|
||||
|
|
@ -103,6 +105,7 @@ def _fields_for_model(model: str):
|
|||
]
|
||||
|
||||
elif model == "worklog":
|
||||
# tell the service to eager-load precisely what the template needs
|
||||
fields = [
|
||||
"id",
|
||||
"contact.label",
|
||||
|
|
@ -165,6 +168,8 @@ def _apply_worklog_updates(worklog, updates, delete_ids):
|
|||
note_svc.delete(uid, actor="bulk_child_delete", commit=False)
|
||||
|
||||
def init_entry_routes(app):
|
||||
# Make helpers available in all templates
|
||||
register_template_globals(app)
|
||||
|
||||
@bp_entry.get("/entry/<model>/<int:id>")
|
||||
def entry(model: str, id: int):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue