fix(academic): commission subjects and shared careers mapping, role-based scoping and gradebook milestones (v3.8.20)
This commit is contained in:
@@ -64,12 +64,20 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="fw-bold mb-1">{{ commission.subject.name }}</h5>
|
||||
<div class="d-flex align-items-center gap-2 mb-3 flex-wrap">
|
||||
<span class="badge bg-secondary-subtle text-secondary font-monospace border">{{ commission.subject.code }}</span>
|
||||
<span class="badge bg-primary-subtle text-primary border">
|
||||
<i class="bi bi-mortarboard me-1"></i>{{ commission.career_name or (commission.subject.career_obj.name if commission.subject.career_obj else 'Carrera General') }}
|
||||
</span>
|
||||
<h5 class="fw-bold mb-1">{{ commission.subject.name or commission.subject_name }}</h5>
|
||||
<div class="d-flex align-items-center gap-1 mb-3 flex-wrap">
|
||||
<span class="badge bg-secondary-subtle text-secondary font-monospace border">{{ commission.subject.code or commission.subject_code }}</span>
|
||||
{% if commission.careers and commission.careers|length > 0 %}
|
||||
{% for c_obj in commission.careers %}
|
||||
<span class="badge bg-primary-subtle text-primary border" title="Carrera Vinculada">
|
||||
<i class="bi bi-mortarboard me-1"></i>{{ c_obj.name }}
|
||||
</span>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<span class="badge bg-primary-subtle text-primary border" title="Carrera">
|
||||
<i class="bi bi-mortarboard me-1"></i>{{ commission.career_name or 'Carrera General' }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-wrap gap-2 mb-3">
|
||||
|
||||
@@ -198,15 +198,17 @@
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="fw-semibold text-primary">{{ comm.subject.name }}</div>
|
||||
<div class="fw-bold text-primary fs-6">{{ comm.subject.name or comm.subject_name }}</div>
|
||||
<div class="d-flex align-items-center gap-1 mt-1 flex-wrap">
|
||||
<span class="badge bg-secondary-subtle text-secondary border font-monospace">{{ comm.subject.code }}</span>
|
||||
{% if comm.subject.code or comm.subject_code %}
|
||||
<span class="badge bg-secondary-subtle text-secondary border font-monospace">{{ comm.subject.code or comm.subject_code }}</span>
|
||||
{% endif %}
|
||||
{% if comm.careers and (comm.careers | length > 0) %}
|
||||
{% for c_obj in comm.careers %}
|
||||
<span class="badge bg-primary-subtle text-primary border" title="Carrera"><i class="bi bi-mortarboard me-1"></i>{{ c_obj.name }}</span>
|
||||
<span class="badge bg-primary-subtle text-primary border" title="Carrera Vinculada"><i class="bi bi-mortarboard me-1"></i>{{ c_obj.name }}</span>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<span class="badge bg-primary-subtle text-primary border" title="Carrera"><i class="bi bi-mortarboard me-1"></i>{{ comm.career_name or comm.subject.career_name or 'Carrera General' }}</span>
|
||||
<span class="badge bg-primary-subtle text-primary border" title="Carrera Vinculada"><i class="bi bi-mortarboard me-1"></i>{{ comm.career_name or 'Carrera General' }}</span>
|
||||
{% endif %}
|
||||
<small class="text-muted ms-1">{{ comm.semester }} {{ comm.year }}</small>
|
||||
</div>
|
||||
@@ -403,21 +405,38 @@
|
||||
<label for="add_subject_id" class="form-label fw-semibold small">
|
||||
<i class="bi bi-book text-primary me-1"></i>Asignatura / Materia Asociada <span class="text-danger">*</span>
|
||||
</label>
|
||||
<select class="form-select" id="add_subject_id" name="subject_id" required>
|
||||
<select class="form-select form-select-sm" id="add_subject_id" name="subject_id" required>
|
||||
<option value="">-- Seleccione la materia a vincular... --</option>
|
||||
{% for s in subjects %}
|
||||
<option value="{{ s.id }}">
|
||||
{{ s.code }} · {{ s.name }} ({{ s.career_name or s.career or 'Carrera General' }})
|
||||
{% set car_names = [] %}
|
||||
{% if s.careers and s.careers|length > 0 %}
|
||||
{% for cr in s.careers %}{% set _ = car_names.push(cr.name) %}{% endfor %}
|
||||
{% elif s.career_name %}
|
||||
{% set _ = car_names.push(s.career_name) %}
|
||||
{% endif %}
|
||||
{% set car_label = car_names|join(', ') if car_names|length > 0 else 'Carrera General' %}
|
||||
<option value="{{ s.id }}" data-careers="{{ car_label }}">
|
||||
{{ s.code }} — {{ s.name }} [Carrera(s): {{ car_label }}]
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<div class="form-text small">La comisión heredará el plan de estudios y carrera de la materia.</div>
|
||||
<div id="add_subject_careers_box" class="alert alert-info py-1 px-2 small mt-2 mb-0 d-flex align-items-center justify-content-between">
|
||||
<div>
|
||||
<i class="bi bi-mortarboard-fill me-1 text-primary"></i>
|
||||
<strong>Carrera(s) heredadas:</strong>
|
||||
<span id="add_subject_careers_text" class="fw-semibold ms-1">-</span>
|
||||
</div>
|
||||
<a href="/admin/subjects_list" target="_blank" class="small text-decoration-none fw-semibold">
|
||||
<i class="bi bi-box-arrow-up-right me-1"></i>Gestionar carreras en Materias
|
||||
</a>
|
||||
</div>
|
||||
<div class="form-text small mt-1">La comisión hereda automáticamente todas las carreras asociadas a esta asignatura.</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<label for="add_code" class="form-label fw-semibold small">
|
||||
<i class="bi bi-tag text-secondary me-1"></i>Código / Identificador <span class="text-danger">*</span>
|
||||
</label>
|
||||
<input type="text" class="form-control" id="add_code" name="code" placeholder="Ej: Comisión A, B, N1, Única" required>
|
||||
<input type="text" class="form-control form-control-sm" id="add_code" name="code" placeholder="Ej: Comisión A, B, N1, Única" required>
|
||||
<div class="form-text small">Identificador visible para docentes y alumnos.</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -532,9 +551,29 @@
|
||||
</label>
|
||||
<select class="form-select form-select-sm" id="edit_subject_id" name="subject_id" required>
|
||||
{% for subj in subjects %}
|
||||
<option value="{{ subj.id }}">{{ subj.code }} — {{ subj.name }} ({{ subj.career_name or 'General' }})</option>
|
||||
{% set car_names = [] %}
|
||||
{% if subj.careers and subj.careers|length > 0 %}
|
||||
{% for cr in subj.careers %}{% set _ = car_names.push(cr.name) %}{% endfor %}
|
||||
{% elif subj.career_name %}
|
||||
{% set _ = car_names.push(subj.career_name) %}
|
||||
{% endif %}
|
||||
{% set car_label = car_names|join(', ') if car_names|length > 0 else 'Carrera General' %}
|
||||
<option value="{{ subj.id }}" data-careers="{{ car_label }}">
|
||||
{{ subj.code }} — {{ subj.name }} [Carrera(s): {{ car_label }}]
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<div id="edit_subject_careers_box" class="alert alert-info py-1 px-2 small mt-2 mb-0 d-flex align-items-center justify-content-between">
|
||||
<div>
|
||||
<i class="bi bi-mortarboard-fill me-1 text-primary"></i>
|
||||
<strong>Carrera(s) heredadas:</strong>
|
||||
<span id="edit_subject_careers_text" class="fw-semibold ms-1">-</span>
|
||||
</div>
|
||||
<a href="/admin/subjects_list" target="_blank" class="small text-decoration-none fw-semibold">
|
||||
<i class="bi bi-box-arrow-up-right me-1"></i>Gestionar carreras en Materias
|
||||
</a>
|
||||
</div>
|
||||
<div class="form-text small mt-1">La comisión hereda automáticamente todas las carreras asociadas a esta asignatura.</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<label for="edit_code" class="form-label fw-semibold small">
|
||||
@@ -708,6 +747,31 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
editTermSelect.addEventListener('change', () => syncTerm(editTermSelect, editYearInput, editSemSelect));
|
||||
}
|
||||
|
||||
// Sincronización de Carreras Heredadas de la Materia
|
||||
function syncSubjectCareers(selectElem, textElem) {
|
||||
if (!selectElem || !textElem) return;
|
||||
const opt = selectElem.options[selectElem.selectedIndex];
|
||||
if (opt && opt.value) {
|
||||
const careers = opt.getAttribute('data-careers') || 'Carrera General';
|
||||
textElem.textContent = careers;
|
||||
} else {
|
||||
textElem.textContent = '-';
|
||||
}
|
||||
}
|
||||
|
||||
const addSubjectSelect = document.getElementById('add_subject_id');
|
||||
const addSubjectCareersText = document.getElementById('add_subject_careers_text');
|
||||
if (addSubjectSelect && addSubjectCareersText) {
|
||||
addSubjectSelect.addEventListener('change', () => syncSubjectCareers(addSubjectSelect, addSubjectCareersText));
|
||||
syncSubjectCareers(addSubjectSelect, addSubjectCareersText);
|
||||
}
|
||||
|
||||
const editSubjectSelect = document.getElementById('edit_subject_id');
|
||||
const editSubjectCareersText = document.getElementById('edit_subject_careers_text');
|
||||
if (editSubjectSelect && editSubjectCareersText) {
|
||||
editSubjectSelect.addEventListener('change', () => syncSubjectCareers(editSubjectSelect, editSubjectCareersText));
|
||||
}
|
||||
|
||||
// Poblar Modal Editar Comisión
|
||||
const modalEdit = document.getElementById('modalEditCommission');
|
||||
if (modalEdit) {
|
||||
@@ -716,7 +780,9 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
if (!btn) return;
|
||||
document.getElementById('edit_commission_id').value = btn.getAttribute('data-id') || '';
|
||||
document.getElementById('edit_code').value = btn.getAttribute('data-code') || '';
|
||||
document.getElementById('edit_subject_id').value = btn.getAttribute('data-subject-id') || '';
|
||||
const subjSelect = document.getElementById('edit_subject_id');
|
||||
subjSelect.value = btn.getAttribute('data-subject-id') || '';
|
||||
syncSubjectCareers(subjSelect, editSubjectCareersText);
|
||||
document.getElementById('edit_academic_term_id').value = btn.getAttribute('data-academic-term-id') || '';
|
||||
document.getElementById('edit_semester').value = btn.getAttribute('data-semester') || '1C';
|
||||
document.getElementById('edit_year').value = btn.getAttribute('data-year') || '2026';
|
||||
|
||||
@@ -994,12 +994,14 @@
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="/schedule/edit_reservation"
|
||||
{% if role in ['admin', 'bedelia', 'docente'] %}
|
||||
<a href="/schedule/edit_reservation?id={{ r.id }}"
|
||||
class="btn btn-sm btn-primary py-0 px-2" style="font-size: 0.72rem;"
|
||||
title="Modificar Fecha, Horario, Aula o Detalles">
|
||||
<i class="bi bi-pencil me-1"></i>Modificar
|
||||
</a>
|
||||
<a href="/schedule/view_reservation"
|
||||
{% endif %}
|
||||
<a href="/schedule/view_reservation?id={{ r.id }}"
|
||||
class="btn btn-sm btn-outline-secondary py-0 px-2" style="font-size: 0.72rem;"
|
||||
title="Ver Ficha Completa">
|
||||
<i class="bi bi-eye"></i>
|
||||
|
||||
@@ -121,11 +121,20 @@
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% if role in ['admin', 'bedelia'] %}
|
||||
{% if role in ['docente', 'admin', 'bedelia'] %}
|
||||
<div class="mt-3">
|
||||
<a href="/admin/commission_detail"
|
||||
class="btn btn-warning btn-sm w-100" id="manage-commission-btn">
|
||||
<i class="bi bi-gear me-1"></i>Gestionar Comisión
|
||||
<a href="/schedule/gradebook/{{ commission.id }}"
|
||||
class="btn btn-primary btn-sm w-100 shadow-sm" id="view-gradebook-btn">
|
||||
<i class="bi bi-journal-check me-1"></i>Libro de Calificaciones (Actas)
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if role in ['admin', 'bedelia'] %}
|
||||
<div class="mt-2">
|
||||
<a href="/admin/commission_detail?id={{ commission.id }}"
|
||||
class="btn btn-outline-warning btn-sm w-100" id="manage-commission-btn">
|
||||
<i class="bi bi-gear me-1"></i>Gestionar Comisión (Admin)
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -219,7 +228,7 @@
|
||||
<i class="bi bi-people display-4 text-muted opacity-40"></i>
|
||||
<p class="text-muted mt-3">No hay alumnos inscriptos en esta comisión todavía.</p>
|
||||
{% if role in ['admin', 'bedelia'] %}
|
||||
<a href="/admin/commission_detail" class="btn btn-outline-success btn-sm">
|
||||
<a href="/admin/commission_detail?id={{ commission.id }}" class="btn btn-outline-success btn-sm">
|
||||
<i class="bi bi-person-plus me-1"></i>Inscribir Alumnos
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-footer border-0 bg-transparent pt-0 pb-3 px-3">
|
||||
<a href="/my_subjects/my_subject_detail"
|
||||
<a href="/my_subjects/detail/{{ comm.id }}"
|
||||
class="btn btn-primary btn-sm w-100" id="view-commission-{{ comm.id }}">
|
||||
<i class="bi bi-eye me-1"></i>Ver detalle
|
||||
</a>
|
||||
|
||||
@@ -4,12 +4,30 @@
|
||||
{% block content %}
|
||||
<div class="container-fluid py-4">
|
||||
|
||||
{% if not commission %}
|
||||
<div class="card border-0 shadow-sm text-center py-5">
|
||||
<div class="card-body">
|
||||
<i class="bi bi-journal-x display-3 text-muted opacity-40"></i>
|
||||
<h4 class="mt-3 fw-bold">Sin Comisiones Asignadas</h4>
|
||||
<p class="text-muted">{{ empty_reason or 'No tenés comisiones asignadas actualmente para calificar.' }}</p>
|
||||
<a href="/my_subjects/my_subjects_list" class="btn btn-outline-primary btn-sm">
|
||||
<i class="bi bi-book me-1"></i>Ir a Mis Materias
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
<!-- Breadcrumb -->
|
||||
<nav aria-label="breadcrumb" class="mb-3">
|
||||
<ol class="breadcrumb small">
|
||||
<li class="breadcrumb-item"><a href="/dashboard">Inicio</a></li>
|
||||
<li class="breadcrumb-item"><a href="/admin/commissions_list">Comisiones</a></li>
|
||||
<li class="breadcrumb-item"><a href="/admin/commission_detail?id={{ commission.id }}">{{ commission.full_code or commission.code }}</a></li>
|
||||
{% if role in ['admin', 'bedelia'] %}
|
||||
<li class="breadcrumb-item"><a href="/admin/commissions_list">Comisiones</a></li>
|
||||
<li class="breadcrumb-item"><a href="/admin/commission_detail?id={{ commission.id }}">{{ commission.full_code or commission.code }}</a></li>
|
||||
{% else %}
|
||||
<li class="breadcrumb-item"><a href="/my_subjects/my_subjects_list">Mis Materias</a></li>
|
||||
<li class="breadcrumb-item"><a href="/my_subjects/detail/{{ commission.id }}">{{ commission.full_code or commission.code }}</a></li>
|
||||
{% endif %}
|
||||
<li class="breadcrumb-item active">Libro de Calificaciones</li>
|
||||
</ol>
|
||||
</nav>
|
||||
@@ -50,6 +68,31 @@
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-wrap align-items-center gap-2">
|
||||
<!-- Conmutador entre comisiones si tiene más de 1 -->
|
||||
{% if all_teacher_commissions and all_teacher_commissions|length > 1 %}
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-outline-primary btn-sm dropdown-toggle shadow-sm" type="button" data-bs-toggle="dropdown">
|
||||
<i class="bi bi-arrow-left-right me-1"></i>Cambiar Comisión
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end shadow" style="max-height: 280px; overflow-y: auto;">
|
||||
{% for c in all_teacher_commissions %}
|
||||
<li>
|
||||
<a class="dropdown-item {% if c.id == commission.id %}active{% endif %}" href="/schedule/gradebook/{{ c.id }}">
|
||||
{{ c.full_code or c.code }} - {{ c.subject.name if c.subject else (c.subject_name or 'Materia') }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Botón Programar Examen / TP -->
|
||||
{% if not commission.grades_closed and role in ['docente', 'admin', 'bedelia'] %}
|
||||
<button type="button" class="btn btn-success btn-sm shadow-sm" data-bs-toggle="modal" data-bs-target="#addMilestoneModal">
|
||||
<i class="bi bi-calendar-plus me-1"></i>Programar Examen / TP
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
<!-- Live Auto-save indicator -->
|
||||
<div id="saveStatusIndicator" class="small px-3 py-1 rounded-pill bg-body-tertiary border text-muted d-flex align-items-center gap-2">
|
||||
<i class="bi bi-cloud-check text-success fs-6" id="saveStatusIcon"></i>
|
||||
@@ -162,8 +205,15 @@
|
||||
<th style="min-width: 220px;">Estudiante</th>
|
||||
<th style="min-width: 110px;">Legajo</th>
|
||||
{% for col in milestone_columns %}
|
||||
<th class="text-center" style="min-width: 130px;">
|
||||
<div>{{ col.title }}</div>
|
||||
<th class="text-center position-relative" style="min-width: 140px;">
|
||||
<div class="d-flex align-items-center justify-content-center gap-1">
|
||||
<span>{{ col.title }}</span>
|
||||
{% if not commission.grades_closed and role in ['docente', 'admin', 'bedelia'] %}
|
||||
<button type="button" class="btn btn-link btn-sm text-danger p-0 delete-milestone-btn" data-milestone-id="{{ col.id }}" title="Eliminar evaluación" style="text-decoration: none;">
|
||||
<i class="bi bi-x-circle-fill"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
<small class="text-muted fw-normal font-monospace">({{ col.date }})</small>
|
||||
</th>
|
||||
{% endfor %}
|
||||
@@ -235,6 +285,53 @@
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Modal: Programar Examen / TP -->
|
||||
<div class="modal fade" id="addMilestoneModal" tabindex="-1" aria-labelledby="addMilestoneModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-success text-white">
|
||||
<h5 class="modal-title h6 fw-bold" id="addMilestoneModalLabel">
|
||||
<i class="bi bi-calendar-plus me-1"></i>Programar Examen / Evaluación
|
||||
</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-semibold">Tipo de Evaluación <span class="text-danger">*</span></label>
|
||||
<select id="milestoneTypeSelect" class="form-select form-select-sm" required>
|
||||
{% for mt in milestone_types %}
|
||||
<option value="{{ mt.id }}">{{ mt.name }}</option>
|
||||
{% else %}
|
||||
<option value="1">Parcial</option>
|
||||
<option value="2">Trabajo Práctico</option>
|
||||
<option value="3">Recuperatorio</option>
|
||||
<option value="4">Final</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-semibold">Título de la Evaluación <span class="text-danger">*</span></label>
|
||||
<input type="text" id="milestoneTitleInput" class="form-control form-control-sm" placeholder="Ej: 1° Examen Parcial / TP N° 1" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-semibold">Fecha de Realización <span class="text-danger">*</span></label>
|
||||
<input type="date" id="milestoneDateInput" class="form-control form-control-sm" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-semibold">Observaciones / Temario (Opcional):</label>
|
||||
<textarea id="milestoneNotesInput" class="form-control form-control-sm" rows="2" placeholder="Temas evaluados, modalidad, etc."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Cancelar</button>
|
||||
<button type="button" class="btn btn-sm btn-success" id="btnConfirmAddMilestone">
|
||||
<i class="bi bi-check2-circle me-1"></i>Guardar Evaluación
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal: Cierre Formal de Acta -->
|
||||
<div class="modal fade" id="closeActaModal" tabindex="-1" aria-labelledby="closeActaModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
@@ -522,6 +619,76 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Add Milestone
|
||||
const btnAddMilestone = document.getElementById('btnConfirmAddMilestone');
|
||||
if (btnAddMilestone) {
|
||||
btnAddMilestone.addEventListener('click', async function() {
|
||||
const typeId = document.getElementById('milestoneTypeSelect').value;
|
||||
const title = document.getElementById('milestoneTitleInput').value.trim();
|
||||
const dateVal = document.getElementById('milestoneDateInput').value;
|
||||
const notes = document.getElementById('milestoneNotesInput').value.trim();
|
||||
|
||||
if (!title || !dateVal) {
|
||||
alert('Debe completar el título y la fecha de la evaluación.');
|
||||
return;
|
||||
}
|
||||
|
||||
this.disabled = true;
|
||||
this.innerHTML = '<span class="spinner-border spinner-border-sm me-1"></span>Guardando...';
|
||||
|
||||
try {
|
||||
const resp = await fetch(`/api/v1/commissions/${commissionId}/milestones`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
milestone_type_id: parseInt(typeId),
|
||||
title: title,
|
||||
date: dateVal,
|
||||
notes: notes
|
||||
})
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (resp.ok && data.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
alert('Error al programar evaluación: ' + (data.message || 'Error del servidor'));
|
||||
btnAddMilestone.disabled = false;
|
||||
btnAddMilestone.innerHTML = '<i class="bi bi-check2-circle me-1"></i>Guardar Evaluación';
|
||||
}
|
||||
} catch (err) {
|
||||
alert('Error de conexión: ' + err.message);
|
||||
btnAddMilestone.disabled = false;
|
||||
btnAddMilestone.innerHTML = '<i class="bi bi-check2-circle me-1"></i>Guardar Evaluación';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Delete Milestone
|
||||
document.querySelectorAll('.delete-milestone-btn').forEach(btn => {
|
||||
btn.addEventListener('click', async function(e) {
|
||||
e.stopPropagation();
|
||||
const milestoneId = this.dataset.milestoneId;
|
||||
if (!confirm('¿Está seguro de eliminar esta evaluación y todas sus calificaciones asociadas? Esta acción no se puede deshacer.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await fetch(`/api/v1/commissions/${commissionId}/milestones/${milestoneId}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (resp.ok && data.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
alert('Error al eliminar evaluación: ' + (data.message || 'Error del servidor'));
|
||||
}
|
||||
} catch (err) {
|
||||
alert('Error de conexión: ' + err.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user