Loading app/Http/Controllers/ContactoController.php +4 −0 Original line number Diff line number Diff line Loading @@ -317,10 +317,14 @@ public function update(Request $request, string $id) // Sincronizar subgrupos y grupos if ($request->has('subgrupo_id')) { $contacto->subgrupos()->sync($request->input('subgrupo_id')); } else { $contacto->subgrupos()->sync([]); } if ($request->has('grupo_id')) { $contacto->grupos()->sync($request->input('grupo_id')); } else { $contacto->grupos()->sync([]); } // Actualizar los datos del contacto Loading resources/views/adminGen/contactos/create.blade.php +30 −10 Original line number Diff line number Diff line Loading @@ -649,9 +649,10 @@ function normalizarTexto(texto){ agregarBtnSubgrupo.addEventListener('click', function(){ const newFormGroup = document.createElement('div'); newFormGroup.classList.add('mb-5', 'relative', 'flex', 'items-center', 'gap-2'); const newSelectSubgrupo = `subgrupo_id_${Date.now()}`; newFormGroup.innerHTML = ` <div class="mb-5"> <div class="flex-1"> <label for="${newSelectSubgrupo}">Subgrupo</label> <select id="${newSelectSubgrupo}" name="subgrupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null" selected>Selecciona una opción</option> Loading @@ -660,6 +661,11 @@ function normalizarTexto(texto){ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> `; dynamicFormContainerSubgrupos.appendChild(newFormGroup); NiceSelect.bind(document.getElementById(newSelectSubgrupo), options); Loading @@ -669,13 +675,18 @@ function normalizarTexto(texto){ aplicarBusquedaNormalizada(nuevoNiceSelect); } }, 50); newFormGroup.querySelector('.removeBtn').addEventListener('click', function() { newFormGroup.remove(); }); }); agregarBtnGrupo.addEventListener('click', function(){ const newFormGroup = document.createElement('div'); newFormGroup.classList.add('mb-5', 'relative', 'flex', 'items-center', 'gap-2'); const newSelectGrupo = `grupo_id_${Date.now()}`; newFormGroup.innerHTML = ` <div class="mb-5"> <div class="flex-1"> <label for="${newSelectGrupo}">Grupo</label> <select id="${newSelectGrupo}" name="grupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null" selected>Selecciona una opción</option> Loading @@ -684,6 +695,11 @@ function normalizarTexto(texto){ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> `; dynamicFormContainerGrupos.appendChild(newFormGroup); NiceSelect.bind(document.getElementById(newSelectGrupo), options); Loading @@ -693,6 +709,10 @@ function normalizarTexto(texto){ aplicarBusquedaNormalizada(nuevoNiceSelect); } }, 50); newFormGroup.querySelector('.removeBtn').addEventListener('click', function() { newFormGroup.remove(); }); }); // Añadir evento de clic para eliminar a los grupos iniciales Loading resources/views/adminGen/contactos/edit.blade.php +45 −15 Original line number Diff line number Diff line Loading @@ -251,8 +251,8 @@ <div id="dynamicFormContainerGrupos"> <label for="grupo_id">Grupos</label> @foreach($contacto->grupos as $grupoSeleccionado) <div> <div class="mb-5"> <div class="mb-5 relative flex items-center gap-2"> <div class="flex-1"> <label for="grupo_id">Grupo</label> <select id="grupo_id" name="grupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null">Selecciona una opción</option> Loading @@ -264,14 +264,19 @@ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> </div> @endforeach </div> <div id="dynamicFormContainerSubgrupos"> <label for="subgrupo_id">Subgrupos</label> @foreach($contacto->subgrupos as $subgrupoSeleccionado) <div> <div class="mb-5"> <div class="mb-5 relative flex items-center gap-2"> <div class="flex-1"> <label for="subgrupo_id">Subgrupo</label> <select id="subgrupo_id" name="subgrupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null">Selecciona una opción</option> Loading @@ -283,6 +288,11 @@ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> </div> @endforeach </div> Loading Loading @@ -708,9 +718,10 @@ function normalizarTexto(texto){ agregarBtnSubgrupo.addEventListener('click', function(){ const newFormGroup = document.createElement('div'); newFormGroup.classList.add('mb-5', 'relative', 'flex', 'items-center', 'gap-2'); const newSelectSubgrupo = `subgrupo_id_${Date.now()}`; newFormGroup.innerHTML = ` <div class="mb-5"> <div class="flex-1"> <label for="${newSelectSubgrupo}">Subgrupo</label> <select id="${newSelectSubgrupo}" name="subgrupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null" selected>Selecciona una opción</option> Loading @@ -719,6 +730,11 @@ function normalizarTexto(texto){ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> `; dynamicFormContainerSubgrupos.appendChild(newFormGroup); NiceSelect.bind(document.getElementById(newSelectSubgrupo), options); Loading @@ -728,13 +744,18 @@ function normalizarTexto(texto){ aplicarBusquedaNormalizada(nuevoNiceSelect); } }, 50); newFormGroup.querySelector('.removeBtn').addEventListener('click', function() { newFormGroup.remove(); }); }); agregarBtnGrupo.addEventListener('click', function(){ const newFormGroup = document.createElement('div'); newFormGroup.classList.add('mb-5', 'relative', 'flex', 'items-center', 'gap-2'); const newSelectGrupo = `grupo_id_${Date.now()}`; newFormGroup.innerHTML = ` <div class="mb-5"> <div class="flex-1"> <label for="${newSelectGrupo}">Grupo</label> <select id="${newSelectGrupo}" name="grupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null" selected>Selecciona una opción</option> Loading @@ -743,6 +764,11 @@ function normalizarTexto(texto){ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> `; dynamicFormContainerGrupos.appendChild(newFormGroup); NiceSelect.bind(document.getElementById(newSelectGrupo), options); Loading @@ -752,12 +778,16 @@ function normalizarTexto(texto){ aplicarBusquedaNormalizada(nuevoNiceSelect); } }, 50); newFormGroup.querySelector('.removeBtn').addEventListener('click', function() { newFormGroup.remove(); }); }); // Añadir evento de clic para eliminar a los grupos iniciales document.querySelectorAll('.removeBtn').forEach(function(btn) { btn.addEventListener('click', function() { btn.closest('.form-group').remove(); btn.closest('.mb-5').remove(); }); }); Loading Loading
app/Http/Controllers/ContactoController.php +4 −0 Original line number Diff line number Diff line Loading @@ -317,10 +317,14 @@ public function update(Request $request, string $id) // Sincronizar subgrupos y grupos if ($request->has('subgrupo_id')) { $contacto->subgrupos()->sync($request->input('subgrupo_id')); } else { $contacto->subgrupos()->sync([]); } if ($request->has('grupo_id')) { $contacto->grupos()->sync($request->input('grupo_id')); } else { $contacto->grupos()->sync([]); } // Actualizar los datos del contacto Loading
resources/views/adminGen/contactos/create.blade.php +30 −10 Original line number Diff line number Diff line Loading @@ -649,9 +649,10 @@ function normalizarTexto(texto){ agregarBtnSubgrupo.addEventListener('click', function(){ const newFormGroup = document.createElement('div'); newFormGroup.classList.add('mb-5', 'relative', 'flex', 'items-center', 'gap-2'); const newSelectSubgrupo = `subgrupo_id_${Date.now()}`; newFormGroup.innerHTML = ` <div class="mb-5"> <div class="flex-1"> <label for="${newSelectSubgrupo}">Subgrupo</label> <select id="${newSelectSubgrupo}" name="subgrupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null" selected>Selecciona una opción</option> Loading @@ -660,6 +661,11 @@ function normalizarTexto(texto){ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> `; dynamicFormContainerSubgrupos.appendChild(newFormGroup); NiceSelect.bind(document.getElementById(newSelectSubgrupo), options); Loading @@ -669,13 +675,18 @@ function normalizarTexto(texto){ aplicarBusquedaNormalizada(nuevoNiceSelect); } }, 50); newFormGroup.querySelector('.removeBtn').addEventListener('click', function() { newFormGroup.remove(); }); }); agregarBtnGrupo.addEventListener('click', function(){ const newFormGroup = document.createElement('div'); newFormGroup.classList.add('mb-5', 'relative', 'flex', 'items-center', 'gap-2'); const newSelectGrupo = `grupo_id_${Date.now()}`; newFormGroup.innerHTML = ` <div class="mb-5"> <div class="flex-1"> <label for="${newSelectGrupo}">Grupo</label> <select id="${newSelectGrupo}" name="grupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null" selected>Selecciona una opción</option> Loading @@ -684,6 +695,11 @@ function normalizarTexto(texto){ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> `; dynamicFormContainerGrupos.appendChild(newFormGroup); NiceSelect.bind(document.getElementById(newSelectGrupo), options); Loading @@ -693,6 +709,10 @@ function normalizarTexto(texto){ aplicarBusquedaNormalizada(nuevoNiceSelect); } }, 50); newFormGroup.querySelector('.removeBtn').addEventListener('click', function() { newFormGroup.remove(); }); }); // Añadir evento de clic para eliminar a los grupos iniciales Loading
resources/views/adminGen/contactos/edit.blade.php +45 −15 Original line number Diff line number Diff line Loading @@ -251,8 +251,8 @@ <div id="dynamicFormContainerGrupos"> <label for="grupo_id">Grupos</label> @foreach($contacto->grupos as $grupoSeleccionado) <div> <div class="mb-5"> <div class="mb-5 relative flex items-center gap-2"> <div class="flex-1"> <label for="grupo_id">Grupo</label> <select id="grupo_id" name="grupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null">Selecciona una opción</option> Loading @@ -264,14 +264,19 @@ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> </div> @endforeach </div> <div id="dynamicFormContainerSubgrupos"> <label for="subgrupo_id">Subgrupos</label> @foreach($contacto->subgrupos as $subgrupoSeleccionado) <div> <div class="mb-5"> <div class="mb-5 relative flex items-center gap-2"> <div class="flex-1"> <label for="subgrupo_id">Subgrupo</label> <select id="subgrupo_id" name="subgrupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null">Selecciona una opción</option> Loading @@ -283,6 +288,11 @@ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> </div> @endforeach </div> Loading Loading @@ -708,9 +718,10 @@ function normalizarTexto(texto){ agregarBtnSubgrupo.addEventListener('click', function(){ const newFormGroup = document.createElement('div'); newFormGroup.classList.add('mb-5', 'relative', 'flex', 'items-center', 'gap-2'); const newSelectSubgrupo = `subgrupo_id_${Date.now()}`; newFormGroup.innerHTML = ` <div class="mb-5"> <div class="flex-1"> <label for="${newSelectSubgrupo}">Subgrupo</label> <select id="${newSelectSubgrupo}" name="subgrupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null" selected>Selecciona una opción</option> Loading @@ -719,6 +730,11 @@ function normalizarTexto(texto){ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> `; dynamicFormContainerSubgrupos.appendChild(newFormGroup); NiceSelect.bind(document.getElementById(newSelectSubgrupo), options); Loading @@ -728,13 +744,18 @@ function normalizarTexto(texto){ aplicarBusquedaNormalizada(nuevoNiceSelect); } }, 50); newFormGroup.querySelector('.removeBtn').addEventListener('click', function() { newFormGroup.remove(); }); }); agregarBtnGrupo.addEventListener('click', function(){ const newFormGroup = document.createElement('div'); newFormGroup.classList.add('mb-5', 'relative', 'flex', 'items-center', 'gap-2'); const newSelectGrupo = `grupo_id_${Date.now()}`; newFormGroup.innerHTML = ` <div class="mb-5"> <div class="flex-1"> <label for="${newSelectGrupo}">Grupo</label> <select id="${newSelectGrupo}" name="grupo_id[]" class="block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> <option value="null" selected>Selecciona una opción</option> Loading @@ -743,6 +764,11 @@ function normalizarTexto(texto){ @endforeach </select> </div> <button type="button" class="btn btn-outline-danger removeBtn h-10 w-10 flex items-center justify-center ml-2" title="Eliminar"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M14.5 9.50002L9.5 14.5M9.49998 9.5L14.5 14.5" stroke="#e7515a" stroke-width="1.5" stroke-linecap="round"/> </svg> </button> `; dynamicFormContainerGrupos.appendChild(newFormGroup); NiceSelect.bind(document.getElementById(newSelectGrupo), options); Loading @@ -752,12 +778,16 @@ function normalizarTexto(texto){ aplicarBusquedaNormalizada(nuevoNiceSelect); } }, 50); newFormGroup.querySelector('.removeBtn').addEventListener('click', function() { newFormGroup.remove(); }); }); // Añadir evento de clic para eliminar a los grupos iniciales document.querySelectorAll('.removeBtn').forEach(function(btn) { btn.addEventListener('click', function() { btn.closest('.form-group').remove(); btn.closest('.mb-5').remove(); }); }); Loading