conflict fix

This commit is contained in:
Paola 2021-08-11 12:03:27 -06:00
commit bf83738055
107 changed files with 2618 additions and 144 deletions

8
package-lock.json generated
View File

@ -13103,6 +13103,14 @@
"opencollective-postinstall": "^2.0.2" "opencollective-postinstall": "^2.0.2"
} }
}, },
"ngx-paypal": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/ngx-paypal/-/ngx-paypal-8.0.0.tgz",
"integrity": "sha512-cmXpEb8Gfwwk/Yn43w0OsURpRXiXghgZ5MbVKBYsPdkAqVacoQtYiWLcNmmU/DYGoPN5lRVqZb+Svg6qbbOvTw==",
"requires": {
"tslib": "^2.2.0"
}
},
"ngx-sharebuttons": { "ngx-sharebuttons": {
"version": "8.0.5", "version": "8.0.5",
"resolved": "https://registry.npmjs.org/ngx-sharebuttons/-/ngx-sharebuttons-8.0.5.tgz", "resolved": "https://registry.npmjs.org/ngx-sharebuttons/-/ngx-sharebuttons-8.0.5.tgz",

View File

@ -90,6 +90,7 @@
"jquery": "^3.6.0", "jquery": "^3.6.0",
"jw-angular-social-buttons": "^1.0.0", "jw-angular-social-buttons": "^1.0.0",
"ngx-infinite-scroll": "10.0.1", "ngx-infinite-scroll": "10.0.1",
"ngx-paypal": "^8.0.0",
"ngx-sharebuttons": "^8.0.5", "ngx-sharebuttons": "^8.0.5",
"ngx-webstorage": "8.0.0", "ngx-webstorage": "8.0.0",
"rxjs": "6.6.7", "rxjs": "6.6.7",

View File

@ -318,6 +318,12 @@
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-messaging</artifactId> <artifactId>spring-security-messaging</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.0.0-2</version>
</dependency>
<!-- jhipster-needle-maven-add-dependency --> <!-- jhipster-needle-maven-add-dependency -->
</dependencies> </dependencies>

View File

@ -64,7 +64,7 @@ public class UsuarioExtra implements Serializable {
joinColumns = @JoinColumn(name = "usuario_extra_id"), joinColumns = @JoinColumn(name = "usuario_extra_id"),
inverseJoinColumns = @JoinColumn(name = "plantilla_id") inverseJoinColumns = @JoinColumn(name = "plantilla_id")
) )
@JsonIgnoreProperties(value = { "pPreguntaCerradas", "pPreguntaAbiertas", "categoria", "usuarioExtras" }, allowSetters = true) @JsonIgnoreProperties(value = { "pPreguntaCerradas", "pPreguntaAbiertas", "usuarioExtras" }, allowSetters = true)
private Set<Plantilla> plantillas = new HashSet<>(); private Set<Plantilla> plantillas = new HashSet<>();
// jhipster-needle-entity-add-field - JHipster will add fields here // jhipster-needle-entity-add-field - JHipster will add fields here

View File

@ -4,6 +4,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Locale; import java.util.Locale;
import javax.mail.MessagingException; import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import org.datasurvey.domain.Factura;
import org.datasurvey.domain.User; import org.datasurvey.domain.User;
import org.datasurvey.domain.UsuarioEncuesta; import org.datasurvey.domain.UsuarioEncuesta;
import org.datasurvey.domain.UsuarioExtra; import org.datasurvey.domain.UsuarioExtra;
@ -33,6 +34,8 @@ public class MailService {
private static final String CONTRASENNA = "contrasenna"; private static final String CONTRASENNA = "contrasenna";
private static final String FACTURA = "factura";
private static final String BASE_URL = "baseUrl"; private static final String BASE_URL = "baseUrl";
private final JHipsterProperties jHipsterProperties; private final JHipsterProperties jHipsterProperties;
@ -128,6 +131,22 @@ public class MailService {
sendEmail(user.getEmail(), subject, content, false, true); sendEmail(user.getEmail(), subject, content, false, true);
} }
@Async
public void sendEmailFromTemplateFactura(User user, Factura factura, String templateName, String titleKey) {
if (user.getEmail() == null) {
log.debug("Email doesn't exist for user '{}'", user.getLogin());
return;
}
Locale locale = Locale.forLanguageTag(user.getLangKey());
Context context = new Context(locale);
context.setVariable(USER, user);
context.setVariable(FACTURA, factura);
context.setVariable(BASE_URL, jHipsterProperties.getMail().getBaseUrl());
String content = templateEngine.process(templateName, context);
String subject = messageSource.getMessage(titleKey, null, locale);
sendEmail(user.getEmail(), subject, content, false, true);
}
@Async @Async
public void sendActivationEmail(User user) { public void sendActivationEmail(User user) {
log.debug("Sending activation email to '{}'", user.getEmail()); log.debug("Sending activation email to '{}'", user.getEmail());
@ -203,4 +222,10 @@ public class MailService {
"email.deleteColaborator.title" "email.deleteColaborator.title"
); );
} }
@Async
public void sendReceiptUser(UsuarioExtra user, Factura factura) {
log.debug("Sending paypal receipt mail to '{}'", user.getUser().getEmail());
sendEmailFromTemplateFactura(user.getUser(), factura, "mail/facturaPayPalEmail", "email.receipt.title");
}
} }

View File

