Commit 759689c68621dcad39492893a440293789eea95c

Authored by Wilmer
1 parent 4a2ade5a31
Exists in master

permite eliminar tareas de las labores

app/Resources/views/solicitudes/pida.html.twig
... ... @@ -77,6 +77,8 @@
77 77 <td>{{ tarea.pidaTareaEspecifico }}
78 78 {% if loop.index == loop.length %}
79 79 <a data-id="{{ pid.id }}" id="add_actividad{{ pid.id }}" data-toggle="modal" data-target="#nueva_actividad" class="btn btn-xs btn-warning">+</a>
  80 + {% else %}
  81 + <a data-id="{{ tarea.id }}" id="remove{{ tarea.id }}" class="btn btn-xs btn-danger">-</a>
80 82 {% endif %}
81 83 </td>
82 84 <td>{{ tarea.idPidaPlazo }}</td>
... ... @@ -201,6 +203,28 @@
201 203 $("#id_pida").val($(this).attr('data-id'));
202 204 });
203 205  
  206 + $('[id^="remove"]').click(function() {
  207 + var x = confirm("eliminar tarea: " + $(this).attr('data-id'));
  208 + if(x) {
  209 + $.ajax({
  210 + method: "POST",
  211 + url: "{{ url('ajax_eliminar_tarea') }}",
  212 + async: true,
  213 + cache: false,
  214 + data: ({eliminar: $(this).attr('data-id')}),
  215 + success: function (data) {
  216 + console.log(data);
  217 + location.reload();
  218 + },
  219 + error: function (XMLHttpRequest, textStatus, errorThrown) {
  220 + console.log(errorThrown);
  221 +
  222 + }
  223 +
  224 + });
  225 + }
  226 + });
  227 +
204 228  
205 229  
206 230  
... ...
src/AppBundle/Controller/AjaxController.php
... ... @@ -239,10 +239,10 @@ class AjaxController extends Controller {
239 239  
240 240  
241 241 /**
242   - * @Route("/ajax/add/tarea", name="ajax_add_tarea")
  242 + * @Route("/ajax/add/tarea", name="ajax_eliminar_tarea")
243 243 * @Method({"POST"})
244 244 */
245   - public function addTareaAction(Request $request){
  245 + public function eliminarTareaAction(Request $request){
246 246  
247 247 if($request->isXmlHttpRequest()){
248 248 $encoders = array(new JsonEncoder());
... ... @@ -250,26 +250,21 @@ class AjaxController extends Controller {
250 250  
251 251 $serializer = new Serializer($normalizers, $encoders);
252 252  
253   - $pida = filter_input(INPUT_POST, 'pida', FILTER_SANITIZE_SPECIAL_CHARS);
  253 + $id = filter_input(INPUT_POST, 'eliminar', FILTER_SANITIZE_SPECIAL_CHARS);
254 254  
255 255  
256 256 $em = $this->getDoctrine()->getManager();
257   - $pida = $em->getRepository("AppBundle:AdscripcionPida")->findOneById($pida);
258   - var_dump($request->request); exit;
259   - $pida->addPidaTareaEspecifico($tarea);
260   - $em->persist($pida);
  257 + $tarea = $em->getRepository("AppBundle:PidaTareaEspecifico")->findOneById($id);
  258 + $em->remove($tarea);
261 259 $em->flush();
262 260  
263 261  
  262 +
  263 +
264 264 $response = new JsonResponse();
265 265 $response->setStatusCode(200);
266 266 $response->setData(array(
267   - 'response' => 'success',
268   - 'jurados' => $jurados,
269   - 'adicionar_nombres' => $nuevos_nombres,
270   - 'adicionar_institucion' => $nuevos_institucion,
271   - 'adicionar_id' => $nuevos_id,
272   - 'ascenso' => $ascensoId
  267 + 'response' => 'success'
273 268 ));
274 269  
275 270 return $response;
... ...