[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}'" onclick="window.location.href='{get_individual_url}?instance_ids={ordered_ids}'"
""" """
sortby_mapping = [ sortby_mapping = [
("Employee", "get_full_name", "get_avatar"), (_("Employee"), "get_full_name", "get_avatar"),
("Badge Id", "badge_id"), (_("Badge Id"), "badge_id"),
( (
"Reporting Manager", _("Reporting Manager"),
"employee_work_info__reporting_manager_id__get_full_name", "employee_work_info__reporting_manager_id__get_full_name",
), ),
( (
"Department", _("Department"),
"employee_work_info__department_id__department", "employee_work_info__department_id__department",
), ),
( (
"Job Position", _("Job Position"),
"employee_work_info__job_position_id__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" data-target="#objectCreateModal"
hx-get="{reverse('work-info-import')}" hx-get="{reverse('work-info-import')}"
hx-target="#objectCreateModalTarget" hx-target="#objectCreateModalTarget"
hx-on-htmx-after-request="setTimeout(() => {{template_download(event);}},100);"
style="cursor: pointer;" style="cursor: pointer;"
""", """,
}, },
@@ -670,7 +669,7 @@ class EmployeeCard(HorillaCardView):
) or is_reportingmanager(self.request): ) or is_reportingmanager(self.request):
self.actions = [ self.actions = [
{ {
"action": "Edit", "action": _("Edit"),
"accessibility": "employee.cbv.accessibility.edit_accessibility", "accessibility": "employee.cbv.accessibility.edit_accessibility",
"attrs": """ "attrs": """
onclick="event.stopPropagation() onclick="event.stopPropagation()

Binary file not shown.

View File

@@ -1,4 +1,4 @@
{% load i18n %} {% load static i18n %}
<div class="oh-modal__dialog-header"> <div class="oh-modal__dialog-header">
<h2 class="oh-modal__dialog-title"> <h2 class="oh-modal__dialog-title">
{% trans "Import Employee" %} {% trans "Import Employee" %}
@@ -33,8 +33,14 @@
</label> </label>
<input type="file" name="file"/ required> <input type="file" name="file"/ required>
<div class="d-inline float-end"> <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)"> <a href="{% static 'employee/work_info_import.xlsx' %}"
<ion-icon name="cloud-download-outline" style="font-size:20px; vertical-align: middle;" role="img" class="md hydrated"></ion-icon> 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> <span>{% trans "Download Template" %}</span>
</a> </a>
</div> </div>
@@ -47,3 +53,12 @@
</form> </form>
</div> </div>
</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> <style>
#progress { #progress {
@@ -233,7 +233,7 @@
<a href="#" class="oh-dropdown__link" <a href="#" class="oh-dropdown__link"
data-toggle="oh-modal-toggle" data-target="#objectCreateModal" data-toggle="oh-modal-toggle" data-target="#objectCreateModal"
hx-get="{% url 'work-info-import' %}" hx-target="#objectCreateModalTarget" hx-get="{% url 'work-info-import' %}" hx-target="#objectCreateModalTarget"
hx-on-htmx-after-request="setTimeout(() => {template_download(event);},100);"> >
{% trans "Import" %} {% trans "Import" %}
</a> </a>
</li> </li>

View File

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

View File

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