Fix bug in list of survey questions and options
This commit is contained in:
parent
2302a615b9
commit
0af94cd9f2
|
@ -58,21 +58,20 @@
|
|||
</div>
|
||||
<ng-container *ngIf="ePregunta.tipo">
|
||||
<ng-container *ngFor="let ePreguntaOpcion of ePreguntasOpciones; let j = index; trackBy: trackId">
|
||||
<ng-container *ngIf="ePreguntaOpcion[j] !== undefined">
|
||||
<ng-container *ngIf="ePregunta.id == ePreguntaOpcion[j].epreguntaCerrada.id">
|
||||
<ng-container *ngFor="let ePreguntaOpcionFinal of ePreguntaOpcion">
|
||||
<ng-container *ngIf="ePregunta.id === ePreguntaOpcionFinal.epreguntaCerrada.id">
|
||||
<div
|
||||
class="ds-survey--option ds-survey--option--base ds-survey--closed-option"
|
||||
*ngFor="let ePreguntaOpcion2 of ePreguntaOpcion; let k = index; trackBy: trackId"
|
||||
[attr.data-id]="ePreguntaOpcion2.id"
|
||||
class="ds-survey--option ds-survey--option--base ds-survey--closed-option can-delete"
|
||||
[attr.data-id]="ePreguntaOpcionFinal.id"
|
||||
>
|
||||
<!-- <input class="ds-survey--checkbox" id="{{ ePregunta.id }}-{{ ePreguntaOpcion2.id }}" type="checkbox" disabled /> -->
|
||||
<label for="{{ ePregunta.id }}-{{ ePreguntaOpcion2.id }}">{{ ePreguntaOpcion2.nombre }}</label>
|
||||
<input class="ds-survey--checkbox" id="{{ ePregunta.id }}-{{ ePreguntaOpcionFinal.id }}" type="checkbox" disabled />
|
||||
<label for="{{ ePregunta.id }}-{{ ePreguntaOpcionFinal.id }}">{{ ePreguntaOpcionFinal.nombre }}</label>
|
||||
<fa-icon
|
||||
*ngIf="encuesta!.estado === 'DRAFT'"
|
||||
class="ds-survey--titulo--icon ds-survey--titulo--icon--small"
|
||||
[icon]="faTimes"
|
||||
(click)="deleteOption($event)"
|
||||
[attr.data-optionid]="ePreguntaOpcion2.id"
|
||||
[attr.data-optionid]="ePreguntaOpcionFinal.id"
|
||||
></fa-icon>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
|
|
@ -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!);
|
||||
});
|
||||
|
||||
if (optionIdsToDelete.length === 0) {
|
||||
this.ePreguntaCerradaService.delete(id).subscribe(e => {
|
||||
this.loadAll();
|
||||
});
|
||||
} else {
|
||||
// Delete question options
|
||||
this.ePreguntaCerradaOpcionService.deleteMany(optionIdsToDelete).subscribe(e => {
|
||||
// Delete question
|
||||
this.ePreguntaCerradaService.delete(id).subscribe(e => {
|
||||
console.log('DELETED CLOSED QUESTION: ' + id);
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue