diff --git a/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html b/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html index d996676..59e46d4 100644 --- a/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html +++ b/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html @@ -15,7 +15,7 @@ style="color: #727070; font-weight: 700; font-size: 1.3rem" jhiTranslate="reset.request.title" > - RESET YOUR PASSWORDD + RESET YOUR PASSWORD

Enter the email address you used to register. diff --git a/src/main/webapp/app/entities/categoria/categoria.module.ts b/src/main/webapp/app/entities/categoria/categoria.module.ts index 59f2dd3..96383a6 100644 --- a/src/main/webapp/app/entities/categoria/categoria.module.ts +++ b/src/main/webapp/app/entities/categoria/categoria.module.ts @@ -1,13 +1,14 @@ import { NgModule } from '@angular/core'; import { SharedModule } from 'app/shared/shared.module'; import { CategoriaComponent } from './list/categoria.component'; +import { CategoriaDetailComponent } from './detail/categoria-detail.component'; import { CategoriaUpdateComponent } from './update/categoria-update.component'; import { CategoriaDeleteDialogComponent } from './delete/categoria-delete-dialog.component'; import { CategoriaRoutingModule } from './route/categoria-routing.module'; @NgModule({ imports: [SharedModule, CategoriaRoutingModule], - declarations: [CategoriaComponent, CategoriaUpdateComponent, CategoriaDeleteDialogComponent], + declarations: [CategoriaComponent, CategoriaDetailComponent, CategoriaUpdateComponent, CategoriaDeleteDialogComponent], entryComponents: [CategoriaDeleteDialogComponent], }) export class CategoriaModule {} diff --git a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html index 0289904..9c1ee95 100644 --- a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html +++ b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html @@ -8,18 +8,23 @@

