From 0af94cd9f2ec86534be20bf3c3bad0070803131f Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Fri, 23 Jul 2021 23:58:25 -0600 Subject: [PATCH] Fix bug in list of survey questions and options --- .../update/encuesta-update.component.html | 15 +++++++------ .../update/encuesta-update.component.ts | 21 ++++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html index 28091d1..f44e302 100644 --- a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html +++ b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html @@ -58,21 +58,20 @@ - - + +
- - + +
diff --git a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.ts b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.ts index 147e59f..45e665b 100644 --- a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.ts +++ b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.ts @@ -150,7 +150,6 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked { const checkboxes = document.getElementsByClassName('ds-survey--checkbox'); for (let i = 0; i < checkboxes.length; i++) { checkboxes[i].addEventListener('click', e => { - console.log(e); if ((e.target as HTMLInputElement).checked) { (e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active'); } else { @@ -176,7 +175,6 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked { const id = event.target.dataset.id; this.ePreguntaCerradaService.find(id).subscribe(e => { this.selectedQuestionToCreateOption = e.body; - console.log(this.selectedQuestionToCreateOption); }); } } @@ -193,22 +191,27 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked { if (e.nodeName !== 'DIV') return; if (i === 0) return; if ((e as HTMLElement).dataset.id === undefined) return; + if (!(e as HTMLElement).classList.contains('can-delete')) return; let optionId = (e as HTMLElement).dataset.id; optionIdsToDelete.push(+optionId!); }); - // Delete question options - this.ePreguntaCerradaOpcionService.deleteMany(optionIdsToDelete).subscribe(e => { - // Delete question + if (optionIdsToDelete.length === 0) { this.ePreguntaCerradaService.delete(id).subscribe(e => { - console.log('DELETED CLOSED QUESTION: ' + id); this.loadAll(); }); - }); + } else { + // Delete question options + this.ePreguntaCerradaOpcionService.deleteMany(optionIdsToDelete).subscribe(e => { + // Delete question + this.ePreguntaCerradaService.delete(id).subscribe(e => { + this.loadAll(); + }); + }); + } } else { // Delete open question this.ePreguntaAbiertaService.delete(id).subscribe(e => { - console.log('DELETED OPEN QUESTION: ' + id); this.loadAll(); }); } @@ -266,8 +269,6 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked { } protected createFromForm(): IEPreguntaCerradaOpcion { - console.log(this.selectedQuestionToCreateOption); - return { // ...new EPreguntaCerradaOpcion(), id: undefined,