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;