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
|
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}%"
|
||||||
|
|||||||
@@ -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}"
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -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">
|
||||||
|
|||||||
Reference in New Issue
Block a user