From fb1a39969484310bea6eae9d6dad2dee135f6b2c Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Fri, 30 Jul 2021 01:34:25 -0600 Subject: [PATCH] Add edit question name --- .../encuesta/list/encuesta.component.ts | 1 - .../update/encuesta-update.component.html | 15 ++++++- .../update/encuesta-update.component.ts | 45 ++++++++++++++++--- .../paper-dashboard/_datasurvey-global.scss | 22 ++++----- 4 files changed, 64 insertions(+), 19 deletions(-) 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 1c39287..f22fa92 100644 --- a/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts +++ b/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts @@ -533,7 +533,6 @@ export class EncuestaComponent implements OnInit, AfterViewInit { 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(); 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 de60d31..0a45aa8 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 }}

  
- {{ i + 1 }}. {{ ePregunta.nombre }} + + {{ i + 1 }}.  + {{ ePregunta.nombre }} + { this.isLoading = false; this.ePreguntas = res.body ?? []; - console.log(this.ePreguntas); }, () => { this.isLoading = false; @@ -141,7 +140,6 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked { (res: any) => { this.isLoading = false; this.usuariosColaboradores = res.body ?? []; - console.log(this.usuariosColaboradores); }, () => { this.isLoading = false; @@ -152,7 +150,6 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked { async loadAplicationParameters(): Promise { const params = await this.parametroAplicacionService.find(1).toPromise(); this.parametrosAplicacion = params.body; - //console.log(this.parametrosAplicacion); } ngOnInit(): void { @@ -348,7 +345,6 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked { createQuestion(): void { const surveyId = this.encuesta?.id; - console.log(surveyId); } protected createFromFormClosedQuestion(): IEPreguntaCerrada { @@ -444,6 +440,45 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked { } } + updateQuestionName(event: any): void { + const questionType = event.target.dataset.tipo; + const questionId = event.target.dataset.id; + const questionName = event.target.innerText; + if (questionType) { + // Closed question + this.ePreguntaCerradaService.find(questionId).subscribe(res => { + const ePreguntaCerrada: EPreguntaCerrada | null = res.body ?? null; + const updatedEPreguntaCerrada = { ...ePreguntaCerrada }; + if (questionName !== ePreguntaCerrada?.nombre && ePreguntaCerrada !== null) { + updatedEPreguntaCerrada.nombre = questionName; + this.ePreguntaCerradaService.update(updatedEPreguntaCerrada).subscribe(updatedQuestion => { + console.log(updatedQuestion); + }); + } + }); + } else { + // Open question + // Closed question + this.ePreguntaAbiertaService.find(questionId).subscribe(res => { + const ePreguntaAbierta: EPreguntaAbierta | null = res.body ?? null; + const updatedEPreguntaAbierta = { ...ePreguntaAbierta }; + if (questionName !== ePreguntaAbierta?.nombre && ePreguntaAbierta !== null) { + updatedEPreguntaAbierta.nombre = questionName; + this.ePreguntaAbiertaService.update(updatedEPreguntaAbierta).subscribe(updatedQuestion => { + console.log(updatedQuestion); + }); + } + }); + } + // const questionId = event.target.dataset.id; + // const survey = { ...this.encuesta }; + // survey.nombre = updatedQuestionName; + // // 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 34ea87d..39e27b8 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss @@ -9,20 +9,20 @@ 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; +.ds-contenteditable { + border: 2.25px solid transparent; + border-radius: 3px; + outline: 0; + text-transform: none; - &:hover { - border: 2.25px solid #e5e5e5; - } + &:hover { + border: 2.25px solid #e5e5e5; + } - &:focus { - border: 2.25px solid #2962ff; - } + &:focus { + border: 2.25px solid #2962ff; } }