From 085d5a16a6f0eb0a08fdf98b9fb5efbce997cff5 Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Sun, 1 Aug 2021 16:18:53 -0600 Subject: [PATCH] Add publish and delete survey template to/from the store --- ...antilla-delete-store-dialog.component.html | 24 +++++++++++++++++ ...plantilla-delete-store-dialog.component.ts | 17 ++++++++++++ ...ntilla-publish-store-dialog.component.html | 24 +++++++++++++++++ ...lantilla-publish-store-dialog.component.ts | 20 ++++++++++++++ .../entities/plantilla/plantilla.module.ts | 4 +++ .../update/plantilla-update.component.html | 20 ++++++++++++++ .../update/plantilla-update.component.ts | 26 ++++++++++++++++++- src/main/webapp/i18n/es/estadoPlantilla.json | 2 +- src/main/webapp/i18n/es/plantilla.json | 6 ++++- 9 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 src/main/webapp/app/entities/plantilla/plantilla-delete-store-dialog/plantilla-delete-store-dialog.component.html create mode 100644 src/main/webapp/app/entities/plantilla/plantilla-delete-store-dialog/plantilla-delete-store-dialog.component.ts create mode 100644 src/main/webapp/app/entities/plantilla/plantilla-publish-store-dialog/plantilla-publish-store-dialog.component.html create mode 100644 src/main/webapp/app/entities/plantilla/plantilla-publish-store-dialog/plantilla-publish-store-dialog.component.ts diff --git a/src/main/webapp/app/entities/plantilla/plantilla-delete-store-dialog/plantilla-delete-store-dialog.component.html b/src/main/webapp/app/entities/plantilla/plantilla-delete-store-dialog/plantilla-delete-store-dialog.component.html new file mode 100644 index 0000000..c63b3d2 --- /dev/null +++ b/src/main/webapp/app/entities/plantilla/plantilla-delete-store-dialog/plantilla-delete-store-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/plantilla/plantilla-delete-store-dialog/plantilla-delete-store-dialog.component.ts b/src/main/webapp/app/entities/plantilla/plantilla-delete-store-dialog/plantilla-delete-store-dialog.component.ts new file mode 100644 index 0000000..d748b4b --- /dev/null +++ b/src/main/webapp/app/entities/plantilla/plantilla-delete-store-dialog/plantilla-delete-store-dialog.component.ts @@ -0,0 +1,17 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; + +@Component({ + templateUrl: './plantilla-delete-store-dialog.component.html', +}) +export class PlantillaDeleteStoreDialogComponent { + constructor(protected activeModal: NgbActiveModal) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDeleteFromStore(): void { + this.activeModal.close('confirm'); + } +} diff --git a/src/main/webapp/app/entities/plantilla/plantilla-publish-store-dialog/plantilla-publish-store-dialog.component.html b/src/main/webapp/app/entities/plantilla/plantilla-publish-store-dialog/plantilla-publish-store-dialog.component.html new file mode 100644 index 0000000..2a7685d --- /dev/null +++ b/src/main/webapp/app/entities/plantilla/plantilla-publish-store-dialog/plantilla-publish-store-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/plantilla/plantilla-publish-store-dialog/plantilla-publish-store-dialog.component.ts b/src/main/webapp/app/entities/plantilla/plantilla-publish-store-dialog/plantilla-publish-store-dialog.component.ts new file mode 100644 index 0000000..070568f --- /dev/null +++ b/src/main/webapp/app/entities/plantilla/plantilla-publish-store-dialog/plantilla-publish-store-dialog.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { faStore } from '@fortawesome/free-solid-svg-icons'; + +@Component({ + templateUrl: './plantilla-publish-store-dialog.component.html', +}) +export class PlantillaPublishStoreDialogComponent { + faStore = faStore; + + constructor(protected activeModal: NgbActiveModal) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmPublishToStore(): void { + this.activeModal.close('confirm'); + } +} diff --git a/src/main/webapp/app/entities/plantilla/plantilla.module.ts b/src/main/webapp/app/entities/plantilla/plantilla.module.ts index f4d2e54..602dba7 100644 --- a/src/main/webapp/app/entities/plantilla/plantilla.module.ts +++ b/src/main/webapp/app/entities/plantilla/plantilla.module.ts @@ -8,6 +8,8 @@ import { PlantillaRoutingModule } from './route/plantilla-routing.module'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { PlantillaDeleteQuestionDialogComponent } from './plantilla-delete-question-dialog/plantilla-delete-question-dialog.component'; import { PlantillaDeleteOptionDialogComponent } from './plantilla-delete-option-dialog/plantilla-delete-option-dialog.component'; +import { PlantillaPublishStoreDialogComponent } from './plantilla-publish-store-dialog/plantilla-publish-store-dialog.component'; +import { PlantillaDeleteStoreDialogComponent } from './plantilla-delete-store-dialog/plantilla-delete-store-dialog.component'; @NgModule({ imports: [SharedModule, PlantillaRoutingModule, FontAwesomeModule], @@ -18,6 +20,8 @@ import { PlantillaDeleteOptionDialogComponent } from './plantilla-delete-option- PlantillaDeleteDialogComponent, PlantillaDeleteQuestionDialogComponent, PlantillaDeleteOptionDialogComponent, + PlantillaPublishStoreDialogComponent, + PlantillaDeleteStoreDialogComponent, ], entryComponents: [PlantillaDeleteDialogComponent], }) diff --git a/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.html b/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.html index 117d224..8f4999e 100644 --- a/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.html +++ b/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.html @@ -26,6 +26,26 @@ >   Crear pregunta + + + + diff --git a/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.ts b/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.ts index 6a380e8..3ccf1f5 100644 --- a/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.ts +++ b/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.ts @@ -25,7 +25,7 @@ import { IPPreguntaCerrada } from 'app/entities/p-pregunta-cerrada/p-pregunta-ce import { PPreguntaCerradaService } from 'app/entities/p-pregunta-cerrada/service/p-pregunta-cerrada.service'; import { PPreguntaCerradaDeleteDialogComponent } from 'app/entities/p-pregunta-cerrada/delete/p-pregunta-cerrada-delete-dialog.component'; -import { faTimes, faPlus, faQuestion, faPollH, faEye } from '@fortawesome/free-solid-svg-icons'; +import { faTimes, faPlus, faQuestion, faPollH, faEye, faStore } from '@fortawesome/free-solid-svg-icons'; import { PreguntaCerradaTipo } from 'app/entities/enumerations/pregunta-cerrada-tipo.model'; import { PlantillaDeleteQuestionDialogComponent } from '../plantilla-delete-question-dialog/plantilla-delete-question-dialog.component'; import { PlantillaDeleteOptionDialogComponent } from '../plantilla-delete-option-dialog/plantilla-delete-option-dialog.component'; @@ -33,6 +33,9 @@ import { PlantillaDeleteOptionDialogComponent } from '../plantilla-delete-option import { ParametroAplicacionService } from './../../parametro-aplicacion/service/parametro-aplicacion.service'; import { IParametroAplicacion } from './../../parametro-aplicacion/parametro-aplicacion.model'; import { Router } from '@angular/router'; +import { EstadoPlantilla } from 'app/entities/enumerations/estado-plantilla.model'; +import { PlantillaDeleteStoreDialogComponent } from '../plantilla-delete-store-dialog/plantilla-delete-store-dialog.component'; +import { PlantillaPublishStoreDialogComponent } from '../plantilla-publish-store-dialog/plantilla-publish-store-dialog.component'; @Component({ selector: 'jhi-plantilla-update', @@ -44,6 +47,7 @@ export class PlantillaUpdateComponent implements OnInit, AfterViewChecked { faPollH = faPollH; faQuestion = faQuestion; faEye = faEye; + faStore = faStore; isSaving = false; isSavingQuestion = false; @@ -449,4 +453,24 @@ export class PlantillaUpdateComponent implements OnInit, AfterViewChecked { trackUsuarioExtraById(index: number, item: IUsuarioExtra): number { return item.id!; } + + publishTemplateToStore(): void { + const modalRef = this.modalService.open(PlantillaPublishStoreDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.closed.subscribe(reason => { + if (reason === 'confirm') { + this.plantilla!.estado = EstadoPlantilla.ACTIVE; + this.plantillaService.update(this.plantilla!).subscribe(res => {}); + } + }); + } + + deleteTemplateFromStore(): void { + const modalRef = this.modalService.open(PlantillaDeleteStoreDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.closed.subscribe(reason => { + if (reason === 'confirm') { + this.plantilla!.estado = EstadoPlantilla.DRAFT; + this.plantillaService.update(this.plantilla!).subscribe(res => {}); + } + }); + } } diff --git a/src/main/webapp/i18n/es/estadoPlantilla.json b/src/main/webapp/i18n/es/estadoPlantilla.json index a574065..ac690aa 100644 --- a/src/main/webapp/i18n/es/estadoPlantilla.json +++ b/src/main/webapp/i18n/es/estadoPlantilla.json @@ -3,7 +3,7 @@ "EstadoPlantilla": { "null": "", "DRAFT": "Borrador", - "ACTIVE": "Activa", + "ACTIVE": "En tienda", "DELETED": "Eliminada", "DISABLED": "Desactivada" } diff --git a/src/main/webapp/i18n/es/plantilla.json b/src/main/webapp/i18n/es/plantilla.json index 7a0d31d..6ec8675 100644 --- a/src/main/webapp/i18n/es/plantilla.json +++ b/src/main/webapp/i18n/es/plantilla.json @@ -12,7 +12,11 @@ "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 }}?" + "question": "¿Seguro que quiere eliminar Plantilla {{ id }}?", + "deletefromstore": "¿Seguro que quiere eliminar esta plantilla de la tienda?" + }, + "publish": { + "store": "¿Seguro que quiere publicar esta plantilla a la tienda?" }, "detail": { "title": "Plantilla"