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/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 +
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 2e92f8a..1c39287 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; @@ -469,18 +477,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'; } @@ -512,4 +524,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/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 24152b7..de60d31 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 }} +

       { - 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(); @@ -432,6 +432,18 @@ 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; + // Prevent user update by setting to null + survey.usuarioExtra!.user = null; + + this.encuestaService.updateSurvey(survey).subscribe(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..34ea87d 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,21 @@ letter-spacing: 0.025rem; text-transform: uppercase; font-size: 1.2rem; + + &--interactive { + border: 2.25px solid transparent; + border-radius: 3px; + outline: 0; + text-transform: none; + + &:hover { + border: 2.25px solid #e5e5e5; + } + + &:focus { + border: 2.25px solid #2962ff; + } + } } .ds-title--small {