From 300f20affd4ad48fb204f1539ec76dc8d7dc1129 Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Thu, 29 Jul 2021 02:10:39 -0600 Subject: [PATCH 1/9] Add update survey --- .../datasurvey/web/rest/EncuestaResource.java | 25 +++++++++++ .../encuesta/service/encuesta.service.ts | 7 ++++ .../update/encuesta-update.component.html | 2 +- .../update/encuesta-update.component.ts | 41 +++++++++++++------ .../paper-dashboard/_datasurvey-global.scss | 14 +++++++ 5 files changed, 75 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/datasurvey/web/rest/EncuestaResource.java b/src/main/java/org/datasurvey/web/rest/EncuestaResource.java index 9547aad..992ae8f 100644 --- a/src/main/java/org/datasurvey/web/rest/EncuestaResource.java +++ b/src/main/java/org/datasurvey/web/rest/EncuestaResource.java @@ -136,6 +136,31 @@ public class EncuestaResource { .body(result); } + @PutMapping("/encuestas/update/{id}") + public ResponseEntity updateEncuestaReal( + @PathVariable(value = "id", required = false) final Long id, + @Valid @RequestBody Encuesta encuesta + ) throws URISyntaxException { + log.debug("REST request to update Encuesta : {}, {}", id, encuesta); + if (encuesta.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, encuesta.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!encuestaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Encuesta result = encuestaService.save(encuesta); + + return ResponseEntity + .ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, encuesta.getId().toString())) + .body(result); + } + @PutMapping("/encuestas/publish/{id}") public ResponseEntity publishEncuesta( @PathVariable(value = "id", required = false) final Long id, diff --git a/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts b/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts index 6e489b4..35bdf0b 100644 --- a/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts +++ b/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts @@ -33,6 +33,13 @@ export class EncuestaService { .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } + updateSurvey(encuesta: IEncuesta): Observable { + const copy = this.convertDateFromClient(encuesta); + return this.http + .put(`${this.resourceUrl}/update/${getEncuestaIdentifier(encuesta) as number}`, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + partialUpdate(encuesta: IEncuesta): Observable { const copy = this.convertDateFromClient(encuesta); return this.http diff --git a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html index bc0f16b..0341438 100644 --- a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html +++ b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html @@ -1,7 +1,7 @@

-

{{ encuesta!.nombre }}

+

{{ encuesta!.nombre }}

   { - if ((e.target as HTMLInputElement).checked) { - (e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active'); - } else { - (e.target as HTMLElement).offsetParent!.classList.remove('ds-survey--closed-option--active'); - } - }); - } - } + // initListeners(): void { + // const checkboxes = document.getElementsByClassName('ds-survey--checkbox'); + // for (let i = 0; i < checkboxes.length; i++) { + // checkboxes[i].addEventListener('click', e => { + // if ((e.target as HTMLInputElement).checked) { + // (e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active'); + // } else { + // (e.target as HTMLElement).offsetParent!.classList.remove('ds-survey--closed-option--active'); + // } + // }); + // } + // } previousState(): void { window.history.back(); @@ -416,6 +416,21 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked { this.isSavingQuestion = false; } + updateSurveyName(event: any) { + const updatedSurveyName = event.target.innerText; + if (updatedSurveyName !== this.encuesta?.nombre) { + const survey = { ...this.encuesta }; + survey.nombre = updatedSurveyName; + survey.usuarioExtra!.user = null; + console.log(survey); + + this.encuestaService.updateSurvey(survey).subscribe(res => { + console.log('UPDATED'); + console.log(res); + }); + } + } + // previousState(): void { // window.history.back(); // } diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss index f2f63e5..7cf14ee 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss @@ -9,6 +9,20 @@ letter-spacing: 0.025rem; text-transform: uppercase; font-size: 1.2rem; + + &--interactive { + border: 2.25px solid transparent; + border-radius: 3px; + outline: 0; + + &:hover { + border: 2.25px solid #e5e5e5; + } + + &:focus { + border: 2.25px solid #2962ff; + } + } } .ds-title--small { From 2e9564577fa44f89ac436b0d6ba371680bfcab3e Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Thu, 29 Jul 2021 21:26:19 -0600 Subject: [PATCH 2/9] Fix typo in password reset (finish state) --- .../finish/password-reset-finish.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html b/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html index 9971405..bbce28c 100644 --- a/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html +++ b/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html @@ -38,8 +38,8 @@
. + sign in +

From 6f0ea69a27f7caeab986ddb9b3f8d23690c06996 Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Thu, 29 Jul 2021 22:15:36 -0600 Subject: [PATCH 3/9] Add edit survey from survey list --- .../encuesta/list/encuesta.component.html | 151 +++++++++++++++++- .../encuesta/list/encuesta.component.ts | 41 ++++- .../update/encuesta-update.component.html | 4 +- .../update/encuesta-update.component.ts | 7 +- .../paper-dashboard/_datasurvey-global.scss | 1 + 5 files changed, 195 insertions(+), 9 deletions(-) diff --git a/src/main/webapp/app/entities/encuesta/list/encuesta.component.html b/src/main/webapp/app/entities/encuesta/list/encuesta.component.html index 613dd54..249c71d 100644 --- a/src/main/webapp/app/entities/encuesta/list/encuesta.component.html +++ b/src/main/webapp/app/entities/encuesta/list/encuesta.component.html @@ -97,7 +97,9 @@
  • - +
  • + + + diff --git a/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts b/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts index afb3beb..6b52be7 100644 --- a/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts +++ b/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts @@ -99,6 +99,14 @@ export class EncuestaComponent implements OnInit, AfterViewInit { // usuarioExtra: [], }); + surveyEditForm = this.fb.group({ + id: [], + nombre: [null, [Validators.required, Validators.minLength(1), Validators.maxLength(50)]], + descripcion: [], + acceso: [null, [Validators.required]], + categoria: [null, [Validators.required]], + }); + createAnother: Boolean = false; selectedSurveyId: number | null = null; @@ -465,18 +473,22 @@ export class EncuestaComponent implements OnInit, AfterViewInit { let res = await this.encuestaService.find(this.selectedSurveyId).toPromise(); this.selectedSurvey = res.body; + // Fill in the edit survey + this.fillSurveyEditForm(); this.isPublished = this.selectedSurvey!.estado === 'ACTIVE' || this.selectedSurvey!.estado === 'FINISHED'; // QUE SE LE MUESTRE CUANDO ESTE EN DRAFT document.getElementById('contextmenu-create--separator')!.style.display = 'none'; - document.getElementById('contextmenu-edit--separator')!.style.display = 'block'; document.getElementById('contextmenu-delete--separator')!.style.display = 'block'; - document.getElementById('contextmenu-edit')!.style.display = 'block'; + document.getElementById('contextmenu-edit--separator')!.style.display = 'block'; document.getElementById('contextmenu-preview')!.style.display = 'block'; if (!this.isPublished) { + document.getElementById('contextmenu-edit--separator')!.style.display = 'block'; + document.getElementById('contextmenu-edit')!.style.display = 'block'; document.getElementById('contextmenu-publish')!.style.display = 'block'; document.getElementById('contextmenu-duplicate')!.style.display = 'block'; } else { + document.getElementById('contextmenu-edit')!.style.display = 'none'; document.getElementById('contextmenu-publish')!.style.display = 'none'; document.getElementById('contextmenu-duplicate')!.style.display = 'none'; } @@ -508,4 +520,29 @@ export class EncuestaComponent implements OnInit, AfterViewInit { const res = await this.encuestaService.duplicate(this.selectedSurveyId!).toPromise(); this.loadAll(); } + + editSurvey(): void { + const survey = { ...this.selectedSurvey }; + survey.nombre = this.surveyEditForm.get(['nombre'])!.value; + survey.descripcion = this.surveyEditForm.get(['descripcion'])!.value; + survey.acceso = this.surveyEditForm.get(['acceso'])!.value; + survey.categoria = this.surveyEditForm.get(['categoria'])!.value; + // Prevent user update by setting to null + survey.usuarioExtra!.user = null; + console.log(survey); + + this.encuestaService.updateSurvey(survey).subscribe(res => { + this.loadAll(); + $('#cancelEditSurveyBtn').click(); + }); + } + + fillSurveyEditForm(): void { + this.surveyEditForm.patchValue({ + nombre: this.selectedSurvey!.nombre, + descripcion: this.selectedSurvey!.descripcion, + acceso: this.selectedSurvey!.acceso, + categoria: this.selectedSurvey!.categoria, + }); + } } diff --git a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html index 0341438..3b84421 100644 --- a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html +++ b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html @@ -1,7 +1,9 @@

    -

    {{ encuesta!.nombre }}

    +

    + {{ encuesta!.nombre }} +

       { - console.log('UPDATED'); - console.log(res); - }); + this.encuestaService.updateSurvey(survey).subscribe(res => {}); } } diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss index 7cf14ee..34ea87d 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss @@ -14,6 +14,7 @@ border: 2.25px solid transparent; border-radius: 3px; outline: 0; + text-transform: none; &:hover { border: 2.25px solid #e5e5e5; From d93378c56fb78036a4e0c2521727944a49bb9415 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Thu, 29 Jul 2021 22:33:00 -0600 Subject: [PATCH 4/9] declarar no uso de index en trackid --- .../webapp/app/entities/plantilla/list/plantilla.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/app/entities/plantilla/list/plantilla.component.ts b/src/main/webapp/app/entities/plantilla/list/plantilla.component.ts index 21ab70f..1c1e111 100644 --- a/src/main/webapp/app/entities/plantilla/list/plantilla.component.ts +++ b/src/main/webapp/app/entities/plantilla/list/plantilla.component.ts @@ -34,7 +34,7 @@ export class PlantillaComponent implements OnInit { this.loadAll(); } - trackId(index: number, item: IPlantilla): number { + trackId(_index: number, item: IPlantilla): number { return item.id!; } From 4b3f1368a7b6f2b46882a30ccc5a4203c4f35042 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Thu, 29 Jul 2021 22:35:19 -0600 Subject: [PATCH 5/9] rehabilitar el link de plantillas en el sidebar --- .../webapp/app/layouts/sidebar/sidebar.constants.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts b/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts index 132e293..5c5d412 100644 --- a/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts +++ b/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts @@ -30,12 +30,12 @@ export const ADMIN_ROUTES: RouteInfo[] = [ type: 'link', icontype: 'nc-icon nc-paper', }, - // { - // path: '/plantilla', - // title: 'Plantillas', - // type: 'link', - // icontype: 'nc-icon nc-album-2', - // }, + { + path: '/plantilla', + title: 'Plantillas', + type: 'link', + icontype: 'nc-icon nc-album-2', + }, { path: '/categoria', title: 'Categorías', From e1cf432fc30971b81362eb8b5f3444d29fed8330 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Thu, 29 Jul 2021 22:49:50 -0600 Subject: [PATCH 6/9] agregar estilos de botones --- .../entities/plantilla/list/plantilla.component.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/app/entities/plantilla/list/plantilla.component.html b/src/main/webapp/app/entities/plantilla/list/plantilla.component.html index c726a6a..0c24c2f 100644 --- a/src/main/webapp/app/entities/plantilla/list/plantilla.component.html +++ b/src/main/webapp/app/entities/plantilla/list/plantilla.component.html @@ -3,7 +3,7 @@ Plantillas
    - @@ -11,7 +11,7 @@ - From 14ec57ab12098e533e31c29e142e8c13342c0f03 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Thu, 29 Jul 2021 22:50:21 -0600 Subject: [PATCH 7/9] =?UTF-8?q?corregir=20uso=20de=20ingl=C3=A9s=20en=20ht?= =?UTF-8?q?ml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/entities/plantilla/list/plantilla.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/app/entities/plantilla/list/plantilla.component.html b/src/main/webapp/app/entities/plantilla/list/plantilla.component.html index 0c24c2f..268a280 100644 --- a/src/main/webapp/app/entities/plantilla/list/plantilla.component.html +++ b/src/main/webapp/app/entities/plantilla/list/plantilla.component.html @@ -15,7 +15,7 @@ [routerLink]="['/plantilla/new']" > - Create a new Plantilla + Create a new Template

    @@ -25,7 +25,7 @@
    - No plantillas found + No templates found
    From 0a774fc11002db497620833db2c2f23cef018cdd Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Thu, 29 Jul 2021 22:50:38 -0600 Subject: [PATCH 8/9] remover columnas innecesarias --- .../app/entities/plantilla/list/plantilla.component.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/webapp/app/entities/plantilla/list/plantilla.component.html b/src/main/webapp/app/entities/plantilla/list/plantilla.component.html index 268a280..ba8d9d5 100644 --- a/src/main/webapp/app/entities/plantilla/list/plantilla.component.html +++ b/src/main/webapp/app/entities/plantilla/list/plantilla.component.html @@ -32,7 +32,6 @@ - @@ -45,9 +44,6 @@ - From c858e73a299d3dd6d2bb44b3fa9ba77c6d0063dc Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Thu, 29 Jul 2021 22:55:16 -0600 Subject: [PATCH 9/9] =?UTF-8?q?Arreglar=20traducci=C3=B3n=20de=20listado?= =?UTF-8?q?=20de=20plantillas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/i18n/es/plantilla.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/webapp/i18n/es/plantilla.json b/src/main/webapp/i18n/es/plantilla.json index a6a62cd..7a0d31d 100644 --- a/src/main/webapp/i18n/es/plantilla.json +++ b/src/main/webapp/i18n/es/plantilla.json @@ -4,13 +4,13 @@ "home": { "title": "Plantillas", "refreshListLabel": "Refrescar lista", - "createLabel": "Crear nuevo Plantilla", - "createOrEditLabel": "Crear o editar Plantilla", - "notFound": "Ningún Plantillas encontrado" + "createLabel": "Crear nueva plantilla", + "createOrEditLabel": "Crear o editar plantilla", + "notFound": "No se encontró ninguna plantilla" }, - "created": "Un nuevo Plantilla ha sido creado con el identificador {{ param }}", - "updated": "Un Plantilla ha sido actualizado con el identificador {{ param }}", - "deleted": "Un Plantilla ha sido eliminado con el identificador {{ param }}", + "created": "Una nueva plantilla ha sido creada con el identificador {{ param }}", + "updated": "Una plantilla ha sido actualizada con el identificador {{ param }}", + "deleted": "Una plantilla ha sido eliminada con el identificador {{ param }}", "delete": { "question": "¿Seguro que quiere eliminar Plantilla {{ id }}?" }, @@ -19,9 +19,9 @@ }, "id": "ID", "nombre": "Nombre", - "descripcion": "Descripcion", - "fechaCreacion": "Fecha Creacion", - "fechaPublicacionTienda": "Fecha Publicacion Tienda", + "descripcion": "Descripción", + "fechaCreacion": "Fecha Creación", + "fechaPublicacionTienda": "Fecha Publicación Tienda", "estado": "Estado", "precio": "Precio", "pPreguntaCerrada": "P Pregunta Cerrada",
    ID Nombre Descripcion Fecha Creacion
    - {{ plantilla.id }} - {{ plantilla.nombre }} {{ plantilla.descripcion }} {{ plantilla.fechaCreacion | formatMediumDatetime }}