form_cliente: linked vacío editable + firma_profesional bloqueada para paciente
This commit is contained in:
+29
-7
@@ -509,9 +509,11 @@ function renderCampos(esquema, prefilled) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isLinked = c.tipo === 'linked';
|
const isLinked = c.tipo === 'linked';
|
||||||
const isReadOnly = isLinked;
|
// Linked con valor → solo lectura. Linked sin valor → editable (el paciente puede completarlo)
|
||||||
const linkedNote = isLinked
|
const isReadOnly = isLinked && !!val;
|
||||||
? '<small class="text-info d-block mt-1"><i class="fas fa-link me-1"></i>Campo autocompletado</small>' : '';
|
const linkedNote = isLinked && val
|
||||||
|
? '<small class="text-info d-block mt-1"><i class="fas fa-link me-1"></i>Campo autocompletado</small>'
|
||||||
|
: (isLinked ? '<small class="text-warning d-block mt-1"><i class="fas fa-edit me-1"></i>Por favor completa este campo</small>' : '');
|
||||||
|
|
||||||
const lbl = `<label class="form-label small fw-semibold mb-1">${esc(c.label)}${star}</label>`;
|
const lbl = `<label class="form-label small fw-semibold mb-1">${esc(c.label)}${star}</label>`;
|
||||||
|
|
||||||
@@ -584,6 +586,18 @@ function renderFirmaInline(fid, modos, label, required, isPro) {
|
|||||||
const lbl = `<label class="form-label fw-semibold">
|
const lbl = `<label class="form-label fw-semibold">
|
||||||
<i class="fas ${iconC} me-1" style="color:${borderC}"></i>${esc(label||'')}${star}${badge}
|
<i class="fas ${iconC} me-1" style="color:${borderC}"></i>${esc(label||'')}${star}${badge}
|
||||||
</label>`;
|
</label>`;
|
||||||
|
|
||||||
|
// Firma profesional: el paciente NO puede firmar — se muestra solo como aviso
|
||||||
|
if (isPro) {
|
||||||
|
return `<div class="mb-4" id="fw-${fid}"><hr class="mb-3">${lbl}
|
||||||
|
<div class="alert py-2 px-3" style="background:#f0fff4;border:2px dashed #198754;border-radius:8px;color:#155724;font-size:.85rem">
|
||||||
|
<i class="fas fa-lock me-2"></i>
|
||||||
|
<strong>Uso exclusivo del profesional.</strong>
|
||||||
|
Esta firma será completada por el profesional de salud encargado.
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
let html = `<div class="mb-4" id="fw-${fid}"><hr class="mb-3">${lbl}`;
|
let html = `<div class="mb-4" id="fw-${fid}"><hr class="mb-3">${lbl}`;
|
||||||
|
|
||||||
// Tabs cuando ambos modos están activos
|
// Tabs cuando ambos modos están activos
|
||||||
@@ -928,8 +942,10 @@ const formCliente = {
|
|||||||
}
|
}
|
||||||
if (hasInlineFirma) {
|
if (hasInlineFirma) {
|
||||||
requestAnimationFrame(() => requestAnimationFrame(() => {
|
requestAnimationFrame(() => requestAnimationFrame(() => {
|
||||||
|
// Solo inicializar el canvas para firma del paciente
|
||||||
|
// firma_profesional se muestra bloqueada, sin canvas
|
||||||
form.esquema_decoded.forEach(c => {
|
form.esquema_decoded.forEach(c => {
|
||||||
if (c.tipo === 'firma' || c.tipo === 'firma_profesional') firmaWidgetInit(c.id);
|
if (c.tipo === 'firma') firmaWidgetInit(c.id);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -942,7 +958,13 @@ const formCliente = {
|
|||||||
|
|
||||||
campos.forEach(c => {
|
campos.forEach(c => {
|
||||||
if (c.tipo === 'separador' || c.tipo === 'firma' || c.tipo === 'firma_profesional' || c.tipo === 'parrafo') return;
|
if (c.tipo === 'separador' || c.tipo === 'firma' || c.tipo === 'firma_profesional' || c.tipo === 'parrafo') return;
|
||||||
if (c.tipo === 'linked') { return; } // linked viene del prefilled
|
// linked: si tenía valor pre-llenado se ignora; si estaba vacío y el paciente lo llenó, recogerlo
|
||||||
|
if (c.tipo === 'linked') {
|
||||||
|
const inp = form.querySelector(`[name="${c.id}"]`);
|
||||||
|
const v = inp ? inp.value.trim() : '';
|
||||||
|
if (v) datos[c.id] = v;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// parrafo_inline: recolectar solo los inputs editables (los que el usuario llenó)
|
// parrafo_inline: recolectar solo los inputs editables (los que el usuario llenó)
|
||||||
if (c.tipo === 'parrafo_inline') {
|
if (c.tipo === 'parrafo_inline') {
|
||||||
@@ -992,9 +1014,9 @@ const formCliente = {
|
|||||||
$('firma-container').scrollIntoView({block:'center', behavior:'smooth'});
|
$('firma-container').scrollIntoView({block:'center', behavior:'smooth'});
|
||||||
return 'La firma es obligatoria en este formulario.';
|
return 'La firma es obligatoria en este formulario.';
|
||||||
}
|
}
|
||||||
// Validar firmas inline requeridas
|
// Validar firmas inline requeridas (solo tipo 'firma' del paciente)
|
||||||
for (const c of campos) {
|
for (const c of campos) {
|
||||||
if (!c.required || (c.tipo !== 'firma' && c.tipo !== 'firma_profesional')) continue;
|
if (!c.required || c.tipo !== 'firma') continue;
|
||||||
if (!firmaWidgetObtenerSVG(c.id) && !firmaWidgetObtenerFoto(c.id)) {
|
if (!firmaWidgetObtenerSVG(c.id) && !firmaWidgetObtenerFoto(c.id)) {
|
||||||
const el = document.getElementById('fw-' + c.id);
|
const el = document.getElementById('fw-' + c.id);
|
||||||
if (el) el.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
if (el) el.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
||||||
|
|||||||
Reference in New Issue
Block a user