diff --git a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts index 14225df..df89d70 100644 --- a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts +++ b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts @@ -1,8 +1,11 @@ +import { HttpResponse } from '@angular/common/http'; import { Component } from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { IEncuesta } from 'app/entities/encuesta/encuesta.model'; import { EncuestaService } from 'app/entities/encuesta/service/encuesta.service'; import { EstadoCategoria } from 'app/entities/enumerations/estado-categoria.model'; +import { Observable } from 'rxjs'; +import { finalize, map } from 'rxjs/operators'; import { Categoria, ICategoria } from '../categoria.model'; import { CategoriaService } from '../service/categoria.service'; @@ -19,45 +22,55 @@ export class CategoriaDeleteDialogComponent { protected categoriaService: CategoriaService, protected activeModal: NgbActiveModal, protected encuestaService: EncuestaService - ) {} + ) { + this.getEncuestas(); + } cancel(): void { this.activeModal.dismiss(); } confirmDelete(categoria: ICategoria): void { - this.ensureNulaExists(); const categoriaNula = new Categoria(0, 'Otra', EstadoCategoria.ACTIVE); - this.getEncuestas(categoria); - if (this.encuestas) { + this.getEncuestas(); + if (categoria.estado == EstadoCategoria.INACTIVE) { + categoria.estado = EstadoCategoria.ACTIVE; + } else { this.encuestas!.forEach(encuesta => { - encuesta.categoria = categoriaNula; - this.encuestaService.update(encuesta); + if (encuesta.categoria != null && encuesta.categoria!.id === categoria.id) { + encuesta.categoria = categoriaNula; + this.subscribeToSaveResponse(this.encuestaService.update(encuesta)); + } }); + categoria.estado = EstadoCategoria.INACTIVE; } - categoria.estado = EstadoCategoria.INACTIVE; this.categoriaService.update(categoria).subscribe(() => { this.activeModal.close('deleted'); }); } - ensureNulaExists(): void { - const categoriaNula = new Categoria(0, 'Otra', EstadoCategoria.ACTIVE); - const categoria = this.categoriaService.find(0); - if (categoria) { - this.categoriaService.update(categoriaNula); - } else { - this.categoriaService.create(categoriaNula); - } - } - protected getEncuestas(categoria: ICategoria): void { + getEncuestas(): void { this.encuestaService.query().subscribe(res => { this.encuestas = res.body ?? []; }); - if (this.encuestas) { - this.encuestasFiltradas = this.encuestas.filter(encuesta => { - encuesta.categoria!.id === categoria.id; - }); - } + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.pipe(finalize(() => this.onSaveFinalize())).subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + + protected onSaveFinalize(): void { + // this.isSaving = false; + } + + protected onSaveSuccess(): void { + // this.previousState(); + } + + protected onSaveError(): void { + // Api for inheritance. } } diff --git a/src/main/webapp/app/entities/categoria/detail/categoria-detail.component.html b/src/main/webapp/app/entities/categoria/detail/categoria-detail.component.html new file mode 100644 index 0000000..51877e5 --- /dev/null +++ b/src/main/webapp/app/entities/categoria/detail/categoria-detail.component.html @@ -0,0 +1,41 @@ +
+
+
+

Categoria

+ +
+ + + + + +
+
ID
+
+ {{ categoria.id }} +
+
Nombre
+
+ {{ categoria.nombre }} +
+
Estado
+
+ {{ categoria.estado }} +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/categoria/detail/categoria-detail.component.spec.ts b/src/main/webapp/app/entities/categoria/detail/categoria-detail.component.spec.ts new file mode 100644 index 0000000..506ac72 --- /dev/null +++ b/src/main/webapp/app/entities/categoria/detail/categoria-detail.component.spec.ts @@ -0,0 +1,38 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { CategoriaDetailComponent } from './categoria-detail.component'; + +describe('Component Tests', () => { + describe('Categoria Management Detail Component', () => { + let comp: CategoriaDetailComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [CategoriaDetailComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { data: of({ categoria: { id: 123 } }) }, + }, + ], + }) + .overrideTemplate(CategoriaDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(CategoriaDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load categoria on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.categoria).toEqual(expect.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/categoria/detail/categoria-detail.component.ts b/src/main/webapp/app/entities/categoria/detail/categoria-detail.component.ts new file mode 100644 index 0000000..36ecdcf --- /dev/null +++ b/src/main/webapp/app/entities/categoria/detail/categoria-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { ICategoria } from '../categoria.model'; + +@Component({ + selector: 'jhi-categoria-detail', + templateUrl: './categoria-detail.component.html', +}) +export class CategoriaDetailComponent implements OnInit { + categoria: ICategoria | null = null; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ categoria }) => { + this.categoria = categoria; + }); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/categoria/list/categoria.component.html b/src/main/webapp/app/entities/categoria/list/categoria.component.html index 7933f24..5042460 100644 --- a/src/main/webapp/app/entities/categoria/list/categoria.component.html +++ b/src/main/webapp/app/entities/categoria/list/categoria.component.html @@ -40,9 +40,9 @@ - {{ categoria.nombre }} - {{ categoria.estado }} - + {{ categoria.nombre }} + {{ categoria.estado }} +
-
diff --git a/src/main/webapp/app/entities/categoria/list/categoria.component.ts b/src/main/webapp/app/entities/categoria/list/categoria.component.ts index 31ddcff..f7a7735 100644 --- a/src/main/webapp/app/entities/categoria/list/categoria.component.ts +++ b/src/main/webapp/app/entities/categoria/list/categoria.component.ts @@ -42,7 +42,7 @@ export class CategoriaComponent implements OnInit { return item.id!; } - delete(categoria: ICategoria): void { + toggleStatus(categoria: ICategoria): void { const modalRef = this.modalService.open(CategoriaDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); modalRef.componentInstance.categoria = categoria; // unsubscribe not needed because closed completes on modal close diff --git a/src/main/webapp/app/entities/categoria/route/categoria-routing.module.ts b/src/main/webapp/app/entities/categoria/route/categoria-routing.module.ts index 95acd27..d48d560 100644 --- a/src/main/webapp/app/entities/categoria/route/categoria-routing.module.ts +++ b/src/main/webapp/app/entities/categoria/route/categoria-routing.module.ts @@ -3,6 +3,7 @@ import { RouterModule, Routes } from '@angular/router'; import { UserRouteAccessService } from 'app/core/auth/user-route-access.service'; import { CategoriaComponent } from '../list/categoria.component'; +import { CategoriaDetailComponent } from '../detail/categoria-detail.component'; import { CategoriaUpdateComponent } from '../update/categoria-update.component'; import { CategoriaRoutingResolveService } from './categoria-routing-resolve.service'; @@ -12,6 +13,14 @@ const categoriaRoute: Routes = [ component: CategoriaComponent, canActivate: [UserRouteAccessService], }, + { + path: ':id/view', + component: CategoriaDetailComponent, + resolve: { + categoria: CategoriaRoutingResolveService, + }, + canActivate: [UserRouteAccessService], + }, { path: 'new', component: CategoriaUpdateComponent, diff --git a/src/main/webapp/app/entities/categoria/update/categoria-update.component.html b/src/main/webapp/app/entities/categoria/update/categoria-update.component.html index 289ccb3..827ff29 100644 --- a/src/main/webapp/app/entities/categoria/update/categoria-update.component.html +++ b/src/main/webapp/app/entities/categoria/update/categoria-update.component.html @@ -49,17 +49,18 @@ class="btn btn-secondary ds-btn ds-btn-secondary" (click)="previousState()" > -  Cancel +  Cancel diff --git a/src/main/webapp/app/entities/categoria/update/categoria-update.component.ts b/src/main/webapp/app/entities/categoria/update/categoria-update.component.ts index e1dd398..a4a5782 100644 --- a/src/main/webapp/app/entities/categoria/update/categoria-update.component.ts +++ b/src/main/webapp/app/entities/categoria/update/categoria-update.component.ts @@ -22,6 +22,7 @@ export class CategoriaUpdateComponent implements OnInit { estado: [null, [Validators.required]], }); public duplicateName: boolean; + id: number | undefined; constructor(protected categoriaService: CategoriaService, protected activatedRoute: ActivatedRoute, protected fb: FormBuilder) { this.duplicateName = false; @@ -88,6 +89,7 @@ export class CategoriaUpdateComponent implements OnInit { } protected updateForm(categoria: ICategoria): void { + this.id = categoria.id; this.editForm.patchValue({ id: categoria.id, nombre: categoria.nombre, diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss index efae4e5..ccb1547 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss @@ -41,6 +41,15 @@ } } +.ds-btn--toggle { + background-color: #ffaa47; + color: #fff; + + &:hover { + background-color: #e09935; + } +} + .ds-btn--secondary { background-color: transparent; color: #2962ff; diff --git a/src/main/webapp/i18n/es/categoria.json b/src/main/webapp/i18n/es/categoria.json index 1a7b898..31f6767 100644 --- a/src/main/webapp/i18n/es/categoria.json +++ b/src/main/webapp/i18n/es/categoria.json @@ -4,15 +4,15 @@ "home": { "title": "Categorías", "refreshListLabel": "Refrescar lista", - "createLabel": "Crear nueva Categoría", - "createOrEditLabel": "Datos de Categoría", - "notFound": "Ninguna Categoría encontrada" + "createLabel": "Crear nueva categoría", + "createOrEditLabel": "Datos de categoría", + "notFound": "Ninguna categoría encontrada" }, - "created": "Una nueva Categoría ha sido creada con el identificador {{ param }}", - "updated": "Una Categoría ha sido actualizado con el identificador {{ param }}", - "deleted": "Una Categoría ha sido eliminado con el identificador {{ param }}", + "created": "Una nueva categoría ha sido creada con el identificador {{ param }}", + "updated": "Los datos de la categoría {{ nombre }} han sido actualizados", + "deleted": "La categoría {{ nombre }} ha sido deshabilitada", "delete": { - "question": "¿Seguro que quiere eliminar Categoría {{ id }}?" + "question": "¿Seguro que quiere cambiar el estado de \"{{ nombre }}\"?" }, "detail": { "title": "Categoría" @@ -23,7 +23,7 @@ "encuesta": "Encuesta", "plantilla": "Plantilla", "errors": { - "duplicateName": "Ya existe una categoría con ese nombre." + "duplicateName": "Ya existe una categoría con ese nombre" } } } diff --git a/src/main/webapp/i18n/es/global.json b/src/main/webapp/i18n/es/global.json index c9eb858..0da30ff 100644 --- a/src/main/webapp/i18n/es/global.json +++ b/src/main/webapp/i18n/es/global.json @@ -126,7 +126,10 @@ "open": "Abrir", "save": "Guardar", "view": "Vista", - "create": "Crear" + "create": "Crear", + "enable": "Habilitar", + "disable": "Deshabilitar", + "toggleStatus": "Cambiar Estado" }, "detail": { "field": "Campo",