Update Employee functionalities: display contract/project name in dashboard

This commit is contained in:
Nguyen Ngo
2025-09-19 12:05:30 -04:00
parent 8a0f4e8f4b
commit 762e477ba1
4 changed files with 17 additions and 8 deletions
+1 -1
View File
@@ -6124,7 +6124,7 @@ def employees():
per_page = 20 # Number of employees per page per_page = 20 # Number of employees per page
# Build query based on search # Build query based on search
query = Employee.query query = Employee.query.outerjoin(Project, Employee.contractId == Project.id)
if search: if search:
search_pattern = f"%{search}%" search_pattern = f"%{search}%"
+9
View File
@@ -70,3 +70,12 @@ class Employee(base.db.Model):
'display_title': self.display_title, 'display_title': self.display_title,
'contractId': self.contractId 'contractId': self.contractId
} }
project = base.db.relationship('Project', foreign_keys=[contractId],
primaryjoin="Employee.contractId == Project.id",
backref='employees')
@property
def contract_name(self):
"""Get project name from contractId"""
return self.project.name if self.project else f"Contract {self.contractId}"
+1 -1
View File
@@ -375,7 +375,7 @@ body.has-sidebar .employees-page {
font-size: 0.875rem; font-size: 0.875rem;
} }
.contract-id .contract-badge { .contract .contract-badge {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
padding: 0.25rem 0.75rem; padding: 0.25rem 0.75rem;
+3 -3
View File
@@ -128,7 +128,7 @@ extra_head %}
<th>Employee ID</th> <th>Employee ID</th>
<th>Name</th> <th>Name</th>
<th>Job Title</th> <th>Job Title</th>
<th>Contract ID</th> <th>Contract</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
@@ -163,8 +163,8 @@ extra_head %}
{% endif %} {% endif %}
</td> </td>
<td class="contract-id"> <td class="contract">
<span class="contract-badge">{{ employee.contractId }}</span> <span class="contract-badge">{{ employee.contract_name }}</span>
</td> </td>
<td class="actions"> <td class="actions">