From a58dd81ec005e07d6d4e2d45ef654bc5e0570ea0 Mon Sep 17 00:00:00 2001 From: Horilla Date: Wed, 11 Sep 2024 12:54:26 +0530 Subject: [PATCH] [UPDT] BASE: Individual view of objects added with data-action for next and previous buttons --- .../base/rotating_shift/individual_view.html | 402 ++++++++---------- .../rotating_work_type/individual_view.html | 341 +++++++-------- .../htmx/allocation_details.html | 8 +- .../htmx/shift_request_detail.html | 4 +- .../htmx/work_type_request_single_view.html | 298 ++++++------- base/views.py | 14 +- .../templates/survey_preview_form.html | 2 +- static/images/ui/drag.svg | 2 +- static/index/index.js | 20 + 9 files changed, 524 insertions(+), 567 deletions(-) diff --git a/base/templates/base/rotating_shift/individual_view.html b/base/templates/base/rotating_shift/individual_view.html index 886c0e3e9..bba7e89ec 100644 --- a/base/templates/base/rotating_shift/individual_view.html +++ b/base/templates/base/rotating_shift/individual_view.html @@ -1,245 +1,187 @@ {% load i18n %} {% load static %} {% load basefilters %} {% if messages %} -
- {% for message in messages %} -
-
- {{ message }} +
+ {% for message in messages %} +
+
+ {{ message }} +
+
+ {% endfor %}
-
- {% endfor %} -
+ {% endif %}
- {% if instance %} + {% if instance %}

{% trans "Details" %}