@ -80,6 +80,14 @@ public class EPreguntaCerradaOpcionResource {
.body(result); .body(result);
} }
@PostMapping("/e-pregunta-cerrada-opcions/count/{id}")
public ResponseEntity<EPreguntaCerradaOpcion> updateOpcionCount(@PathVariable(value = "id", required = true) final Long id) {
EPreguntaCerradaOpcion updatedOpcion = getEPreguntaCerradaOpcion(id).getBody();
int cantidad = updatedOpcion.getCantidad();
updatedOpcion.setCantidad(cantidad += 1);
return ResponseEntity.ok(updatedOpcion);
}
/** /**
* {@code PUT /e-pregunta-cerrada-opcions/:id} : Updates an existing ePreguntaCerradaOpcion. * {@code PUT /e-pregunta-cerrada-opcions/:id} : Updates an existing ePreguntaCerradaOpcion.
* *

View File

@ -11,10 +11,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.datasurvey.domain.EPreguntaAbierta; import org.datasurvey.domain.*;
import org.datasurvey.domain.EPreguntaCerrada;
import org.datasurvey.domain.EPreguntaCerradaOpcion;
import org.datasurvey.domain.Encuesta;
import org.datasurvey.domain.enumeration.AccesoEncuesta; import org.datasurvey.domain.enumeration.AccesoEncuesta;
import org.datasurvey.repository.EncuestaRepository; import org.datasurvey.repository.EncuestaRepository;
import org.datasurvey.service.*; import org.datasurvey.service.*;
@ -59,6 +56,14 @@ public class EncuestaResource {
private final EPreguntaCerradaOpcionService ePreguntaCerradaOpcionService; private final EPreguntaCerradaOpcionService ePreguntaCerradaOpcionService;
private final PlantillaService plantillaService;
private final PPreguntaCerradaService pPreguntaCerradaService;
private final PPreguntaAbiertaService pPreguntaAbiertaService;
private final PPreguntaCerradaOpcionService pPreguntaCerradaOpcionService;
public EncuestaResource( public EncuestaResource(
EncuestaService encuestaService, EncuestaService encuestaService,
EncuestaRepository encuestaRepository, EncuestaRepository encuestaRepository,
@ -66,7 +71,11 @@ public class EncuestaResource {
MailService mailService, MailService mailService,
EPreguntaCerradaService ePreguntaCerradaService, EPreguntaCerradaService ePreguntaCerradaService,
EPreguntaAbiertaService ePreguntaAbiertaService, EPreguntaAbiertaService ePreguntaAbiertaService,
EPreguntaCerradaOpcionService ePreguntaCerradaOpcionService EPreguntaCerradaOpcionService ePreguntaCerradaOpcionService,
PlantillaService plantillaService,
PPreguntaCerradaService pPreguntaCerradaService,
PPreguntaAbiertaService pPreguntaAbiertaService,
PPreguntaCerradaOpcionService pPreguntaCerradaOpcionService
) { ) {
this.encuestaService = encuestaService; this.encuestaService = encuestaService;
this.encuestaRepository = encuestaRepository; this.encuestaRepository = encuestaRepository;
@ -75,6 +84,10 @@ public class EncuestaResource {
this.ePreguntaCerradaService = ePreguntaCerradaService; this.ePreguntaCerradaService = ePreguntaCerradaService;
this.ePreguntaAbiertaService = ePreguntaAbiertaService; this.ePreguntaAbiertaService = ePreguntaAbiertaService;
this.ePreguntaCerradaOpcionService = ePreguntaCerradaOpcionService; this.ePreguntaCerradaOpcionService = ePreguntaCerradaOpcionService;
this.plantillaService = plantillaService;
this.pPreguntaCerradaService = pPreguntaCerradaService;
this.pPreguntaAbiertaService = pPreguntaAbiertaService;
this.pPreguntaCerradaOpcionService = pPreguntaCerradaOpcionService;
} }
/** /**
@ -97,6 +110,78 @@ public class EncuestaResource {
.body(result); .body(result);
} }
@PostMapping("/encuestas/{plantillaId}")
public ResponseEntity<Encuesta> createEncuestaFromTemplate(
@Valid @RequestBody Encuesta encuesta,
@PathVariable(value = "plantillaId", required = false) final Long plantillaId
) throws URISyntaxException {
log.debug("REST request to save Encuesta : {}", encuesta);
if (encuesta.getId() != null) {
throw new BadRequestAlertException("A new encuesta cannot already have an ID", ENTITY_NAME, "idexists");
}
// Copy from survey template to survey
Optional<Plantilla> plantilla = plantillaService.findOne(plantillaId);
if (plantilla.isPresent()) {
encuesta.setNombre(plantilla.get().getNombre());
encuesta.setDescripcion(plantilla.get().getDescripcion());
encuesta.setCategoria(plantilla.get().getCategoria());
Encuesta encuestaCreated = encuestaService.save(encuesta);
// Preguntas cerradas
List<PPreguntaCerrada> preguntasCerradas = pPreguntaCerradaService.findAll();
for (PPreguntaCerrada pPreguntaCerrada : preguntasCerradas) {
if (pPreguntaCerrada.getPlantilla().getId().equals(plantillaId)) {
EPreguntaCerrada newEPreguntaCerrada = new EPreguntaCerrada();
newEPreguntaCerrada.setNombre(pPreguntaCerrada.getNombre());
newEPreguntaCerrada.setTipo(pPreguntaCerrada.getTipo());
newEPreguntaCerrada.setOpcional(pPreguntaCerrada.getOpcional());
newEPreguntaCerrada.setOrden(pPreguntaCerrada.getOrden());
newEPreguntaCerrada.setEncuesta(encuestaCreated);
ePreguntaCerradaService.save(newEPreguntaCerrada);
// Opciones de preguntas cerradas
List<PPreguntaCerradaOpcion> opciones = pPreguntaCerradaOpcionService.findAll();
for (PPreguntaCerradaOpcion pPreguntaCerradaOpcion : opciones) {
if (pPreguntaCerradaOpcion.getPPreguntaCerrada().getId().equals(pPreguntaCerrada.getId())) {
EPreguntaCerradaOpcion newEPreguntaCerradaOpcion = new EPreguntaCerradaOpcion();
newEPreguntaCerradaOpcion.setNombre(pPreguntaCerradaOpcion.getNombre());
newEPreguntaCerradaOpcion.setOrden(pPreguntaCerradaOpcion.getOrden());
newEPreguntaCerradaOpcion.setCantidad(0);
newEPreguntaCerradaOpcion.setEPreguntaCerrada(newEPreguntaCerrada);
ePreguntaCerradaOpcionService.save(newEPreguntaCerradaOpcion);
}
}
}
}
// Preguntas abiertas
List<PPreguntaAbierta> preguntasAbiertas = pPreguntaAbiertaService.findAll();
for (PPreguntaAbierta pPreguntaAbierta : preguntasAbiertas) {
if (pPreguntaAbierta.getPlantilla().getId().equals(plantillaId)) {
EPreguntaAbierta newEPreguntaAbierta = new EPreguntaAbierta();
newEPreguntaAbierta.setNombre(pPreguntaAbierta.getNombre());
newEPreguntaAbierta.setOpcional(pPreguntaAbierta.getOpcional());
newEPreguntaAbierta.setOrden(pPreguntaAbierta.getOrden());
newEPreguntaAbierta.setEncuesta(encuestaCreated);
ePreguntaAbiertaService.save(newEPreguntaAbierta);
}
}
return ResponseEntity
.created(new URI("/api/encuestas/" + encuestaCreated.getId()))
.headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, encuestaCreated.getId().toString()))
.body(encuestaCreated);
}
return ResponseEntity.ok().body(null);
}
/** /**
* {@code PUT /encuestas/:id} : Updates an existing encuesta. * {@code PUT /encuestas/:id} : Updates an existing encuesta.
* *

View File

@ -8,9 +8,12 @@ import java.util.Optional;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.datasurvey.domain.Factura; import org.datasurvey.domain.Factura;
import org.datasurvey.domain.UsuarioExtra;
import org.datasurvey.repository.FacturaRepository; import org.datasurvey.repository.FacturaRepository;
import org.datasurvey.service.FacturaQueryService; import org.datasurvey.service.FacturaQueryService;
import org.datasurvey.service.FacturaService; import org.datasurvey.service.FacturaService;
import org.datasurvey.service.MailService;
import org.datasurvey.service.UsuarioExtraService;
import org.datasurvey.service.criteria.FacturaCriteria; import org.datasurvey.service.criteria.FacturaCriteria;
import org.datasurvey.web.rest.errors.BadRequestAlertException; import org.datasurvey.web.rest.errors.BadRequestAlertException;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -41,10 +44,22 @@ public class FacturaResource {
private final FacturaQueryService facturaQueryService; private final FacturaQueryService facturaQueryService;
public FacturaResource(FacturaService facturaService, FacturaRepository facturaRepository, FacturaQueryService facturaQueryService) { private final UsuarioExtraService userExtraService;
private final MailService mailService;
public FacturaResource(
FacturaService facturaService,
FacturaRepository facturaRepository,
FacturaQueryService facturaQueryService,
UsuarioExtraService userExtraService,
MailService mailService
) {
this.facturaService = facturaService; this.facturaService = facturaService;
this.facturaRepository = facturaRepository; this.facturaRepository = facturaRepository;
this.facturaQueryService = facturaQueryService; this.facturaQueryService = facturaQueryService;
this.userExtraService = userExtraService;
this.mailService = mailService;
} }
/** /**
@ -60,11 +75,22 @@ public class FacturaResource {
if (factura.getId() != null) { if (factura.getId() != null) {
throw new BadRequestAlertException("A new factura cannot already have an ID", ENTITY_NAME, "idexists"); throw new BadRequestAlertException("A new factura cannot already have an ID", ENTITY_NAME, "idexists");
} }
Optional<UsuarioExtra> usuarioExtra = userExtraService.findOne(Long.parseLong(factura.getNombreUsuario()));
factura.setNombreUsuario(usuarioExtra.get().getNombre());
Factura result = facturaService.save(factura); Factura result = facturaService.save(factura);
mailService.sendReceiptUser(usuarioExtra.get(), factura);
return ResponseEntity return ResponseEntity
.created(new URI("/api/facturas/" + result.getId())) .created(new URI("/api/facturas/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString())) .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString()))
.body(result); .body(result);
//retrieve yser
//Enviar el correo
} }
/** /**

View File

@ -64,3 +64,11 @@ email.deleteColaborator.title=Se le ha expulsado de una encuesta como colaborado
email.deleteColaborator.greeting=¡Se le ha expulsado, {0}! email.deleteColaborator.greeting=¡Se le ha expulsado, {0}!
email.deleteColaborator.text1=Fue expulsado de la encuesta {0}(#{1})" email.deleteColaborator.text1=Fue expulsado de la encuesta {0}(#{1})"
email.deleteColaborator.text2=Saludos, email.deleteColaborator.text2=Saludos,
email.receipt.title=Comprobante de pago
email.receipt.user={0}
email.receipt.fecha={0}
email.receipt.plantilla={0}
email.receipt.precio=${0}

View File

@ -0,0 +1,262 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:lang="${#locale.language}" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width" />
<!-- Forcing initial-scale shouldn't be necessary -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Use the latest (edge) version of IE rendering engine -->
<meta name="x-apple-disable-message-reformatting" />
<!-- Disable auto-scale in iOS 10 Mail entirely -->
<title th:text="#{email.receipt.title}">JHipster activation</title>
<link rel="icon" th:href="@{|${baseUrl}/favicon.ico|}" />
<link href="https://fonts.googleapis.com/css?family=NotoSansSP:300,400,700" rel="stylesheet" />
<link rel="manifest" href="manifest.webapp" />
<link
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"
crossorigin="anonymous"
/>
<style>
body {
margin-top: 20px;
color: #484b51;
}
.brc-default-l1 {
border-color: #dce9f0 !important;
}
.ml-n1,
.mx-n1 {
margin-left: -0.25rem !important;
}
.mr-n1,
.mx-n1 {
margin-right: -0.25rem !important;
}
.mb-4,
.my-4 {
margin-bottom: 1.5rem !important;
}
hr {
margin-top: 1rem;
margin-bottom: 1rem;
border: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.text-grey-m2 {
color: #888a8d !important;
}
.font-bolder,
.text-600 {
font-weight: 600 !important;
}
.text-110 {
font-size: 110% !important;
}
.text-blue {
color: #478fcc !important;
}
.pb-25,
.py-25 {
padding-bottom: 0.75rem !important;
}
.pt-25,
.py-25 {
padding-top: 0.75rem !important;
}
.bgc-default-tp1 {
background-color: rgba(121, 169, 197, 0.92) !important;
}
.page-header .page-tools {
-ms-flex-item-align: end;
align-self: flex-end;
}
.text-blue-m2 {
color: #68a3d5 !important;
}
.text-150 {
font-size: 150% !important;
}
</style>
</head>
<body width="100%" style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background-color: #f1f1f1">
<center style="width: 100%; background-color: #f1f1f1">
<div
style="
display: none;
font-size: 1px;
max-height: 0px;
max-width: 0px;
opacity: 0;
overflow: hidden;
mso-hide: all;
font-family: sans-serif;
"
>
&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;
</div>
<div style="max-width: 600px; margin: 0 auto" class="email-container">
<!-- BEGIN BODY -->
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center">
<h1>
<a href="#"
><img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333881/DataSurveyLogo2_smr2ok.png"
alt=""
width="300"
/></a>
</h1>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<!-- end tr -->
<div class="page-content container">
<div class="container px-0">
<div class="row mt-4">
<div class="col-12 col-lg-10 offset-lg-1">
<!-- .row -->
<hr class="row brc-default-l1 mx-n1 mb-4" />
<div class="row">
<div class="col-sm-6">
<div>
<span class="text-sm text-grey-m2 align-middle">Usuario:</span>
<span
class="text-600 text-110 text-blue align-middle"
th:text="#{email.receipt.user(${factura.getNombreUsuario()})}"
></span>
</div>
</div>
<!-- /.col -->
<div class="text-95 col-sm-6 align-self-start d-sm-flex justify-content-end">
<hr class="d-sm-none" />
<div class="text-grey-m2">
<div class="my-2">
<i class="fa fa-circle text-blue-m2 text-xs mr-1"></i>
<span class="text-600 text-90" th:text="#{email.receipt.fecha(${factura.getFecha()}, 'dd-MM-yyyy HH:mm' )}"
>Fecha:</span
>
</div>
</div>
</div>
<!-- /.col -->
</div>
<div class="mt-4">
<div class="row text-600 text-white bgc-default-tp1 py-25">
<div class="col-9 col-sm-5">Plantilla</div>
<div class="d-none d-sm-block col-4 col-sm-2">Cantidad</div>
<div class="d-none d-sm-block col-sm-2">Precio</div>
</div>
<div class="text-95 text-secondary-d3">
<div class="row mb-2 mb-sm-0 py-25">
<div class="col-9 col-sm-5" th:text="#{email.receipt.plantilla(${factura.getNombrePlantilla()})}"></div>
<div class="d-none d-sm-block col-2">1</div>
<div class="d-none d-sm-block col-2 text-95" th:text="#{email.receipt.precio(${factura.getCosto()})}"></div>
</div>
</div>
</div>
<div class="row mt-3">
<div class="col-12 col-sm-5 text-grey text-90 order-first order-sm-last">
<div class="row my-2 align-items-center bgc-primary-l3 p-2">
<div class="col-7 text-right">Monto total</div>
<div class="col-5">
<span class="text-150 text-success-d3 opacity-2" th:text="#{email.receipt.precio(${factura.getCosto()})}"></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px">
<h3 class="heading">Acerca de</h3>
<p>DataSurvey es su compañero más cercano para poder recolectar información valiosa para usted</p>
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<ul>
<li><span href="mailto:datasurveyapp@gmail.com" class="text">datasurveyapp@gmail.com</span></li>
</ul>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- end: tr -->
<tr>
<td class="bg_light" style="text-align: center">
<p><a href="https://datasurvey.org" style="color: rgba(0, 0, 0, 0.8)">DataSurvey.org</a></p>
</td>
</tr>
</table>
</div>
</center>
<script
src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous"
></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.4.1/cjs/popper.min.js"
integrity="sha256-T3bYsIPyOLpEfeZOX4M7J59ZoDMzuYFUsPiSN3Xcc2M="
crossorigin="anonymous"
></script>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
crossorigin="anonymous"
></script>
</body>
</html>

View File

@ -91,7 +91,7 @@ export class RegisterComponent implements AfterViewInit {
login, login,
email, email,
password, password,
langKey: this.translateService.currentLang, langKey: this.translateService.currentLang!,
name, name,
firstName, firstName,
profileIcon: this.profileIcon, profileIcon: this.profileIcon,

View File

@ -32,7 +32,9 @@ import { FooterComponent } from './layouts/footer/footer.component';
import { PageRibbonComponent } from './layouts/profiles/page-ribbon.component'; import { PageRibbonComponent } from './layouts/profiles/page-ribbon.component';
import { ErrorComponent } from './layouts/error/error.component'; import { ErrorComponent } from './layouts/error/error.component';
import { SidebarComponent } from './layouts/sidebar/sidebar.component'; import { SidebarComponent } from './layouts/sidebar/sidebar.component';
import { PaginaPrincipalComponent } from './pagina-principal/pagina-principal.component'; import { ListarPlantillaTiendaModule } from './entities/tienda/listar-tienda-plantilla/listar-plantilla-tienda.module';
import { PaypalDialogComponent } from './entities/tienda/paypal-dialog/paypal-dialog.component';
import { NgxPayPalModule } from 'ngx-paypal';
import { ShareButtonsModule } from 'ngx-sharebuttons/buttons'; import { ShareButtonsModule } from 'ngx-sharebuttons/buttons';
import { ShareIconsModule } from 'ngx-sharebuttons/icons'; import { ShareIconsModule } from 'ngx-sharebuttons/icons';
@ -44,6 +46,7 @@ import { ShareIconsModule } from 'ngx-sharebuttons/icons';
SharedModule, SharedModule,
HomeModule, HomeModule,
PaginaPrincipalModule, PaginaPrincipalModule,
ListarPlantillaTiendaModule,
// jhipster-needle-angular-add-module JHipster will add new module here // jhipster-needle-angular-add-module JHipster will add new module here
EntityRoutingModule, EntityRoutingModule,
AppRoutingModule, AppRoutingModule,
@ -65,6 +68,7 @@ import { ShareIconsModule } from 'ngx-sharebuttons/icons';
}), }),
ShareButtonsModule, ShareButtonsModule,
ShareIconsModule, ShareIconsModule,
NgxPayPalModule,
], ],
providers: [ providers: [
Title, Title,
@ -84,7 +88,15 @@ import { ShareIconsModule } from 'ngx-sharebuttons/icons';
} as SocialAuthServiceConfig, } as SocialAuthServiceConfig,
}, },
], ],
declarations: [MainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, FooterComponent, SidebarComponent], declarations: [
MainComponent,
NavbarComponent,
ErrorComponent,
PageRibbonComponent,
FooterComponent,
SidebarComponent,
PaypalDialogComponent,
],
bootstrap: [MainComponent], bootstrap: [MainComponent],
}) })
export class AppModule { export class AppModule {

View File

@ -19,7 +19,7 @@
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span> <fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button> </button>
<button id="jhi-confirm-delete-categoria" data-cy="entityConfirmDeleteButton" type="submit" class="ds-btn ds-btn--danger"> <button id="jhi-confirm-delete-categoria" data-cy="entityConfirmDeleteButton" type="submit" class="ds-btn ds-btn--toggle">
<fa-icon [icon]="faExchangeAlt"></fa-icon> <fa-icon [icon]="faExchangeAlt"></fa-icon>
<span jhiTranslate="entity.action.toggleStatus">Toggle Status</span> <span jhiTranslate="entity.action.toggleStatus">Toggle Status</span>
</button> </button>

View File

@ -5,7 +5,7 @@ import { IEncuesta } from 'app/entities/encuesta/encuesta.model';
import { EncuestaService } from 'app/entities/encuesta/service/encuesta.service'; import { EncuestaService } from 'app/entities/encuesta/service/encuesta.service';
import { EstadoCategoria } from 'app/entities/enumerations/estado-categoria.model'; import { EstadoCategoria } from 'app/entities/enumerations/estado-categoria.model';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { finalize, map } from 'rxjs/operators'; import { finalize } from 'rxjs/operators';
import { Categoria, ICategoria } from '../categoria.model'; import { Categoria, ICategoria } from '../categoria.model';
import { CategoriaService } from '../service/categoria.service'; import { CategoriaService } from '../service/categoria.service';
@ -42,7 +42,7 @@ export class CategoriaDeleteDialogComponent {
this.encuestas!.forEach(encuesta => { this.encuestas!.forEach(encuesta => {
if (encuesta.categoria != null && encuesta.categoria!.id === categoria.id) { if (encuesta.categoria != null && encuesta.categoria!.id === categoria.id) {
encuesta.categoria = categoriaNula; encuesta.categoria = categoriaNula;
this.subscribeToSaveResponse(this.encuestaService.update(encuesta)); this.subscribeToSaveResponse(this.encuestaService.updateSurvey(encuesta));
} }
}); });
categoria.estado = EstadoCategoria.INACTIVE; categoria.estado = EstadoCategoria.INACTIVE;

View File

@ -44,7 +44,7 @@
<input type="text" name="searchString" placeholder="Buscar..." [(ngModel)]="searchString" /> <input type="text" name="searchString" placeholder="Buscar..." [(ngModel)]="searchString" />
</div> </div>
</form> </form>
<table class="table table-striped" aria-describedby="page-heading"> <table class="ds-table table table-striped" aria-describedby="page-heading">
<thead> <thead>
<tr> <tr>
<th scope="col"><span jhiTranslate="dataSurveyApp.categoria.nombre">Nombre</span></th> <th scope="col"><span jhiTranslate="dataSurveyApp.categoria.nombre">Nombre</span></th>
@ -67,7 +67,7 @@
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span> <span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</button> </button>
<button type="submit" (click)="toggleStatus(categoria)" class="ds-btn ds-btn--danger" data-cy="entityDeleteButton"> <button type="submit" (click)="toggleStatus(categoria)" class="ds-btn ds-btn--toggle" data-cy="entityDeleteButton">
<fa-icon [icon]="faExchangeAlt"></fa-icon> <fa-icon [icon]="faExchangeAlt"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.toggleStatus">Toggle Status</span> <span class="d-none d-md-inline" jhiTranslate="entity.action.toggleStatus">Toggle Status</span>
</button> </button>

View File

@ -0,0 +1 @@
<p>dashboard-admin works!</p>

View File

@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DashboardAdminComponent } from './dashboard-admin.component';
describe('DashboardAdminComponent', () => {
let component: DashboardAdminComponent;
let fixture: ComponentFixture<DashboardAdminComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [DashboardAdminComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(DashboardAdminComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,12 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'jhi-dashboard-admin',
templateUrl: './dashboard-admin.component.html',
styleUrls: ['./dashboard-admin.component.scss'],
})
export class DashboardAdminComponent implements OnInit {
constructor() {}
ngOnInit(): void {}
}

View File

@ -0,0 +1 @@
<p>dashboard-user works!</p>

View File

@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DashboardUserComponent } from './dashboard-user.component';
describe('DashboardUserComponent', () => {
let component: DashboardUserComponent;
let fixture: ComponentFixture<DashboardUserComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [DashboardUserComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(DashboardUserComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,12 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'jhi-dashboard-user',
templateUrl: './dashboard-user.component.html',
styleUrls: ['./dashboard-user.component.scss'],
})
export class DashboardUserComponent implements OnInit {
constructor() {}
ngOnInit(): void {}
}

View File

@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { DashboardUserComponent } from './dashboard-user/dashboard-user.component';
import { DashboardAdminComponent } from './dashboard-admin/dashboard-admin.component';
import { SharedModule } from '../../shared/shared.module';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { DashboardRoutingModule } from './route/dashboard-routing.module';
@NgModule({
declarations: [DashboardUserComponent, DashboardAdminComponent],
imports: [CommonModule, SharedModule, DashboardRoutingModule, FontAwesomeModule],
})
export class DashboardModule {}

View File

@ -0,0 +1,25 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { DashboardUserComponent } from '../dashboard-user/dashboard-user.component';
import { DashboardAdminComponent } from '../dashboard-admin/dashboard-admin.component';
import { UserRouteAccessService } from '../../../core/auth/user-route-access.service';
const dashboardRoute: Routes = [
{
path: 'admin',
component: DashboardAdminComponent,
canActivate: [UserRouteAccessService],
},
{
path: 'user',
component: DashboardUserComponent,
canActivate: [UserRouteAccessService],
},
];
@NgModule({
imports: [RouterModule.forChild(dashboardRoute)],
exports: [RouterModule],
})
export class DashboardRoutingModule {}

View File

@ -16,6 +16,10 @@ export class EPreguntaCerradaOpcionService {
constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {} constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {}
updateCount(id: any) {
return this.http.post(`${this.resourceUrl}/count/${id}`, id, { observe: 'response' });
}
create(ePreguntaCerradaOpcion: IEPreguntaCerradaOpcion, preguntaId?: number): Observable<EntityResponseType> { create(ePreguntaCerradaOpcion: IEPreguntaCerradaOpcion, preguntaId?: number): Observable<EntityResponseType> {
return this.http.post<IEPreguntaCerradaOpcion>(`${this.resourceUrl}/${preguntaId}`, ePreguntaCerradaOpcion, { observe: 'response' }); return this.http.post<IEPreguntaCerradaOpcion>(`${this.resourceUrl}/${preguntaId}`, ePreguntaCerradaOpcion, { observe: 'response' });
} }

View File

@ -0,0 +1,175 @@
<div class="container-fluid" *ngIf="encuesta">
<div>
<h2 id="page-heading" data-cy="EPreguntaCerradaHeading">
<div class="d-flex align-items-center">
<p class="ds-title">Vista previa de {{ encuesta!.nombre }}</p>
&nbsp;&nbsp;<fa-icon class="ds-info--icon" [icon]="faQuestion" data-toggle="modal" data-target="#verParametros"></fa-icon>
</div>
<p class="ds-subtitle">Creada el día {{ encuesta!.fechaCreacion | formatShortDatetime | lowercase }}</p>
<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>&nbsp;&nbsp;<span jhiTranslate="entity.action.back">Back</span>
</button>
</div>
</h2>
<jhi-alert-error></jhi-alert-error>
<div class="alert alert-warning" id="no-result" *ngIf="ePreguntas?.length === 0">
<span>No se encontraron preguntas</span>
</div>
<div class="ds-survey preview-survey" id="entities" *ngIf="ePreguntas && ePreguntas.length > 0">
<div class="ds-survey--all-question-wrapper col-8">
<div class="ds-survey--question-wrapper card-encuesta lift" *ngFor="let ePregunta of ePreguntas; let i = index; trackBy: trackId">
<div
[attr.data-index]="ePregunta.id"
[attr.data-tipo]="ePregunta.tipo"
[attr.data-opcional]="ePregunta.opcional"
class="ds-survey--question"
>
<div class="ds-survey--titulo">
<span class="ds-survey--titulo--name">{{ i + 1 }}. {{ ePregunta.nombre }}</span>
</div>
<div>
<span *ngIf="ePregunta.tipo === 'SINGLE'" class="ds-subtitle"
>Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate | lowercase }}
{{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
<span *ngIf="ePregunta.tipo === 'MULTIPLE'" class="ds-subtitle"
>Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate | lowercase }}
{{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
<span *ngIf="!ePregunta.tipo" class="ds-subtitle"
>Pregunta de respuesta abierta {{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
</div>
<ng-container *ngIf="ePregunta.tipo">
<ng-container *ngFor="let ePreguntaOpcion of ePreguntasOpciones; let j = index; trackBy: trackId">
<ng-container *ngFor="let ePreguntaOpcionFinal of ePreguntaOpcion">
<ng-container *ngIf="ePregunta.id === ePreguntaOpcionFinal.epreguntaCerrada.id">
<div
class="ds-survey--option ds-survey--option--base ds-survey--closed-option can-delete"
[attr.data-id]="ePreguntaOpcionFinal.id"
>
<div class="radio" *ngIf="ePregunta.tipo === 'SINGLE'">
<input
type="radio"
(change)="onCheck(ePreguntaOpcionFinal)"
[value]="ePreguntaOpcionFinal.id"
style="border-radius: 3px"
name="{{ 'radio' + ePregunta.id }}"
id="{{ 'radio' + ePreguntaOpcionFinal.id }}"
/>
<label for="{{ 'radio' + ePreguntaOpcionFinal.id }}">{{ ePreguntaOpcionFinal.nombre }}</label>
</div>
<div class="checkbox" *ngIf="ePregunta.tipo === 'MULTIPLE'">
<input
(change)="toggleOption(ePreguntaOpcionFinal)"
type="checkbox"
style="border-radius: 3px"
id="{{ 'checkbox' + ePreguntaOpcionFinal.id }}"
/>
<label for="{{ 'checkbox' + ePreguntaOpcionFinal.id }}">{{ ePreguntaOpcionFinal.nombre }}</label>
</div>
</div>
</ng-container>
</ng-container>
</ng-container>
</ng-container>
<div class="ds-survey--option ds-survey--option--base ds-survey--open-option" *ngIf="!ePregunta.tipo">
<textarea id="{{ ePregunta.id }}" cols="33" rows="10"></textarea>
</div>
</div>
</div>
<button class="ds-btn ds-btn--primary" (click)="finish()">Finalizar</button>
</div>
<div
class="modal fade ds-modal"
id="verParametros"
tabindex="-1"
role="dialog"
aria-labelledby="exampleModalCenterTitle"
aria-hidden="true"
>
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="exampleModalLongTitle">Información de encuesta</h1>
</div>
<div class="modal-body">
<div>
<div class="mb-5">
<p style="font-size: 1.2em" class="ds-subtitle">Cantidad de preguntas</p>
<p>{{ ePreguntas?.length }}</p>
</div>
<div class="mb-5">
<p class="ds-subtitle" jhiTranslate="dataSurveyApp.encuesta.acceso">Acceso</p>
<p jhiTranslate="{{ 'dataSurveyApp.AccesoEncuesta.' + encuesta.acceso }}">{{ encuesta.acceso }}</p>
</div>
<div *ngIf="encuesta.acceso === 'PRIVATE'" class="mb-5">
<p class="ds-subtitle">Contraseña</p>
<p>{{ encuesta.contrasenna }}</p>
</div>
<div class="mb-5">
<p class="ds-subtitle">Estado:</p>
<p jhiTranslate="{{ 'dataSurveyApp.EstadoEncuesta.' + encuesta.estado }}">{{ encuesta.estado }}</p>
</div>
<div *ngIf="encuesta.categoria" class="mb-5">
<p class="ds-subtitle">Categoría</p>
<P> </P> {{ encuesta.categoria?.nombre }}
</div>
<div class="mb-5">
<p class="ds-subtitle">Fecha de publicación</p>
<P
>{{
encuesta.fechaPublicacion === undefined
? 'Sin publicar'
: (encuesta.fechaPublicacion | formatShortDatetime | lowercase)
}}
</P>
</div>
<div class="mb-5">
<p class="ds-subtitle">Fecha de finalización</p>
<P>
{{
encuesta.fechaFinalizada === undefined
? 'Sin finalizar'
: (encuesta.fechaFinalizada | formatShortDatetime | lowercase)
}}
</P>
</div>
<div class="mb-5">
<p class="ds-subtitle">Calificación</p>
<div>
<fa-icon *ngFor="let i of [].constructor(encuesta.calificacion)" class="entity-icon--star" [icon]="faStar"></fa-icon
><fa-icon
*ngFor="let i of [].constructor(5 - encuesta.calificacion!)"
class="entity-icon--star--off"
[icon]="faStar"
></fa-icon>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button id="cancelBtnVerParametros" type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal">
<fa-icon icon="arrow-left"></fa-icon>&nbsp;&nbsp;<span>Volver</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { EncuestaCompleteComponent } from './complete.component';
describe('EncuestaCompleteComponent', () => {
let component: EncuestaCompleteComponent;
let fixture: ComponentFixture<EncuestaCompleteComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [EncuestaCompleteComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(EncuestaCompleteComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,229 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { finalize } from 'rxjs/operators';
import { IEncuesta } from '../encuesta.model';
import { EncuestaService } from '../service/encuesta.service';
import { ICategoria } from 'app/entities/categoria/categoria.model';
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 { IEPreguntaCerrada } from 'app/entities/e-pregunta-cerrada/e-pregunta-cerrada.model';
import { EPreguntaCerradaService } from 'app/entities/e-pregunta-cerrada/service/e-pregunta-cerrada.service';
import { EPreguntaAbiertaService } from '../../e-pregunta-abierta/service/e-pregunta-abierta.service';
import { EPreguntaAbiertaRespuestaService } from '../../e-pregunta-abierta-respuesta/service/e-pregunta-abierta-respuesta.service';
import { EPreguntaCerradaOpcionService } from '../../e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service';
import { faStar, faQuestion } from '@fortawesome/free-solid-svg-icons';
import { AccesoEncuesta } from 'app/entities/enumerations/acceso-encuesta.model';
import { EncuestaPasswordDialogComponent } from '../encuesta-password-dialog/encuesta-password-dialog.component';
import { PreguntaCerradaTipo } from 'app/entities/enumerations/pregunta-cerrada-tipo.model';
import { EPreguntaAbiertaRespuesta } from 'app/entities/e-pregunta-abierta-respuesta/e-pregunta-abierta-respuesta.model';
import { Observable } from 'rxjs/internal/Observable';
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
@Component({
selector: 'jhi-complete',
templateUrl: './complete.component.html',
})
export class EncuestaCompleteComponent implements OnInit {
categoriasSharedCollection: ICategoria[] = [];
usuarioExtrasSharedCollection: IUsuarioExtra[] = [];
faStar = faStar;
faQuestion = faQuestion;
encuesta?: IEncuesta;
isLoading = false;
ePreguntas?: any[];
ePreguntasOpciones?: any[];
isLocked?: boolean;
selectedOpenOptions: any;
selectedSingleOptions: any;
selectedMultiOptions: any;
error: boolean;
constructor(
protected activatedRoute: ActivatedRoute,
protected encuestaService: EncuestaService,
protected usuarioExtraService: UsuarioExtraService,
protected fb: FormBuilder,
protected modalService: NgbModal,
protected ePreguntaCerradaService: EPreguntaCerradaService,
protected ePreguntaCerradaOpcionService: EPreguntaCerradaOpcionService,
protected ePreguntaAbiertaService: EPreguntaAbiertaService,
protected ePreguntaAbiertaRespuestaService: EPreguntaAbiertaRespuestaService
) {
this.selectedOpenOptions = {};
this.selectedSingleOptions = {};
this.selectedMultiOptions = [];
this.error = false;
}
ngOnInit(): void {
this.activatedRoute.data.subscribe(({ encuesta }) => {
if (encuesta) {
this.encuesta = encuesta;
}
this.isLocked = this.verifyPassword();
if (this.isLocked) {
this.previousState();
} else {
this.loadAll();
}
});
for (let pregunta of this.ePreguntas!) {
if (pregunta.tipo && pregunta.tipo === PreguntaCerradaTipo.SINGLE) {
this.selectedSingleOptions[pregunta.id] = null;
}
}
}
verifyPassword(): boolean {
if (this.encuesta!.acceso === AccesoEncuesta.PUBLIC) {
return false;
} else {
const modalRef = this.modalService.open(EncuestaPasswordDialogComponent, { size: 'lg', backdrop: 'static' });
modalRef.componentInstance.encuesta = this.encuesta;
modalRef.closed.subscribe(reason => {
return reason === 'success';
});
}
return true;
}
ngAfterViewChecked(): void {
this.initListeners();
}
initListeners(): void {
const questions = document.getElementsByClassName('ds-survey--question-wrapper');
for (let i = 0; i < questions.length; i++) {
if (questions[i].classList.contains('ds-survey--closed-option')) {
questions[i].addEventListener('click', e => {
if ((e.target as HTMLInputElement).checked) {
(e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active');
(e.target as HTMLElement).id;
} else {
(e.target as HTMLElement).offsetParent!.classList.remove('ds-survey--closed-option--active');
}
});
}
}
}
trackId(_index: number, item: IEPreguntaCerrada): number {
return item.id!;
}
trackEPreguntaCerradaById(_index: number, item: IEPreguntaCerrada): number {
return item.id!;
}
trackCategoriaById(_index: number, item: ICategoria): number {
return item.id!;
}
trackUsuarioExtraById(_index: number, item: IUsuarioExtra): number {
return item.id!;
}
loadAll(): void {
this.isLoading = true;
this.encuestaService
.findQuestions(this.encuesta?.id!)
.pipe(
finalize(() =>
this.encuestaService.findQuestionsOptions(this.encuesta?.id!).subscribe(
(res: any) => {
this.isLoading = false;
this.ePreguntasOpciones = res.body ?? [];
},
() => {
this.isLoading = false;
}
)
)
)
.subscribe(
(res: any) => {
this.isLoading = false;
this.ePreguntas = res.body ?? [];
},
() => {
this.isLoading = false;
}
);
if (this.ePreguntas!.length == 0) {
this.previousState();
}
}
previousState(): void {
window.history.back();
}
onCheck(preguntaOpcion: { epreguntaCerrada: any; id: any }): void {
this.selectedSingleOptions[preguntaOpcion.epreguntaCerrada!.id!] = preguntaOpcion.id;
}
toggleOption(ePreguntaOpcionFinal: { id: any }): void {
if (this.selectedMultiOptions.includes(ePreguntaOpcionFinal.id)) {
for (let i = 0; i < this.selectedMultiOptions.length; i++) {
if (this.selectedMultiOptions[i] === ePreguntaOpcionFinal.id) {
this.selectedMultiOptions.splice(i, 1);
}
}
} else {
this.selectedMultiOptions.push(ePreguntaOpcionFinal.id);
}
}
finish(): void {
this.getOpenQuestionAnswers();
this.registerOpenQuestionAnswers();
this.updateClosedOptionsCount();
}
updateClosedOptionsCount() {
for (let key in this.selectedSingleOptions) {
this.subscribeToSaveResponse(this.ePreguntaCerradaOpcionService.updateCount(this.selectedSingleOptions[key]));
}
this.selectedMultiOptions.forEach((option: any) => {
this.subscribeToSaveResponse(this.ePreguntaCerradaOpcionService.updateCount(option));
});
}
registerOpenQuestionAnswers() {
for (let id in this.selectedOpenOptions) {
let pregunta = this.ePreguntas!.find(p => {
return p.id == id;
});
let newRespuesta = new EPreguntaAbiertaRespuesta(0, this.selectedOpenOptions[id], pregunta);
this.subscribeToSaveResponse(this.ePreguntaAbiertaRespuestaService.create(newRespuesta));
}
}
protected onSaveFinalize(): void {
// this.isSaving = false;
}
processError(response: HttpErrorResponse): void {
if (response.status === 400) {
this.error = true;
}
}
protected subscribeToSaveResponse(result: Observable<HttpResponse<any>>): void {
result.pipe(finalize(() => this.onSaveFinalize())).subscribe(
() => this.previousState(),
response => this.processError(response)
);
}
getOpenQuestionAnswers() {
this.ePreguntas!.forEach(pregunta => {
if (!pregunta.tipo) {
let textValue = (document.getElementById(pregunta.id) as HTMLInputElement).value;
this.selectedOpenOptions[pregunta.id] = textValue;
}
});
}
}

View File

@ -34,7 +34,7 @@
<p class="ds-subtitle text-center">Inicie creando preguntas y opciones para su encuesta.</p> <p class="ds-subtitle text-center">Inicie creando preguntas y opciones para su encuesta.</p>
</ng-container> </ng-container>
<div class="ds-survey--question-wrapper card-encuesta lift" *ngFor="let ePregunta of ePreguntas; let i = index; trackBy: trackId"> <div class="ds-survey--question-wrapper card-encuesta" *ngFor="let ePregunta of ePreguntas; let i = index; trackBy: trackId">
<div <div
[attr.data-index]="ePregunta.id" [attr.data-index]="ePregunta.id"
[attr.data-tipo]="ePregunta.tipo" [attr.data-tipo]="ePregunta.tipo"

View File

@ -1,9 +1,8 @@
<form *ngIf="encuesta" name="deleteForm" (ngSubmit)="confirmFinalizar(encuesta!)"> <form *ngIf="encuesta" name="deleteForm" (ngSubmit)="confirmFinalizar(encuesta!)">
<div class="modal-header"> <div class="modal-header"></div>
<h4 class="ds-title--small" data-cy="encuestaDeleteDialogHeading">Finalizar encuesta</h4>
</div>
<div class="modal-body"> <div class="modal-body">
<p class="ds-title--small" data-cy="encuestaDeleteDialogHeading">Finalizar encuesta</p>
<p class="ds-subtitle" id="jhi-delete-encuesta-heading">¿Está seguro de querer finalizar la encuesta?</p> <p class="ds-subtitle" id="jhi-delete-encuesta-heading">¿Está seguro de querer finalizar la encuesta?</p>
</div> </div>

View File

@ -0,0 +1,28 @@
<form class="ds-form" [formGroup]="passwordForm" name="deleteForm" (ngSubmit)="submitPassword()">
<div *ngIf="this.isWrong">
<p>Contraseña incorrecta</p>
</div>
<div class="modal-body">
<p class="ds-title--small" jhiTranslate="dataSurveyApp.encuesta.password.title">Enter password</p>
<p class="ds-subtitle" id="jhi-delete-encuesta-heading" jhiTranslate="dataSurveyApp.encuesta.password.text">
This survey is marked as private, please enter the password
</p>
<input [(ngModel)]="passwordInput" type="password" name="passwordInput" id="passwordInput" placeholder="qwerty..." />
</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>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button
id="jhi-confirm-delete-option"
data-cy="submit"
type="submit"
class="ds-btn ds-btn--primary"
[disabled]="passwordForm.get('password')!.invalid"
>
<span jhiTranslate="entity.action.submit">Submit</span>
</button>
</div>
</form>

View File

@ -0,0 +1,4 @@
input {
margin: 2%;
width: 100%;
}

View File

@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { EncuestaPasswordDialogComponent } from './encuesta-password-dialog.component';
describe('EncuestaPasswordDialogComponent', () => {
let component: EncuestaPasswordDialogComponent;
let fixture: ComponentFixture<EncuestaPasswordDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [EncuestaPasswordDialogComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(EncuestaPasswordDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,36 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { IEncuesta } from '../encuesta.model';
@Component({
selector: 'jhi-encuesta-password-dialog',
templateUrl: './encuesta-password-dialog.component.html',
styleUrls: ['./encuesta-password-dialog.component.scss'],
})
export class EncuestaPasswordDialogComponent implements OnInit {
passwordForm = this.fb.group({
password: [null, [Validators.required]],
});
encuesta?: IEncuesta;
isWrong?: boolean;
passwordInput?: string;
constructor(protected activeModal: NgbActiveModal, protected fb: FormBuilder) {}
ngOnInit(): void {}
submitPassword() {
const password = this.passwordForm.get(['password'])!.value;
if (this.passwordForm.valid && password === this.encuesta!.contrasenna) {
this.activeModal.close('success');
} else {
this.isWrong = true;
}
}
cancel(): void {
this.activeModal.close('cancel');
}
}

View File

@ -11,6 +11,8 @@ import { EncuestaDeleteQuestionDialogComponent } from './encuesta-delete-questio
import { EncuestaDeleteOptionDialogComponent } from './encuesta-delete-option-dialog/encuesta-delete-option-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 { EncuestaCompartirDialogComponent } from './encuesta-compartir-dialog/encuesta-compartir-dialog.component';
import { ShareButtonsModule } from 'ngx-sharebuttons/buttons'; import { ShareButtonsModule } from 'ngx-sharebuttons/buttons';
import { EncuestaCompleteComponent } from './complete/complete.component';
import { EncuestaPasswordDialogComponent } from './encuesta-password-dialog/encuesta-password-dialog.component';
import { EncuestaFinalizarDialogComponent } from './encuesta-finalizar-dialog/encuesta-finalizar-dialog.component'; import { EncuestaFinalizarDialogComponent } from './encuesta-finalizar-dialog/encuesta-finalizar-dialog.component';
import { EncuestaDeleteColaboratorDialogComponent } from './encuesta-delete-colaborator-dialog/encuesta-delete-colaborator-dialog.component'; import { EncuestaDeleteColaboratorDialogComponent } from './encuesta-delete-colaborator-dialog/encuesta-delete-colaborator-dialog.component';
@ -25,6 +27,8 @@ import { EncuestaDeleteColaboratorDialogComponent } from './encuesta-delete-cola
EncuestaDeleteQuestionDialogComponent, EncuestaDeleteQuestionDialogComponent,
EncuestaDeleteOptionDialogComponent, EncuestaDeleteOptionDialogComponent,
EncuestaCompartirDialogComponent, EncuestaCompartirDialogComponent,
EncuestaCompleteComponent,
EncuestaPasswordDialogComponent,
EncuestaFinalizarDialogComponent, EncuestaFinalizarDialogComponent,
EncuestaDeleteColaboratorDialogComponent, EncuestaDeleteColaboratorDialogComponent,
], ],

View File

@ -40,10 +40,6 @@
</button> </button>
</div> </div>
<div class="alert alert-warning" id="no-result" *ngIf="encuestas?.length === 0">
<span jhiTranslate="dataSurveyApp.encuesta.home.notFound">No surveys found</span>
</div>
<form class="ds-form"> <form class="ds-form">
<div class="input-group"> <div class="input-group">
<div class="ds-filter"> <div class="ds-filter">
@ -83,8 +79,17 @@
</div> </div>
</form> </form>
<div class="ds-survey" id="entities" *ngIf="encuestas?.length === 0">
<div class="ds-survey--all-question-wrapper">
<ng-container class="">
<p class="ds-title text-center">No posee encuestas</p>
<p class="ds-subtitle text-center">Incie a explorar, colaborar y adquirir datos al crear encuestas mundialmente</p>
</ng-container>
</div>
</div>
<!-- Lista de Encuestas del Usuario --> <!-- Lista de Encuestas del Usuario -->
<div class="ds-list" (contextmenu)="openContextMenu($event)" *ngIf="!isAdmin()"> <div class="ds-list" (contextmenu)="openContextMenu($event)" *ngIf="!isAdmin() && encuestas?.length !== 0">
<!-- Context Menu --> <!-- Context Menu -->
<div class="ds-contextmenu ds-contextmenu--closed" id="contextmenu"> <div class="ds-contextmenu ds-contextmenu--closed" id="contextmenu">
<ul id="ds-context-menu__list"> <ul id="ds-context-menu__list">
@ -212,7 +217,7 @@
</div> </div>
</div> </div>
<div class="table-responsive" id="entities" *ngIf="isAdmin() && encuestas && encuestas.length > 0"> <div class="table-responsive" id="entities" *ngIf="isAdmin() && encuestas && encuestas.length > 0">
<table class="table table-striped" aria-describedby="page-heading"> <table class="ds-table table table-striped" aria-describedby="page-heading">
<thead> <thead>
<tr> <tr>
<th scope="col"><span jhiTranslate="dataSurveyApp.encuesta.nombre">Nombre</span></th> <th scope="col"><span jhiTranslate="dataSurveyApp.encuesta.nombre">Nombre</span></th>

View File

@ -6,6 +6,7 @@ import { EncuestaComponent } from '../list/encuesta.component';
import { EncuestaDetailComponent } from '../detail/encuesta-detail.component'; import { EncuestaDetailComponent } from '../detail/encuesta-detail.component';
import { EncuestaUpdateComponent } from '../update/encuesta-update.component'; import { EncuestaUpdateComponent } from '../update/encuesta-update.component';
import { EncuestaRoutingResolveService } from './encuesta-routing-resolve.service'; import { EncuestaRoutingResolveService } from './encuesta-routing-resolve.service';
import { EncuestaCompleteComponent } from '../complete/complete.component';
const encuestaRoute: Routes = [ const encuestaRoute: Routes = [
{ {
@ -37,6 +38,14 @@ const encuestaRoute: Routes = [
}, },
canActivate: [UserRouteAccessService], canActivate: [UserRouteAccessService],
}, },
{
path: ':id/complete',
component: EncuestaCompleteComponent,
resolve: {
encuesta: EncuestaRoutingResolveService,
},
canActivate: [UserRouteAccessService],
},
]; ];
@NgModule({ @NgModule({

View File

@ -26,6 +26,13 @@ export class EncuestaService {
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
} }
createFromTemplate(encuesta: IEncuesta, plantillaId: Number): Observable<EntityResponseType> {
const copy = this.convertDateFromClient(encuesta);
return this.http
.post<IEncuesta>(`${this.resourceUrl}/${plantillaId}`, copy, { observe: 'response' })
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
}
//update para publicar //update para publicar
update(encuesta: IEncuesta): Observable<EntityResponseType> { update(encuesta: IEncuesta): Observable<EntityResponseType> {
const copy = this.convertDateFromClient(encuesta); const copy = this.convertDateFromClient(encuesta);

View File

@ -42,9 +42,6 @@
</div> </div>
<p class="ds-subtitle">Creada el día {{ encuesta!.fechaCreacion | formatShortDatetime | lowercase }}</p> <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>&nbsp;&nbsp;<span>Finalizar</span>
</button>
<div class="d-flex justify-content-end"> <div class="d-flex justify-content-end">
<button type="button" class="ds-btn ds-btn--secondary" (click)="previousState()"> <button type="button" class="ds-btn ds-btn--secondary" (click)="previousState()">
@ -65,6 +62,10 @@
> >
<fa-icon icon="sync" [icon]="faPlus"></fa-icon>&nbsp;&nbsp;<span>Crear pregunta</span> <fa-icon icon="sync" [icon]="faPlus"></fa-icon>&nbsp;&nbsp;<span>Crear pregunta</span>
</button> </button>
<button type="button" class="ds-btn ds-btn--danger" (click)="finalizar()" *ngIf="encuesta!.estado === 'ACTIVE'">
<fa-icon icon="sync" [icon]="faTimes"></fa-icon>&nbsp;&nbsp;<span>Finalizar</span>
</button>
</div> </div>
</h2> </h2>

View File

@ -77,6 +77,21 @@ import { RouterModule } from '@angular/router';
loadChildren: () => loadChildren: () =>
import('./p-pregunta-cerrada-opcion/p-pregunta-cerrada-opcion.module').then(m => m.PPreguntaCerradaOpcionModule), import('./p-pregunta-cerrada-opcion/p-pregunta-cerrada-opcion.module').then(m => m.PPreguntaCerradaOpcionModule),
}, },
{
path: 'mis-plantillas',
data: { pageTitle: 'dataSurveyApp.usuarioExtra.plantillas.title' },
loadChildren: () => import('./usuario-plantillas/usuario-plantillas.module').then(m => m.UsuarioPlantillasModule),
},
{
path: 'dashboard',
data: { pageTitle: 'dataSurveyApp.Dashboard.title' },
loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule),
},
{
path: 'dashboard',
data: { pageTitle: 'dataSurveyApp.Dashboard.title' },
loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule),
},
/* jhipster-needle-add-entity-route - JHipster will add entity modules routes here */ /* jhipster-needle-add-entity-route - JHipster will add entity modules routes here */
]), ]),
], ],

