690 lines
30 KiB
HTML
690 lines
30 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static i18n %}
|
|
|
|
{% block title %} {% blocktrans %} Screening Stage - {{ job.title }} - University ATS{% endblocktrans %}{% endblock %}
|
|
{% block customCSS %}
|
|
<style>
|
|
/* KAAT-S UI Variables */
|
|
:root {
|
|
--kaauh-teal: #00636e;
|
|
--kaauh-teal-dark: #004a53;
|
|
--kaauh-border: #eaeff3;
|
|
--kaauh-primary-text: #343a40;
|
|
--kaauh-success: #28a745;
|
|
--kaauh-info: #17a2b8;
|
|
--kaauh-danger: #dc3545;
|
|
--kaauh-warning: #ffc107;
|
|
}
|
|
|
|
/* Primary Color Overrides */
|
|
.text-primary-theme { color: var(--kaauh-teal) !important; }
|
|
.bg-primary-theme { background-color: var(--kaauh-teal) !important; }
|
|
|
|
/* 1. Main Container & Card Styling */
|
|
.kaauh-card {
|
|
border: 1px solid var(--kaauh-border);
|
|
border-radius: 0.75rem;
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.06);
|
|
background-color: white;
|
|
}
|
|
|
|
/* Dedicated style for the filter block */
|
|
.filter-controls {
|
|
background-color: #f8f9fa;
|
|
border-radius: 0.75rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 2rem;
|
|
border: 1px solid var(--kaauh-border);
|
|
}
|
|
|
|
/* 2. Button Styling (Themed for Main Actions) */
|
|
.btn-main-action {
|
|
background-color: var(--kaauh-teal);
|
|
border-color: var(--kaauh-teal);
|
|
color: white;
|
|
font-weight: 600;
|
|
transition: all 0.2s ease;
|
|
}
|
|
.btn-main-action:hover {
|
|
background-color: var(--kaauh-teal-dark);
|
|
border-color: var(--kaauh-teal-dark);
|
|
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
|
|
}
|
|
.btn-outline-secondary {
|
|
color: var(--kaauh-teal-dark);
|
|
border-color: var(--kaauh-teal);
|
|
}
|
|
.btn-outline-secondary:hover {
|
|
background-color: var(--kaauh-teal-dark);
|
|
color: white;
|
|
border-color: var(--kaauh-teal-dark);
|
|
}
|
|
/* Style for the Bulk Move button */
|
|
.btn-bulk-action {
|
|
background-color: var(--kaauh-teal-dark);
|
|
border-color: var(--kaauh-teal-dark);
|
|
color: white;
|
|
font-weight: 500;
|
|
}
|
|
.btn-bulk-action:hover {
|
|
background-color: #00363e;
|
|
border-color: #00363e;
|
|
}
|
|
|
|
/* 3. Application Table Styling (Aligned with KAAT-S) */
|
|
.application-table {
|
|
table-layout: fixed;
|
|
width: 100%;
|
|
border-collapse: separate;
|
|
border-spacing: 0;
|
|
background-color: white;
|
|
border-radius: 0.5rem;
|
|
overflow: hidden;
|
|
}
|
|
.application-table thead {
|
|
background-color: var(--kaauh-border);
|
|
}
|
|
.application-table th {
|
|
padding: 0.75rem 1rem;
|
|
font-weight: 600;
|
|
color: var(--kaauh-teal-dark);
|
|
border-bottom: 2px solid var(--kaauh-teal);
|
|
font-size: 0.9rem;
|
|
vertical-align: middle;
|
|
}
|
|
.application-table td {
|
|
padding: 0.75rem 1rem;
|
|
border-bottom: 1px solid var(--kaauh-border);
|
|
vertical-align: middle;
|
|
font-size: 0.9rem;
|
|
}
|
|
.application-table tbody tr:hover {
|
|
background-color: #f1f3f4;
|
|
}
|
|
.application-table thead th:nth-child(1) { width: 40px; }
|
|
.application-table thead th:nth-child(4) { width: 10%; }
|
|
.application-table thead th:nth-child(7) { width: 100px; }
|
|
|
|
.application-name {
|
|
font-weight: 600;
|
|
color: var(--kaauh-primary-text);
|
|
}
|
|
.application-details {
|
|
font-size: 0.8rem;
|
|
color: #6c757d;
|
|
}
|
|
|
|
/* 4. Badges and Statuses */
|
|
.ai-score-badge {
|
|
background-color: var(--kaauh-teal-dark) !important;
|
|
color: white;
|
|
font-weight: 700;
|
|
padding: 0.4em 0.8em;
|
|
border-radius: 0.4rem;
|
|
}
|
|
.status-badge {
|
|
font-size: 0.75rem;
|
|
padding: 0.3em 0.7em;
|
|
border-radius: 0.35rem;
|
|
font-weight: 700;
|
|
}
|
|
.bg-applicant { background-color: #6c757d !important; color: white; }
|
|
.bg-application { background-color: var(--kaauh-success) !important; color: white; }
|
|
|
|
/* Stage Badges */
|
|
.stage-badge {
|
|
font-size: 0.75rem;
|
|
padding: 0.25rem 0.6rem;
|
|
border-radius: 0.3rem;
|
|
font-weight: 600;
|
|
display: inline-block;
|
|
margin-bottom: 0.2rem;
|
|
}
|
|
.stage-Applied { background-color: #e9ecef; color: #495057; }
|
|
.stage-Screening { background-color: var(--kaauh-info); color: white; }
|
|
.stage-Exam { background-color: var(--kaauh-warning); color: #856404; }
|
|
.stage-Interview { background-color: #17a2b8; color: white; }
|
|
.stage-Offer { background-color: var(--kaauh-success); color: white; }
|
|
|
|
/* Timeline specific container */
|
|
.applicant-tracking-timeline {
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
/* --- CUSTOM HEIGHT OPTIMIZATION (MAKING INPUTS/BUTTONS SMALLER) --- */
|
|
.form-control-sm,
|
|
.btn-sm {
|
|
/* Reduce vertical padding even more than default Bootstrap 'sm' */
|
|
padding-top: 0.2rem !important;
|
|
padding-bottom: 0.2rem !important;
|
|
/* Ensure a consistent, small height for both */
|
|
height: 28px !important;
|
|
font-size: 0.8rem !important; /* Slightly smaller font */
|
|
}
|
|
|
|
.kaats-spinner {
|
|
animation: kaats-spinner-rotate 1.5s linear infinite; /* Faster rotation */
|
|
width: 40px; /* Standard size */
|
|
height: 40px;
|
|
display: inline-block; /* Useful for table cells */
|
|
vertical-align: middle;
|
|
}
|
|
|
|
.kaats-spinner .path {
|
|
stroke: var(--kaauh-teal, #00636e); /* Use Teal color, fallback to dark teal */
|
|
stroke-linecap: round;
|
|
/* Optional: Add a lighter background circle for contrast */
|
|
/* stroke-dashoffset will be reset by the dash animation */
|
|
}
|
|
|
|
/* Optional: Background circle for better contrast (similar to Bootstrap) */
|
|
.kaats-spinner circle {
|
|
stroke: var(--kaauh-border, #e9ecef); /* Light gray background */
|
|
fill: none;
|
|
stroke-width: 5; /* Keep stroke-width on both circles */
|
|
}
|
|
|
|
/* ------------------------------------------- */
|
|
/* 2. Keyframe Animations */
|
|
/* ------------------------------------------- */
|
|
@keyframes kaats-spinner-rotate {
|
|
100% {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
|
|
@keyframes kaats-spinner-dash {
|
|
0% {
|
|
stroke-dasharray: 1, 150;
|
|
stroke-dashoffset: 0;
|
|
}
|
|
50% {
|
|
stroke-dasharray: 90, 150;
|
|
stroke-dashoffset: -35;
|
|
}
|
|
100% {
|
|
stroke-dasharray: 90, 150;
|
|
stroke-dashoffset: -124;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
{% block content %}
|
|
|
|
<div class="container-fluid py-4">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<div>
|
|
<h1 class="h3 mb-1 page-header">
|
|
<i class="fas fa-layer-group me-2"></i>
|
|
{% trans "Application Screening" %}
|
|
</h1>
|
|
<h2 class="h5 text-muted mb-0">
|
|
{% trans "Job:" %} {{ job.title }}
|
|
<span class="badge bg-secondary ms-2 fw-normal">{{ job.internal_job_id }}</span>
|
|
</h2>
|
|
</div>
|
|
<div class="d-flex gap-2">
|
|
<a href="{% url 'export_applications_csv' job.slug 'screening' %}"
|
|
class="btn btn-outline-secondary"
|
|
title="{% trans 'Export screening applications to CSV' %}">
|
|
<i class="fas fa-download me-1"></i> {% trans "Export CSV" %}
|
|
</a>
|
|
<a href="{% url 'job_detail' job.slug %}" class="btn btn-outline-secondary">
|
|
<i class="fas fa-arrow-left me-1"></i> {% trans "Back to Job" %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="applicant-tracking-timeline mb-4">
|
|
{% include 'jobs/partials/applicant_tracking.html' %}
|
|
</div>
|
|
|
|
<div class="filter-controls">
|
|
<h4 class="h6 mb-3 fw-bold">
|
|
<i class="fas fa-sort-numeric-up me-1"></i> {% trans "AI Scoring & Top Application Filter" %}
|
|
</h4>
|
|
|
|
<form method="GET" class="mb-0">
|
|
<div class="row g-3 align-items-end">
|
|
|
|
<div class="col-auto">
|
|
<label for="gpa" class="form-label small text-muted mb-1">
|
|
{% trans "GPA" %}
|
|
</label>
|
|
<input type="number" name="GPA" id="gpa" class="form-control form-control-sm"
|
|
value="{{ gpa }}" step="0.01" min="0" max="4"
|
|
placeholder="e.g., 3.5" style="width: 120px;">
|
|
</div>
|
|
<div class="col-auto">
|
|
<label for="min_ai_score" class="form-label small text-muted mb-1">
|
|
{% trans "Min AI Score" %}
|
|
</label>
|
|
<input type="number" name="min_ai_score" id="min_ai_score" class="form-control form-control-sm"
|
|
value="{{ min_ai_score}}" min="0" max="100" step="1"
|
|
placeholder="e.g., 75" style="width: 120px;">
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
<label for="min_experience" class="form-label small text-muted mb-1">
|
|
{% trans "Min Years Exp" %}
|
|
</label>
|
|
<input type="number" name="min_experience" id="min_experience" class="form-control form-control-sm"
|
|
value="{{ min_experience }}" min="0" step="0.5" step="0.5"
|
|
placeholder="e.g., 2" style="width: 120px;">
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
<label for="screening_rating" class="form-label small text-muted mb-1">
|
|
{% trans "Screening Rating" %}
|
|
</label>
|
|
<select name="screening_rating" id="screening_rating" class="form-select form-select-sm" style="width: 120px;">
|
|
<option value="">{% trans "Any Rating" %}</option>
|
|
<option value="Highly Qualified" {% if screening_rating == "Highly Qualified" %}selected{% endif %}>
|
|
{% trans "Highly Qualified" %}
|
|
</option>
|
|
<option value="Qualified" {% if screening_rating == "Qualified" %}selected{% endif %}>
|
|
{% trans "Qualified" %}
|
|
</option>
|
|
<option value="Partially Qualified" {% if screening_rating == "Partially Qualified" %}selected{% endif %}>
|
|
{% trans "Partially Qualified" %}
|
|
</option>
|
|
<option value="Not Qualified" {% if screening_rating == "Not Qualified" %}selected{% endif %}>
|
|
{% trans "Not Qualified" %}
|
|
</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
<label for="tier1_count" class="form-label small text-muted mb-1">
|
|
{% trans "Top N applications" %}
|
|
</label>
|
|
<input type="number" name="tier1_count" id="tier1_count" class="form-control form-control-sm"
|
|
value="{{ tier1_count }}" min="1" max="{{ total_applications }}" style="width: 120px;">
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
<button type="submit" name="update_tiers" class="btn btn-main-action btn-sm">
|
|
<i class="fas fa-sync-alt me-1"></i> {% trans "Update Filters" %}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<h2 class="h4 mb-3" style="color: var(--kaauh-primary-text);">
|
|
<i class="fas fa-users me-1"></i> {% trans "Application List" %}
|
|
<span class="badge bg-primary-theme ms-2">{{ applications|length }} / {{ total_applications }} {% trans "Total" %}</span>
|
|
</h2>
|
|
|
|
<div class="kaauh-card p-3">
|
|
{% if applications %}
|
|
<div class="bulk-action-bar p-3 bg-light border-bottom">
|
|
<form hx-boost="true" hx-include="#application-form" action="{% url 'application_update_status' job.slug %}" method="post" class="action-group">
|
|
{% csrf_token %}
|
|
|
|
{# MODIFIED: Using d-flex for horizontal alignment and align-items-end to align everything based on the baseline of the button/select #}
|
|
<div class="d-flex align-items-end gap-3">
|
|
|
|
{# Select Input Group #}
|
|
<div>
|
|
|
|
<select name="mark_as" id="update_status" class="form-select form-select-sm" style="min-width: 150px;">
|
|
<option selected>
|
|
----------
|
|
</option>
|
|
<option value="Exam">
|
|
{% trans "Exam Stage" %}
|
|
</option>
|
|
{# Include other options here, such as Interview, Offer, Rejected, etc. #}
|
|
</select>
|
|
</div>
|
|
|
|
{# Button #}
|
|
<button id="changeStage" type="submit" class="btn btn-main-action btn-sm">
|
|
<i class="fas fa-arrow-right me-1"></i> {% trans "Change Stage" %}
|
|
</button>
|
|
{# email button#}
|
|
<button id="emailBotton" type="button" class="btn btn-outline-primary btn-sm"
|
|
data-bs-toggle="modal"
|
|
hx-boost='true'
|
|
data-bs-target="#emailModal"
|
|
hx-get="{% url 'compose_application_email' job.slug %}"
|
|
hx-target="#emailModalBody"
|
|
hx-include="#application-form"
|
|
title="Email Participants">
|
|
<i class="fas fa-envelope"></i>
|
|
</button>
|
|
|
|
</div>
|
|
</form>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="table-responsive">
|
|
<form id="application-form" action="{% url 'application_update_status' job.slug %}" method="post">
|
|
{% csrf_token %}
|
|
<table class="table application-table align-middle">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col" style="width: 2%;">
|
|
{% if applications %}
|
|
<div class="form-check">
|
|
<input
|
|
type="checkbox" class="form-check-input" id="selectAllCheckbox">
|
|
</div>
|
|
{% endif %}
|
|
</th>
|
|
<th scope="col" style="width: 13%;">
|
|
<i class="fas fa-user me-1"></i> {% trans "Name" %}
|
|
</th>
|
|
<th scope="col" style="width: 15%;">
|
|
<i class="fas fa-phone me-1"></i> {% trans "Contact Info" %}
|
|
</th>
|
|
<th scope="col" style="width: 5%;">
|
|
<i class="fas fa-graduation-cap me-1"></i> {% trans "GPA" %}
|
|
</th>
|
|
<th scope="col" style="width: 5%;">
|
|
<i class="fas fa-graduation-cap me-1"></i> {% trans "Years of Experience" %}
|
|
</th>
|
|
<th scope="col" style="width: 5%;" class="text-center">
|
|
<i class="fas fa-robot me-1"></i> {% trans "AI Score" %}
|
|
</th>
|
|
<th scope="col" style="width: 10%;" class="text-center">
|
|
<i class="fas fa-robot me-1"></i> {% trans "Is Qualified?" %}
|
|
</th>
|
|
<th scope="col" style="width: 20%;">
|
|
<i class="fas fa-graduation-cap me-1"></i> {% trans "Professional Category" %}
|
|
</th>
|
|
<th scope="col" style="width: 15%;">
|
|
<i class="fas fa-graduation-cap me-1"></i> {% trans "Top 3 Skills" %}
|
|
</th>
|
|
<th scope="col" style="width: 10%;" class="text-center">
|
|
<i class="fas fa-cog me-1"></i> {% trans "Note" %}
|
|
</th>
|
|
<th scope="col" style="width: 5%;" class="text-center">
|
|
<i class="fas fa-cog me-1"></i> {% trans "Actions" %}
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for application in applications %}
|
|
<tr>
|
|
<td>
|
|
<div class="form-check">
|
|
<input
|
|
name="candidate_ids"
|
|
value="{{ application.id }}"
|
|
type="checkbox" class="form-check-input rowCheckbox" id="application-{{ application.id }}">
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<a href="#" class="application-name text-primary-theme text-decoration-none">
|
|
{{ application.name }}
|
|
</a>
|
|
</td>
|
|
<td>
|
|
<div class="application-details">
|
|
<i class="fas fa-envelope me-1"></i> {{ application.email }}<br>
|
|
<i class="fas fa-phone me-1"></i> {{ application.phone }}
|
|
</div>
|
|
</td>
|
|
<td class="text-center">{{application.person.gpa|default:"0"}}</td>
|
|
<td class="text-center">
|
|
<span class="badge ai-score-badge">
|
|
{{ application.years_of_experience }}
|
|
</span>
|
|
</td>
|
|
<td class="text-center">
|
|
{% if application.is_resume_parsed %}
|
|
{% if application.match_score %}
|
|
<span class="badge ai-score-badge">
|
|
{{ application.match_score|default:"0" }}%
|
|
</span>
|
|
{% endif %}
|
|
{% else %}
|
|
<div class="text-nowrap">
|
|
<svg class="kaats-spinner" viewBox="0 0 50 50" style="width: 25px; height: 25px;">
|
|
<circle cx="25" cy="25" r="20"></circle>
|
|
<circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="5"
|
|
style="animation: kaats-spinner-dash 1.5s ease-in-out infinite;"></circle>
|
|
</svg>
|
|
<span class="text-teal-primary">{% trans 'AI scoring..' %}</span>
|
|
</div>
|
|
{% endif %}
|
|
</td>
|
|
<td class="text-center">
|
|
{% if application.screening_stage_rating %}
|
|
<span class="badge ai-score-badge d-inline-block text-wrap">
|
|
{{ application.screening_stage_rating|default:"--" }}
|
|
</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="text-center">
|
|
{% if application.professional_category %}
|
|
<span class="badge ai-score-badge">
|
|
{{ application.professional_category }}
|
|
</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if application.top_3_keywords %}
|
|
<div class="d-flex flex-wrap gap-2">
|
|
{% for skill in application.top_3_keywords %}
|
|
<span class="badge ai-score-badge" style="font-size: smaller;">
|
|
{{ skill }}
|
|
</span>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</td>
|
|
<td><button type="button" class="btn btn-outline-primary btn-sm"
|
|
data-bs-toggle="modal"
|
|
data-bs-target="#noteModal"
|
|
hx-get="{% url 'application_add_note' application.slug %}"
|
|
hx-swap="innerHTML"
|
|
hx-target=".notemodal">
|
|
<i class="fas fa-calendar-plus me-1"></i>
|
|
Add note
|
|
</button></td>
|
|
<td class="text-center">
|
|
<button type="button" class="btn btn-outline-secondary btn-sm"
|
|
data-bs-toggle="modal"
|
|
data-bs-target="#candidateviewModal"
|
|
hx-get="{% url 'application_criteria_view_htmx' application.pk %}"
|
|
hx-target="#candidateviewModalBody"
|
|
title="View Application Profile and Criteria">
|
|
<i class="fas fa-eye"></i>
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
{% if not applications %}
|
|
<div class="alert alert-info text-center mt-3 mb-0" role="alert">
|
|
<i class="fas fa-info-circle me-1"></i>
|
|
{% trans "No applications match the current stage and filter criteria." %}
|
|
</div>
|
|
{% endif %}
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="modal fade modal-lg" id="candidateviewModal" tabindex="-1" aria-labelledby="candidateviewModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content kaauh-card">
|
|
<div class="modal-header" style="border-bottom: 1px solid var(--kaauh-border);">
|
|
<h5 class="modal-title" id="candidateviewModalLabel" style="color: var(--kaauh-teal-dark);">
|
|
{% trans "Application Criteria Review" %}
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div id="candidateviewModalBody" class="modal-body">
|
|
<div class="text-center py-5 text-muted">
|
|
<i class="fas fa-spinner fa-spin fa-2x"></i><br>
|
|
{% trans "Loading application data..." %}
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer" style="border-top: 1px solid var(--kaauh-border);">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
|
|
{% trans "Close" %}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Email Modal -->
|
|
<div class="modal fade" id="emailModal" tabindex="-1" aria-labelledby="emailModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-lg" role="document">
|
|
<div class="modal-content kaauh-card">
|
|
<div class="modal-header" style="border-bottom: 1px solid var(--kaauh-border);">
|
|
<h5 class="modal-title" id="emailModalLabel" style="color: var(--kaauh-teal-dark);">
|
|
<i class="fas fa-envelope me-2"></i>{% trans "Compose Email" %}
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div id="emailModalBody" class="modal-body">
|
|
<div class="text-center py-5 text-muted">
|
|
<i class="fas fa-spinner fa-spin fa-2x"></i><br>
|
|
{% trans "Loading email form..." %}
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% include "recruitment/partials/note_modal.html" %}
|
|
{% include "recruitment/partials/stage_confirmation_modal.html" %}
|
|
|
|
{% endblock %}
|
|
|
|
|
|
{% block customJS %}
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const selectAllCheckbox = document.getElementById('selectAllCheckbox');
|
|
const rowCheckboxes = document.querySelectorAll('.rowCheckbox');
|
|
const changeStageButton = document.getElementById('changeStage');
|
|
const emailButton = document.getElementById('emailBotton');
|
|
const updateStatus = document.getElementById('update_status');
|
|
const stageConfirmationModal = new bootstrap.Modal(document.getElementById('stageConfirmationModal'));
|
|
const confirmStageChangeButton = document.getElementById('confirmStageChangeButton');
|
|
let isConfirmed = false;
|
|
|
|
if (selectAllCheckbox) {
|
|
|
|
// Function to safely update the header checkbox state
|
|
function updateSelectAllState() {
|
|
const checkedCount = Array.from(rowCheckboxes).filter(cb => cb.checked).length;
|
|
const totalCount = rowCheckboxes.length;
|
|
|
|
if (checkedCount === 0) {
|
|
selectAllCheckbox.checked = false;
|
|
selectAllCheckbox.indeterminate = false;
|
|
changeStageButton.disabled = true;
|
|
emailButton.disabled = true;
|
|
updateStatus.disabled = true;
|
|
} else if (checkedCount === totalCount) {
|
|
selectAllCheckbox.checked = true;
|
|
selectAllCheckbox.indeterminate = false;
|
|
changeStageButton.disabled = false;
|
|
emailButton.disabled = false;
|
|
updateStatus.disabled = false;
|
|
} else {
|
|
// Set to indeterminate state (partially checked)
|
|
selectAllCheckbox.checked = false;
|
|
selectAllCheckbox.indeterminate = true;
|
|
changeStageButton.disabled = false;
|
|
emailButton.disabled = false;
|
|
updateStatus.disabled = false;
|
|
}
|
|
}
|
|
|
|
// 1. Logic for the 'Select All' checkbox (Clicking it updates all rows)
|
|
selectAllCheckbox.addEventListener('change', function () {
|
|
const isChecked = selectAllCheckbox.checked;
|
|
|
|
// Temporarily disable the change listener on rows to prevent cascading events
|
|
rowCheckboxes.forEach(checkbox => checkbox.removeEventListener('change', updateSelectAllState));
|
|
|
|
// Update all row checkboxes
|
|
rowCheckboxes.forEach(function (checkbox) {
|
|
checkbox.checked = isChecked;
|
|
|
|
// Dispatch event for the framework (data-bind-selections)
|
|
checkbox.dispatchEvent(new Event('change', { bubbles: true }));
|
|
});
|
|
|
|
// Re-attach the change listeners to the rows
|
|
rowCheckboxes.forEach(checkbox => checkbox.addEventListener('change', updateSelectAllState));
|
|
|
|
// Ensure the header state is correct after forcing all changes
|
|
updateSelectAllState();
|
|
});
|
|
|
|
// 2. Logic to update 'Select All' state based on row checkboxes
|
|
// Attach the function to be called whenever a row checkbox changes
|
|
rowCheckboxes.forEach(function (checkbox) {
|
|
checkbox.addEventListener('change', updateSelectAllState);
|
|
});
|
|
|
|
// Initial check to set the correct state on load (in case items are pre-checked)
|
|
updateSelectAllState();
|
|
}
|
|
|
|
// Stage Confirmation Logic
|
|
if (changeStageButton) {
|
|
changeStageButton.addEventListener('click', function(event) {
|
|
const selectedStage = updateStatus.value;
|
|
|
|
// Check if a stage is selected (not the default empty option)
|
|
if (selectedStage && selectedStage.trim() !== '') {
|
|
// If not yet confirmed, show modal and prevent submission
|
|
if (!isConfirmed) {
|
|
event.preventDefault();
|
|
|
|
// Count selected candidates
|
|
const checkedCount = Array.from(rowCheckboxes).filter(cb => cb.checked).length;
|
|
|
|
// Update confirmation message
|
|
const messageElement = document.getElementById('stageConfirmationMessage');
|
|
const targetStageElement = document.getElementById('targetStageName');
|
|
if (messageElement && targetStageElement) {
|
|
if (checkedCount > 0) {
|
|
messageElement.textContent = `{% trans "Are you sure you want to move" %} ${checkedCount} {% trans "candidate(s) to this stage?" %}`;
|
|
targetStageElement.textContent = selectedStage;
|
|
} else {
|
|
messageElement.textContent = '{% trans "Please select at least one candidate." %}';
|
|
targetStageElement.textContent = '--';
|
|
}
|
|
}
|
|
|
|
// Show confirmation modal
|
|
stageConfirmationModal.show();
|
|
return false;
|
|
}
|
|
// If confirmed, let the form submit normally (reset flag for next time)
|
|
isConfirmed = false;
|
|
}
|
|
});
|
|
|
|
// Handle confirm button click in modal
|
|
if (confirmStageChangeButton) {
|
|
confirmStageChangeButton.addEventListener('click', function() {
|
|
// Hide modal
|
|
stageConfirmationModal.hide();
|
|
|
|
// Set confirmed flag
|
|
isConfirmed = true;
|
|
|
|
// Programmatically trigger the button click to submit form
|
|
changeStageButton.click();
|
|
});
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
{% endblock %}
|