- {% endif %} - + {% endif %} +
{% if instance %} -
- {% if request.GET.instances_ids %} -
- +
+ {% if request.GET.instances_ids %} +
+ - -
- {% endif %} + +
+ {% endif %} - -
-
- Mary Magdalene -
-
- {{instance.employee_id}} - - {{instance.employee_id.employee_work_info.department_id}} / - {{instance.employee_id.employee_work_info.job_position_id}} -
-
-
-
-
-
- {% trans "Title" %} - {{instance.rotating_shift_id}} -
-
- {% trans "Based On" %} - - {{instance.get_based_on_display}} - -
-
-
-
- {% trans "Rotate" %} - - {% if instance.based_on == 'after' %} - {% trans "Rotate after" %} - {{instance.rotate_after_day}} {% trans "days" %} - {% elif instance.based_on == "weekly" %} - {% trans "Weekly every" %} {{instance.rotate_every_weekend}} - {% elif instance.based_on == "monthly" %} - {% if instance.rotate_every == "1" %} - {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "st day of month" %} - {% elif instance.rotate_every == "2" %} {% trans "Rotate every" %} - {{instance.rotate_every}}{% trans "nd day of month" %} - {% elif instance.rotate_every == "3" %} {% trans "Rotate every" %} - {{instance.rotate_every}}{% trans "rd day of month" %} - {% elif instance.rotate_every == "last" %} - {% trans "Rotate every last day of month" %} - {% else %} - {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "th day of month" %} - {% endif %} - {% endif %} - -
-
- {% trans "Start Date" %} - {{instance.start_date}} -
-
-
-
- {% trans "Current Shift" %} - {{instance.current_shift}} -
-
- {% trans "Next Shift" %} - - {{instance.next_shift}} - -
-
+ +
+
+ Mary Magdalene +
+
+ {{instance.employee_id}} + + {{instance.employee_id.employee_work_info.department_id}} / + {{instance.employee_id.employee_work_info.job_position_id}} +
+
+
+
+
+
+ {% trans "Title" %} + {{instance.rotating_shift_id}} +
+
+ {% trans "Based On" %} + + {{instance.get_based_on_display}} + +
+
+
+
+ {% trans "Rotate" %} + + {% if instance.based_on == 'after' %} + {% trans "Rotate after" %} {{instance.rotate_after_day}} {% trans "days" %} + {% elif instance.based_on == "weekly" %} + {% trans "Weekly every" %} {{instance.rotate_every_weekend}} + {% elif instance.based_on == "monthly" %} + {% if instance.rotate_every == "1" %} + {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "st day of month" %} + {% elif instance.rotate_every == "2" %} {% trans "Rotate every" %} + {{instance.rotate_every}}{% trans "nd day of month" %} + {% elif instance.rotate_every == "3" %} {% trans "Rotate every" %} + {{instance.rotate_every}}{% trans "rd day of month" %} + {% elif instance.rotate_every == "last" %} + {% trans "Rotate every last day of month" %} + {% else %} + {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "th day of month" %} + {% endif %} + {% endif %} + +
+
+ {% trans "Start Date" %} + {{instance.start_date}} +
+
+
+
+ {% trans "Current Shift" %} + {{instance.current_shift}} +
+
+ {% trans "Next Shift" %} + + {{instance.next_shift}} + +
+
-
-
- {% trans "Next Change Date" %} - - {{instance.next_change_date}} - -
-
- {% trans "Status" %} - - {% if instance.is_active %} - {% trans "Is Active" %} - {% else %} - {% trans "Archived" %} - {% endif %} - -
-
- {% if perms.base.change_rotatingshiftassign or request.user|is_reportingmanager or perms.base.delete_rotatingshiftassign %} -
-
- {% if perms.base.change_rotatingshiftassign or request.user|is_reportingmanager %} - - {% trans "Edit" %} - -
- -
- {% endif %} - {% if perms.base.delete_rotatingshiftassign or request.user|is_reportingmanager %} -
- {% csrf_token %} - -
- {% endif %} +
+
+ {% trans "Next Change Date" %} + + {{instance.next_change_date}} + +
+
+ {% trans "Status" %} + + {% if instance.is_active %} + {% trans "Is Active" %} + {% else %} + {% trans "Archived" %} + {% endif %} + +
+
+ {% if perms.base.change_rotatingshiftassign or request.user|is_reportingmanager or perms.base.delete_rotatingshiftassign %} +
+
+ {% if perms.base.change_rotatingshiftassign or request.user|is_reportingmanager %} + + {% trans "Edit" %} + +
+ +
+ {% endif %} + {% if perms.base.delete_rotatingshiftassign or request.user|is_reportingmanager %} +
+ {% csrf_token %} + + +
+ {% endif %} +
+
+ {% endif %}
-
- {% endif %} -
-
+
{% else %} -
- Page not found. 404. -
- {% trans "There are no rotating shift assigned to this employee." %} -
-
+
+ Page not found. 404. +
+ {% trans "There are no rotating shift assigned to this employee." %} +
+
{% endif %} diff --git a/base/templates/base/rotating_work_type/individual_view.html b/base/templates/base/rotating_work_type/individual_view.html index b1fb8c401..38a4f3215 100644 --- a/base/templates/base/rotating_work_type/individual_view.html +++ b/base/templates/base/rotating_work_type/individual_view.html @@ -1,15 +1,16 @@ {% load i18n %} {% load static %} {% load basefilters %} {% if messages %} -
- {% for message in messages %} -
-
- {{ message }} +
+ {% for message in messages %} +
+
+ {{ message }} +
+
+ {% endfor %}
-
- {% endfor %} -
+ {% endif %}
{% if instance %} @@ -20,171 +21,177 @@ {% trans "Details" %} {% endif %} -
{% if instance %} -
-{% if request.GET.instances_ids %} -
- +
+ {% if request.GET.instances_ids %} +
+ - -
-{% endif %} - -
-
- Mary Magdalene -
-
- {{instance.employee_id}} - - {{instance.employee_id.employee_work_info.department_id}} / - {{instance.employee_id.employee_work_info.job_position_id}} -
-
-
-
-
-
- {% trans "Title" %} - {{instance.get_based_on_display}} -
-
- {% trans "Based On" %} - - {{instance.get_based_on_display}} - -
-
-
-
- {% trans "Rotate" %} - - {% if instance.based_on == 'after' %} - {% trans "Rotate after" %} {{instance.rotate_after_day}} {% trans "days" %} - {% elif instance.based_on == "weekly" %} - {% trans "Weekly every" %} {{instance.rotate_every_weekend}} - {% elif instance.based_on == "monthly" %} - {% if instance.rotate_every == "1" %} - {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "st day of month" %} - {% elif instance.rotate_every == "2" %} - {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "nd day of month" %} - {% elif instance.rotate_every == "3" %} - {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "rd day of month" %} - {% elif instance.rotate_every == "last" %} - {% trans "Rotate every last day of month" %} - {% else %} - {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "th day of month" %} - {% endif %} - {% endif %} - -
-
- {% trans "Start Date" %} - {{instance.start_date}} -
-
-
-
- {% trans "Current Work Type" %} - {{instance.current_work_type}} -
-
- {% trans "Next Work Type" %} - - {{instance.next_work_type}} - -
-
- -
-
- {% trans "Next Change Date" %} - - {{instance.next_change_date}} - -
-
- {% trans "Status" %} - {% if instance.is_active %}{% trans "Is Active" %}{% else %}{% trans "Archived" %}{% endif %} -
-
- {% if perms.base.change_rotatingworktypeassign or request.user|is_reportingmanager or perms.base.delete_rotatingworktypeassign %} -
-
- {% if perms.base.change_rotatingworktypeassign or request.user|is_reportingmanager %} - - - {% trans "Edit" %} - -
- -
- {% endif %} - {% if perms.base.delete_rotatingworktypeassign or request.user|is_reportingmanager %} -
- {% csrf_token %} - -
- {% endif %} -
+
{% endif %} -
-
+ +
+
+ Mary Magdalene +
+
+ {{instance.employee_id}} + + {{instance.employee_id.employee_work_info.department_id}} / + {{instance.employee_id.employee_work_info.job_position_id}} +
+
+
+
+
+
+ {% trans "Title" %} + {{instance.get_based_on_display}} +
+
+ {% trans "Based On" %} + + {{instance.get_based_on_display}} + +
+
+
+
+ {% trans "Rotate" %} + + {% if instance.based_on == 'after' %} + {% trans "Rotate after" %} {{instance.rotate_after_day}} {% trans "days" %} + {% elif instance.based_on == "weekly" %} + {% trans "Weekly every" %} {{instance.rotate_every_weekend}} + {% elif instance.based_on == "monthly" %} + {% if instance.rotate_every == "1" %} + {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "st day of month" %} + {% elif instance.rotate_every == "2" %} + {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "nd day of month" %} + {% elif instance.rotate_every == "3" %} + {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "rd day of month" %} + {% elif instance.rotate_every == "last" %} + {% trans "Rotate every last day of month" %} + {% else %} + {% trans "Rotate every" %} {{instance.rotate_every}}{% trans "th day of month" %} + {% endif %} + {% endif %} + +
+
+ {% trans "Start Date" %} + {{instance.start_date}} +
+
+
+
+ {% trans "Current Work Type" %} + {{instance.current_work_type}} +
+
+ {% trans "Next Work Type" %} + + {{instance.next_work_type}} + +
+
+ +
+
+ {% trans "Next Change Date" %} + + {{instance.next_change_date}} + +
+
+ {% trans "Status" %} + {% if instance.is_active %}{% trans "Is Active" %}{% else %}{% trans "Archived" %}{% endif %} +
+
+ {% if perms.base.change_rotatingworktypeassign or request.user|is_reportingmanager or perms.base.delete_rotatingworktypeassign %} +
+
+ {% if perms.base.change_rotatingworktypeassign or request.user|is_reportingmanager %} + + + {% trans "Edit" %} + +
+ +
+ {% endif %} + {% if perms.base.delete_rotatingworktypeassign or request.user|is_reportingmanager %} +
+ {% csrf_token %} + +
+ {% endif %} +
+
+ {% endif %} +
+
{% else %} -
- Page not found. 404. -
- {% trans "There are no rotating work type assigned to this employee." %} -
-
+
+ Page not found. 404. +
+ {% trans "There are no rotating work type assigned to this employee." %} +
+
{% endif %} diff --git a/base/templates/shift_request/htmx/allocation_details.html b/base/templates/shift_request/htmx/allocation_details.html index 06ce545a2..465120e7e 100644 --- a/base/templates/shift_request/htmx/allocation_details.html +++ b/base/templates/shift_request/htmx/allocation_details.html @@ -18,7 +18,9 @@ @@ -26,7 +28,9 @@ diff --git a/base/templates/shift_request/htmx/shift_request_detail.html b/base/templates/shift_request/htmx/shift_request_detail.html index 197fbb907..d09520c0f 100644 --- a/base/templates/shift_request/htmx/shift_request_detail.html +++ b/base/templates/shift_request/htmx/shift_request_detail.html @@ -17,6 +17,7 @@ diff --git a/base/templates/work_type_request/htmx/work_type_request_single_view.html b/base/templates/work_type_request/htmx/work_type_request_single_view.html index ceb4396bd..32138e0e2 100644 --- a/base/templates/work_type_request/htmx/work_type_request_single_view.html +++ b/base/templates/work_type_request/htmx/work_type_request_single_view.html @@ -1,169 +1,153 @@ {% load basefilters %} {% load i18n %} {% load horillafilters %} {% load static %} {% if messages %} -
- {% for message in messages %} -
-
- {{ message }} +
+ {% for message in messages %} +
+
+ {{ message }} +
+
+ {% endfor %}
-
- {% endfor %} -
- - + {% endif %} {% if work_type_request %} -
- - {% trans "Details" %} - - -
-
-{% if request.GET.instances_ids %} -
- - - -
-{% endif %} - -
-
- Mary Magdalene -
-
- {{work_type_request.employee_id}} - - {{work_type_request.employee_id.employee_work_info.department_id}} / - {{work_type_request.employee_id.employee_work_info.job_position_id}} -
-
-
- -
-
-
- {% trans "Requested work type" %} - {{work_type_request.work_type_id}} -
-
- {% trans "Previous work type" %} - {{work_type_request.previous_work_type_id}} -
+
+ + {% trans "Details" %} + +
-
-
- {% trans "Requested date" %} - {{work_type_request.requested_date}} -
-
- {% trans "Requested till" %} - {{work_type_request.requested_till}} -
-
-
-
- {% trans "Description" %} - {{work_type_request.description}} -
-
- {% trans "Is permenent work type" %} - - {% if work_type_request.is_permanent_work_type == True %} {% trans "Yes" %} - {% else %} {% trans "No" %} - {% endif %} - -
-
-
-
- {% if dashboard == 'true' %} - {% trans "Approve" %} +
+ {% if request.GET.instances_ids %} +
+ - {% trans "Reject" %} - {% else %} - {% if work_type_request.approved == False and not work_type_request.canceled %} - - {% else %} - - {% endif %} - {% if work_type_request.approved == False and work_type_request.canceled == False %} -
- {% csrf_token %} - -
- {% else %} - - {% endif %} + +
{% endif %} -
+ +
+
+ Mary Magdalene +
+
+ {{work_type_request.employee_id}} + + {{work_type_request.employee_id.employee_work_info.department_id}} / + {{work_type_request.employee_id.employee_work_info.job_position_id}} +
+
+
+ +
+
+
+ {% trans "Requested work type" %} + {{work_type_request.work_type_id}} +
+
+ {% trans "Previous work type" %} + {{work_type_request.previous_work_type_id}} +
+
+
+
+ {% trans "Requested date" %} + {{work_type_request.requested_date}} +
+
+ {% trans "Requested till" %} + {{work_type_request.requested_till}} +
+
+
+
+ {% trans "Description" %} + {{work_type_request.description}} +
+
+ {% trans "Is permenent work type" %} + + {% if work_type_request.is_permanent_work_type == True %} + {% trans "Yes" %} + {% else %} + {% trans "No" %} + {% endif %} + +
+
+
+
+ {% if dashboard == 'true' %} + + {% trans "Approve" %} + + + {% trans "Reject" %} + + {% else %} + {% if work_type_request.approved == False and not work_type_request.canceled %} + + {% else %} + + + {% endif %} + {% if work_type_request.approved == False and work_type_request.canceled == False %} +
+ {% csrf_token %} + +
+ {% else %} + + {% endif %} + {% endif %} +
+
+
-
-
{% else %} -
- - -
-
- Page not found. 404. -
- {% trans "There are no work type requets to display." %} -
-
+
+ + +
+
+ Page not found. 404. +
+ {% trans "There are no work type requets to display." %} +
+
{% endif %} diff --git a/base/views.py b/base/views.py index 4044491ce..d78d2b510 100644 --- a/base/views.py +++ b/base/views.py @@ -2214,10 +2214,9 @@ def rotating_work_type_assign_redirect(request, obj_id=None, employee_id=None): json.loads(instances_ids), obj_id ) - return redirect( - f"/rwork-individual-view/{next_instance}/?{previous_data}\ - &instances_ids={instances_list}" - ) + url = f"/rwork-individual-view/{next_instance}/" + params = f"?{previous_data}&instances_ids={instances_list}" + return redirect(url + params) elif hx_target and hx_target == "shift_target" and employee_id: return redirect(f"/employee/shift-tab/{employee_id}") elif hx_target: @@ -2872,10 +2871,9 @@ def rotating_shift_assign_redirect(request, obj_id, employee_id): previous_instance, next_instance = closest_numbers( json.loads(instances_ids), obj_id ) - return redirect( - f"/rshit-individual-view/{next_instance}/?{previous_data}\ - &instances_ids={instances_list}" - ) + url = f"/rshit-individual-view/{next_instance}/" + params = f"?{previous_data}&instances_ids={instances_list}" + return redirect(url + params) elif hx_target and hx_target == "shift_target" and employee_id: return redirect(f"/employee/shift-tab/{employee_id}") elif hx_target: diff --git a/recruitment/templates/survey_preview_form.html b/recruitment/templates/survey_preview_form.html index b674b78f3..75988c47f 100644 --- a/recruitment/templates/survey_preview_form.html +++ b/recruitment/templates/survey_preview_form.html @@ -7,7 +7,7 @@
-
+
{{form.non_field_errors}}
diff --git a/static/images/ui/drag.svg b/static/images/ui/drag.svg index 5e8fa2385..6a6bbd341 100644 --- a/static/images/ui/drag.svg +++ b/static/images/ui/drag.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/static/index/index.js b/static/index/index.js index 0ba9bf36c..cd2b36f20 100644 --- a/static/index/index.js +++ b/static/index/index.js @@ -127,8 +127,28 @@ function attendanceDateChange(selectElement) { } $(document).on('keydown', function (event) { + // Check if the cursor is not focused on an input field + var isInputFocused = $(document.activeElement).is('input, textarea, select'); + if (event.keyCode === 46) { // Click the delete option from navbar of current page $('[data-action="delete"]').click(); + } else if (event.keyCode === 107) { // Key code for the + key on the numeric keypad + if (!isInputFocused) { + // Click the create option from navbar of current page + $('[data-action="create"]').click(); + } + } + else if (event.keyCode === 39) { // Key code for the right arrow key + if (!isInputFocused) { + // Click on the next button in detail view modal + $('[data-action="next"]').click(); + } + } + else if (event.keyCode === 37) { // Key code for the left arrow key + if (!isInputFocused) { + // Click on the previous button in detail view modal + $('[data-action="previous"]').click(); + } } });