View File

@ -19,6 +19,7 @@ export class FacturaService {
constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {} constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {}
create(factura: IFactura): Observable<EntityResponseType> { create(factura: IFactura): Observable<EntityResponseType> {
debugger;
const copy = this.convertDateFromClient(factura); const copy = this.convertDateFromClient(factura);
return this.http return this.http
.post<IFactura>(this.resourceUrl, copy, { observe: 'response' }) .post<IFactura>(this.resourceUrl, copy, { observe: 'response' })

View File

@ -1,24 +1,23 @@
<form *ngIf="plantilla" name="deleteForm" (ngSubmit)="confirmDelete(plantilla.id!)"> <form class="ds-form" *ngIf="plantilla" name="deleteForm" (ngSubmit)="confirmDelete(plantilla)">
<div class="modal-header">
<h4 class="modal-title" data-cy="plantillaDeleteDialogHeading" jhiTranslate="entity.delete.title">Confirm delete operation</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="cancel()">&times;</button>
</div>
<div class="modal-body"> <div class="modal-body">
<jhi-alert-error></jhi-alert-error> <jhi-alert-error></jhi-alert-error>
<p class="ds-title--small">Eliminar plantilla</p>
<p id="jhi-delete-plantilla-heading" jhiTranslate="dataSurveyApp.plantilla.delete.question" [translateValues]="{ id: plantilla.id }"> <p
class="ds-subtitle"
id="jhi-delete-plantilla-heading"
jhiTranslate="dataSurveyApp.plantilla.delete.question"
[translateValues]="{ id: plantilla.id }"
>
Are you sure you want to delete this Plantilla? Are you sure you want to delete this Plantilla?
</p> </p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="cancel()"> <button type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal" (click)="cancel()">
<fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span> <fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button> </button>
<button id="jhi-confirm-delete-plantilla" data-cy="entityConfirmDeleteButton" type="submit" class="btn btn-danger"> <button id="jhi-confirm-delete-plantilla" data-cy="entityConfirmDeleteButton" type="submit" class="ds-btn ds-btn--danger">
<fa-icon icon="times"></fa-icon>&nbsp;<span jhiTranslate="entity.action.delete">Delete</span> <fa-icon icon="times"></fa-icon>&nbsp;<span jhiTranslate="entity.action.delete">Delete</span>
</button> </button>
</div> </div>

View File

@ -1,65 +0,0 @@
jest.mock('@ng-bootstrap/ng-bootstrap');
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { of } from 'rxjs';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { PlantillaService } from '../service/plantilla.service';
import { PlantillaDeleteDialogComponent } from './plantilla-delete-dialog.component';
describe('Component Tests', () => {
describe('Plantilla Management Delete Component', () => {
let comp: PlantillaDeleteDialogComponent;
let fixture: ComponentFixture<PlantillaDeleteDialogComponent>;
let service: PlantillaService;
let mockActiveModal: NgbActiveModal;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
declarations: [PlantillaDeleteDialogComponent],
providers: [NgbActiveModal],
})
.overrideTemplate(PlantillaDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(PlantillaDeleteDialogComponent);
comp = fixture.componentInstance;
service = TestBed.inject(PlantillaService);
mockActiveModal = TestBed.inject(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
jest.spyOn(service, 'delete').mockReturnValue(of(new HttpResponse({})));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.close).toHaveBeenCalledWith('deleted');
})
));
it('Should not call delete service on clear', () => {
// GIVEN
jest.spyOn(service, 'delete');
// WHEN
comp.cancel();
// THEN
expect(service.delete).not.toHaveBeenCalled();
expect(mockActiveModal.close).not.toHaveBeenCalled();
expect(mockActiveModal.dismiss).toHaveBeenCalled();
});
});
});
});

