Update index.php
This commit is contained in:
@@ -350,6 +350,7 @@ try {
|
|||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
<i class="fas fa-paper-plane"></i> Enviar Mensaje
|
<i class="fas fa-paper-plane"></i> Enviar Mensaje
|
||||||
</button>
|
</button>
|
||||||
|
<input type="hidden" name="template_params" id="template-params" value="">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -769,6 +770,53 @@ try {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Enhancer: pedir nombre para la plantilla `contacto_nuevo` antes de enviar
|
||||||
|
(function(){
|
||||||
|
const form = document.getElementById('send-message-form');
|
||||||
|
if (!form) return;
|
||||||
|
|
||||||
|
form.addEventListener('submit', function(e){
|
||||||
|
try {
|
||||||
|
const typeEl = document.getElementById('message-type');
|
||||||
|
const tplEl = document.getElementById('message-template');
|
||||||
|
const recipientTypeEl = document.getElementById('recipient-type');
|
||||||
|
if (!typeEl || !tplEl) return; // nothing to do
|
||||||
|
|
||||||
|
const type = typeEl.value;
|
||||||
|
const tpl = tplEl.value;
|
||||||
|
|
||||||
|
if (type === 'template' && tpl === 'contacto_nuevo') {
|
||||||
|
// obtener valor por defecto para el prompt
|
||||||
|
let defaultName = '';
|
||||||
|
if (recipientTypeEl && recipientTypeEl.value === 'existing') {
|
||||||
|
const sel = document.getElementById('message-recipient');
|
||||||
|
if (sel && sel.options && sel.selectedIndex >= 0) defaultName = sel.options[sel.selectedIndex].text || '';
|
||||||
|
} else {
|
||||||
|
const manual = document.getElementById('manual-recipient');
|
||||||
|
if (manual) defaultName = manual.value || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = prompt('Ingrese el nombre para la plantilla contacto_nuevo:', defaultName);
|
||||||
|
if (name === null) {
|
||||||
|
// usuario canceló
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const paramsInput = document.getElementById('template-params');
|
||||||
|
if (paramsInput) {
|
||||||
|
const clean = (typeof name === 'string') ? name.trim() : '';
|
||||||
|
paramsInput.value = JSON.stringify({ name: clean || defaultName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('template name prompt failed', err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- Lightbox Modal -->
|
<!-- Lightbox Modal -->
|
||||||
<div class="modal fade" id="imageLightboxModal" tabindex="-1" aria-hidden="true">
|
<div class="modal fade" id="imageLightboxModal" tabindex="-1" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||||
|
|||||||
Reference in New Issue
Block a user