Update Employee functionalities: display contract/project name in dashboard
This commit is contained in:
@@ -6124,8 +6124,8 @@ def employees():
|
||||
per_page = 20 # Number of employees per page
|
||||
|
||||
# Build query based on search
|
||||
query = Employee.query
|
||||
|
||||
query = Employee.query.outerjoin(Project, Employee.contractId == Project.id)
|
||||
|
||||
if search:
|
||||
search_pattern = f"%{search}%"
|
||||
query = query.filter(
|
||||
@@ -6136,7 +6136,7 @@ def employees():
|
||||
Employee.id.like(search_pattern)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# Order by first name, then last name
|
||||
query = query.order_by(Employee.firstName, Employee.lastName)
|
||||
|
||||
|
||||
+10
-1
@@ -69,4 +69,13 @@ class Employee(base.db.Model):
|
||||
'title': self.title,
|
||||
'display_title': self.display_title,
|
||||
'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}"
|
||||
@@ -375,7 +375,7 @@ body.has-sidebar .employees-page {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.contract-id .contract-badge {
|
||||
.contract .contract-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0.25rem 0.75rem;
|
||||
|
||||
@@ -128,7 +128,7 @@ extra_head %}
|
||||
<th>Employee ID</th>
|
||||
<th>Name</th>
|
||||
<th>Job Title</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Contract</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -163,8 +163,8 @@ extra_head %}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="contract-id">
|
||||
<span class="contract-badge">{{ employee.contractId }}</span>
|
||||
<td class="contract">
|
||||
<span class="contract-badge">{{ employee.contract_name }}</span>
|
||||
</td>
|
||||
|
||||
<td class="actions">
|
||||
|
||||
Reference in New Issue
Block a user