View File

@ -3,6 +3,7 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { IPlantilla } from '../plantilla.model'; import { IPlantilla } from '../plantilla.model';
import { PlantillaService } from '../service/plantilla.service'; import { PlantillaService } from '../service/plantilla.service';
import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model';
@Component({ @Component({
templateUrl: './plantilla-delete-dialog.component.html', templateUrl: './plantilla-delete-dialog.component.html',
@ -16,8 +17,9 @@ export class PlantillaDeleteDialogComponent {
this.activeModal.dismiss(); this.activeModal.dismiss();
} }
confirmDelete(id: number): void { confirmDelete(pPlantilla: IPlantilla): void {
this.plantillaService.delete(id).subscribe(() => { pPlantilla.estado = EstadoPlantilla.DELETED;
this.plantillaService.update(pPlantilla).subscribe(() => {
this.activeModal.close('deleted'); this.activeModal.close('deleted');
}); });
} }

View File

@ -24,7 +24,7 @@
<p class="ds-subtitle text-center">Inicie creando preguntas y opciones para su plantilla.</p> <p class="ds-subtitle text-center">Inicie creando preguntas y opciones para su plantilla.</p>
</ng-container> </ng-container>
<div class="ds-survey--question-wrapper card-plantilla lift" *ngFor="let pPregunta of pPreguntas; let i = index; trackBy: trackId"> <div class="ds-survey--question-wrapper card-plantilla" *ngFor="let pPregunta of pPreguntas; let i = index; trackBy: trackId">
<div <div
[attr.data-index]="pPregunta.id" [attr.data-index]="pPregunta.id"
[attr.data-tipo]="pPregunta.tipo" [attr.data-tipo]="pPregunta.tipo"

View File

@ -25,7 +25,36 @@
</div> </div>
</div> </div>
</h2> </h2>
<form class="ds-form" *ngIf="isAdmin() && isAuthenticated()">
<div class="input-group">
<div class="ds-filter">
<div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
<input type="text" name="searchString" placeholder="Buscar por nombre..." [(ngModel)]="searchString" />
</div>
<div class="ds-filter">
<div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
<select name="estadoPlantilla" id="estadoPlantilla" [(ngModel)]="estadoPlantilla" style="width: 200px">
<option value="" selected="selected" disabled="disabled">Filtrar por estado</option>
<option value="">Todos Estados</option>
<option value="Draft">Borradores</option>
<option value="Active">En tienda</option>
<option value="Disabled">Desactivadas</option>
</select>
</div>
<!--<div class="col-3">
<div class="input-group-addon "><i class="glyphicon glyphicon-search"></i></div>
<select id="categoriaEncuesta" name="categoriaEncuesta" [(ngModel)]="categoriaEncuesta">
<option [ngValue]="null" selected>Filtre por categoría</option>
<option
*ngFor="let categoriaOption of categoriasSharedCollection; trackBy: trackCategoriaById"
[ngValue]="categoriaOption.nombre" >
{{ categoriaOption.nombre }}
</option>
</select>
</div>-->
</div>
</form>
<!-- <jhi-alert-error></jhi-alert-error> <!-- <jhi-alert-error></jhi-alert-error>
<jhi-alert></jhi-alert> --> <jhi-alert></jhi-alert> -->
@ -35,11 +64,10 @@
</div> </div>
<div class="table-responsive" id="entities" *ngIf="plantillas && plantillas.length > 0"> <div class="table-responsive" id="entities" *ngIf="plantillas && plantillas.length > 0">
<table class="table table-striped" aria-describedby="page-heading"> <table class="ds-table table table-striped" aria-describedby="page-heading">
<thead> <thead>
<tr> <tr>
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.nombre">Nombre</span></th> <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.fechaPublicacionTienda">Fecha Publicacion Tienda</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.estado">Estado</span></th> <th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.estado">Estado</span></th>
@ -49,9 +77,11 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let plantilla of plantillas; trackBy: trackId" data-cy="entityTable"> <tr
*ngFor="let plantilla of plantillas | filter: 'nombre':searchString | filter: 'estado':estadoPlantilla; trackBy: trackId"
data-cy="entityTable"
>
<td>{{ plantilla.nombre }}</td> <td>{{ plantilla.nombre }}</td>
<td>{{ plantilla.descripcion }}</td>
<!-- <td>{{ plantilla.fechaCreacion | formatMediumDatetime }}</td> --> <!-- <td>{{ plantilla.fechaCreacion | formatMediumDatetime }}</td> -->
<td *ngIf="plantilla.fechaPublicacionTienda">{{ plantilla.fechaPublicacionTienda | formatShortDatetime | titlecase }}</td> <td *ngIf="plantilla.fechaPublicacionTienda">{{ plantilla.fechaPublicacionTienda | formatShortDatetime | titlecase }}</td>
<td *ngIf="!plantilla.fechaPublicacionTienda">No establecida</td> <td *ngIf="!plantilla.fechaPublicacionTienda">No establecida</td>
@ -70,7 +100,6 @@
<fa-icon icon="eye"></fa-icon> <fa-icon icon="eye"></fa-icon>
<span class="d-none d-md-inline">Vista previa</span> <span class="d-none d-md-inline">Vista previa</span>
</button> </button>
<button <button
type="submit" type="submit"
[routerLink]="['/plantilla', plantilla.id, 'edit']" [routerLink]="['/plantilla', plantilla.id, 'edit']"
@ -79,7 +108,10 @@
> >
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span> <span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</button> </button>
<button type="submit" (click)="cambiarEstado(plantilla)" class="ds-btn btn-warning btn-sm" data-cy="entityDeleteButton">
<fa-icon [icon]="faExchangeAlt"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="dataSurveyApp.plantilla.updated.buttonChangeEstado">Change status</span>
</button>
<button type="submit" (click)="delete(plantilla)" class="ds-btn ds-btn--danger btn-sm" data-cy="entityDeleteButton"> <button type="submit" (click)="delete(plantilla)" class="ds-btn ds-btn--danger btn-sm" data-cy="entityDeleteButton">
<fa-icon icon="times"></fa-icon> <fa-icon icon="times"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span> <span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>

View File

@ -17,6 +17,9 @@ import { CategoriaService } from 'app/entities/categoria/service/categoria.servi
import * as dayjs from 'dayjs'; import * as dayjs from 'dayjs';
import { DATE_TIME_FORMAT } from 'app/config/input.constants'; import { DATE_TIME_FORMAT } from 'app/config/input.constants';
import { PlantillaChangeStatusDialogComponent } from '../plantilla-change-status-dialog/plantilla-change-status-dialog.component';
import { faExchangeAlt } from '@fortawesome/free-solid-svg-icons';
@Component({ @Component({
selector: 'jhi-plantilla', selector: 'jhi-plantilla',
@ -39,21 +42,31 @@ export class PlantillaComponent implements OnInit {
categoria: [null, [Validators.required]], categoria: [null, [Validators.required]],
}); });
faExchangeAlt = faExchangeAlt;
public searchString: string;
public estadoPlantilla: string;
constructor( constructor(
protected plantillaService: PlantillaService, protected plantillaService: PlantillaService,
protected modalService: NgbModal, protected modalService: NgbModal,
protected accountService: AccountService, protected accountService: AccountService,
protected fb: FormBuilder, protected fb: FormBuilder,
protected categoriaService: CategoriaService protected categoriaService: CategoriaService
) {} ) {
this.searchString = '';
this.estadoPlantilla = '';
}
loadAll(): void { loadAll(): void {
this.isLoading = true; this.isLoading = true;
this.searchString = '';
this.estadoPlantilla = '';
this.plantillaService.query().subscribe( this.plantillaService.query().subscribe(
(res: HttpResponse<IPlantilla[]>) => { (res: HttpResponse<IPlantilla[]>) => {
this.isLoading = false; this.isLoading = false;
this.plantillas = res.body ?? []; const tempPlantillas = res.body ?? [];
this.plantillas = tempPlantillas.filter(p => p.estado !== EstadoPlantilla.DELETED);
}, },
() => { () => {
this.isLoading = false; this.isLoading = false;
@ -81,6 +94,17 @@ export class PlantillaComponent implements OnInit {
}); });
} }
cambiarEstado(plantilla: IPlantilla): void {
const modalRef = this.modalService.open(PlantillaChangeStatusDialogComponent, { size: 'lg', backdrop: 'static' });
modalRef.componentInstance.plantilla = plantilla;
// unsubscribe not needed because closed completes on modal close
modalRef.closed.subscribe(reason => {
if (reason === 'updated') {
this.loadAll();
}
});
}
isAdmin(): boolean { isAdmin(): boolean {
return this.accountService.hasAnyAuthority('ROLE_ADMIN'); return this.accountService.hasAnyAuthority('ROLE_ADMIN');
} }

View File

@ -0,0 +1,32 @@
<form *ngIf="plantilla" class="ds-form" name="changeStatusForm" (ngSubmit)="confirmChangeStatus(plantilla)">
<div class="modal-body">
<p class="ds-title--small">Cambiar estado</p>
<p
*ngIf="plantilla.estado != 'DISABLED'"
class="ds-subtitle"
id="jhi-inactive-plantilla-heading"
jhiTranslate="dataSurveyApp.plantilla.desactivar.question"
>
Are you sure you want to delete this option?
</p>
<p
*ngIf="plantilla.estado == 'DISABLED'"
class="ds-subtitle"
id="jhi-active-plantilla-heading"
jhiTranslate="dataSurveyApp.plantilla.activar.question"
>
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>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button id="jhi-confirm-change-status-option" data-cy="entityConfirmChangeButton" type="submit" class="ds-btn btn-warning">
<fa-icon [icon]="faExchangeAlt"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="dataSurveyApp.plantilla.updated.buttonChangeEstado">Cambiar estado</span>
</button>
</div>
</form>

View File

@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PlantillaChangeStatusDialogComponent } from './plantilla-change-status-dialog.component';
describe('PlantillaChangeStatusDialogComponent', () => {
let component: PlantillaChangeStatusDialogComponent;
let fixture: ComponentFixture<PlantillaChangeStatusDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [PlantillaChangeStatusDialogComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PlantillaChangeStatusDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,36 @@
import { Component } from '@angular/core';
import { PlantillaService } from '../service/plantilla.service';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model';
import { IPlantilla } from '../plantilla.model';
import { faExchangeAlt } from '@fortawesome/free-solid-svg-icons';
@Component({
selector: 'jhi-plantilla-change-status-dialog',
templateUrl: './plantilla-change-status-dialog.component.html',
styleUrls: ['./plantilla-change-status-dialog.component.scss'],
})
export class PlantillaChangeStatusDialogComponent {
plantilla?: IPlantilla;
faExchangeAlt = faExchangeAlt;
constructor(protected plantillaService: PlantillaService, protected activeModal: NgbActiveModal) {}
cancel(): void {
this.activeModal.dismiss();
}
confirmChangeStatus(pPlantilla: IPlantilla) {
if (this.plantilla) {
if (pPlantilla.estado === EstadoPlantilla.DISABLED) {
this.plantilla.estado = EstadoPlantilla.DRAFT;
} else {
this.plantilla.estado = EstadoPlantilla.DISABLED;
}
this.plantillaService.update(this.plantilla).subscribe(() => {
this.activeModal.close('updated');
});
}
}
}

View File

@ -10,6 +10,7 @@ import { PlantillaDeleteQuestionDialogComponent } from './plantilla-delete-quest
import { PlantillaDeleteOptionDialogComponent } from './plantilla-delete-option-dialog/plantilla-delete-option-dialog.component'; import { PlantillaDeleteOptionDialogComponent } from './plantilla-delete-option-dialog/plantilla-delete-option-dialog.component';
import { PlantillaPublishStoreDialogComponent } from './plantilla-publish-store-dialog/plantilla-publish-store-dialog.component'; import { PlantillaPublishStoreDialogComponent } from './plantilla-publish-store-dialog/plantilla-publish-store-dialog.component';
import { PlantillaDeleteStoreDialogComponent } from './plantilla-delete-store-dialog/plantilla-delete-store-dialog.component'; import { PlantillaDeleteStoreDialogComponent } from './plantilla-delete-store-dialog/plantilla-delete-store-dialog.component';
import { PlantillaChangeStatusDialogComponent } from './plantilla-change-status-dialog/plantilla-change-status-dialog.component';
@NgModule({ @NgModule({
imports: [SharedModule, PlantillaRoutingModule, FontAwesomeModule], imports: [SharedModule, PlantillaRoutingModule, FontAwesomeModule],
@ -22,6 +23,7 @@ import { PlantillaDeleteStoreDialogComponent } from './plantilla-delete-store-di
PlantillaDeleteOptionDialogComponent, PlantillaDeleteOptionDialogComponent,
PlantillaPublishStoreDialogComponent, PlantillaPublishStoreDialogComponent,
PlantillaDeleteStoreDialogComponent, PlantillaDeleteStoreDialogComponent,
PlantillaChangeStatusDialogComponent,
], ],
entryComponents: [PlantillaDeleteDialogComponent], entryComponents: [PlantillaDeleteDialogComponent],
}) })

View File

@ -0,0 +1,11 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { SharedModule } from 'app/shared/shared.module';
import { TIENDA_PLANTILLA_ROUTE } from './listar-tienda-plantilla.route';
import { ListarTiendaPlantillaComponent } from './listar-tienda-plantilla.component';
@NgModule({
imports: [SharedModule, RouterModule.forChild([TIENDA_PLANTILLA_ROUTE])],
declarations: [ListarTiendaPlantillaComponent],
})
export class ListarPlantillaTiendaModule {}

View File

@ -0,0 +1,115 @@
<div class="row">
<div class="col">
<div class="page-header-ui page-header-ui-dark bg-img-cover overlay">
<div class="container px-0 text-black">
<h1 class="page-header-ui-title">¡Compre y utilice las plantillas!</h1>
<h2>Puede comprar sus plantillas mediante <b> PayPal </b> <fa-icon [icon]="faCreditCard"></fa-icon></h2>
</div>
</div>
<div class="bg-light py-10 container-encuestas">
<div class="container px-0">
<!--filtrado-->
<div class="input-group">
<div class="ds-filter">
<div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
<input class="form-control" type="text" name="searchString" placeholder="Buscar por nombre..." [(ngModel)]="searchString" />
</div>
<!--<div class="ds-filter">
<select name="searchCategoria" class="form-control" [(ngModel)]="searchCategoria" style="width: 200px">
<option value="" selected="selected" disabled="disabled">Filtrar por categoría</option>
<option value="">Todas las categorías</option>
<option *ngFor="let categoria of categorias" [value]="categoria.nombre">{{ categoria.nombre }}</option>
</select>
</div>-->
<!--<div class="ds-filter">
<div class="form-check pl-0 mb-3">
<input type="radio" class="form-check-input" id="under25" name="materialExampleRadios" [value]="0">
<label for="under25" [(ngModel)]="searchPrecio">GRATIS</label>
</div>
<div class="form-check pl-0 mb-3">
<input type="radio" class="form-check-input" id="2550" name="materialExampleRadios" [value]="">
<label for="2550" [(ngModel)]="searchPrecio"> $5 - $10</label>
</div>
<div class="form-check pl-0 mb-3">
<input type="radio" class="form-check-input" id="50100" name="materialExampleRadios">
<label for="50100" [(ngModel)]="searchPrecio">$10 - $20</label>
</div>
<div class="form-check pl-0 mb-3">
<input type="radio" class="form-check-input" id="100200" name="materialExampleRadios">
<label for="100200" [(ngModel)]="searchPrecio">$20 - $30</label>
</div>
<div class="form-check pl-0 mb-3">
<input type="radio" class="form-check-input" id="200above" name="materialExampleRadios">
<label [(ngModel)]="searchPrecio">Más de $30 </label>
</div>
</div>-->
</div>
<hr />
<div class="container" *ngIf="plantillas && plantillas.length == 0">
<h1 class="ds-title">Plantillas</h1>
<hr />
<div class="social-box">
<h1>
<fa-icon [icon]="faFileAlt"></fa-icon>
</h1>
</div>
</div>
<!--Inicio de los cards-->
<div class="row gx-5" *ngIf="plantillas && plantillas.length > 0">
<div
class="col-xl-4 col-lg-4 col-md-6 mb-5"
*ngFor="
let plantilla of plantillas
| filter: 'nombre':searchString
| filter: 'categoria.nombre':searchCategoria
| filter: 'precio':searchPrecio;
trackBy: trackId
"
>
<div class="card-encuesta lift h-100" [attr.data-id]="plantilla.id">
<!--(dblclick)="openSurvey($event)"
(click)="selectSurvey($event)"
-->
<div class="card-body p-3">
<div class="card-title mb-0">{{ plantilla.nombre }}</div>
<div class="entity-body--row m-2">
<span class="tag mt-2" *ngIf="plantilla.precio">Precio: {{ plantilla.precio | currency }}</span>
<span class="tag mt-2" *ngIf="plantilla.precio == 0 || plantilla.precio == null">Precio: GRATIS</span>
</div>
<div class="entity-body--row m-2" *ngIf="plantilla.categoria != null">
<span class="mt-2">{{ plantilla.categoria.nombre | lowercase }}</span>
</div>
<div class="entity-body--row m-2" *ngIf="plantilla.descripcion != null">
<span class="mt-2">{{ plantilla.descripcion | lowercase }}</span>
</div>
<div class="text-xs text-gray-500">
<div class="entity-body">
<div class="entity-body--row m-2">
<button class="ds-btn btn-outline-success btn-card" (click)="triggerPaypalDialog(plantilla)">
<fa-icon [icon]="faCreditCard"></fa-icon>&nbsp;&nbsp;Comprar con PayPal
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--Inicio de cards-->
</div>

View File

@ -0,0 +1,449 @@
/* ==========================================================================
Main page styles
========================================================================== */
.hipster {
display: inline-block;
width: 347px;
height: 497px;
background-size: contain;
}
.bg-img-cover {
background-position: center;
background-size: cover;
background-repeat: no-repeat;
background-color: #192e4d;
}
/*SPLIT CSS*/
.split {
height: 90%;
width: 100%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
padding-top: 20px;
}
.left {
left: 0;
background-color: #192e4d;
}
.right {
right: 0;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.bg-img-style {
padding-top: 2px;
margin-left: 50%;
margin-top: 0;
width: 400px;
height: 300px;
}
.overlay {
position: relative;
}
.overlay:before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #000;
opacity: 0.1;
}
.overlay-10:before {
opacity: 0.1;
}
.overlay-20:before {
opacity: 0.2;
}
.overlay-30:before {
opacity: 0.3;
}
.overlay-40:before {
opacity: 0.4;
}
.overlay-50:before {
opacity: 0.5;
}
.overlay-60:before {
opacity: 0.6;
}
.overlay-70:before {
opacity: 0.7;
}
.overlay-80:before {
opacity: 0.8;
}
.overlay-90:before {
opacity: 0.9;
}
.fixed-top,
.page-header-ui.navbar-fixed .navbar {
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: 1030;
}
.text-white-75,
.page-header-ui-dark .page-header-ui-text a {
color: rgba(255, 255, 255, 0.75) !important;
}
.page-header-ui {
position: relative;
padding-top: 4%;
padding-bottom: 4%;
}
.page-header-ui .page-header-ui-content .page-header-ui-title {
font-size: 2.5rem;
color: #000000;
}
.page-header-ui .page-header-ui-content .page-header-ui-text {
font-size: 1.15rem;
}
.page-header-ui .page-header-ui-content .page-header-ui-text.small {
font-size: 0.9rem;
}
.page-header-ui-dark {
color: #fffcf5 !important;
background-color: #212832;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.svg-border-rounded svg {
position: absolute;
bottom: 0;
left: 0;
height: 1rem;
width: 100%;
}
@media (min-width: 576px) {
.svg-border-rounded svg {
height: 1.5rem;
}
}
@media (min-width: 768px) {
.svg-border-rounded svg {
height: 2rem;
}
}
@media (min-width: 992px) {
.svg-border-rounded svg {
height: 2.5rem;
}
}
@media (min-width: 1200px) {
.svg-border-rounded svg {
height: 3rem;
}
}
/**
Cards
**/
.lift {
box-shadow: 0 0.15rem 1.75rem 0 rgba(33, 40, 50, 0.15);
transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.lift:hover {
transform: translateY(-0.3333333333rem);
box-shadow: 0 0.5rem 2rem 0 rgba(33, 40, 50, 0.25);
}
.lift:active {
transform: none;
box-shadow: 0 0.15rem 1.75rem 0 rgba(33, 40, 50, 0.15);
}
.lift-sm {
box-shadow: 0 0.125rem 0.25rem 0 rgba(33, 40, 50, 0.2);
}
.lift-sm:hover {
transform: translateY(-0.1666666667rem);
box-shadow: 0 0.25rem 1rem 0 rgba(33, 40, 50, 0.25);
}
.lift-sm:active {
transform: none;
box-shadow: 0 0.125rem 0.25rem 0 rgba(33, 40, 50, 0.2);
}
/*.card.lift {
text-decoration: none;
color: inherit;
}
.card-flag {
position: absolute;
font-size: 0.7rem;
padding: 0.3rem 0.5rem;
line-height: 1;
}
.card-flag-dark {
background-color: rgba(33, 40, 50, 0.7);
color: #fff;
}
.card-flag-light {
background-color: rgba(255, 255, 255, 0.7);
color: #69707a;
}
.card-flag-lg {
font-size: 0.9rem;
padding: 0.5rem 0.65rem;
}
.card-flag-top-right {
border-top-left-radius: 0.25rem;
border-bottom-left-radius: 0.25rem;
top: 0.5rem;
right: 0;
}
.card-flag-top-left {
border-top-right-radius: 0.25rem;
border-bottom-right-radius: 0.25rem;
top: 0.5rem;
left: 0;
}*/
.border-cyan {
border-color: #00cfd5 !important;
}
.py-10 {
padding-top: 6rem !important;
padding-bottom: 6rem !important;
}
/* wait autoprefixer update to allow simple generation of high pixel density media query */
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (-moz-min-device-pixel-ratio: 2),
only screen and (-o-min-device-pixel-ratio: 2/1),
only screen and (min-resolution: 192dpi),
only screen and (min-resolution: 2dppx) {
.hipster {
background-size: contain;
}
}
.icon-stack {
display: inline-flex;
justify-content: center;
align-items: center;
border-radius: 100%;
height: 2.5rem;
width: 2.5rem;
font-size: 1rem;
background-color: #f2f6fc;
flex-shrink: 0;
}
.icon-stack svg {
height: 1rem;
width: 1rem;
}
.icon-stack-sm {
height: 2rem;
width: 2rem;
}
.icon-stack-lg {
height: 4rem;
width: 4rem;
font-size: 1.5rem;
}
.icon-stack-lg svg {
height: 1.5rem;
width: 1.5rem;
}
.icon-stack-xl {
height: 5rem;
width: 5rem;
font-size: 1.75rem;
}
.icon-stack-xl svg {
height: 1.75rem;
width: 1.75rem;
}
.container-encuestas {
max-height: 1536px;
overflow-y: auto;
}
.bg-gradient-primary-to-secondary {
background-color: #1c44b2 !important;
background-image: linear-gradient(135deg, #1c44b2 0%, #00b88d 100%) !important;
}
/*.card .entity-icon--star {
color: #ffcc47;
margin-right: 0.2rem;
}
.card .card-title {
font-size: 2em;
}
.card .tag {
font-size: 0.8rem;
color: #f8f8f8;
margin-top: 0.5rem;
padding: 0.2rem 1.5rem;
background-color: #2962ff94;
border-radius: 15px;
}
.card .subtitle {
color: rgba(0, 0, 0, 0.54);
font-size: 0.9rem;
}
.card .btn-card {
padding: 11px 10px !important;
}*/
.accordion-button {
position: relative;
display: flex;
align-items: center;
width: 100%;
padding: 1rem 1.25rem;
font-size: 1rem;
color: #69707a;
text-align: left;
background-color: #fff;
border: 0;
border-radius: 0;
overflow-anchor: none;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out,
border-radius 0.15s ease;
}
@media (prefers-reduced-motion: reduce) {
.accordion-button {
transition: none;
}
}
.accordion-button:not(.collapsed) {
color: #0057da;
background-color: #e6effe;
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.125);
}
.accordion-button:not(.collapsed)::after {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%230057da'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
transform: rotate(-180deg);
}
.accordion-button::after {
flex-shrink: 0;
width: 1.25rem;
height: 1.25rem;
margin-left: auto;
content: '';
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2369707a'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
background-repeat: no-repeat;
background-size: 1.25rem;
transition: transform 0.2s ease-in-out;
}
@media (prefers-reduced-motion: reduce) {
.accordion-button::after {
transition: none;
}
}
.accordion-button:hover {
z-index: 2;
}
.accordion-button:focus {
z-index: 3;
border-color: transparent;
outline: 0;
box-shadow: 0 0 0 0.25rem #00b88d3a;
}
.accordion-header {
margin-bottom: 0;
}
.accordion-item {
background-color: #fff;
border: 1px solid rgba(0, 0, 0, 0.125);
}
.accordion-item:first-of-type {
border-top-left-radius: 0.35rem;
border-top-right-radius: 0.35rem;
}
.accordion-item:first-of-type .accordion-button {
border-top-left-radius: calc(0.35rem - 1px);
border-top-right-radius: calc(0.35rem - 1px);
}
.accordion-item:not(:first-of-type) {
border-top: 0;
}
.accordion-item:last-of-type {
border-bottom-right-radius: 0.35rem;
border-bottom-left-radius: 0.35rem;
}
.accordion-item:last-of-type .accordion-button.collapsed {
border-bottom-right-radius: calc(0.35rem - 1px);
border-bottom-left-radius: calc(0.35rem - 1px);
}
.accordion-item:last-of-type .accordion-collapse {
border-bottom-right-radius: 0.35rem;
border-bottom-left-radius: 0.35rem;
}
.accordion-body {
padding: 1rem 1.25rem;
}
.accordion-flush .accordion-collapse {
border-width: 0;
}
.accordion-flush .accordion-item {
border-right: 0;
border-left: 0;
border-radius: 0;
}
.accordion-flush .accordion-item:first-child {
border-top: 0;
}
.accordion-flush .accordion-item:last-child {
border-bottom: 0;
}
.accordion-flush .accordion-item .accordion-button {
border-radius: 0;
}
.card-header {
padding: 0;
}
.card-header .collapsed {
background-color: #e6effe;
}

View File

@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ListarTiendaPlantillaComponent } from './listar-tienda-plantilla.component';
describe('ListarTiendaPlantillaComponent', () => {
let component: ListarTiendaPlantillaComponent;
let fixture: ComponentFixture<ListarTiendaPlantillaComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ListarTiendaPlantillaComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ListarTiendaPlantillaComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,131 @@
import { Component, OnInit } from '@angular/core';
import { ICategoria } from '../../categoria/categoria.model';
import { Account } from '../../../core/auth/account.model';
import { UsuarioExtra } from '../../usuario-extra/usuario-extra.model';
import { IEncuesta } from '../../encuesta/encuesta.model';
import { Subject } from 'rxjs';
import { EncuestaService } from '../../encuesta/service/encuesta.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { CategoriaService } from '../../categoria/service/categoria.service';
import { UsuarioExtraService } from '../../usuario-extra/service/usuario-extra.service';
import { ActivatedRoute, Router } from '@angular/router';
import { FormBuilder } from '@angular/forms';
import { AccountService } from '../../../core/auth/account.service';
import { takeUntil } from 'rxjs/operators';
import { HttpResponse } from '@angular/common/http';
import { faPollH, faCalendarAlt, faStar, faListAlt, faFileAlt, faCreditCard } from '@fortawesome/free-solid-svg-icons';
import { IPlantilla } from '../../plantilla/plantilla.model';
import { PlantillaService } from '../../plantilla/service/plantilla.service';
import { EncuestaPublishDialogComponent } from '../../encuesta/encuesta-publish-dialog/encuesta-publish-dialog.component';
import { PaypalDialogComponent } from '../paypal-dialog/paypal-dialog.component';
@Component({
selector: 'jhi-listar-tienda-plantilla',
templateUrl: './listar-tienda-plantilla.component.html',
styleUrls: ['./listar-tienda-plantilla.component.scss'],
})
export class ListarTiendaPlantillaComponent implements OnInit {
public searchString: string;
public searchCategoria: string;
public searchPrecio: string;
categorias?: ICategoria[];
account: Account | null = null;
public searchEncuestaPublica: string;
notAccount: boolean = true;
usuarioExtra: UsuarioExtra | null = null;
plantillas?: IPlantilla[];
successPayment = false;
isLoading = false;
private readonly destroy$ = new Subject<void>();
faStar = faStar;
faCalendarAlt = faCalendarAlt;
faPollH = faPollH;
faListAlt = faListAlt;
faFileAlt = faFileAlt;
faCreditCard = faCreditCard;
constructor(
protected plantillaService: PlantillaService,
protected modalService: NgbModal,
protected categoriaService: CategoriaService,
protected usuarioExtraService: UsuarioExtraService,
protected activatedRoute: ActivatedRoute,
protected fb: FormBuilder,
protected accountService: AccountService,
protected router: Router
) {
this.searchEncuestaPublica = '';
this.searchString = '';
this.searchCategoria = '';
this.searchPrecio = '';
}
ngOnInit(): void {
this.searchEncuestaPublica = '';
this.accountService
.getAuthenticationState()
.pipe(takeUntil(this.destroy$))
.subscribe(account => {
if (account !== null) {
this.account = account;
this.notAccount = false;
} else {
this.notAccount = true;
}
});
this.loadAll();
this.loadAllCategorias();
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
loadAll(): void {
this.isLoading = true;
this.plantillaService.query().subscribe(
(res: HttpResponse<IPlantilla[]>) => {
this.isLoading = false;
const plantillasBody = res.body ?? [];
this.plantillas = plantillasBody.filter(e => e.estado === 'ACTIVE');
},
() => {
this.isLoading = false;
}
);
}
loadAllCategorias(): void {
this.isLoading = true;
this.categoriaService.query().subscribe(
(res: HttpResponse<ICategoria[]>) => {
this.isLoading = false;
this.categorias = res.body ?? [];
},
() => {
this.isLoading = false;
}
);
}
trackId(index: number, item: IEncuesta): number {
return item.id!;
}
triggerPaypalDialog(plantilla: IPlantilla): void {
const modalRef = this.modalService.open(PaypalDialogComponent, { size: 'lg', backdrop: 'static' });
modalRef.componentInstance.plantilla = plantilla;
// unsubscribe not needed because closed completes on modal close
modalRef.closed.subscribe(reason => {
if (reason === 'published') {
this.successPayment = true;
this.loadAll();
}
});
}
}

View File

@ -0,0 +1,10 @@
import { Route, RouterModule } from '@angular/router';
import { ListarTiendaPlantillaComponent } from './listar-tienda-plantilla.component';
export const TIENDA_PLANTILLA_ROUTE: Route = {
path: 'tienda-plantilla',
component: ListarTiendaPlantillaComponent,
data: {
pageTitle: 'tiendaPlantilla.title',
},
};

View File

@ -0,0 +1,26 @@
<form name="deleteForm">
<div class="modal-header">
<!-- <h4 class="modal-title" data-cy="encuestaDeleteDialogHeading" jhiTranslate="entity.publish.title">Confirm delete operation</h4>-->
</div>
<div class="modal-body">
<h1 class="ds-title">Plantilla: {{ plantilla!.nombre }}</h1>
<h2 class="ds-title--small">Cantidad: 1</h2>
<h2 class="ds-title--small">Total: ${{ plantilla!.precio }}</h2>
<hr />
<h2 class="entity-body--row m-2">La plantilla ha comprar no tiene costo alguno</h2>
<button type="button" class="ds-btn btn-outline-success fc-center" data-dismiss="modal" (click)="freePurchase()">
<fa-icon [icon]="faCheck"></fa-icon>&nbsp;<span>Finalizar compra</span>
</button>
<ngx-paypal [config]="payPalConfig" *ngIf="plantilla!.precio != 0"></ngx-paypal>
</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>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
</div>
</form>

View File

@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PaypalDialogComponent } from './paypal-dialog.component';
describe('PaypalDialogComponent', () => {
let component: PaypalDialogComponent;
let fixture: ComponentFixture<PaypalDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [PaypalDialogComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PaypalDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,161 @@
import { Component, OnInit } from '@angular/core';
import { IPayPalConfig, ICreateOrderRequest } from 'ngx-paypal';
import { ParametroAplicacionService } from '../../parametro-aplicacion/service/parametro-aplicacion.service';
import { EncuestaService } from '../../encuesta/service/encuesta.service';
import { FormBuilder } from '@angular/forms';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { IPlantilla } from '../../plantilla/plantilla.model';
import { faCreditCard, faCheck } from '@fortawesome/free-solid-svg-icons';
import { Account } from '../../../core/auth/account.model';
import { UsuarioExtra } from '../../usuario-extra/usuario-extra.model';
import { UsuarioExtraService } from '../../usuario-extra/service/usuario-extra.service';
import { IFactura } from '../../factura/factura.model';
import { takeUntil } from 'rxjs/operators';
import { AccountService } from '../../../core/auth/account.service';
import { Subject } from 'rxjs';
import * as dayjs from 'dayjs';
import { FacturaService } from '../../factura/service/factura.service';
@Component({
selector: 'jhi-paypal-dialog',
templateUrl: './paypal-dialog.component.html',
styleUrls: ['./paypal-dialog.component.scss'],
})
export class PaypalDialogComponent implements OnInit {
public payPalConfig?: IPayPalConfig;
showSuccess = false;
plantilla?: IPlantilla;
account: Account | null = null;
usuarioExtra: UsuarioExtra | null = null;
factura?: IFactura;
notAccount: boolean = true;
private readonly destroy$ = new Subject<void>();
faCreditCard = faCreditCard;
faCheck = faCheck;
constructor(
protected facturaService: FacturaService,
protected usuarioExtraService: UsuarioExtraService,
protected activeModal: NgbActiveModal,
protected accountService: AccountService
) {}
ngOnInit(): void {
this.accountService
.getAuthenticationState()
.pipe(takeUntil(this.destroy$))
.subscribe(account => {
if (account !== null) {
this.account = account;
this.notAccount = false;
} else {
this.notAccount = true;
}
});
this.getUser();
this.initConfig();
}
private initConfig(): void {
this.payPalConfig = {
currency: 'USD',
clientId: 'AUIxW_mYvd_h3mMqTtHdrSNMJ9yPmJkpiOCkNq454vDxXCN6hgadgPHIX_9PTeQn1Qv8m-ozcQUQkUjZ',
createOrderOnClient: data =>
<ICreateOrderRequest>{
intent: 'CAPTURE',
purchase_units: [
{
amount: {
currency_code: 'USD',
value: String(this.plantilla?.precio),
breakdown: {
item_total: {
currency_code: 'USD',
value: String(this.plantilla?.precio),
},
},
},
items: [
{
name: this.plantilla?.nombre,
quantity: '1',
unit_amount: {
currency_code: 'USD',
value: String(this.plantilla?.precio),
},
},
],
},
],
},
advanced: {
commit: 'true',
},
style: {
label: 'paypal',
layout: 'vertical',
},
onApprove: (data, actions) => {
console.log('onApprove - transaction was approved, but not authorized', data, actions);
actions.order.get().then((details: any) => {
//calls baxkend
console.log('onApprove - you can get full order details inside onApprove: ', details);
});
},
onClientAuthorization: data => {
debugger;
console.log('onClientAuthorization - you should probably inform your server about completed transaction at this point', data);
this.updateUser();
this.sendReceipt();
},
};
}
cancel(): void {
this.activeModal.dismiss();
}
getUser(): void {
debugger;
// Get jhi_user and usuario_extra information
if (this.account !== null) {
this.usuarioExtraService.find(this.account.id).subscribe(usuarioExtra => {
this.usuarioExtra = usuarioExtra.body;
});
}
}
updateUser(): void {
this.usuarioExtra?.plantillas?.push(this.plantilla!);
this.usuarioExtraService.update(this.usuarioExtra!).subscribe(() => {
this.showSuccess = true;
});
}
sendReceipt(): void {
const now = dayjs();
debugger;
this.factura = {
nombreUsuario: String(this.usuarioExtra?.id!),
nombrePlantilla: this.plantilla?.nombre!,
costo: this.plantilla?.precio,
fecha: now,
};
this.facturaService.create(this.factura).subscribe(() => {
this.showSuccess = true;
this.cancel();
});
//send
}
freePurchase(): void {
this.getUser();
this.sendReceipt();
}
}

View File

@ -33,12 +33,18 @@
</div> </div>
</div> </div>
</form> </form>
<div class="alert alert-warning" id="no-result" *ngIf="usuarioEncuestas?.length === 0">
<span jhiTranslate="dataSurveyApp.usuarioEncuesta.home.notFound">No usuarioEncuestas found</span> <div class="ds-survey" id="entities" *ngIf="usuarioEncuestas?.length === 0">
<div class="ds-survey--all-question-wrapper">
<ng-container class="">
<p class="ds-title text-center">No posee colaboraciones</p>
<p class="ds-subtitle text-center">Inicie colaborando con otros usuarios mundialmente al recibir una invitación</p>
</ng-container>
</div>
</div> </div>
<div class="table-responsive" id="entities" *ngIf="usuarioEncuestas && usuarioEncuestas.length > 0"> <div class="table-responsive" id="entities" *ngIf="usuarioEncuestas && usuarioEncuestas.length > 0">
<table class="table table-striped" aria-describedby="page-heading"> <table class="ds-table table table-striped" aria-describedby="page-heading">
<thead> <thead>
<tr> <tr>
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.rol">Rol</span></th> <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.rol">Rol</span></th>

View File

@ -15,7 +15,7 @@
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span> <fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button> </button>
<button id="jhi-confirm-delete-usuarioExtra" data-cy="entityConfirmDeleteButton" type="submit" class="ds-btn ds-btn--danger"> <button id="jhi-confirm-delete-usuarioExtra" data-cy="entityConfirmDeleteButton" type="submit" class="ds-btn ds-btn--toggle">
<fa-icon [icon]="faExchangeAlt"></fa-icon> <fa-icon [icon]="faExchangeAlt"></fa-icon>
<span jhiTranslate="entity.action.toggleStatus">Cambiar estado</span> <span jhiTranslate="entity.action.toggleStatus">Cambiar estado</span>
</button> </button>

View File

@ -43,7 +43,7 @@
</div> </div>
</form> </form>
<div class="table-responsive" id="entities" *ngIf="usuarioExtras && usuarioExtras.length > 0"> <div class="table-responsive" id="entities" *ngIf="usuarioExtras && usuarioExtras.length > 0">
<table class="table table-striped" aria-describedby="page-heading"> <table class="ds-table table table-striped" aria-describedby="page-heading">
<thead> <thead>
<tr> <tr>
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.rol">Rol</span></th> <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.rol">Rol</span></th>
@ -96,7 +96,7 @@
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span> <span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
</button> --> </button> -->
<button type="submit" (click)="delete(usuarioExtra)" class="ds-btn ds-btn--danger" data-cy="entityDeleteButton"> <button type="submit" (click)="delete(usuarioExtra)" class="ds-btn ds-btn--toggle" data-cy="entityDeleteButton">
<fa-icon [icon]="faExchangeAlt"></fa-icon> <fa-icon [icon]="faExchangeAlt"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.toggleStatus">Toggle Status</span> <span class="d-none d-md-inline" jhiTranslate="entity.action.toggleStatus">Toggle Status</span>
</button> </button>

View File

@ -88,7 +88,7 @@ export class UsuarioExtraUpdateComponent {
login, login,
email, email,
password, password,
langKey: this.translateService.currentLang, langKey: this.translateService.currentLang!,
name, name,
firstName, firstName,
profileIcon: this.profileIcon, profileIcon: this.profileIcon,

View File

@ -0,0 +1,73 @@
<div *ngIf="usuarioExtra">
<h2 id="page-heading" data-cy="UsuarioEncuestaHeading">
<span class="ds-title" jhiTranslate="dataSurveyApp.usuarioExtra.plantillas.title">Mis Plantillas </span>
<p class="ds-subtitle">Cree encuestas a partir de las plantillas previamente compradas</p>
<div class="d-flex justify-content-end">
<button class="ds-btn ds-btn--secondary mr-2" (click)="loadAll()" [disabled]="isLoading">
<fa-icon icon="sync" [spin]="isLoading"></fa-icon>
<span jhiTranslate="dataSurveyApp.usuarioExtra.home.refreshListLabel">Refresh List</span>
</button>
</div>
</h2>
<jhi-alert-error></jhi-alert-error>
<jhi-alert></jhi-alert>
<form *ngIf="misPlantillas?.length === 0" class="ds-form">
<div class="input-group">
<div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
<input type="text" name="searchString" placeholder="Buscar..." [(ngModel)]="searchString" />
</div>
</form>
<div class="ds-survey" id="entities" *ngIf="misPlantillas?.length === 0">
<div class="ds-survey--all-question-wrapper">
<ng-container>
<p class="ds-title text-center">No posee plantillas</p>
<p class="ds-subtitle text-center">Adquiera y compre diferentes plantillas disponibles en nuestra tienda</p>
</ng-container>
</div>
</div>
<div class="table-responsive" id="entities" *ngIf="misPlantillas && misPlantillas.length > 0">
<table class="ds-table table table-striped" aria-describedby="page-heading">
<thead>
<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.categoria">Categoria</span></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let miPlantilla of misPlantillas | filter: 'nombre':searchString; trackBy: trackId" data-cy="entityTable">
<td>{{ miPlantilla.nombre }}</td>
<td>{{ miPlantilla.descripcion }}</td>
<td>{{ miPlantilla.categoria?.nombre }}</td>
<td class="text-right">
<div class="btn-group">
<button
type="submit"
[routerLink]="['/plantilla', miPlantilla.id, 'preview']"
class="ds-btn ds-btn--secondary btn-sm"
data-cy="entityDetailsButton"
>
<fa-icon icon="eye"></fa-icon>
<span class="d-none d-md-inline">Vista previa</span>
</button>
<button
type="submit"
class="ds-btn ds-btn--primary btn-sm"
data-cy="entityCreateButton"
(click)="crearEncuesta(miPlantilla.id)"
>
<span class="d-none d-md-inline" jhiTranslate="dataSurveyApp.usuarioExtra.plantillas.crearEncuesta">Crear Encuesta</span>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>

View File

@ -0,0 +1,100 @@
import { Component, OnInit } from '@angular/core';
import { UsuarioExtra } from '../../usuario-extra/usuario-extra.model';
import { IPlantilla } from '../../plantilla/plantilla.model';
import { PlantillaService } from '../../plantilla/service/plantilla.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { CategoriaService } from '../../categoria/service/categoria.service';
import { UsuarioExtraService } from '../../usuario-extra/service/usuario-extra.service';
import { ActivatedRoute, Router } from '@angular/router';
import { FormBuilder } from '@angular/forms';
import { AccountService } from '../../../core/auth/account.service';
import * as dayjs from 'dayjs';
import { DATE_TIME_FORMAT } from 'app/config/input.constants';
import { Account } from '../../../core/auth/account.model';
import { Encuesta } from './../../encuesta/encuesta.model';
import { EncuestaService } from 'app/entities/encuesta/service/encuesta.service';
import { AccesoEncuesta } from 'app/entities/enumerations/acceso-encuesta.model';
import { EstadoEncuesta } from 'app/entities/enumerations/estado-encuesta.model';
@Component({
selector: 'jhi-usuario-plantillas',
templateUrl: './usuario-plantillas.component.html',
styleUrls: ['./usuario-plantillas.component.scss'],
})
export class UsuarioPlantillasComponent implements OnInit {
misPlantillas?: IPlantilla[] | null | undefined;
isLoading = false;
usuarioExtra: UsuarioExtra | null = null;
account: Account | null = null;
searchString: string;
constructor(
protected plantillaService: PlantillaService,
protected modalService: NgbModal,
protected categoriaService: CategoriaService,
protected usuarioExtraService: UsuarioExtraService,
protected activatedRoute: ActivatedRoute,
protected fb: FormBuilder,
protected accountService: AccountService,
protected encuestaService: EncuestaService,
protected router: Router
) {
this.searchString = '';
}
ngOnInit(): void {
this.accountService.getAuthenticationState().subscribe(account => {
if (account !== null) {
this.account = account;
this.loadAll();
}
});
}
loadAll() {
this.isLoading = true;
// Get jhi_user and usuario_extra information
if (this.account !== null) {
this.usuarioExtraService.find(this.account.id).subscribe(usuarioExtra => {
this.usuarioExtra = usuarioExtra.body;
this.misPlantillas = usuarioExtra.body?.plantillas;
this.isLoading = false;
if (this.usuarioExtra !== null) {
if (this.usuarioExtra.id === undefined) {
const today = dayjs().startOf('day');
this.usuarioExtra.fechaNacimiento = today;
}
}
});
}
}
trackId(_index: number, item: IPlantilla): number {
return item.id!;
}
crearEncuesta(plantillaId: any): void {
const now = dayjs();
const newSurvey = {
...new Encuesta(),
id: undefined,
nombre: 'This is a survey',
descripcion: 'This is a survey',
fechaCreacion: dayjs(now, DATE_TIME_FORMAT),
calificacion: 5,
acceso: AccesoEncuesta.PUBLIC,
contrasenna: undefined,
estado: EstadoEncuesta.DRAFT,
categoria: undefined,
usuarioExtra: this.usuarioExtra,
};
console.log(plantillaId, newSurvey);
this.encuestaService.createFromTemplate(newSurvey, plantillaId).subscribe(_res => {
this.router.navigate(['/encuesta']);
});
}
}

View File

@ -0,0 +1,11 @@
import { Route, RouterModule } from '@angular/router';
import { UsuarioPlantillasComponent } from '../list/usuario-plantillas.component';
export const USUARIO_PLANTILLAS_ROUTE: Route = {
path: '',
component: UsuarioPlantillasComponent,
data: {
pageTitle: 'dataSurveyApp.usuarioExtra.plantillas.title',
},
};

View File

@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { UsuarioPlantillasComponent } from './list/usuario-plantillas.component';
import { RouterModule } from '@angular/router';
import { USUARIO_PLANTILLAS_ROUTE } from './route/usuario-plantillas.route';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { SharedModule } from '../../shared/shared.module';
@NgModule({
declarations: [UsuarioPlantillasComponent],
imports: [CommonModule, RouterModule.forChild([USUARIO_PLANTILLAS_ROUTE]), FontAwesomeModule, SharedModule],
})
export class UsuarioPlantillasModule {}

View File

@ -21,6 +21,7 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
</div> </div>
<!-- <div *ngIf="isNotMobileMenu()"> <!-- <div *ngIf="isNotMobileMenu()">
<form class="navbar-form navbar-left navbar-search-form" role="search"> <form class="navbar-form navbar-left navbar-search-form" role="search">
<div class="input-group"> <div class="input-group">

View File

@ -24,6 +24,12 @@ export const ADMIN_ROUTES: RouteInfo[] = [
// }, // },
{ path: '/pagina-principal', title: 'Inicio', type: 'link', icontype: 'nc-icon nc-world-2' }, { path: '/pagina-principal', title: 'Inicio', type: 'link', icontype: 'nc-icon nc-world-2' },
{
path: '/dashboard/admin',
title: 'Dashboard',
type: 'link',
icontype: 'nc-icon nc-chart-bar-32',
},
{ {
path: '/encuesta', path: '/encuesta',
title: 'Encuestas', title: 'Encuestas',
@ -58,28 +64,35 @@ export const ADMIN_ROUTES: RouteInfo[] = [
export const USER_ROUTES: RouteInfo[] = [ export const USER_ROUTES: RouteInfo[] = [
{ path: '/pagina-principal', title: 'Inicio', type: 'link', icontype: 'nc-icon nc-world-2' }, { path: '/pagina-principal', title: 'Inicio', type: 'link', icontype: 'nc-icon nc-world-2' },
{
path: '/dashboard/user',
title: 'Dashboard',
type: 'link',
icontype: 'nc-icon nc-chart-bar-32',
},
{ {
path: '/encuesta', path: '/encuesta',
title: 'Encuestas', title: 'Encuestas',
type: 'link', type: 'link',
icontype: 'nc-icon nc-paper', icontype: 'nc-icon nc-paper',
}, },
{ path: '/tienda-plantilla', title: 'Tienda', type: 'link', icontype: 'nc-icon nc-shop' },
// { // {
// path: '/tienda', // path: '/tienda',
// title: 'Tienda', // title: 'Tienda',
// type: 'link', // type: 'link',
// icontype: 'nc-icon nc-cart-simple', // icontype: 'nc-icon nc-cart-simple',
// }, // },
// { {
// path: '/plantilla', path: '/mis-plantillas',
// title: 'Plantillas', title: 'Mis Plantillas',
// type: 'link', type: 'link',
// icontype: 'nc-icon nc-album-2', icontype: 'nc-icon nc-album-2',
// }, },
{ {
path: '/colaboraciones', path: '/colaboraciones',
title: 'Colaboraciones', title: 'Colaboraciones',
type: 'link', type: 'link',
icontype: 'nc-icon nc-world-2', icontype: 'nc-icon nc-single-02',
}, },
]; ];

View File

@ -97,7 +97,7 @@
> >
</div> </div>
<div class="entity-body--row m-2"> <div class="entity-body--row m-2">
<p>Calificacion</p> <p>Calificación</p>
<fa-icon *ngFor="let i of [].constructor(encuesta.calificacion)" class="entity-icon--star" [icon]="faStar"></fa-icon> <fa-icon *ngFor="let i of [].constructor(encuesta.calificacion)" class="entity-icon--star" [icon]="faStar"></fa-icon>
<fa-icon <fa-icon
*ngFor="let i of [].constructor(5 - encuesta.calificacion!)" *ngFor="let i of [].constructor(5 - encuesta.calificacion!)"
@ -106,7 +106,9 @@
></fa-icon> ></fa-icon>
</div> </div>
<div class="entity-body--row m-2"> <div class="entity-body--row m-2">
<button class="ds-btn btn-card"><fa-icon [icon]="faPollH"></fa-icon>&nbsp;&nbsp;Completar encuesta</button> <button (click)="completeEncuesta(encuesta)" class="ds-btn btn-card">
<fa-icon [icon]="faPollH"></fa-icon>&nbsp;&nbsp;Completar encuesta
</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -15,6 +15,8 @@ import { Subject } from 'rxjs';
import { faPollH, faCalendarAlt, faStar, faListAlt, faFileAlt } from '@fortawesome/free-solid-svg-icons'; import { faPollH, faCalendarAlt, faStar, faListAlt, faFileAlt } from '@fortawesome/free-solid-svg-icons';
import { ICategoria } from '../entities/categoria/categoria.model'; import { ICategoria } from '../entities/categoria/categoria.model';
import { AccesoEncuesta } from 'app/entities/enumerations/acceso-encuesta.model';
import { EncuestaPasswordDialogComponent } from 'app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component';
@Component({ @Component({
selector: 'jhi-pagina-principal', selector: 'jhi-pagina-principal',
@ -106,7 +108,21 @@ export class PaginaPrincipalComponent implements OnInit {
); );
} }
trackId(index: number, item: IEncuesta): number { trackId(_index: number, item: IEncuesta): number {
return item.id!; return item.id!;
} }
completeEncuesta(encuesta: IEncuesta): void {
this.router.navigate(['/encuesta', encuesta.id, 'complete']);
}
confirmPassword(encuesta: IEncuesta): void {
const modalRef = this.modalService.open(EncuestaPasswordDialogComponent, { size: 'lg', backdrop: 'static' });
modalRef.componentInstance.encuesta = encuesta;
modalRef.closed.subscribe(isValid => {
if (isValid) {
// Load the survey
}
});
}
} }

View File

@ -1,8 +1,6 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { SharedModule } from 'app/shared/shared.module'; import { SharedModule } from 'app/shared/shared.module';
import { PAGINA_PRINCIPAL_ROUTE } from './pagina-princial.route'; import { PAGINA_PRINCIPAL_ROUTE } from './pagina-princial.route';
import { PaginaPrincipalComponent } from './pagina-principal.component'; import { PaginaPrincipalComponent } from './pagina-principal.component';

View File

@ -6,6 +6,7 @@ import { Pipe, PipeTransform, Injectable } from '@angular/core';
@Injectable() @Injectable()
export class FilterPipe implements PipeTransform { export class FilterPipe implements PipeTransform {
transform(items: any[], field: string, value: string): any[] { transform(items: any[], field: string, value: string): any[] {
debugger;
if (!items) { if (!items) {
return []; return [];
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@ -102,8 +102,8 @@
@import 'paper-dashboard/datasurvey-home'; @import 'paper-dashboard/datasurvey-home';
@import 'paper-dashboard/datasurvey-filter'; @import 'paper-dashboard/datasurvey-filter';
@import 'paper-dashboard/datasurvey-survey'; @import 'paper-dashboard/datasurvey-survey';
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap'); @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap');
@import '~ngx-sharebuttons/themes/material/material-dark-theme'; @import '~ngx-sharebuttons/themes/material/material-dark-theme';
@import '~ngx-sharebuttons/themes/modern/modern-light-theme'; @import '~ngx-sharebuttons/themes/modern/modern-light-theme';
@import '~ngx-sharebuttons/themes/circles/circles-dark-theme'; @import '~ngx-sharebuttons/themes/circles/circles-dark-theme';
@import 'paper-dashboard/datasurvey-switch';

View File

@ -42,11 +42,11 @@
} }
.ds-btn--toggle { .ds-btn--toggle {
background-color: #ffaa47; background-color: #ff9a27;
color: #fff; color: #fff;
&:hover { &:hover {
background-color: #e09935; background-color: #d48020;
} }
} }

Some files were not shown because too many files have changed in this diff Show More