diff --git a/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.tmpSpec.ts b/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.tmpSpec.ts deleted file mode 100644 index 696fc99..0000000 --- a/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.tmpSpec.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { Plantilla } from '../plantilla.model'; -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { of } from 'rxjs'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; - -import { PlantillaService } from '../service/plantilla.service'; - -import { PlantillaDeleteDialogComponent } from './plantilla-delete-dialog.component'; -import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model'; - -jest.mock('@ng-bootstrap/ng-bootstrap'); - -describe('Component Tests', () => { - describe('Plantilla Management Delete Component', () => { - let comp: PlantillaDeleteDialogComponent; - let fixture: ComponentFixture; - let service: PlantillaService; - let mockActiveModal: NgbActiveModal; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - declarations: [PlantillaDeleteDialogComponent], - providers: [NgbActiveModal], - }) - .overrideTemplate(PlantillaDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(PlantillaDeleteDialogComponent); - comp = fixture.componentInstance; - service = TestBed.inject(PlantillaService); - mockActiveModal = TestBed.inject(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - jest.spyOn(service, 'delete').mockReturnValue(of(new HttpResponse({}))); - const pPlantilla = new Plantilla(); - - pPlantilla.id = 123; - pPlantilla.estado = EstadoPlantilla.DELETED; - // WHEN - comp.confirmDelete(pPlantilla); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.close).toHaveBeenCalledWith('deleted'); - }) - )); - - it('Should not call delete service on clear', () => { - // GIVEN - jest.spyOn(service, 'delete'); - - // WHEN - comp.cancel(); - - // THEN - expect(service.delete).not.toHaveBeenCalled(); - expect(mockActiveModal.close).not.toHaveBeenCalled(); - expect(mockActiveModal.dismiss).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/src/main/webapp/app/entities/plantilla/list/plantilla.component.html b/src/main/webapp/app/entities/plantilla/list/plantilla.component.html index 2e3dab0..1e9f101 100644 --- a/src/main/webapp/app/entities/plantilla/list/plantilla.component.html +++ b/src/main/webapp/app/entities/plantilla/list/plantilla.component.html @@ -67,7 +67,10 @@ > Edit - + + + + + diff --git a/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.scss b/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.temSpec.ts b/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.temSpec.ts new file mode 100644 index 0000000..0cd0af9 --- /dev/null +++ b/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.temSpec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PlantillaChangeStatusDialogComponent } from './plantilla-change-status-dialog.component'; + +describe('PlantillaChangeStatusDialogComponent', () => { + let component: PlantillaChangeStatusDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [PlantillaChangeStatusDialogComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PlantillaChangeStatusDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.ts b/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.ts new file mode 100644 index 0000000..ff5f9f0 --- /dev/null +++ b/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.ts @@ -0,0 +1,36 @@ +import { Component } from '@angular/core'; +import { PlantillaService } from '../service/plantilla.service'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model'; +import { IPlantilla } from '../plantilla.model'; + +import { faExchangeAlt } from '@fortawesome/free-solid-svg-icons'; + +@Component({ + selector: 'jhi-plantilla-change-status-dialog', + templateUrl: './plantilla-change-status-dialog.component.html', + styleUrls: ['./plantilla-change-status-dialog.component.scss'], +}) +export class PlantillaChangeStatusDialogComponent { + plantilla?: IPlantilla; + + faExchangeAlt = faExchangeAlt; + constructor(protected plantillaService: PlantillaService, protected activeModal: NgbActiveModal) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmChangeStatus(pPlantilla: IPlantilla) { + if (this.plantilla) { + if (pPlantilla.estado === EstadoPlantilla.DISABLED) { + this.plantilla.estado = EstadoPlantilla.DRAFT; + } else { + this.plantilla.estado = EstadoPlantilla.DISABLED; + } + this.plantillaService.update(this.plantilla).subscribe(() => { + this.activeModal.close('updated'); + }); + } + } +} diff --git a/src/main/webapp/app/entities/plantilla/plantilla.module.ts b/src/main/webapp/app/entities/plantilla/plantilla.module.ts index 602dba7..5ead5a0 100644 --- a/src/main/webapp/app/entities/plantilla/plantilla.module.ts +++ b/src/main/webapp/app/entities/plantilla/plantilla.module.ts @@ -10,6 +10,7 @@ import { PlantillaDeleteQuestionDialogComponent } from './plantilla-delete-quest 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'; +import { PlantillaChangeStatusDialogComponent } from './plantilla-change-status-dialog/plantilla-change-status-dialog.component'; @NgModule({ imports: [SharedModule, PlantillaRoutingModule, FontAwesomeModule], @@ -22,6 +23,7 @@ import { PlantillaDeleteStoreDialogComponent } from './plantilla-delete-store-di PlantillaDeleteOptionDialogComponent, PlantillaPublishStoreDialogComponent, PlantillaDeleteStoreDialogComponent, + PlantillaChangeStatusDialogComponent, ], entryComponents: [PlantillaDeleteDialogComponent], }) diff --git a/src/main/webapp/i18n/es/plantilla.json b/src/main/webapp/i18n/es/plantilla.json index dacb35c..4e45c2f 100644 --- a/src/main/webapp/i18n/es/plantilla.json +++ b/src/main/webapp/i18n/es/plantilla.json @@ -9,7 +9,10 @@ "notFound": "No se encontró ninguna plantilla" }, "created": "Una nueva plantilla ha sido creada con el identificador {{ param }}", - "updated": "Una plantilla ha sido actualizada con el identificador {{ param }}", + "updated": { + "detail": "Una plantilla ha sido actualizada con el identificador {{ param }}", + "buttonChangeEstado": "Cambiar estado" + }, "deleted": "Una plantilla ha sido eliminada con el identificador {{ param }}", "delete": { "question": "¿Seguro que quiere eliminar esta plantilla?", @@ -21,6 +24,14 @@ "detail": { "title": "Plantilla" }, + "desactivar": { + "titulo": "Desactivar plantilla", + "question": "¿Seguro que quiere desactivar la plantilla?" + }, + "activar": { + "titulo": "Activar plantilla", + "question": "¿Seguro que quiere activar la plantilla?. Esta será activada en estado de 'Borrador'" + }, "id": "ID", "nombre": "Nombre", "descripcion": "Descripción",