Update Employee functionalities: display contract/project name in dashboard
This commit is contained in:
@@ -6124,7 +6124,7 @@ 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}%"
|
||||
|
||||
@@ -70,3 +70,12 @@ class Employee(base.db.Model):
|
||||
'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