[UPDT] HORILLA_THEME: Added actions to offboarding kanban view
This commit is contained in:
@@ -60,3 +60,35 @@ def delete_stage_accessibility(
|
||||
"""
|
||||
perm = request.user.has_perm("offboarding.delete_offboarding")
|
||||
return perm
|
||||
|
||||
|
||||
def archive_employee_accessibility(
|
||||
request, instance: object = None, user_perms: PermWrapper = [], *args, **kwargs
|
||||
):
|
||||
stage_type = instance.stage_id.type
|
||||
if stage_type == "archived" and add_employee_accessibility(request):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def edit_employee_accessibility(
|
||||
request, instance: object = None, user_perms: PermWrapper = [], *args, **kwargs
|
||||
):
|
||||
stage_type = instance.stage_id.type
|
||||
if stage_type != "archived" and add_employee_accessibility(request):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def managing_records_accessibility(
|
||||
request, instance: object = None, user_perms: PermWrapper = [], *args, **kwargs
|
||||
):
|
||||
if (
|
||||
instance.employee_id
|
||||
and instance.employee_id.get_archive_condition()
|
||||
and add_employee_accessibility(request)
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -480,6 +480,40 @@ class OffboardingKanbanView(KanbanView):
|
||||
data-group-order='{ordered_group_json}'
|
||||
"""
|
||||
|
||||
group_actions = [
|
||||
{
|
||||
"action": "Add Employee",
|
||||
"accessibility": "offboarding.cbv.accessibility.add_employee_accessibility",
|
||||
"attrs": """
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#genericModal"
|
||||
hx-get="{get_add_employee_url}"
|
||||
hx-target="#genericModalBody"
|
||||
class="oh-dropdown__link"
|
||||
""",
|
||||
},
|
||||
{
|
||||
"action": "Edit",
|
||||
"accessibility": "offboarding.cbv.accessibility.edit_stage_accessibility",
|
||||
"attrs": """
|
||||
hx-target="#genericModalBody"
|
||||
hx-get="{get_update_url}"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#genericModal"
|
||||
""",
|
||||
},
|
||||
{
|
||||
"action": "Delete",
|
||||
"accessibility": "offboarding.cbv.accessibility.delete_stage_accessibility",
|
||||
"attrs": """
|
||||
data-target="#deleteConfirmation"
|
||||
data-toggle="oh-modal-toggle"
|
||||
hx-get="{get_delete_url}"
|
||||
hx-target="#deleteConfirmationBody"
|
||||
""",
|
||||
},
|
||||
]
|
||||
|
||||
details = {
|
||||
"image_src": "{employee_id__get_avatar}",
|
||||
"title": "{employee_id__get_full_name}",
|
||||
@@ -487,6 +521,76 @@ class OffboardingKanbanView(KanbanView):
|
||||
"Notice period end": "{notice_period_ends}",
|
||||
}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
self.actions = [
|
||||
{
|
||||
"action": "Send Mail",
|
||||
"accessibility": "offboarding.cbv.accessibility.add_employee_accessibility",
|
||||
"attrs": """
|
||||
data-target="#sendMailModal"
|
||||
data-toggle="oh-modal-toggle"
|
||||
hx-get="{get_mail_send_url}"
|
||||
hx-target="#mail-content"
|
||||
""",
|
||||
},
|
||||
{
|
||||
"action": "Notes",
|
||||
"attrs": """
|
||||
data-target="#genericSidebar"
|
||||
data-toggle="oh-modal-toggle"
|
||||
hx-get="{get_notes_url}"
|
||||
hx-target="#genericOffCanvas"
|
||||
onclick="$('#genericSidebar').addClass('oh-activity-sidebar--show')"
|
||||
""",
|
||||
},
|
||||
{
|
||||
"action": "get_archive_title",
|
||||
"accessibility": "offboarding.cbv.accessibility.archive_employee_accessibility",
|
||||
"attrs": """
|
||||
data-target="#objectDetailsModal"
|
||||
data-toggle="oh-modal-toggle"
|
||||
hx-get="{get_archive_url}"
|
||||
hx-target="#objectDetailsModalTarget"
|
||||
""",
|
||||
},
|
||||
{
|
||||
"action": "Edit",
|
||||
"accessibility": "offboarding.cbv.accessibility.edit_employee_accessibility",
|
||||
"attrs": """
|
||||
data-target="#objectDetailsModal"
|
||||
data-toggle="oh-modal-toggle"
|
||||
hx-get="{get_edit_url}"
|
||||
hx-target="#objectDetailsModalTarget"
|
||||
""",
|
||||
},
|
||||
{
|
||||
"action": "managing records",
|
||||
"accessibility": "offboarding.cbv.accessibility.edit_employee_accessibility",
|
||||
"attrs": """
|
||||
data-target="#objectDetailsModal"
|
||||
data-toggle="oh-modal-toggle"
|
||||
hx-get="{get_managing_record_url}"
|
||||
hx-target="#objectDetailsModalTarget"
|
||||
""",
|
||||
},
|
||||
]
|
||||
|
||||
if self.request.user.has_perm("offboarding.delete_offboardingemployee"):
|
||||
self.actions.append(
|
||||
{
|
||||
"action": "Delete",
|
||||
"accessibility": "offboarding.cbv.accessibility.add_employee_accessibility",
|
||||
"attrs": f"""
|
||||
hx-confirm="Do you want to delete this offboarding user?"
|
||||
hx-post="{{get_delete_url}}"
|
||||
hx-swap="none"
|
||||
hx-on-htmx-after-request = "$(`#{self.view_id}`).find('.reload-record').click()"
|
||||
""",
|
||||
},
|
||||
)
|
||||
|
||||
def get_related_groups(self, *args, **kwargs):
|
||||
related_groups = super().get_related_groups(*args, **kwargs)
|
||||
off_id = self.kwargs.get("pk")
|
||||
|
||||
@@ -184,7 +184,7 @@ class OffboardingEmployee(HorillaModel):
|
||||
|
||||
def get_individual_url(self):
|
||||
"""
|
||||
This method is used to get update url
|
||||
This method is used to get individual view url
|
||||
"""
|
||||
return f'{reverse_lazy("offboarding-individual-view", kwargs={"pk": self.pk})}'
|
||||
|
||||
@@ -289,6 +289,44 @@ class OffboardingEmployee(HorillaModel):
|
||||
)
|
||||
return ordered_group_json
|
||||
|
||||
def get_archive_title(self):
|
||||
"""
|
||||
This method is used to get title for the archive in actions
|
||||
"""
|
||||
return "Archive" if self.employee_id.is_active else "Un-Archive"
|
||||
|
||||
def get_mail_send_url(self):
|
||||
"""
|
||||
This method is used to get the mail send url
|
||||
"""
|
||||
return f'{reverse_lazy("send-mail-employee", kwargs={"emp_id": self.pk})}'
|
||||
|
||||
def get_notes_url(self):
|
||||
"""
|
||||
This method is used to get the employee note view url
|
||||
"""
|
||||
return (
|
||||
f'{reverse_lazy("view-offboarding-note", kwargs={"employee_id": self.pk})}'
|
||||
)
|
||||
|
||||
def get_archive_url(self):
|
||||
"""
|
||||
This method is used to get the mail send url
|
||||
"""
|
||||
return f'{reverse_lazy("employee-archive", kwargs={"obj_id": self.pk})}'
|
||||
|
||||
def get_edit_url(self):
|
||||
"""
|
||||
This method is used to get the mail send url
|
||||
"""
|
||||
return f'{reverse_lazy("add-employee", kwargs={"pk": self.pk})}?stage_id={self.stage_id.id}'
|
||||
|
||||
def get_managing_record_url(self):
|
||||
"""
|
||||
This method is used to get the mail send url
|
||||
"""
|
||||
return f'{reverse_lazy("get-manager-in")}?employee_id={self.employee_id.id}&offboarding=True'
|
||||
|
||||
|
||||
class ResignationLetter(HorillaModel):
|
||||
"""
|
||||
|
||||
@@ -47,10 +47,6 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endblock content %}
|
||||
|
||||
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="sendMailModal"
|
||||
@@ -70,3 +66,5 @@
|
||||
<div class="oh-modal__dialog-body" id="mail-content"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock content %}
|
||||
|
||||
Reference in New Issue
Block a user