fixed project view title appearing as JSON string
This commit is contained in:
@@ -347,11 +347,15 @@ async def get_project_dashboard(
|
||||
# Project Types
|
||||
# ============================================================================
|
||||
|
||||
@router.get("/{project_id}/header", response_class=JSONResponse)
|
||||
async def get_project_header(project_id: str, db: Session = Depends(get_db)):
|
||||
@router.get("/{project_id}/header", response_class=HTMLResponse)
|
||||
async def get_project_header(
|
||||
project_id: str,
|
||||
request: Request,
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""
|
||||
Get project header information for dynamic display.
|
||||
Returns JSON with project name, status, and type.
|
||||
Returns HTML partial with project name, status, and type.
|
||||
"""
|
||||
project = db.query(Project).filter_by(id=project_id).first()
|
||||
if not project:
|
||||
@@ -359,12 +363,10 @@ async def get_project_header(project_id: str, db: Session = Depends(get_db)):
|
||||
|
||||
project_type = db.query(ProjectType).filter_by(id=project.project_type_id).first()
|
||||
|
||||
return JSONResponse({
|
||||
"id": project.id,
|
||||
"name": project.name,
|
||||
"status": project.status,
|
||||
"project_type_id": project.project_type_id,
|
||||
"project_type_name": project_type.name if project_type else None,
|
||||
return templates.TemplateResponse("partials/projects/project_header.html", {
|
||||
"request": request,
|
||||
"project": project,
|
||||
"project_type": project_type,
|
||||
})
|
||||
|
||||
|
||||
|
||||
14
templates/partials/projects/project_header.html
Normal file
14
templates/partials/projects/project_header.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<div class="mb-8">
|
||||
<h1 class="text-3xl font-bold text-gray-900 dark:text-white mb-2">{{ project.name }}</h1>
|
||||
<div class="flex items-center gap-4">
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium
|
||||
{% if project.status == 'active' %}bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200
|
||||
{% elif project.status == 'completed' %}bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200
|
||||
{% else %}bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200{% endif %}">
|
||||
{{ project.status|title }}
|
||||
</span>
|
||||
{% if project_type %}
|
||||
<span class="text-gray-500 dark:text-gray-400">{{ project_type.name }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user