From 300f20affd4ad48fb204f1539ec76dc8d7dc1129 Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Thu, 29 Jul 2021 02:10:39 -0600 Subject: [PATCH 1/3] 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/3] 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/3] 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;