Merge branch 'feature/US-65' into feature/US-43
This commit is contained in:
commit
b649ac4d4e
|
@ -2,11 +2,14 @@ package org.datasurvey.web.rest;
|
|||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.datasurvey.domain.EPreguntaCerrada;
|
||||
import org.datasurvey.domain.PPreguntaCerrada;
|
||||
import org.datasurvey.domain.PPreguntaCerradaOpcion;
|
||||
import org.datasurvey.repository.PPreguntaCerradaOpcionRepository;
|
||||
import org.datasurvey.service.PPreguntaCerradaOpcionQueryService;
|
||||
|
@ -58,10 +61,15 @@ public class PPreguntaCerradaOpcionResource {
|
|||
* @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new pPreguntaCerradaOpcion, or with status {@code 400 (Bad Request)} if the pPreguntaCerradaOpcion has already an ID.
|
||||
* @throws URISyntaxException if the Location URI syntax is incorrect.
|
||||
*/
|
||||
@PostMapping("/p-pregunta-cerrada-opcions")
|
||||
@PostMapping("/p-pregunta-cerrada-opcions/{id}")
|
||||
public ResponseEntity<PPreguntaCerradaOpcion> createPPreguntaCerradaOpcion(
|
||||
@Valid @RequestBody PPreguntaCerradaOpcion pPreguntaCerradaOpcion
|
||||
@Valid @RequestBody PPreguntaCerradaOpcion pPreguntaCerradaOpcion,
|
||||
@PathVariable(value = "id", required = false) final Long id
|
||||
) throws URISyntaxException {
|
||||
PPreguntaCerrada pPreguntaCerrada = new PPreguntaCerrada();
|
||||
pPreguntaCerrada.setId(id);
|
||||
pPreguntaCerradaOpcion.setPPreguntaCerrada(pPreguntaCerrada);
|
||||
|
||||
log.debug("REST request to save PPreguntaCerradaOpcion : {}", pPreguntaCerradaOpcion);
|
||||
if (pPreguntaCerradaOpcion.getId() != null) {
|
||||
throw new BadRequestAlertException("A new pPreguntaCerradaOpcion cannot already have an ID", ENTITY_NAME, "idexists");
|
||||
|
@ -196,4 +204,15 @@ public class PPreguntaCerradaOpcionResource {
|
|||
.headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString()))
|
||||
.build();
|
||||
}
|
||||
|
||||
@PostMapping("/p-pregunta-cerrada-opcions/deleteMany")
|
||||
public ResponseEntity<Void> deleteManyPPreguntaCerradaOpcion(@Valid @RequestBody int[] ids) {
|
||||
for (int id : ids) {
|
||||
pPreguntaCerradaOpcionService.delete((long) id);
|
||||
}
|
||||
return ResponseEntity
|
||||
.noContent()
|
||||
.headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, Arrays.toString(ids)))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,17 @@ package org.datasurvey.web.rest;
|
|||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.datasurvey.domain.Plantilla;
|
||||
import org.datasurvey.domain.*;
|
||||
import org.datasurvey.repository.PlantillaRepository;
|
||||
import org.datasurvey.service.PlantillaQueryService;
|
||||
import org.datasurvey.service.PlantillaService;
|
||||
import org.datasurvey.service.*;
|
||||
import org.datasurvey.service.criteria.PlantillaCriteria;
|
||||
import org.datasurvey.web.rest.errors.BadRequestAlertException;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -41,14 +43,26 @@ public class PlantillaResource {
|
|||
|
||||
private final PlantillaQueryService plantillaQueryService;
|
||||
|
||||
private final PPreguntaCerradaService pPreguntaCerradaService;
|
||||
|
||||
private final PPreguntaAbiertaService pPreguntaAbiertaService;
|
||||
|
||||
private final PPreguntaCerradaOpcionService pPreguntaCerradaOpcionService;
|
||||
|
||||
public PlantillaResource(
|
||||
PlantillaService plantillaService,
|
||||
PlantillaRepository plantillaRepository,
|
||||
PlantillaQueryService plantillaQueryService
|
||||
PlantillaQueryService plantillaQueryService,
|
||||
PPreguntaCerradaService pPreguntaCerradaService,
|
||||
PPreguntaAbiertaService pPreguntaAbiertaService,
|
||||
PPreguntaCerradaOpcionService ePreguntaCerradaOpcionService
|
||||
) {
|
||||
this.plantillaService = plantillaService;
|
||||
this.plantillaRepository = plantillaRepository;
|
||||
this.plantillaQueryService = plantillaQueryService;
|
||||
this.pPreguntaCerradaService = pPreguntaCerradaService;
|
||||
this.pPreguntaAbiertaService = pPreguntaAbiertaService;
|
||||
this.pPreguntaCerradaOpcionService = ePreguntaCerradaOpcionService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,6 +168,55 @@ public class PlantillaResource {
|
|||
return ResponseEntity.ok().body(entityList);
|
||||
}
|
||||
|
||||
@GetMapping("/plantillas/preguntas/{id}")
|
||||
public ResponseEntity<List<Object>> getPreguntasByIdPlantilla(@PathVariable Long id) {
|
||||
List<PPreguntaCerrada> preguntasCerradas = pPreguntaCerradaService.findAll();
|
||||
List<PPreguntaAbierta> preguntasAbiertas = pPreguntaAbiertaService.findAll();
|
||||
List<Object> preguntas = Stream.concat(preguntasCerradas.stream(), preguntasAbiertas.stream()).collect(Collectors.toList());
|
||||
List<Object> preguntasFiltered = new ArrayList<>();
|
||||
|
||||
for (Object obj : preguntas) {
|
||||
if (obj.getClass() == PPreguntaCerrada.class) {
|
||||
if (((PPreguntaCerrada) obj).getPlantilla() != null) {
|
||||
if (((PPreguntaCerrada) obj).getPlantilla().getId().equals(id)) {
|
||||
preguntasFiltered.add(obj);
|
||||
}
|
||||
}
|
||||
} else if (obj.getClass() == PPreguntaAbierta.class) {
|
||||
if (((PPreguntaAbierta) obj).getPlantilla() != null) {
|
||||
if (((PPreguntaAbierta) obj).getPlantilla().getId().equals(id)) {
|
||||
preguntasFiltered.add(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ResponseEntity.ok().body(preguntasFiltered);
|
||||
}
|
||||
|
||||
@GetMapping("/plantillas/preguntas-opciones/{id}")
|
||||
public ResponseEntity<List<List<PPreguntaCerradaOpcion>>> getPreguntaCerradaOpcionByIdPlantilla(@PathVariable Long id) {
|
||||
List<List<PPreguntaCerradaOpcion>> res = new ArrayList<>();
|
||||
List<PPreguntaCerrada> preguntasCerradas = pPreguntaCerradaService.findAll();
|
||||
List<PPreguntaCerrada> preguntasCerradasFiltered = preguntasCerradas
|
||||
.stream()
|
||||
.filter(p -> Objects.nonNull(p.getPlantilla()))
|
||||
.filter(p -> p.getPlantilla().getId().equals(id))
|
||||
.collect(Collectors.toList());
|
||||
List<PPreguntaCerradaOpcion> opciones = pPreguntaCerradaOpcionService.findAll();
|
||||
|
||||
for (PPreguntaCerrada pPreguntaCerrada : preguntasCerradasFiltered) {
|
||||
long preguntaCerradaId = pPreguntaCerrada.getId();
|
||||
List<PPreguntaCerradaOpcion> opcionesFiltered = opciones
|
||||
.stream()
|
||||
.filter(o -> Objects.nonNull(o.getPPreguntaCerrada()))
|
||||
.filter(o -> o.getPPreguntaCerrada().getId().equals(preguntaCerradaId))
|
||||
.collect(Collectors.toList());
|
||||
res.add(opcionesFiltered);
|
||||
}
|
||||
|
||||
return ResponseEntity.ok().body(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code GET /plantillas/count} : count all the plantillas.
|
||||
*
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<button type="button" class="ds-btn ds-btn--secondary" (click)="previousState()">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.back">Back</span>
|
||||
</button>
|
||||
<ng-container *ngIf="encuesta!.estado === 'DRAFT'">
|
||||
<ng-container *ngIf="encuesta!.estado === 'DRAFT' && (isAutor() || isEscritor())">
|
||||
<button type="button" class="ds-btn ds-btn--primary" (click)="publishSurvey()">Publicar encuesta</button>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
|
|
@ -14,7 +14,7 @@ import { IEncuesta, Encuesta } from '../encuesta.model';
|
|||
import { EncuestaService } from '../service/encuesta.service';
|
||||
import { ICategoria } from 'app/entities/categoria/categoria.model';
|
||||
import { CategoriaService } from 'app/entities/categoria/service/categoria.service';
|
||||
import { IUsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model';
|
||||
import { IUsuarioExtra, UsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model';
|
||||
import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario-extra.service';
|
||||
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
@ -30,6 +30,10 @@ import { PreguntaCerradaTipo } from 'app/entities/enumerations/pregunta-cerrada-
|
|||
|
||||
import { faTimes, faPlus, faStar, faQuestion } from '@fortawesome/free-solid-svg-icons';
|
||||
import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component';
|
||||
import { UsuarioEncuestaService } from 'app/entities/usuario-encuesta/service/usuario-encuesta.service';
|
||||
import { Account } from '../../../core/auth/account.model';
|
||||
import { AccountService } from 'app/core/auth/account.service';
|
||||
import { IUsuarioEncuesta } from '../../usuario-encuesta/usuario-encuesta.model';
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-encuesta-detail',
|
||||
|
@ -47,6 +51,8 @@ export class EncuestaDetailComponent implements OnInit {
|
|||
successPublished = false;
|
||||
ePreguntas?: any[];
|
||||
ePreguntasOpciones?: any[];
|
||||
usuarioExtra: UsuarioExtra | null = null;
|
||||
usuariosColaboradores: IUsuarioEncuesta[] = [];
|
||||
|
||||
constructor(
|
||||
protected activatedRoute: ActivatedRoute,
|
||||
|
@ -57,7 +63,9 @@ export class EncuestaDetailComponent implements OnInit {
|
|||
protected modalService: NgbModal,
|
||||
protected ePreguntaCerradaService: EPreguntaCerradaService,
|
||||
protected ePreguntaCerradaOpcionService: EPreguntaCerradaOpcionService,
|
||||
protected ePreguntaAbiertaService: EPreguntaAbiertaService
|
||||
protected ePreguntaAbiertaService: EPreguntaAbiertaService,
|
||||
protected accountService: AccountService,
|
||||
protected usuarioEncuestaService: UsuarioEncuestaService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
@ -69,6 +77,15 @@ export class EncuestaDetailComponent implements OnInit {
|
|||
this.previousState();
|
||||
}
|
||||
});
|
||||
|
||||
// Get jhi_user and usuario_extra information
|
||||
this.accountService.getAuthenticationState().subscribe(account => {
|
||||
if (account !== null) {
|
||||
this.usuarioExtraService.find(account.id).subscribe(usuarioExtra => {
|
||||
this.usuarioExtra = usuarioExtra.body;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewChecked(): void {
|
||||
|
@ -145,6 +162,16 @@ export class EncuestaDetailComponent implements OnInit {
|
|||
this.isLoading = false;
|
||||
}
|
||||
);*/
|
||||
|
||||
this.usuarioEncuestaService.findCollaborators(this.encuesta?.id!).subscribe(
|
||||
(res: any) => {
|
||||
this.isLoading = false;
|
||||
this.usuariosColaboradores = res.body ?? [];
|
||||
},
|
||||
() => {
|
||||
this.isLoading = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
publishSurvey(): void {
|
||||
const modalRef = this.modalService.open(EncuestaPublishDialogComponent, { size: 'lg', backdrop: 'static' });
|
||||
|
@ -161,4 +188,20 @@ export class EncuestaDetailComponent implements OnInit {
|
|||
previousState(): void {
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
isAutor() {
|
||||
return this.usuarioExtra?.id === this.encuesta?.usuarioExtra?.id;
|
||||
}
|
||||
|
||||
isEscritor() {
|
||||
let escritor = false;
|
||||
this.usuariosColaboradores.forEach(c => {
|
||||
if (this.usuarioExtra?.id === c.usuarioExtra?.id) {
|
||||
if (c.rol === 'WRITE') {
|
||||
escritor = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return escritor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<form *ngIf="encuesta" name="deleteForm" (ngSubmit)="confirmFinalizar(encuesta!)">
|
||||
<div class="modal-header">
|
||||
<h4 class="ds-title--small" data-cy="encuestaDeleteDialogHeading">Finalizar encuesta</h4>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<p class="ds-subtitle" id="jhi-delete-encuesta-heading">¿Está seguro de querer finalizar la encuesta?</p>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal" (click)="cancel()">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||
</button>
|
||||
|
||||
<button id="jhi-confirm-delete-encuesta" data-cy="entityConfirmDeleteButton" type="submit" class="ds-btn ds-btn--danger">
|
||||
<span>Finalizar</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
|
@ -0,0 +1,24 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { EncuestaFinalizarDialogComponent } from './encuesta-finalizar-dialog.component';
|
||||
|
||||
describe('EncuestaFinalizarDialogComponent', () => {
|
||||
let component: EncuestaFinalizarDialogComponent;
|
||||
let fixture: ComponentFixture<EncuestaFinalizarDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [EncuestaFinalizarDialogComponent],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EncuestaFinalizarDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,36 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { IEncuesta } from '../encuesta.model';
|
||||
import { EstadoEncuesta } from '../../enumerations/estado-encuesta.model';
|
||||
import { EncuestaService } from '../service/encuesta.service';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import * as dayjs from 'dayjs';
|
||||
import { DATE_TIME_FORMAT } from '../../../config/input.constants';
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-encuesta-finalizar-dialog',
|
||||
templateUrl: './encuesta-finalizar-dialog.component.html',
|
||||
styleUrls: ['./encuesta-finalizar-dialog.component.scss'],
|
||||
})
|
||||
export class EncuestaFinalizarDialogComponent implements OnInit {
|
||||
encuesta?: IEncuesta;
|
||||
|
||||
constructor(protected encuestaService: EncuestaService, protected activeModal: NgbActiveModal) {}
|
||||
|
||||
ngOnInit(): void {}
|
||||
|
||||
confirmFinalizar(encuesta: IEncuesta): void {
|
||||
debugger;
|
||||
const now = dayjs();
|
||||
|
||||
encuesta.estado = EstadoEncuesta.FINISHED;
|
||||
encuesta.fechaFinalizada = dayjs(now, DATE_TIME_FORMAT);
|
||||
|
||||
this.encuestaService.updateSurvey(encuesta).subscribe(() => {
|
||||
this.activeModal.close('finalized');
|
||||
});
|
||||
}
|
||||
|
||||
cancel(): void {
|
||||
this.activeModal.dismiss();
|
||||
}
|
||||
}
|
|
@ -10,6 +10,9 @@ import { EncuestaPublishDialogComponent } from './encuesta-publish-dialog/encues
|
|||
import { EncuestaDeleteQuestionDialogComponent } from './encuesta-delete-question-dialog/encuesta-delete-question-dialog.component';
|
||||
import { EncuestaDeleteOptionDialogComponent } from './encuesta-delete-option-dialog/encuesta-delete-option-dialog.component';
|
||||
import { EncuestaCompartirDialogComponent } from './encuesta-compartir-dialog/encuesta-compartir-dialog.component';
|
||||
|
||||
import { EncuestaFinalizarDialogComponent } from './encuesta-finalizar-dialog/encuesta-finalizar-dialog.component';
|
||||
|
||||
import { EncuestaDeleteColaboratorDialogComponent } from './encuesta-delete-colaborator-dialog/encuesta-delete-colaborator-dialog.component';
|
||||
|
||||
@NgModule({
|
||||
|
@ -23,6 +26,7 @@ import { EncuestaDeleteColaboratorDialogComponent } from './encuesta-delete-cola
|
|||
EncuestaDeleteQuestionDialogComponent,
|
||||
EncuestaDeleteOptionDialogComponent,
|
||||
EncuestaCompartirDialogComponent,
|
||||
EncuestaFinalizarDialogComponent,
|
||||
EncuestaDeleteColaboratorDialogComponent,
|
||||
],
|
||||
entryComponents: [EncuestaDeleteDialogComponent],
|
||||
|
|
|
@ -26,6 +26,7 @@ export class EncuestaService {
|
|||
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
|
||||
}
|
||||
|
||||
//update para publicar
|
||||
update(encuesta: IEncuesta): Observable<EntityResponseType> {
|
||||
const copy = this.convertDateFromClient(encuesta);
|
||||
return this.http
|
||||
|
@ -33,6 +34,7 @@ export class EncuestaService {
|
|||
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
|
||||
}
|
||||
|
||||
//update normal
|
||||
updateSurvey(encuesta: IEncuesta): Observable<EntityResponseType> {
|
||||
const copy = this.convertDateFromClient(encuesta);
|
||||
return this.http
|
||||
|
|
|
@ -42,6 +42,9 @@
|
|||
</div>
|
||||
|
||||
<p class="ds-subtitle">Creada el día {{ encuesta!.fechaCreacion | formatShortDatetime | lowercase }}</p>
|
||||
<button type="button" class="ds-btn ds-btn--danger" (click)="finalizar()" *ngIf="encuesta!.estado === 'ACTIVE'">
|
||||
<fa-icon icon="sync" [icon]="faTimes"></fa-icon> <span>Finalizar</span>
|
||||
</button>
|
||||
|
||||
<div class="d-flex justify-content-end">
|
||||
<button type="button" class="ds-btn ds-btn--secondary" (click)="previousState()">
|
||||
|
@ -58,6 +61,7 @@
|
|||
[disabled]="isLoading"
|
||||
data-toggle="modal"
|
||||
data-target="#crearPregunta"
|
||||
*ngIf="encuesta!.estado !== 'FINISHED' && (isAutor() || isEscritor())"
|
||||
>
|
||||
<fa-icon icon="sync" [icon]="faPlus"></fa-icon> <span>Crear pregunta</span>
|
||||
</button>
|
||||
|
@ -108,7 +112,7 @@
|
|||
>
|
||||
</span>
|
||||
<fa-icon
|
||||
*ngIf="encuesta!.estado === 'DRAFT'"
|
||||
*ngIf="encuesta!.estado === 'DRAFT' && (isAutor() || isEscritor())"
|
||||
class="ds-survey--titulo--icon"
|
||||
[icon]="faTimes"
|
||||
(click)="deleteQuestion($event)"
|
||||
|
@ -140,7 +144,7 @@
|
|||
<!-- <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'"
|
||||
*ngIf="encuesta!.estado === 'DRAFT' && (isAutor() || isEscritor())"
|
||||
class="ds-survey--titulo--icon ds-survey--titulo--icon--small"
|
||||
[icon]="faTimes"
|
||||
(click)="deleteOption($event)"
|
||||
|
@ -156,6 +160,7 @@
|
|||
data-toggle="modal"
|
||||
data-target="#crearOpcion"
|
||||
[attr.data-id]="ePregunta.id"
|
||||
*ngIf="isAutor() || isEscritor()"
|
||||
>
|
||||
<fa-icon
|
||||
class="ds-survey--add-option--icon"
|
||||
|
|
|
@ -38,6 +38,11 @@ import { IUsuarioEncuesta, UsuarioEncuesta } from '../../usuario-encuesta/usuari
|
|||
import { RolColaborador } from '../../enumerations/rol-colaborador.model';
|
||||
import { Account } from '../../../core/auth/account.model';
|
||||
import { AccountService } from 'app/core/auth/account.service';
|
||||
|
||||
import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component';
|
||||
import { EncuestaFinalizarDialogComponent } from '../encuesta-finalizar-dialog/encuesta-finalizar-dialog.component';
|
||||
|
||||
import { EncuestaDeleteDialogComponent } from '../delete/encuesta-delete-dialog.component';
|
||||
import { EncuestaDeleteColaboratorDialogComponent } from '../encuesta-delete-colaborator-dialog/encuesta-delete-colaborator-dialog.component';
|
||||
import { IUser } from '../../user/user.model';
|
||||
|
||||
|
@ -59,6 +64,7 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
|
|||
isSaving = false;
|
||||
isSavingQuestion = false;
|
||||
isSavingCollab = false;
|
||||
finalizada = false;
|
||||
public rolSeleccionado: RolColaborador | undefined = undefined;
|
||||
categoriasSharedCollection: ICategoria[] = [];
|
||||
usuarioExtrasSharedCollection: IUsuarioExtra[] = [];
|
||||
|
@ -730,10 +736,30 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
|
|||
}
|
||||
|
||||
isAutor() {
|
||||
return this.usuarioExtra?.id == this.encuesta?.usuarioExtra?.id;
|
||||
return this.usuarioExtra?.id === this.encuesta?.usuarioExtra?.id;
|
||||
}
|
||||
|
||||
/*sendInvitation(Colla) {
|
||||
this.usuarioEncuestaService.sendCorreoInvitacion(correo);
|
||||
}*/
|
||||
isEscritor() {
|
||||
let escritor = false;
|
||||
this.usuariosColaboradores.forEach(c => {
|
||||
if (this.usuarioExtra?.id === c.usuarioExtra?.id) {
|
||||
if (c.rol === 'WRITE') {
|
||||
escritor = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return escritor;
|
||||
}
|
||||
|
||||
finalizar(): void {
|
||||
const modalRef = this.modalService.open(EncuestaFinalizarDialogComponent, { size: 'lg', backdrop: 'static' });
|
||||
modalRef.componentInstance.encuesta = this.encuesta;
|
||||
// unsubscribe not needed because closed completes on modal close
|
||||
modalRef.closed.subscribe(reason => {
|
||||
if (reason === 'finalized') {
|
||||
this.finalizada = true;
|
||||
this.loadAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ import { RouterModule } from '@angular/router';
|
|||
import('./e-pregunta-cerrada-opcion/e-pregunta-cerrada-opcion.module').then(m => m.EPreguntaCerradaOpcionModule),
|
||||
},
|
||||
{
|
||||
path: 'usuario-encuesta',
|
||||
path: 'colaboraciones',
|
||||
data: { pageTitle: 'dataSurveyApp.usuarioEncuesta.home.title' },
|
||||
loadChildren: () => import('./usuario-encuesta/usuario-encuesta.module').then(m => m.UsuarioEncuestaModule),
|
||||
},
|
||||
|
|
|
@ -16,8 +16,8 @@ export class PPreguntaCerradaOpcionService {
|
|||
|
||||
constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {}
|
||||
|
||||
create(pPreguntaCerradaOpcion: IPPreguntaCerradaOpcion): Observable<EntityResponseType> {
|
||||
return this.http.post<IPPreguntaCerradaOpcion>(this.resourceUrl, pPreguntaCerradaOpcion, { observe: 'response' });
|
||||
create(pPreguntaCerradaOpcion: IPPreguntaCerradaOpcion, preguntaId?: number): Observable<EntityResponseType> {
|
||||
return this.http.post<IPPreguntaCerradaOpcion>(`${this.resourceUrl}/${preguntaId}`, pPreguntaCerradaOpcion, { observe: 'response' });
|
||||
}
|
||||
|
||||
update(pPreguntaCerradaOpcion: IPPreguntaCerradaOpcion): Observable<EntityResponseType> {
|
||||
|
@ -49,6 +49,10 @@ export class PPreguntaCerradaOpcionService {
|
|||
return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' });
|
||||
}
|
||||
|
||||
deleteMany(ids: number[]): Observable<EntityResponseType> {
|
||||
return this.http.post<IPPreguntaCerradaOpcion>(`${this.resourceUrl}/deleteMany`, ids, { observe: 'response' });
|
||||
}
|
||||
|
||||
addPPreguntaCerradaOpcionToCollectionIfMissing(
|
||||
pPreguntaCerradaOpcionCollection: IPPreguntaCerradaOpcion[],
|
||||
...pPreguntaCerradaOpcionsToCheck: (IPPreguntaCerradaOpcion | null | undefined)[]
|
||||
|
|
|
@ -1,22 +1,28 @@
|
|||
<div>
|
||||
<h2 id="page-heading" data-cy="PlantillaHeading">
|
||||
<span jhiTranslate="dataSurveyApp.plantilla.home.title">Plantillas</span>
|
||||
<div class="d-flex flex-sm-row flex-column justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="ds-title" jhiTranslate="dataSurveyApp.plantilla.home.title">Encuestas</span>
|
||||
<p class="ds-subtitle">Administre las plantillas comprables de la tienda</p>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="ds-btn btn-info mr-2" (click)="loadAll()" [disabled]="isLoading">
|
||||
<fa-icon icon="sync" [spin]="isLoading"></fa-icon>
|
||||
<span jhiTranslate="dataSurveyApp.plantilla.home.refreshListLabel">Refresh List</span>
|
||||
</button>
|
||||
<div>
|
||||
<button class="ds-btn ds-btn--secondary" (click)="loadAll()" [disabled]="isLoading">
|
||||
<fa-icon icon="sync" [spin]="isLoading"></fa-icon>
|
||||
<span jhiTranslate="dataSurveyApp.plantilla.home.refreshListLabel">Refresh List</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="jh-create-entity"
|
||||
data-cy="entityCreateButton"
|
||||
class="ds-btn ds-btn--primary jh-create-entity create-plantilla"
|
||||
[routerLink]="['/plantilla/new']"
|
||||
>
|
||||
<fa-icon icon="plus"></fa-icon>
|
||||
<span jhiTranslate="dataSurveyApp.plantilla.home.createLabel"> Create a new Template </span>
|
||||
</button>
|
||||
<button
|
||||
*ngIf="isAdmin() && isAuthenticated()"
|
||||
type="button"
|
||||
class="ds-btn ds-btn--primary"
|
||||
(click)="resetCreateTemplateForm()"
|
||||
data-toggle="modal"
|
||||
data-target="#crearPlantilla"
|
||||
>
|
||||
Crear plantilla
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</h2>
|
||||
|
||||
|
@ -34,7 +40,7 @@
|
|||
<tr>
|
||||
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.nombre">Nombre</span></th>
|
||||
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.descripcion">Descripcion</span></th>
|
||||
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.fechaCreacion">Fecha Creacion</span></th>
|
||||
<!-- <th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.fechaCreacion">Fecha Creacion</span></th> -->
|
||||
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.fechaPublicacionTienda">Fecha Publicacion Tienda</span></th>
|
||||
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.estado">Estado</span></th>
|
||||
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.precio">Precio</span></th>
|
||||
|
@ -46,25 +52,22 @@
|
|||
<tr *ngFor="let plantilla of plantillas; trackBy: trackId" data-cy="entityTable">
|
||||
<td>{{ plantilla.nombre }}</td>
|
||||
<td>{{ plantilla.descripcion }}</td>
|
||||
<td>{{ plantilla.fechaCreacion | formatMediumDatetime }}</td>
|
||||
<td>{{ plantilla.fechaPublicacionTienda | formatMediumDatetime }}</td>
|
||||
<!-- <td>{{ plantilla.fechaCreacion | formatMediumDatetime }}</td> -->
|
||||
<td *ngIf="plantilla.fechaPublicacionTienda">{{ plantilla.fechaPublicacionTienda | formatShortDatetime | titlecase }}</td>
|
||||
<td *ngIf="!plantilla.fechaPublicacionTienda">No establecida</td>
|
||||
<td jhiTranslate="{{ 'dataSurveyApp.EstadoPlantilla.' + plantilla.estado }}">{{ plantilla.estado }}</td>
|
||||
<td>{{ plantilla.precio }}</td>
|
||||
<td>
|
||||
<div *ngIf="plantilla.categoria">
|
||||
<a [routerLink]="['/categoria', plantilla.categoria?.id, 'view']">{{ plantilla.categoria?.nombre }}</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ plantilla.precio | currency: 'USD':'symbol-narrow' }}</td>
|
||||
<td>{{ plantilla.categoria?.nombre }}</td>
|
||||
<td class="text-right">
|
||||
<div class="btn-group">
|
||||
<button
|
||||
type="submit"
|
||||
[routerLink]="['/plantilla', plantilla.id, 'view']"
|
||||
class="ds-btn btn-info btn-sm"
|
||||
class="ds-btn ds-btn--secondary btn-sm"
|
||||
data-cy="entityDetailsButton"
|
||||
>
|
||||
<fa-icon icon="eye"></fa-icon>
|
||||
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
|
||||
<span class="d-none d-md-inline">Vista previa</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
|
@ -73,7 +76,6 @@
|
|||
class="ds-btn ds-btn--primary btn-sm"
|
||||
data-cy="entityEditButton"
|
||||
>
|
||||
<fa-icon icon="pencil-alt"></fa-icon>
|
||||
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
|
||||
</button>
|
||||
|
||||
|
@ -88,3 +90,143 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div
|
||||
class="modal fade ds-modal"
|
||||
id="crearPlantilla"
|
||||
tabindex="-1"
|
||||
role="dialog"
|
||||
aria-labelledby="exampleModalCenterTitle"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<form
|
||||
autocomplete="off"
|
||||
class="ds-form"
|
||||
name="templateCreateForm"
|
||||
role="form"
|
||||
novalidate
|
||||
(ngSubmit)="save()"
|
||||
[formGroup]="templateCreateForm"
|
||||
>
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title" id="exampleModalLongTitle">Crear Plantilla</h1>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Template Registration Modal -->
|
||||
<div>
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.nombre" for="field_nombre">Nombre</label>
|
||||
<input type="text" class="form-control" name="nombre" id="field_nombre" data-cy="nombre" formControlName="nombre" />
|
||||
<div
|
||||
*ngIf="
|
||||
templateCreateForm.get('nombre')!.invalid &&
|
||||
(templateCreateForm.get('nombre')!.dirty || templateCreateForm.get('nombre')!.touched)
|
||||
"
|
||||
>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="templateCreateForm.get('nombre')?.errors?.required"
|
||||
jhiTranslate="entity.validation.required"
|
||||
>
|
||||
This field is required.
|
||||
</small>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="templateCreateForm.get('nombre')?.errors?.minlength"
|
||||
jhiTranslate="entity.validation.minlength"
|
||||
[translateValues]="{ min: 1 }"
|
||||
>
|
||||
This field is required to be at least 1 characters.
|
||||
</small>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="templateCreateForm.get('nombre')?.errors?.maxlength"
|
||||
jhiTranslate="entity.validation.maxlength"
|
||||
[translateValues]="{ max: 50 }"
|
||||
>
|
||||
This field cannot be longer than 50 characters.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.descripcion" for="field_descripcion"
|
||||
>Descripcion</label
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
name="descripcion"
|
||||
id="field_descripcion"
|
||||
data-cy="descripcion"
|
||||
formControlName="descripcion"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.plantilla.precio" for="field_precio">Precio</label>
|
||||
<input type="number" class="form-control" name="precio" id="field_precio" data-cy="precio" formControlName="precio" />
|
||||
<div
|
||||
*ngIf="
|
||||
templateCreateForm.get('precio')!.invalid &&
|
||||
(templateCreateForm.get('precio')!.dirty || templateCreateForm.get('precio')!.touched)
|
||||
"
|
||||
>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="templateCreateForm.get('precio')?.errors?.required"
|
||||
jhiTranslate="entity.validation.required"
|
||||
>
|
||||
This field is required.
|
||||
</small>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
[hidden]="!templateCreateForm.get('precio')?.errors?.number"
|
||||
jhiTranslate="entity.validation.number"
|
||||
>
|
||||
This field should be a number.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.plantilla.categoria" for="field_categoria">Categoria</label>
|
||||
<select class="form-control" id="field_categoria" data-cy="categoria" name="categoria" formControlName="categoria">
|
||||
<option [ngValue]="null"></option>
|
||||
<option
|
||||
[ngValue]="
|
||||
categoriaOption.id === templateCreateForm.get('categoria')!.value?.id
|
||||
? templateCreateForm.get('categoria')!.value
|
||||
: categoriaOption
|
||||
"
|
||||
*ngFor="let categoriaOption of categoriasSharedCollection; trackBy: trackCategoriaById"
|
||||
>
|
||||
{{ categoriaOption.nombre }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<input id="createAnother" type="checkbox" (change)="createAnotherTemplateChange($event)" />
|
||||
<label for="createAnother">Crear otra</label>
|
||||
<button id="cancelBtn" type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
id="save-entity"
|
||||
data-cy="entityCreateSaveButton"
|
||||
class="ds-btn ds-btn--primary"
|
||||
[disabled]="templateCreateForm.invalid || isSaving"
|
||||
>
|
||||
<span jhiTranslate="entity.action.create">Create</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Observable } from 'rxjs';
|
||||
import { finalize, map } from 'rxjs/operators';
|
||||
|
||||
import { IPlantilla } from '../plantilla.model';
|
||||
import { IPlantilla, Plantilla } from '../plantilla.model';
|
||||
import { PlantillaService } from '../service/plantilla.service';
|
||||
import { PlantillaDeleteDialogComponent } from '../delete/plantilla-delete-dialog.component';
|
||||
|
||||
import { AccountService } from 'app/core/auth/account.service';
|
||||
import { Account } from 'app/core/auth/account.model';
|
||||
import { FormBuilder, Validators } from '@angular/forms';
|
||||
import { EstadoPlantilla } from 'app/entities/enumerations/estado-plantilla.model';
|
||||
import { ICategoria } from 'app/entities/categoria/categoria.model';
|
||||
import { CategoriaService } from 'app/entities/categoria/service/categoria.service';
|
||||
|
||||
import * as dayjs from 'dayjs';
|
||||
import { DATE_TIME_FORMAT } from 'app/config/input.constants';
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-plantilla',
|
||||
templateUrl: './plantilla.component.html',
|
||||
|
@ -13,8 +25,27 @@ import { PlantillaDeleteDialogComponent } from '../delete/plantilla-delete-dialo
|
|||
export class PlantillaComponent implements OnInit {
|
||||
plantillas?: IPlantilla[];
|
||||
isLoading = false;
|
||||
isSaving = false;
|
||||
createAnotherTemplate: Boolean = false;
|
||||
|
||||
constructor(protected plantillaService: PlantillaService, protected modalService: NgbModal) {}
|
||||
account: Account | null = null;
|
||||
categoriasSharedCollection: ICategoria[] = [];
|
||||
|
||||
templateCreateForm = this.fb.group({
|
||||
id: [],
|
||||
nombre: [null, [Validators.minLength(1), Validators.maxLength(50)]],
|
||||
descripcion: [],
|
||||
precio: [null, [Validators.required]],
|
||||
categoria: [],
|
||||
});
|
||||
|
||||
constructor(
|
||||
protected plantillaService: PlantillaService,
|
||||
protected modalService: NgbModal,
|
||||
protected accountService: AccountService,
|
||||
protected fb: FormBuilder,
|
||||
protected categoriaService: CategoriaService
|
||||
) {}
|
||||
|
||||
loadAll(): void {
|
||||
this.isLoading = true;
|
||||
|
@ -32,6 +63,7 @@ export class PlantillaComponent implements OnInit {
|
|||
|
||||
ngOnInit(): void {
|
||||
this.loadAll();
|
||||
this.loadRelationshipsOptions();
|
||||
}
|
||||
|
||||
trackId(_index: number, item: IPlantilla): number {
|
||||
|
@ -48,4 +80,90 @@ export class PlantillaComponent implements OnInit {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
isAdmin(): boolean {
|
||||
return this.accountService.hasAnyAuthority('ROLE_ADMIN');
|
||||
}
|
||||
|
||||
isAuthenticated(): boolean {
|
||||
return this.accountService.isAuthenticated();
|
||||
}
|
||||
|
||||
resetCreateTemplateForm(): void {
|
||||
this.templateCreateForm.reset();
|
||||
}
|
||||
|
||||
createAnotherTemplateChange(event: any): void {
|
||||
// ID: #crearPlantilla
|
||||
this.createAnotherTemplate = event.target.checked;
|
||||
}
|
||||
|
||||
previousState(): void {
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
save(): void {
|
||||
this.isSaving = true;
|
||||
const plantilla = this.createFromForm();
|
||||
if (plantilla.id !== undefined) {
|
||||
this.subscribeToSaveResponse(this.plantillaService.update(plantilla));
|
||||
} else {
|
||||
this.subscribeToSaveResponse(this.plantillaService.create(plantilla));
|
||||
}
|
||||
}
|
||||
|
||||
trackCategoriaById(index: number, item: ICategoria): number {
|
||||
return item.id!;
|
||||
}
|
||||
|
||||
protected subscribeToSaveResponse(result: Observable<HttpResponse<IPlantilla>>): void {
|
||||
result.pipe(finalize(() => this.onSaveFinalize())).subscribe(
|
||||
() => this.onSaveSuccess(),
|
||||
() => this.onSaveError()
|
||||
);
|
||||
}
|
||||
|
||||
protected onSaveSuccess(): void {
|
||||
this.templateCreateForm.reset();
|
||||
this.plantillas = [];
|
||||
this.loadAll();
|
||||
if (!this.createAnotherTemplate) {
|
||||
$('#cancelBtn').click();
|
||||
}
|
||||
}
|
||||
|
||||
protected onSaveError(): void {
|
||||
// Api for inheritance.
|
||||
}
|
||||
|
||||
protected onSaveFinalize(): void {
|
||||
this.isSaving = false;
|
||||
}
|
||||
|
||||
protected loadRelationshipsOptions(): void {
|
||||
this.categoriaService
|
||||
.query()
|
||||
.pipe(map((res: HttpResponse<ICategoria[]>) => res.body ?? []))
|
||||
.pipe(
|
||||
map((categorias: ICategoria[]) =>
|
||||
this.categoriaService.addCategoriaToCollectionIfMissing(categorias, this.templateCreateForm.get('categoria')!.value)
|
||||
)
|
||||
)
|
||||
.subscribe((categorias: ICategoria[]) => (this.categoriasSharedCollection = categorias));
|
||||
}
|
||||
|
||||
protected createFromForm(): IPlantilla {
|
||||
const now = dayjs();
|
||||
|
||||
return {
|
||||
...new Plantilla(),
|
||||
id: undefined,
|
||||
nombre: this.templateCreateForm.get(['nombre'])!.value,
|
||||
descripcion: this.templateCreateForm.get(['descripcion'])!.value,
|
||||
fechaCreacion: dayjs(now, DATE_TIME_FORMAT),
|
||||
estado: EstadoPlantilla.DRAFT,
|
||||
precio: this.templateCreateForm.get(['precio'])!.value,
|
||||
categoria: this.templateCreateForm.get(['categoria'])!.value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<form class="ds-form" name="deleteForm" (ngSubmit)="confirmDelete()">
|
||||
<div class="modal-header">
|
||||
<!-- <h2 class="ds-title" data-cy="encuestaDeleteDialogHeading" jhiTranslate="entity.delete.title">Confirm delete operation</h2>
|
||||
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="cancel()">×</button>-->
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<p class="ds-title--small">Eliminar opción</p>
|
||||
<p class="ds-subtitle" id="jhi-delete-encuesta-heading" jhiTranslate="dataSurveyApp.encuesta.delete.deleteoption">
|
||||
Are you sure you want to delete this option?
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal" (click)="cancel()">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||
</button>
|
||||
|
||||
<button id="jhi-confirm-delete-option" data-cy="entityConfirmDeleteButton" type="submit" class="ds-btn ds-btn--danger">
|
||||
<fa-icon icon="times"></fa-icon> <span jhiTranslate="entity.action.delete">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
|
@ -0,0 +1,17 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
@Component({
|
||||
templateUrl: './plantilla-delete-option-dialog.component.html',
|
||||
})
|
||||
export class PlantillaDeleteOptionDialogComponent {
|
||||
constructor(protected activeModal: NgbActiveModal) {}
|
||||
|
||||
cancel(): void {
|
||||
this.activeModal.dismiss();
|
||||
}
|
||||
|
||||
confirmDelete(): void {
|
||||
this.activeModal.close('confirm');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<form class="ds-form" name="deleteForm" (ngSubmit)="confirmDelete()">
|
||||
<div class="modal-header">
|
||||
<!-- <h2 class="ds-title" data-cy="encuestaDeleteDialogHeading" jhiTranslate="entity.delete.title">Confirm delete operation</h2>
|
||||
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="cancel()">×</button>-->
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<p class="ds-title--small">Eliminar pregunta</p>
|
||||
<p class="ds-subtitle" id="jhi-delete-encuesta-heading" jhiTranslate="dataSurveyApp.encuesta.delete.deletequestion">
|
||||
Are you sure you want to delete this question?
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal" (click)="cancel()">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||
</button>
|
||||
|
||||
<button id="jhi-confirm-delete-question" data-cy="entityConfirmDeleteButton" type="submit" class="ds-btn ds-btn--danger">
|
||||
<fa-icon icon="times"></fa-icon> <span jhiTranslate="entity.action.delete">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
|
@ -0,0 +1,17 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
@Component({
|
||||
templateUrl: './plantilla-delete-question-dialog.component.html',
|
||||
})
|
||||
export class PlantillaDeleteQuestionDialogComponent {
|
||||
constructor(protected activeModal: NgbActiveModal) {}
|
||||
|
||||
cancel(): void {
|
||||
this.activeModal.dismiss();
|
||||
}
|
||||
|
||||
confirmDelete(): void {
|
||||
this.activeModal.close('confirm');
|
||||
}
|
||||
}
|
|
@ -5,10 +5,20 @@ import { PlantillaDetailComponent } from './detail/plantilla-detail.component';
|
|||
import { PlantillaUpdateComponent } from './update/plantilla-update.component';
|
||||
import { PlantillaDeleteDialogComponent } from './delete/plantilla-delete-dialog.component';
|
||||
import { PlantillaRoutingModule } from './route/plantilla-routing.module';
|
||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||
import { PlantillaDeleteQuestionDialogComponent } from './plantilla-delete-question-dialog/plantilla-delete-question-dialog.component';
|
||||
import { PlantillaDeleteOptionDialogComponent } from './plantilla-delete-option-dialog/plantilla-delete-option-dialog.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [SharedModule, PlantillaRoutingModule],
|
||||
declarations: [PlantillaComponent, PlantillaDetailComponent, PlantillaUpdateComponent, PlantillaDeleteDialogComponent],
|
||||
imports: [SharedModule, PlantillaRoutingModule, FontAwesomeModule],
|
||||
declarations: [
|
||||
PlantillaComponent,
|
||||
PlantillaDetailComponent,
|
||||
PlantillaUpdateComponent,
|
||||
PlantillaDeleteDialogComponent,
|
||||
PlantillaDeleteQuestionDialogComponent,
|
||||
PlantillaDeleteOptionDialogComponent,
|
||||
],
|
||||
entryComponents: [PlantillaDeleteDialogComponent],
|
||||
})
|
||||
export class PlantillaModule {}
|
||||
|
|
|
@ -45,6 +45,22 @@ export class PlantillaService {
|
|||
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
|
||||
}
|
||||
|
||||
findPlantilla(id: number): Observable<IPlantilla> {
|
||||
return this.http.get<IPlantilla>(`${this.resourceUrl}/${id}`);
|
||||
}
|
||||
|
||||
findQuestions(id: number): Observable<EntityResponseType> {
|
||||
return this.http
|
||||
.get<any>(`${this.resourceUrl}/preguntas/${id}`, { observe: 'response' })
|
||||
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
|
||||
}
|
||||
|
||||
findQuestionsOptions(id: number): Observable<EntityResponseType> {
|
||||
return this.http
|
||||
.get<any>(`${this.resourceUrl}/preguntas-opciones/${id}`, { observe: 'response' })
|
||||
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
|
||||
}
|
||||
|
||||
query(req?: any): Observable<EntityArrayResponseType> {
|
||||
const options = createRequestOption(req);
|
||||
return this.http
|
||||
|
|
|
@ -1,165 +1,355 @@
|
|||
<div class="row justify-content-center">
|
||||
<div class="col-8">
|
||||
<form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
|
||||
<h2 id="jhi-plantilla-heading" data-cy="PlantillaCreateUpdateHeading" jhiTranslate="dataSurveyApp.plantilla.home.createOrEditLabel">
|
||||
Create or edit a Plantilla
|
||||
</h2>
|
||||
<div>
|
||||
<h2 id="page-heading" data-cy="EPreguntaCerradaHeading">
|
||||
<div class="d-flex align-items-center">
|
||||
<p class="ds-title ds-contenteditable" contenteditable="true" spellcheck="false" (blur)="updateTemplateName($event)">
|
||||
{{ plantilla!.nombre }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
<p class="ds-subtitle">Creada el día {{ plantilla!.fechaCreacion | formatShortDatetime | lowercase }}</p>
|
||||
|
||||
<div class="form-group" [hidden]="editForm.get('id')!.value == null">
|
||||
<label class="form-control-label" jhiTranslate="global.field.id" for="field_id">ID</label>
|
||||
<input type="number" class="form-control" name="id" id="field_id" data-cy="id" formControlName="id" [readonly]="true" />
|
||||
</div>
|
||||
<div class="d-flex justify-content-end">
|
||||
<button type="button" class="ds-btn ds-btn--secondary" (click)="previousState()">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.back">Back</span>
|
||||
</button>
|
||||
<button type="button" class="ds-btn ds-btn--secondary" (click)="loadAll()" [disabled]="isLoading">
|
||||
<fa-icon icon="sync" [spin]="isLoading"></fa-icon> <span>Refrescar preguntas</span>
|
||||
</button>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.plantilla.nombre" for="field_nombre">Nombre</label>
|
||||
<input type="text" class="form-control" name="nombre" id="field_nombre" data-cy="nombre" formControlName="nombre" />
|
||||
<div *ngIf="editForm.get('nombre')!.invalid && (editForm.get('nombre')!.dirty || editForm.get('nombre')!.touched)">
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editForm.get('nombre')?.errors?.minlength"
|
||||
jhiTranslate="entity.validation.minlength"
|
||||
[translateValues]="{ min: 1 }"
|
||||
>
|
||||
This field is required to be at least 1 characters.
|
||||
</small>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editForm.get('nombre')?.errors?.maxlength"
|
||||
jhiTranslate="entity.validation.maxlength"
|
||||
[translateValues]="{ max: 50 }"
|
||||
>
|
||||
This field cannot be longer than 50 characters.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="ds-btn ds-btn--primary"
|
||||
(click)="createQuestion()"
|
||||
[disabled]="isLoading"
|
||||
data-toggle="modal"
|
||||
data-target="#crearPregunta"
|
||||
>
|
||||
<fa-icon icon="sync" [icon]="faPlus"></fa-icon> <span>Crear pregunta</span>
|
||||
</button>
|
||||
</div>
|
||||
</h2>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.plantilla.descripcion" for="field_descripcion">Descripcion</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
name="descripcion"
|
||||
id="field_descripcion"
|
||||
data-cy="descripcion"
|
||||
formControlName="descripcion"
|
||||
/>
|
||||
</div>
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.plantilla.fechaCreacion" for="field_fechaCreacion"
|
||||
>Fecha Creacion</label
|
||||
>
|
||||
<div class="d-flex">
|
||||
<input
|
||||
id="field_fechaCreacion"
|
||||
data-cy="fechaCreacion"
|
||||
type="datetime-local"
|
||||
class="form-control"
|
||||
name="fechaCreacion"
|
||||
formControlName="fechaCreacion"
|
||||
placeholder="YYYY-MM-DD HH:mm"
|
||||
/>
|
||||
</div>
|
||||
<!-- <jhi-alert></jhi-alert> -->
|
||||
|
||||
<!-- <div class="alert alert-warning" id="no-result" *ngIf="pPreguntas?.length === 0">
|
||||
<span>No se encontraron preguntas</span>
|
||||
</div> -->
|
||||
<!-- *ngIf="pPreguntas && pPreguntas.length > 0" -->
|
||||
<div class="ds-survey" id="entities">
|
||||
<div class="ds-survey--all-question-wrapper">
|
||||
<ng-container *ngIf="plantilla!.estado === 'ACTIVE'">
|
||||
<p class="ds-title text-center">Plantilla en tienda</p>
|
||||
<p class="ds-subtitle">No puede modificar la plantilla debido a que esta ya está en la tienda.</p>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="plantilla!.estado === 'DRAFT' && pPreguntas && pPreguntas.length === 0">
|
||||
<p class="ds-title text-center">Plantilla vacía</p>
|
||||
<p class="ds-subtitle">Inicie creando preguntas y opciones para la plantilla.</p>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="plantilla!.estado === 'DRAFT'">
|
||||
<div class="ds-survey--question-wrapper" *ngFor="let pPregunta of pPreguntas; let i = index; trackBy: trackId">
|
||||
<div
|
||||
*ngIf="
|
||||
editForm.get('fechaCreacion')!.invalid && (editForm.get('fechaCreacion')!.dirty || editForm.get('fechaCreacion')!.touched)
|
||||
"
|
||||
[attr.data-index]="pPregunta.id"
|
||||
[attr.data-tipo]="pPregunta.tipo"
|
||||
[attr.data-opcional]="pPregunta.opcional"
|
||||
class="ds-survey--question"
|
||||
>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editForm.get('fechaCreacion')?.errors?.required"
|
||||
jhiTranslate="entity.validation.required"
|
||||
>
|
||||
This field is required.
|
||||
</small>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
[hidden]="!editForm.get('fechaCreacion')?.errors?.ZonedDateTimelocal"
|
||||
jhiTranslate="entity.validation.ZonedDateTimelocal"
|
||||
>
|
||||
This field should be a date and time.
|
||||
</small>
|
||||
<div class="ds-survey--titulo">
|
||||
<span class="ds-survey--titulo--name">
|
||||
<span>{{ i + 1 }}.</span>
|
||||
<span
|
||||
class="ds-contenteditable"
|
||||
[attr.data-id]="pPregunta.id"
|
||||
[attr.data-tipo]="pPregunta.tipo"
|
||||
contenteditable="true"
|
||||
spellcheck="false"
|
||||
(blur)="updateQuestionName($event)"
|
||||
>{{ pPregunta.nombre }}</span
|
||||
>
|
||||
</span>
|
||||
<fa-icon
|
||||
*ngIf="plantilla!.estado === 'DRAFT'"
|
||||
class="ds-survey--titulo--icon"
|
||||
[icon]="faTimes"
|
||||
(click)="deleteQuestion($event)"
|
||||
[attr.data-id]="pPregunta.id"
|
||||
[attr.data-type]="pPregunta.tipo"
|
||||
></fa-icon>
|
||||
</div>
|
||||
<div>
|
||||
<span *ngIf="pPregunta.tipo === 'SINGLE'" class="ds-subtitle"
|
||||
>Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate | lowercase }}
|
||||
{{ pPregunta.opcional ? '(opcional)' : '' }}</span
|
||||
>
|
||||
<span *ngIf="pPregunta.tipo === 'MULTIPLE'" class="ds-subtitle"
|
||||
>Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate | lowercase }}
|
||||
{{ pPregunta.opcional ? '(opcional)' : '' }}</span
|
||||
>
|
||||
<span *ngIf="!pPregunta.tipo" class="ds-subtitle"
|
||||
>Pregunta de respuesta abierta {{ pPregunta.opcional ? '(opcional)' : '' }}</span
|
||||
>
|
||||
</div>
|
||||
<ng-container *ngIf="pPregunta.tipo">
|
||||
<ng-container *ngFor="let pPreguntaOpcion of pPreguntasOpciones; let j = index; trackBy: trackId">
|
||||
<ng-container *ngFor="let pPreguntaOpcionFinal of pPreguntaOpcion">
|
||||
<ng-container *ngIf="pPregunta.id === pPreguntaOpcionFinal.ppreguntaCerrada.id">
|
||||
<div
|
||||
class="ds-survey--option ds-survey--option--base ds-survey--closed-option can-delete"
|
||||
[attr.data-id]="pPreguntaOpcionFinal.id"
|
||||
>
|
||||
<!-- <input class="ds-survey--checkbox" id="{{ pPregunta.id }}-{{ pPreguntaOpcionFinal.id }}" type="checkbox" disabled /> -->
|
||||
<label for="{{ pPregunta.id }}-{{ pPreguntaOpcionFinal.id }}">{{ pPreguntaOpcionFinal.nombre }}</label>
|
||||
<fa-icon
|
||||
*ngIf="plantilla!.estado === 'DRAFT'"
|
||||
class="ds-survey--titulo--icon ds-survey--titulo--icon--small"
|
||||
[icon]="faTimes"
|
||||
(click)="deleteOption($event)"
|
||||
[attr.data-optionid]="pPreguntaOpcionFinal.id"
|
||||
></fa-icon>
|
||||
</div>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
<div
|
||||
class="ds-survey--option ds-survey--option--add ds-survey--closed-option"
|
||||
(click)="resetForm($event)"
|
||||
data-toggle="modal"
|
||||
data-target="#crearOpcion"
|
||||
[attr.data-id]="pPregunta.id"
|
||||
>
|
||||
<fa-icon
|
||||
class="ds-survey--add-option--icon"
|
||||
[icon]="faPlus"
|
||||
[attr.data-id]="pPregunta.id"
|
||||
[attr.data-type]="pPregunta.tipo"
|
||||
></fa-icon>
|
||||
<span class="ds-survey--add-option">Añadir opción</span>
|
||||
</div>
|
||||
</ng-container>
|
||||
<div class="ds-survey--option ds-survey--option--base ds-survey--open-option" *ngIf="!pPregunta.tipo">
|
||||
<textarea name="" id="" cols="30" rows="10" disabled></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.plantilla.fechaPublicacionTienda" for="field_fechaPublicacionTienda"
|
||||
>Fecha Publicacion Tienda</label
|
||||
>
|
||||
<div class="d-flex">
|
||||
<input
|
||||
id="field_fechaPublicacionTienda"
|
||||
data-cy="fechaPublicacionTienda"
|
||||
type="datetime-local"
|
||||
class="form-control"
|
||||
name="fechaPublicacionTienda"
|
||||
formControlName="fechaPublicacionTienda"
|
||||
placeholder="YYYY-MM-DD HH:mm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.plantilla.estado" for="field_estado">Estado</label>
|
||||
<select class="form-control" name="estado" formControlName="estado" id="field_estado" data-cy="estado">
|
||||
<option [ngValue]="null">{{ 'dataSurveyApp.EstadoPlantilla.null' | translate }}</option>
|
||||
<option value="DRAFT">{{ 'dataSurveyApp.EstadoPlantilla.DRAFT' | translate }}</option>
|
||||
<option value="ACTIVE">{{ 'dataSurveyApp.EstadoPlantilla.ACTIVE' | translate }}</option>
|
||||
<option value="DELETED">{{ 'dataSurveyApp.EstadoPlantilla.DELETED' | translate }}</option>
|
||||
<option value="DISABLED">{{ 'dataSurveyApp.EstadoPlantilla.DISABLED' | translate }}</option>
|
||||
</select>
|
||||
<div *ngIf="editForm.get('estado')!.invalid && (editForm.get('estado')!.dirty || editForm.get('estado')!.touched)">
|
||||
<small class="form-text text-danger" *ngIf="editForm.get('estado')?.errors?.required" jhiTranslate="entity.validation.required">
|
||||
This field is required.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.plantilla.precio" for="field_precio">Precio</label>
|
||||
<input type="number" class="form-control" name="precio" id="field_precio" data-cy="precio" formControlName="precio" />
|
||||
<div *ngIf="editForm.get('precio')!.invalid && (editForm.get('precio')!.dirty || editForm.get('precio')!.touched)">
|
||||
<small class="form-text text-danger" *ngIf="editForm.get('precio')?.errors?.required" jhiTranslate="entity.validation.required">
|
||||
This field is required.
|
||||
</small>
|
||||
<small class="form-text text-danger" [hidden]="!editForm.get('precio')?.errors?.number" jhiTranslate="entity.validation.number">
|
||||
This field should be a number.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.plantilla.categoria" for="field_categoria">Categoria</label>
|
||||
<select class="form-control" id="field_categoria" data-cy="categoria" name="categoria" formControlName="categoria">
|
||||
<option [ngValue]="null"></option>
|
||||
<option
|
||||
[ngValue]="categoriaOption.id === editForm.get('categoria')!.value?.id ? editForm.get('categoria')!.value : categoriaOption"
|
||||
*ngFor="let categoriaOption of categoriasSharedCollection; trackBy: trackCategoriaById"
|
||||
>
|
||||
{{ categoriaOption.nombre }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" (click)="previousState()">
|
||||
<fa-icon icon="ban"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
id="save-entity"
|
||||
data-cy="entityCreateSaveButton"
|
||||
[disabled]="editForm.invalid || isSaving"
|
||||
class="btn btn-primary"
|
||||
>
|
||||
<fa-icon icon="save"></fa-icon> <span jhiTranslate="entity.action.save">Save</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Create Option Modal -->
|
||||
<div class="modal fade ds-modal" id="crearOpcion" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<form autocomplete="off" class="ds-form" name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title" id="exampleModalLongTitle">Crear Opción</h1>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Survey Closed Question Create Option Modal -->
|
||||
<div>
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.pPreguntaCerradaOpcion.nombre" for="field_nombre">Nombre</label>
|
||||
<input type="text" class="form-control" name="nombre" id="field_nombre" data-cy="nombre" formControlName="nombre" />
|
||||
<div *ngIf="editForm.get('nombre')!.invalid && (editForm.get('nombre')!.dirty || editForm.get('nombre')!.touched)">
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editForm.get('nombre')?.errors?.required"
|
||||
jhiTranslate="entity.validation.required"
|
||||
>
|
||||
This field is required.
|
||||
</small>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editForm.get('nombre')?.errors?.minlength"
|
||||
jhiTranslate="entity.validation.minlength"
|
||||
[translateValues]="{ min: 1 }"
|
||||
>
|
||||
This field is required to be at least 1 characters.
|
||||
</small>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editForm.get('nombre')?.errors?.maxlength"
|
||||
jhiTranslate="entity.validation.maxlength"
|
||||
[translateValues]="{ max: 500 }"
|
||||
>
|
||||
This field cannot be longer than 500 characters.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<input id="createAnother" type="checkbox" (change)="createAnotherChange($event)" />
|
||||
<label for="createAnother">Crear otra</label>
|
||||
<button id="cancelBtn" type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
id="save-entity"
|
||||
data-cy="entityCreateSaveButton"
|
||||
class="ds-btn ds-btn--primary"
|
||||
[disabled]="editForm.invalid || isSaving"
|
||||
>
|
||||
<span jhiTranslate="entity.action.create">Create</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ------------------------------------------------------------------------------------------------- -->
|
||||
|
||||
<!-- Create Question Modal -->
|
||||
<div
|
||||
class="modal fade ds-modal"
|
||||
id="crearPregunta"
|
||||
tabindex="-1"
|
||||
role="dialog"
|
||||
aria-labelledby="exampleModalCenterTitle"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<form
|
||||
autocomplete="off"
|
||||
class="ds-form"
|
||||
name="editFormQuestion"
|
||||
role="form"
|
||||
novalidate
|
||||
(ngSubmit)="saveQuestion()"
|
||||
[formGroup]="editFormQuestion"
|
||||
>
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title" id="exampleModalLongTitle1">Crear Pregunta</h1>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Survey Create Question Modal -->
|
||||
<div>
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_nombre">Pregunta</label>
|
||||
<input type="text" class="form-control" name="nombre" id="field_nombre2" data-cy="nombre" formControlName="nombre" />
|
||||
<div
|
||||
*ngIf="
|
||||
editFormQuestion.get('nombre')!.invalid &&
|
||||
(editFormQuestion.get('nombre')!.dirty || editFormQuestion.get('nombre')!.touched)
|
||||
"
|
||||
>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editFormQuestion.get('nombre')?.errors?.required"
|
||||
jhiTranslate="entity.validation.required"
|
||||
>
|
||||
This field is required.
|
||||
</small>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editFormQuestion.get('nombre')?.errors?.minlength"
|
||||
jhiTranslate="entity.validation.minlength"
|
||||
[translateValues]="{ min: 1 }"
|
||||
>
|
||||
This field is required to be at least 1 characters.
|
||||
</small>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editFormQuestion.get('nombre')?.errors?.maxlength"
|
||||
jhiTranslate="entity.validation.maxlength"
|
||||
[translateValues]="{ max: 500 }"
|
||||
>
|
||||
This field cannot be longer than 500 characters.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Custom Form Group (Closed & Open Question Validation) -->
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_tipo">Tipo de pregunta</label>
|
||||
<select class="form-control" name="tipopregunta" formControlName="tipopregunta" id="field_tipo2" data-cy="tipopregunta">
|
||||
<option selected value="CLOSED">Opción multiple</option>
|
||||
<option value="OPEN">Respuesta abierta</option>
|
||||
</select>
|
||||
<div
|
||||
*ngIf="
|
||||
editFormQuestion.get('tipopregunta')!.invalid &&
|
||||
(editFormQuestion.get('tipopregunta')!.dirty || editFormQuestion.get('tipopregunta')!.touched)
|
||||
"
|
||||
>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editFormQuestion.get('tipopregunta')?.errors?.required"
|
||||
jhiTranslate="entity.validation.required"
|
||||
>
|
||||
This field is required.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ng-container *ngIf="editFormQuestion.get('tipopregunta')!.value === 'CLOSED'">
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" jhiTranslate="dataSurveyApp.ePreguntaCerrada.tiporespuesta" for="field_tipo">Tipo</label>
|
||||
<select class="form-control" name="tipo" formControlName="tipo" id="field_tipo" data-cy="tipo">
|
||||
<option selected value="SINGLE">{{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate }}</option>
|
||||
<option value="MULTIPLE">{{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate }}</option>
|
||||
</select>
|
||||
<div
|
||||
*ngIf="
|
||||
editFormQuestion.get('tipo')!.invalid && (editFormQuestion.get('tipo')!.dirty || editFormQuestion.get('tipo')!.touched)
|
||||
"
|
||||
>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editFormQuestion.get('tipo')?.errors?.required"
|
||||
jhiTranslate="entity.validation.required"
|
||||
>
|
||||
This field is required.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="field_opcional">Opcional</label>
|
||||
<input type="checkbox" class="form-check" name="opcional" id="field_opcional" data-cy="opcional" formControlName="opcional" />
|
||||
<div
|
||||
*ngIf="
|
||||
editFormQuestion.get('opcional')!.invalid &&
|
||||
(editFormQuestion.get('opcional')!.dirty || editFormQuestion.get('opcional')!.touched)
|
||||
"
|
||||
>
|
||||
<small
|
||||
class="form-text text-danger"
|
||||
*ngIf="editFormQuestion.get('opcional')?.errors?.required"
|
||||
jhiTranslate="entity.validation.required"
|
||||
>
|
||||
This field is required.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<input id="createAnotherQuestion" type="checkbox" (change)="createAnotherQuestionChange($event)" />
|
||||
<label for="createAnotherQuestion">Crear otra</label>
|
||||
<button id="cancelBtnQuestion" type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
id="save-question"
|
||||
data-cy="entityCreateSaveButton"
|
||||
class="ds-btn ds-btn--primary"
|
||||
[disabled]="editFormQuestion.invalid || isSaving"
|
||||
>
|
||||
<span jhiTranslate="entity.action.create">Create</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { PPreguntaAbierta, IPPreguntaAbierta } from './../../p-pregunta-abierta/p-pregunta-abierta.model';
|
||||
import { PPreguntaCerrada } from './../../p-pregunta-cerrada/p-pregunta-cerrada.model';
|
||||
import { PPreguntaCerradaOpcion, IPPreguntaCerradaOpcion } from './../../p-pregunta-cerrada-opcion/p-pregunta-cerrada-opcion.model';
|
||||
import { PPreguntaAbiertaService } from './../../p-pregunta-abierta/service/p-pregunta-abierta.service';
|
||||
import { PPreguntaCerradaOpcionService } from './../../p-pregunta-cerrada-opcion/service/p-pregunta-cerrada-opcion.service';
|
||||
import { AfterViewChecked, Component, OnInit } from '@angular/core';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
import { FormBuilder, Validators } from '@angular/forms';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
@ -12,67 +17,258 @@ import { IPlantilla, Plantilla } from '../plantilla.model';
|
|||
import { PlantillaService } from '../service/plantilla.service';
|
||||
import { ICategoria } from 'app/entities/categoria/categoria.model';
|
||||
import { CategoriaService } from 'app/entities/categoria/service/categoria.service';
|
||||
import { IUsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model';
|
||||
import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario-extra.service';
|
||||
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { IPPreguntaCerrada } from 'app/entities/p-pregunta-cerrada/p-pregunta-cerrada.model';
|
||||
import { PPreguntaCerradaService } from 'app/entities/p-pregunta-cerrada/service/p-pregunta-cerrada.service';
|
||||
import { PPreguntaCerradaDeleteDialogComponent } from 'app/entities/p-pregunta-cerrada/delete/p-pregunta-cerrada-delete-dialog.component';
|
||||
|
||||
import { faTimes, faPlus, faQuestion, faPollH, faEye } from '@fortawesome/free-solid-svg-icons';
|
||||
import { PreguntaCerradaTipo } from 'app/entities/enumerations/pregunta-cerrada-tipo.model';
|
||||
import { PlantillaDeleteQuestionDialogComponent } from '../plantilla-delete-question-dialog/plantilla-delete-question-dialog.component';
|
||||
import { PlantillaDeleteOptionDialogComponent } from '../plantilla-delete-option-dialog/plantilla-delete-option-dialog.component';
|
||||
|
||||
import { ParametroAplicacionService } from './../../parametro-aplicacion/service/parametro-aplicacion.service';
|
||||
import { IParametroAplicacion } from './../../parametro-aplicacion/parametro-aplicacion.model';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-plantilla-update',
|
||||
templateUrl: './plantilla-update.component.html',
|
||||
})
|
||||
export class PlantillaUpdateComponent implements OnInit {
|
||||
export class PlantillaUpdateComponent implements OnInit, AfterViewChecked {
|
||||
faTimes = faTimes;
|
||||
faPlus = faPlus;
|
||||
faPollH = faPollH;
|
||||
faQuestion = faQuestion;
|
||||
faEye = faEye;
|
||||
|
||||
isSaving = false;
|
||||
isSavingQuestion = false;
|
||||
|
||||
categoriasSharedCollection: ICategoria[] = [];
|
||||
usuarioExtrasSharedCollection: IUsuarioExtra[] = [];
|
||||
|
||||
editForm = this.fb.group({
|
||||
id: [],
|
||||
nombre: [null, [Validators.minLength(1), Validators.maxLength(50)]],
|
||||
descripcion: [],
|
||||
fechaCreacion: [null, [Validators.required]],
|
||||
fechaPublicacionTienda: [],
|
||||
estado: [null, [Validators.required]],
|
||||
precio: [null, [Validators.required]],
|
||||
categoria: [],
|
||||
nombre: [null, [Validators.required, Validators.minLength(1), Validators.maxLength(500)]],
|
||||
});
|
||||
|
||||
editFormQuestion = this.fb.group({
|
||||
id: [],
|
||||
nombre: [null, [Validators.required, Validators.minLength(1), Validators.maxLength(500)]],
|
||||
tipo: [PreguntaCerradaTipo.SINGLE],
|
||||
opcional: [false],
|
||||
tipopregunta: ['CLOSED'],
|
||||
});
|
||||
|
||||
pPreguntas?: any[];
|
||||
pPreguntasOpciones?: any[];
|
||||
plantilla: Plantilla | null = null;
|
||||
parametrosAplicacion?: IParametroAplicacion | null = null;
|
||||
|
||||
isLoading = false;
|
||||
|
||||
createAnother: Boolean = false;
|
||||
createAnotherQuestion: Boolean = false;
|
||||
selectedQuestionToCreateOption: IPPreguntaCerrada | null = null;
|
||||
|
||||
constructor(
|
||||
protected plantillaService: PlantillaService,
|
||||
protected categoriaService: CategoriaService,
|
||||
protected usuarioExtraService: UsuarioExtraService,
|
||||
protected activatedRoute: ActivatedRoute,
|
||||
protected fb: FormBuilder
|
||||
protected fb: FormBuilder,
|
||||
protected modalService: NgbModal,
|
||||
protected pPreguntaCerradaService: PPreguntaCerradaService,
|
||||
protected pPreguntaCerradaOpcionService: PPreguntaCerradaOpcionService,
|
||||
protected parametroAplicacionService: ParametroAplicacionService,
|
||||
protected pPreguntaAbiertaService: PPreguntaAbiertaService,
|
||||
protected router: Router
|
||||
) {}
|
||||
|
||||
loadAll(): void {
|
||||
this.isLoading = true;
|
||||
|
||||
this.plantillaService.findQuestions(this.plantilla?.id!).subscribe(
|
||||
(res: any) => {
|
||||
this.isLoading = false;
|
||||
this.pPreguntas = res.body ?? [];
|
||||
},
|
||||
() => {
|
||||
this.isLoading = false;
|
||||
}
|
||||
);
|
||||
|
||||
this.plantillaService.findQuestionsOptions(this.plantilla?.id!).subscribe(
|
||||
(res: any) => {
|
||||
this.isLoading = false;
|
||||
this.pPreguntasOpciones = res.body ?? [];
|
||||
},
|
||||
() => {
|
||||
this.isLoading = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async loadAplicationParameters(): Promise<void> {
|
||||
const params = await this.parametroAplicacionService.find(1).toPromise();
|
||||
this.parametrosAplicacion = params.body;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.activatedRoute.data.subscribe(({ plantilla }) => {
|
||||
if (plantilla.id === undefined) {
|
||||
const today = dayjs().startOf('day');
|
||||
plantilla.fechaCreacion = today;
|
||||
plantilla.fechaPublicacionTienda = today;
|
||||
plantilla.fechaPublicacion = today;
|
||||
plantilla.fechaFinalizar = today;
|
||||
plantilla.fechaFinalizada = today;
|
||||
} else {
|
||||
this.plantilla = plantilla;
|
||||
this.loadAll();
|
||||
this.loadAplicationParameters();
|
||||
}
|
||||
|
||||
this.updateForm(plantilla);
|
||||
// this.updateForm(plantilla);
|
||||
|
||||
this.loadRelationshipsOptions();
|
||||
// this.loadRelationshipsOptions();
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewChecked(): void {
|
||||
// this.initListeners();
|
||||
}
|
||||
|
||||
trackId(index: number, item: IPPreguntaCerrada): number {
|
||||
return item.id!;
|
||||
}
|
||||
|
||||
delete(pPreguntaCerrada: IPPreguntaCerrada): void {
|
||||
const modalRef = this.modalService.open(PPreguntaCerradaDeleteDialogComponent, { size: 'lg', backdrop: 'static' });
|
||||
modalRef.componentInstance.pPreguntaCerrada = pPreguntaCerrada;
|
||||
// unsubscribe not needed because closed completes on modal close
|
||||
modalRef.closed.subscribe(reason => {
|
||||
if (reason === 'deleted') {
|
||||
this.loadAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// initListeners(): void {
|
||||
// const checkboxes = document.getElementsByClassName('ds-survey--checkbox');
|
||||
// for (let i = 0; i < checkboxes.length; i++) {
|
||||
// checkboxes[i].addEventListener('click', e => {
|
||||
// if ((e.target as HTMLInputElement).checked) {
|
||||
// (e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active');
|
||||
// } else {
|
||||
// (e.target as HTMLElement).offsetParent!.classList.remove('ds-survey--closed-option--active');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
previousState(): void {
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
save(): void {
|
||||
this.isSaving = true;
|
||||
const plantilla = this.createFromForm();
|
||||
if (plantilla.id !== undefined) {
|
||||
this.subscribeToSaveResponse(this.plantillaService.update(plantilla));
|
||||
} else {
|
||||
this.subscribeToSaveResponse(this.plantillaService.create(plantilla));
|
||||
publishSurvey(): void {}
|
||||
|
||||
finishSurvey(): void {}
|
||||
|
||||
addOption(event: any): void {}
|
||||
|
||||
openPreview() {
|
||||
const surveyId = this.plantilla?.id;
|
||||
this.router.navigate(['/plantilla', surveyId, 'preview']);
|
||||
}
|
||||
|
||||
resetForm(event: any): void {
|
||||
this.editForm.reset();
|
||||
if (event !== null) {
|
||||
const id = event.target.dataset.id;
|
||||
this.pPreguntaCerradaService.find(id).subscribe(e => {
|
||||
this.selectedQuestionToCreateOption = e.body;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
trackCategoriaById(index: number, item: ICategoria): number {
|
||||
deleteQuestion(event: any) {
|
||||
const modalRef = this.modalService.open(PlantillaDeleteQuestionDialogComponent, { size: 'lg', backdrop: 'static' });
|
||||
modalRef.closed.subscribe(reason => {
|
||||
if (reason === 'confirm') {
|
||||
const id = event.target.dataset.id;
|
||||
if (event.target.dataset.type) {
|
||||
// Delete closed question
|
||||
const questionElement = (event.target as HTMLElement).parentElement?.parentElement;
|
||||
const optionIdsToDelete: number[] = [];
|
||||
|
||||
// Get options IDs
|
||||
questionElement?.childNodes.forEach((e, i) => {
|
||||
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.pPreguntaCerradaService.delete(id).subscribe(e => {
|
||||
this.loadAll();
|
||||
});
|
||||
} else {
|
||||
// Delete question options
|
||||
this.pPreguntaCerradaOpcionService.deleteMany(optionIdsToDelete).subscribe(e => {
|
||||
// Delete question
|
||||
this.pPreguntaCerradaService.delete(id).subscribe(e => {
|
||||
this.loadAll();
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Delete open question
|
||||
this.pPreguntaAbiertaService.delete(id).subscribe(e => {
|
||||
this.loadAll();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deleteOption(event: any): void {
|
||||
const modalRef = this.modalService.open(PlantillaDeleteOptionDialogComponent, { size: 'lg', backdrop: 'static' });
|
||||
modalRef.closed.subscribe(reason => {
|
||||
if (reason === 'confirm') {
|
||||
const id = event.target.dataset.optionid;
|
||||
this.pPreguntaCerradaOpcionService.delete(id).subscribe(e => {
|
||||
this.pPreguntas = [];
|
||||
this.pPreguntasOpciones = [];
|
||||
this.loadAll();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
save(): void {
|
||||
this.isSaving = true;
|
||||
const pPreguntaCerradaOpcion = this.createFromForm();
|
||||
if (pPreguntaCerradaOpcion.id !== undefined) {
|
||||
this.subscribeToSaveResponse(this.pPreguntaCerradaOpcionService.update(pPreguntaCerradaOpcion));
|
||||
} else {
|
||||
this.subscribeToSaveResponse(
|
||||
this.pPreguntaCerradaOpcionService.create(pPreguntaCerradaOpcion, this.selectedQuestionToCreateOption?.id!)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
trackPPreguntaCerradaById(index: number, item: IPPreguntaCerrada): number {
|
||||
return item.id!;
|
||||
}
|
||||
|
||||
protected subscribeToSaveResponse(result: Observable<HttpResponse<IPlantilla>>): void {
|
||||
protected subscribeToSaveResponse(result: Observable<HttpResponse<IPPreguntaCerradaOpcion>>): void {
|
||||
result.pipe(finalize(() => this.onSaveFinalize())).subscribe(
|
||||
() => this.onSaveSuccess(),
|
||||
() => this.onSaveError()
|
||||
|
@ -80,7 +276,14 @@ export class PlantillaUpdateComponent implements OnInit {
|
|||
}
|
||||
|
||||
protected onSaveSuccess(): void {
|
||||
this.previousState();
|
||||
// this.previousState();
|
||||
this.resetForm(null);
|
||||
this.pPreguntas = [];
|
||||
this.pPreguntasOpciones = [];
|
||||
this.loadAll();
|
||||
if (!this.createAnother) {
|
||||
$('#cancelBtn').click();
|
||||
}
|
||||
}
|
||||
|
||||
protected onSaveError(): void {
|
||||
|
@ -91,51 +294,159 @@ export class PlantillaUpdateComponent implements OnInit {
|
|||
this.isSaving = false;
|
||||
}
|
||||
|
||||
protected updateForm(plantilla: IPlantilla): void {
|
||||
this.editForm.patchValue({
|
||||
id: plantilla.id,
|
||||
nombre: plantilla.nombre,
|
||||
descripcion: plantilla.descripcion,
|
||||
fechaCreacion: plantilla.fechaCreacion ? plantilla.fechaCreacion.format(DATE_TIME_FORMAT) : null,
|
||||
fechaPublicacionTienda: plantilla.fechaPublicacionTienda ? plantilla.fechaPublicacionTienda.format(DATE_TIME_FORMAT) : null,
|
||||
estado: plantilla.estado,
|
||||
precio: plantilla.precio,
|
||||
categoria: plantilla.categoria,
|
||||
});
|
||||
protected createFromForm(): IPPreguntaCerradaOpcion {
|
||||
return {
|
||||
...new PPreguntaCerradaOpcion(),
|
||||
id: undefined,
|
||||
nombre: this.editForm.get(['nombre'])!.value,
|
||||
orden: 10,
|
||||
pPreguntaCerrada: this.selectedQuestionToCreateOption,
|
||||
};
|
||||
}
|
||||
|
||||
this.categoriasSharedCollection = this.categoriaService.addCategoriaToCollectionIfMissing(
|
||||
this.categoriasSharedCollection,
|
||||
plantilla.categoria
|
||||
createAnotherChange(event: any) {
|
||||
this.createAnother = event.target.checked;
|
||||
}
|
||||
|
||||
createQuestion(): void {
|
||||
const surveyId = this.plantilla?.id;
|
||||
}
|
||||
|
||||
protected createFromFormClosedQuestion(): IPPreguntaCerrada {
|
||||
return {
|
||||
// ...new PPreguntaCerrada(),
|
||||
id: undefined,
|
||||
nombre: this.editFormQuestion.get(['nombre'])!.value,
|
||||
tipo: this.editFormQuestion.get(['tipo'])!.value,
|
||||
opcional: this.editFormQuestion.get(['opcional'])!.value,
|
||||
orden: 10,
|
||||
plantilla: this.plantilla,
|
||||
};
|
||||
}
|
||||
|
||||
protected createFromFormOpenQuestion(): IPPreguntaAbierta {
|
||||
return {
|
||||
// ...new PPreguntaAbierta(),
|
||||
id: undefined,
|
||||
nombre: this.editFormQuestion.get(['nombre'])!.value,
|
||||
opcional: this.editFormQuestion.get(['opcional'])!.value,
|
||||
orden: 10,
|
||||
plantilla: this.plantilla,
|
||||
};
|
||||
}
|
||||
|
||||
createAnotherQuestionChange(event: any) {
|
||||
this.createAnotherQuestion = event.target.checked;
|
||||
}
|
||||
|
||||
saveQuestion(): void {
|
||||
this.isSavingQuestion = true;
|
||||
const tipoPregunta = this.editFormQuestion.get(['tipopregunta'])!.value;
|
||||
|
||||
if (tipoPregunta === 'CLOSED') {
|
||||
const pPreguntaCerrada = this.createFromFormClosedQuestion();
|
||||
if (pPreguntaCerrada.id !== undefined) {
|
||||
this.subscribeToSaveResponseQuestionClosed(this.pPreguntaCerradaService.update(pPreguntaCerrada));
|
||||
} else {
|
||||
this.subscribeToSaveResponseQuestionClosed(this.pPreguntaCerradaService.create(pPreguntaCerrada));
|
||||
}
|
||||
} else if (tipoPregunta === 'OPEN') {
|
||||
const pPreguntaAbierta = this.createFromFormOpenQuestion();
|
||||
if (pPreguntaAbierta.id !== undefined) {
|
||||
this.subscribeToSaveResponseQuestionOpen(this.pPreguntaAbiertaService.update(pPreguntaAbierta));
|
||||
} else {
|
||||
this.subscribeToSaveResponseQuestionOpen(this.pPreguntaAbiertaService.create(pPreguntaAbierta));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected subscribeToSaveResponseQuestionClosed(result: Observable<HttpResponse<IPPreguntaCerrada>>): void {
|
||||
result.pipe(finalize(() => this.onSaveFinalizeQuestion())).subscribe(
|
||||
() => this.onSaveSuccessQuestion(),
|
||||
() => this.onSaveErrorQuestion()
|
||||
);
|
||||
}
|
||||
|
||||
protected loadRelationshipsOptions(): void {
|
||||
this.categoriaService
|
||||
.query()
|
||||
.pipe(map((res: HttpResponse<ICategoria[]>) => res.body ?? []))
|
||||
.pipe(
|
||||
map((categorias: ICategoria[]) =>
|
||||
this.categoriaService.addCategoriaToCollectionIfMissing(categorias, this.editForm.get('categoria')!.value)
|
||||
)
|
||||
)
|
||||
.subscribe((categorias: ICategoria[]) => (this.categoriasSharedCollection = categorias));
|
||||
protected subscribeToSaveResponseQuestionOpen(result: Observable<HttpResponse<IPPreguntaAbierta>>): void {
|
||||
result.pipe(finalize(() => this.onSaveFinalizeQuestion())).subscribe(
|
||||
() => this.onSaveSuccessQuestion(),
|
||||
() => this.onSaveErrorQuestion()
|
||||
);
|
||||
}
|
||||
|
||||
protected createFromForm(): IPlantilla {
|
||||
return {
|
||||
...new Plantilla(),
|
||||
id: this.editForm.get(['id'])!.value,
|
||||
nombre: this.editForm.get(['nombre'])!.value,
|
||||
descripcion: this.editForm.get(['descripcion'])!.value,
|
||||
fechaCreacion: this.editForm.get(['fechaCreacion'])!.value
|
||||
? dayjs(this.editForm.get(['fechaCreacion'])!.value, DATE_TIME_FORMAT)
|
||||
: undefined,
|
||||
fechaPublicacionTienda: this.editForm.get(['fechaPublicacionTienda'])!.value
|
||||
? dayjs(this.editForm.get(['fechaPublicacionTienda'])!.value, DATE_TIME_FORMAT)
|
||||
: undefined,
|
||||
estado: this.editForm.get(['estado'])!.value,
|
||||
precio: this.editForm.get(['precio'])!.value,
|
||||
categoria: this.editForm.get(['categoria'])!.value,
|
||||
};
|
||||
protected onSaveSuccessQuestion(): void {
|
||||
this.editFormQuestion.reset({ tipo: PreguntaCerradaTipo.SINGLE, tipopregunta: 'CLOSED', opcional: false });
|
||||
this.editForm.reset();
|
||||
this.pPreguntas = [];
|
||||
this.pPreguntasOpciones = [];
|
||||
this.loadAll();
|
||||
if (!this.createAnotherQuestion) {
|
||||
$('#cancelBtnQuestion').click();
|
||||
}
|
||||
}
|
||||
|
||||
protected onSaveErrorQuestion(): void {
|
||||
// Api for inheritance.
|
||||
}
|
||||
|
||||
protected onSaveFinalizeQuestion(): void {
|
||||
this.isSavingQuestion = false;
|
||||
}
|
||||
|
||||
updateTemplateName(event: any) {
|
||||
const updatedSurveyName = event.target.innerText;
|
||||
if (updatedSurveyName !== this.plantilla?.nombre) {
|
||||
const survey = { ...this.plantilla };
|
||||
survey.nombre = updatedSurveyName;
|
||||
|
||||
this.plantillaService.update(survey).subscribe(res => {});
|
||||
}
|
||||
}
|
||||
|
||||
updateQuestionName(event: any): void {
|
||||
const questionType = event.target.dataset.tipo;
|
||||
const questionId = event.target.dataset.id;
|
||||
const questionName = event.target.innerText;
|
||||
if (questionType) {
|
||||
// Closed question
|
||||
this.pPreguntaCerradaService.find(questionId).subscribe(res => {
|
||||
const pPreguntaCerrada: PPreguntaCerrada | null = res.body ?? null;
|
||||
const updatedPPreguntaCerrada = { ...pPreguntaCerrada };
|
||||
if (questionName !== pPreguntaCerrada?.nombre && pPreguntaCerrada !== null) {
|
||||
updatedPPreguntaCerrada.nombre = questionName;
|
||||
this.pPreguntaCerradaService.update(updatedPPreguntaCerrada).subscribe(updatedQuestion => {
|
||||
console.log(updatedQuestion);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Open question
|
||||
// Closed question
|
||||
this.pPreguntaAbiertaService.find(questionId).subscribe(res => {
|
||||
const pPreguntaAbierta: PPreguntaAbierta | null = res.body ?? null;
|
||||
const updatedPPreguntaAbierta = { ...pPreguntaAbierta };
|
||||
if (questionName !== pPreguntaAbierta?.nombre && pPreguntaAbierta !== null) {
|
||||
updatedPPreguntaAbierta.nombre = questionName;
|
||||
this.pPreguntaAbiertaService.update(updatedPPreguntaAbierta).subscribe(updatedQuestion => {
|
||||
console.log(updatedQuestion);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// const questionId = event.target.dataset.id;
|
||||
// const survey = { ...this.plantilla };
|
||||
// survey.nombre = updatedQuestionName;
|
||||
// // Prevent user update by setting to null
|
||||
// survey.usuarioExtra!.user = null;
|
||||
|
||||
// this.plantillaService.updateSurvey(survey).subscribe(res => {});
|
||||
}
|
||||
|
||||
trackCategoriaById(index: number, item: ICategoria): number {
|
||||
return item.id!;
|
||||
}
|
||||
|
||||
trackUsuarioExtraById(index: number, item: IUsuarioExtra): number {
|
||||
return item.id!;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
<form *ngIf="usuarioEncuesta" name="deleteForm" (ngSubmit)="confirmDelete(usuarioEncuesta.id!)">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" data-cy="usuarioEncuestaDeleteDialogHeading" jhiTranslate="entity.delete.title">Confirm delete operation</h4>
|
||||
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="cancel()">×</button>
|
||||
</div>
|
||||
|
||||
<form class="ds-form" *ngIf="usuarioEncuesta" name="deleteForm" (ngSubmit)="confirmDelete(usuarioEncuesta.id!)">
|
||||
<div class="modal-body">
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
|
||||
<p class="ds-title--small">Salir de colaboración</p>
|
||||
<p
|
||||
class="ds-subtitle"
|
||||
id="jhi-delete-usuarioEncuesta-heading"
|
||||
jhiTranslate="dataSurveyApp.usuarioEncuesta.delete.question"
|
||||
jhiTranslate="dataSurveyApp.usuarioEncuesta.delete.questionGetOut"
|
||||
[translateValues]="{ id: usuarioEncuesta.id }"
|
||||
>
|
||||
Are you sure you want to delete this Usuario Encuesta?
|
||||
|
@ -18,12 +12,12 @@
|
|||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="cancel()">
|
||||
<fa-icon icon="ban"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||
<button type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal" (click)="cancel()">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||
</button>
|
||||
|
||||
<button id="jhi-confirm-delete-usuarioEncuesta" data-cy="entityConfirmDeleteButton" type="submit" class="btn btn-danger">
|
||||
<fa-icon icon="times"></fa-icon> <span jhiTranslate="entity.action.delete">Delete</span>
|
||||
<fa-icon icon="sign-out-alt"></fa-icon> <span jhiTranslate="dataSurveyApp.usuarioEncuesta.delete.getOut">Get Out</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -1,29 +1,38 @@
|
|||
<div>
|
||||
<h2 id="page-heading" data-cy="UsuarioEncuestaHeading">
|
||||
<span jhiTranslate="dataSurveyApp.usuarioEncuesta.home.title">Usuario Encuestas</span>
|
||||
<span class="ds-title" jhiTranslate="dataSurveyApp.usuarioEncuesta.home.title">Colaboraciones </span>
|
||||
<p class="ds-subtitle">Gestione las colaboraciones en encuestas a las que se encuentra agregado</p>
|
||||
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="btn btn-info mr-2" (click)="loadAll()" [disabled]="isLoading">
|
||||
<button class="ds-btn ds-btn--secondary mr-2" (click)="loadAll()" [disabled]="isLoading">
|
||||
<fa-icon icon="sync" [spin]="isLoading"></fa-icon>
|
||||
<span jhiTranslate="dataSurveyApp.usuarioEncuesta.home.refreshListLabel">Refresh List</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="jh-create-entity"
|
||||
data-cy="entityCreateButton"
|
||||
class="btn btn-primary jh-create-entity create-usuario-encuesta"
|
||||
[routerLink]="['/usuario-encuesta/new']"
|
||||
>
|
||||
<fa-icon icon="plus"></fa-icon>
|
||||
<span jhiTranslate="dataSurveyApp.usuarioEncuesta.home.createLabel"> Create a new Usuario Encuesta </span>
|
||||
</button>
|
||||
</div>
|
||||
</h2>
|
||||
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
|
||||
<jhi-alert></jhi-alert>
|
||||
|
||||
<form class="ds-form">
|
||||
<div class="input-group">
|
||||
<div class="ds-filter">
|
||||
<div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
|
||||
<select name="searchRol" id="searchRol" [(ngModel)]="searchRol" style="width: 200px">
|
||||
<option value="" selected="selected" disabled="disabled">Filtrar por rol</option>
|
||||
<option value="">Todos los roles</option>
|
||||
<option value="Read">Lector</option>
|
||||
<option value="Write">Escritor</option>
|
||||
</select>
|
||||
<select name="searchRol" id="searchEstado" [(ngModel)]="searchEstado" style="width: 200px">
|
||||
<option value="" selected="selected" disabled="disabled">Filtrar por estado</option>
|
||||
<option value="">Todos los estados</option>
|
||||
<option value="ACTIVE">Activos</option>
|
||||
<option value="PENDING">Pendientes</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="alert alert-warning" id="no-result" *ngIf="usuarioEncuestas?.length === 0">
|
||||
<span jhiTranslate="dataSurveyApp.usuarioEncuesta.home.notFound">No usuarioEncuestas found</span>
|
||||
</div>
|
||||
|
@ -32,58 +41,39 @@
|
|||
<table class="table table-striped" aria-describedby="page-heading">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><span jhiTranslate="global.field.id">ID</span></th>
|
||||
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.rol">Rol</span></th>
|
||||
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.estado">Estado</span></th>
|
||||
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.fechaAgregado">Fecha Agregado</span></th>
|
||||
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.usuarioExtra">Usuario Extra</span></th>
|
||||
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.encuesta">Encuesta</span></th>
|
||||
<th scope="col"><span>Encuesta</span></th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let usuarioEncuesta of usuarioEncuestas; trackBy: trackId" data-cy="entityTable">
|
||||
<td>
|
||||
<a [routerLink]="['/usuario-encuesta', usuarioEncuesta.id, 'view']">{{ usuarioEncuesta.id }}</a>
|
||||
</td>
|
||||
<tr
|
||||
*ngFor="let usuarioEncuesta of usuarioEncuestas | filter: 'rol':searchRol | filter: 'estado':searchEstado; trackBy: trackId"
|
||||
data-cy="entityTable"
|
||||
>
|
||||
<td jhiTranslate="{{ 'dataSurveyApp.RolColaborador.' + usuarioEncuesta.rol }}">{{ usuarioEncuesta.rol }}</td>
|
||||
<td jhiTranslate="{{ 'dataSurveyApp.EstadoColaborador.' + usuarioEncuesta.estado }}">{{ usuarioEncuesta.estado }}</td>
|
||||
<td>{{ usuarioEncuesta.fechaAgregado | formatMediumDatetime }}</td>
|
||||
<td>
|
||||
<div *ngIf="usuarioEncuesta.usuarioExtra">
|
||||
<a [routerLink]="['/usuario-extra', usuarioEncuesta.usuarioExtra?.id, 'view']">{{ usuarioEncuesta.usuarioExtra?.id }}</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ usuarioEncuesta.fechaAgregado | formatShortDatetime | titlecase }}</td>
|
||||
<td>
|
||||
<div *ngIf="usuarioEncuesta.encuesta">
|
||||
<a [routerLink]="['/encuesta', usuarioEncuesta.encuesta?.id, 'view']">{{ usuarioEncuesta.encuesta?.id }}</a>
|
||||
<a>{{ usuarioEncuesta.encuesta?.nombre }} (#{{ usuarioEncuesta.encuesta?.id }})</a>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div class="btn-group">
|
||||
<div class="btn-group" *ngIf="usuarioEncuesta.encuesta">
|
||||
<button
|
||||
type="submit"
|
||||
[routerLink]="['/usuario-encuesta', usuarioEncuesta.id, 'view']"
|
||||
class="btn btn-info btn-sm"
|
||||
data-cy="entityDetailsButton"
|
||||
type="button"
|
||||
[routerLink]="['/encuesta', usuarioEncuesta.encuesta.id, 'edit']"
|
||||
class="ds-btn ds-btn--primary"
|
||||
[disabled]="isLoading"
|
||||
>
|
||||
<fa-icon icon="eye"></fa-icon>
|
||||
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
|
||||
<span>Editar encuesta</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
[routerLink]="['/usuario-encuesta', usuarioEncuesta.id, 'edit']"
|
||||
class="btn btn-primary btn-sm"
|
||||
data-cy="entityEditButton"
|
||||
>
|
||||
<fa-icon icon="pencil-alt"></fa-icon>
|
||||
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
|
||||
</button>
|
||||
|
||||
<button type="submit" (click)="delete(usuarioEncuesta)" class="btn btn-danger btn-sm" data-cy="entityDeleteButton">
|
||||
<fa-icon icon="times"></fa-icon>
|
||||
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>
|
||||
<button type="submit" (click)="delete(usuarioEncuesta)" class="ds-btn ds-btn--danger btn-sm" data-cy="entityDeleteButton">
|
||||
<fa-icon icon="sign-out-alt"></fa-icon>
|
||||
<span class="d-none d-md-inline" jhiTranslate="dataSurveyApp.usuarioEncuesta.delete.getOut">Get Out</span>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
@ -5,16 +5,43 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
|||
import { IUsuarioEncuesta } from '../usuario-encuesta.model';
|
||||
import { UsuarioEncuestaService } from '../service/usuario-encuesta.service';
|
||||
import { UsuarioEncuestaDeleteDialogComponent } from '../delete/usuario-encuesta-delete-dialog.component';
|
||||
import * as dayjs from 'dayjs';
|
||||
import { faPollH, faPencilAlt } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
import { AccountService } from 'app/core/auth/account.service';
|
||||
import { Account } from 'app/core/auth/account.model';
|
||||
import { IUsuarioExtra, UsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model';
|
||||
import { IUser } from '../../user/user.model';
|
||||
import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario-extra.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-usuario-encuesta',
|
||||
templateUrl: './usuario-encuesta.component.html',
|
||||
})
|
||||
export class UsuarioEncuestaComponent implements OnInit {
|
||||
faPollH = faPollH;
|
||||
faPencilAlt = faPencilAlt;
|
||||
|
||||
usuarioEncuestas?: IUsuarioEncuesta[];
|
||||
isLoading = false;
|
||||
usuarioExtra: IUsuarioExtra | null = null;
|
||||
user: IUser | null = null;
|
||||
|
||||
constructor(protected usuarioEncuestaService: UsuarioEncuestaService, protected modalService: NgbModal) {}
|
||||
public searchRol: string;
|
||||
public searchEstado: string;
|
||||
|
||||
constructor(
|
||||
protected usuarioEncuestaService: UsuarioEncuestaService,
|
||||
protected modalService: NgbModal,
|
||||
protected usuarioExtraService: UsuarioExtraService,
|
||||
protected activatedRoute: ActivatedRoute,
|
||||
protected accountService: AccountService,
|
||||
protected router: Router
|
||||
) {
|
||||
this.searchRol = '';
|
||||
this.searchEstado = '';
|
||||
}
|
||||
|
||||
loadAll(): void {
|
||||
this.isLoading = true;
|
||||
|
@ -22,7 +49,10 @@ export class UsuarioEncuestaComponent implements OnInit {
|
|||
this.usuarioEncuestaService.query().subscribe(
|
||||
(res: HttpResponse<IUsuarioEncuesta[]>) => {
|
||||
this.isLoading = false;
|
||||
this.usuarioEncuestas = res.body ?? [];
|
||||
const tempUsuarioEncuestas = res.body ?? [];
|
||||
this.usuarioEncuestas = tempUsuarioEncuestas
|
||||
.filter(c => c.usuarioExtra?.id === this.usuarioExtra?.id)
|
||||
.filter(c => c.encuesta?.estado !== 'DELETED');
|
||||
},
|
||||
() => {
|
||||
this.isLoading = false;
|
||||
|
@ -31,7 +61,22 @@ export class UsuarioEncuestaComponent implements OnInit {
|
|||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadAll();
|
||||
this.searchRol = '';
|
||||
this.searchEstado = '';
|
||||
this.accountService.getAuthenticationState().subscribe(account => {
|
||||
if (account !== null) {
|
||||
this.usuarioExtraService.find(account.id).subscribe(usuarioExtra => {
|
||||
this.usuarioExtra = usuarioExtra.body;
|
||||
this.loadAll();
|
||||
if (this.usuarioExtra !== null) {
|
||||
if (this.usuarioExtra.id === undefined) {
|
||||
const today = dayjs().startOf('day');
|
||||
this.usuarioExtra.fechaNacimiento = today;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
trackId(index: number, item: IUsuarioEncuesta): number {
|
||||
|
|
|
@ -6,6 +6,9 @@ import { UsuarioEncuestaComponent } from '../list/usuario-encuesta.component';
|
|||
import { UsuarioEncuestaDetailComponent } from '../detail/usuario-encuesta-detail.component';
|
||||
import { UsuarioEncuestaUpdateComponent } from '../update/usuario-encuesta-update.component';
|
||||
import { UsuarioEncuestaRoutingResolveService } from './usuario-encuesta-routing-resolve.service';
|
||||
import { EncuestaDetailComponent } from '../../encuesta/detail/encuesta-detail.component';
|
||||
import { EncuestaUpdateComponent } from '../../encuesta/update/encuesta-update.component';
|
||||
import { EncuestaRoutingResolveService } from '../../encuesta/route/encuesta-routing-resolve.service';
|
||||
|
||||
const usuarioEncuestaRoute: Routes = [
|
||||
{
|
||||
|
@ -37,6 +40,22 @@ const usuarioEncuestaRoute: Routes = [
|
|||
},
|
||||
canActivate: [UserRouteAccessService],
|
||||
},
|
||||
{
|
||||
path: '/encuesta/:id/preview',
|
||||
component: EncuestaDetailComponent,
|
||||
resolve: {
|
||||
usuarioEncuesta: EncuestaRoutingResolveService,
|
||||
},
|
||||
canActivate: [UserRouteAccessService],
|
||||
},
|
||||
{
|
||||
path: '/encuesta/:id/edit',
|
||||
component: EncuestaUpdateComponent,
|
||||
resolve: {
|
||||
usuarioEncuesta: EncuestaRoutingResolveService,
|
||||
},
|
||||
canActivate: [UserRouteAccessService],
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
|
|
@ -76,10 +76,10 @@ export const USER_ROUTES: RouteInfo[] = [
|
|||
// type: 'link',
|
||||
// icontype: 'nc-icon nc-album-2',
|
||||
// },
|
||||
// {
|
||||
// path: '/colaboraciones',
|
||||
// title: 'Colaboraciones',
|
||||
// type: 'link',
|
||||
// icontype: 'nc-icon nc-world-2',
|
||||
// },
|
||||
{
|
||||
path: '/colaboraciones',
|
||||
title: 'Colaboraciones',
|
||||
type: 'link',
|
||||
icontype: 'nc-icon nc-world-2',
|
||||
},
|
||||
];
|
||||
|
|
|
@ -94,7 +94,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
|||
}
|
||||
},
|
||||
response => {
|
||||
debugger;
|
||||
if (response.status == 401 && response.error.detail == 'Bad credentials') {
|
||||
this.activateGoogle();
|
||||
} else {
|
||||
|
@ -109,7 +108,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
|||
}
|
||||
|
||||
processError(response: HttpErrorResponse): void {
|
||||
debugger;
|
||||
if (response.status === 400 && response.error.type === LOGIN_ALREADY_USED_TYPE) {
|
||||
this.errorUserExists = true;
|
||||
} else if (response.status === 400 && response.error.type === EMAIL_ALREADY_USED_TYPE) {
|
||||
|
@ -153,7 +151,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
|||
login(): void {
|
||||
this.error = false;
|
||||
this.userSuspended = false;
|
||||
debugger;
|
||||
this.loginService
|
||||
.login({
|
||||
username: this.loginForm.get('username')!.value,
|
||||
|
@ -162,9 +159,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
|||
})
|
||||
.subscribe(
|
||||
value => {
|
||||
debugger;
|
||||
console.log(value);
|
||||
|
||||
/*if (value?.activated == false){
|
||||
this.userSuspended = true;
|
||||
|
||||
|
@ -178,7 +172,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
|||
// }
|
||||
},
|
||||
response => {
|
||||
debugger;
|
||||
if (response.status == 401 && response.error.detail == 'Bad credentials') {
|
||||
this.error = true;
|
||||
} else {
|
||||
|
|
|
@ -12,7 +12,6 @@ export class LoginService {
|
|||
constructor(private accountService: AccountService, private authServerProvider: AuthServerProvider) {}
|
||||
|
||||
login(credentials: Login): Observable<Account | null> {
|
||||
debugger;
|
||||
return this.authServerProvider.login(credentials).pipe(mergeMap(() => this.accountService.identity(true)));
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
"deleted": "Un Colaborador ha sido expulsado de la encuesta",
|
||||
"delete": {
|
||||
"question": "¿Seguro que quiere expulsar al colaborador de la encuesta?",
|
||||
"action": "Expulsar"
|
||||
"action": "Expulsar",
|
||||
"questionGetOut": "¿Seguro que quiere salirse de la colaboracion de encuesta?",
|
||||
"getOut": "Salir"
|
||||
},
|
||||
"detail": {
|
||||
"title": "Colaborador"
|
||||
|
|
Loading…
Reference in New Issue