[UPDT] EMPLOYEE: Updated employee import template download from js to static

This commit is contained in:
Horilla
2025-12-20 11:58:01 +05:30
parent faef77b1b6
commit da0524eda8
6 changed files with 42 additions and 24 deletions

View File

@@ -310,21 +310,21 @@ class EmployeesList(HorillaListView):
onclick="window.location.href='{get_individual_url}?instance_ids={ordered_ids}'"
"""
sortby_mapping = [
("Employee", "get_full_name", "get_avatar"),
("Badge Id", "badge_id"),
(_("Employee"), "get_full_name", "get_avatar"),
(_("Badge Id"), "badge_id"),
(
"Reporting Manager",
_("Reporting Manager"),
"employee_work_info__reporting_manager_id__get_full_name",
),
(
"Department",
_("Department"),
"employee_work_info__department_id__department",
),
(
"Job Position",
_("Job Position"),
"employee_work_info__job_position_id__job_position",
),
("Date of Joining", "employee_work_info__date_joining"),
(_("Date of Joining"), "employee_work_info__date_joining"),
]
@@ -485,7 +485,6 @@ class EmployeeNav(HorillaNavView):
data-target="#objectCreateModal"
hx-get="{reverse('work-info-import')}"
hx-target="#objectCreateModalTarget"
hx-on-htmx-after-request="setTimeout(() => {{template_download(event);}},100);"
style="cursor: pointer;"
""",
},
@@ -670,7 +669,7 @@ class EmployeeCard(HorillaCardView):
) or is_reportingmanager(self.request):
self.actions = [
{
"action": "Edit",
"action": _("Edit"),
"accessibility": "employee.cbv.accessibility.edit_accessibility",
"attrs": """
onclick="event.stopPropagation()

Binary file not shown.

View File

@@ -1,4 +1,4 @@
{% load i18n %}
{% load static i18n %}
<div class="oh-modal__dialog-header">
<h2 class="oh-modal__dialog-title">
{% trans "Import Employee" %}
@@ -33,8 +33,14 @@
</label>
<input type="file" name="file"/ required>
<div class="d-inline float-end">
<a href="#" style="text-decoration:none; display: inline-block;" class="oh-dropdown__link" hx-on:click="template_download(event)">
<ion-icon name="cloud-download-outline" style="font-size:20px; vertical-align: middle;" role="img" class="md hydrated"></ion-icon>
<a href="{% static 'employee/work_info_import.xlsx' %}"
class="oh-dropdown__link"
id="workInfoImportButton"
style="text-decoration:none; display:inline-block;"
onclick="return confirm('Do you want to download the template?')"
download>
<ion-icon name="cloud-download-outline"
style="font-size:20px; vertical-align: middle;"></ion-icon>
<span>{% trans "Download Template" %}</span>
</a>
</div>
@@ -47,3 +53,12 @@
</form>
</div>
</div>
<script>
document.getElementById("workInfoImportButton")
.dispatchEvent(new MouseEvent("click", {
bubbles: true,
cancelable: true,
view: window
}));
</script>

View File

@@ -1,4 +1,4 @@
{% load static %} {% load i18n %}
{% load static i18n %}
<style>
#progress {
@@ -233,7 +233,7 @@
<a href="#" class="oh-dropdown__link"
data-toggle="oh-modal-toggle" data-target="#objectCreateModal"
hx-get="{% url 'work-info-import' %}" hx-target="#objectCreateModalTarget"
hx-on-htmx-after-request="setTimeout(() => {template_download(event);},100);">
>
{% trans "Import" %}
</a>
</li>

View File

@@ -242,11 +242,11 @@ urlpatterns = [
path("employee-import/", views.employee_import, name="employee-import"),
path("employee-export/", views.employee_export, name="employee-export"),
path("work-info-import/", views.work_info_import, name="work-info-import"),
path(
"work-info-import-file/",
views.work_info_import_file,
name="work-info-import-file",
),
# path(
# "work-info-import-file/",
# views.work_info_import_file,
# name="work-info-import-file",
# ),
path("work-info-export/", views.work_info_export, name="work-info-export"),
path("get-birthday/", views.get_employees_birthday, name="get-birthday"),
path("dashboard/", views.dashboard, name="dashboard"),

View File

@@ -1,4 +1,4 @@
{% load generic_template_filters i18n %}
{% load static generic_template_filters i18n %}
<style>
.opacity-50{
opacity: .5!important;
@@ -34,11 +34,15 @@
</label>
<input id="resumeUpload{{ view_id }}" type="file" name="file" required="" />
<div class="d-inline float-end">
<a onclick="
$('#submitGetImportSheet{{ view_id }}').click();
" style="text-decoration:none; display: inline-block;" class="oh-dropdown__link" hx-on:click="template_download(event)">
<ion-icon name="cloud-download-outline" style="font-size:20px; vertical-align: middle;" role="img" class="md hydrated"></ion-icon>
<span>Download Template</span>
<a href="{% static 'employee/work_info_import.xlsx' %}"
class="oh-dropdown__link"
id="workInfoImportButton"
style="text-decoration:none; display:inline-block;"
onclick="return confirm('Do you want to download the template?')"
download>
<ion-icon name="cloud-download-outline"
style="font-size:20px; vertical-align: middle;"></ion-icon>
<span>{% trans "Download Template" %}</span>
</a>
</div>
</div>