Merge branch 'dev' into feature/US-55

This commit is contained in:
Mariela Bonilla 2021-07-18 22:41:40 -06:00
commit 6a50453a75
15 changed files with 191 additions and 47 deletions

View File

@ -15,7 +15,7 @@
style="color: #727070; font-weight: 700; font-size: 1.3rem" style="color: #727070; font-weight: 700; font-size: 1.3rem"
jhiTranslate="reset.request.title" jhiTranslate="reset.request.title"
> >
RESET YOUR PASSWORDD RESET YOUR PASSWORD
</h4> </h4>
<p class="mb-4" style="color: rgba(146, 146, 146, 0.664)" jhiTranslate="reset.request.messages.info"> <p class="mb-4" style="color: rgba(146, 146, 146, 0.664)" jhiTranslate="reset.request.messages.info">
Enter the email address you used to register. Enter the email address you used to register.

View File

@ -1,13 +1,14 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { SharedModule } from 'app/shared/shared.module'; import { SharedModule } from 'app/shared/shared.module';
import { CategoriaComponent } from './list/categoria.component'; import { CategoriaComponent } from './list/categoria.component';
import { CategoriaDetailComponent } from './detail/categoria-detail.component';
import { CategoriaUpdateComponent } from './update/categoria-update.component'; import { CategoriaUpdateComponent } from './update/categoria-update.component';
import { CategoriaDeleteDialogComponent } from './delete/categoria-delete-dialog.component'; import { CategoriaDeleteDialogComponent } from './delete/categoria-delete-dialog.component';
import { CategoriaRoutingModule } from './route/categoria-routing.module'; import { CategoriaRoutingModule } from './route/categoria-routing.module';
@NgModule({ @NgModule({
imports: [SharedModule, CategoriaRoutingModule], imports: [SharedModule, CategoriaRoutingModule],
declarations: [CategoriaComponent, CategoriaUpdateComponent, CategoriaDeleteDialogComponent], declarations: [CategoriaComponent, CategoriaDetailComponent, CategoriaUpdateComponent, CategoriaDeleteDialogComponent],
entryComponents: [CategoriaDeleteDialogComponent], entryComponents: [CategoriaDeleteDialogComponent],
}) })
export class CategoriaModule {} export class CategoriaModule {}

View File

@ -8,18 +8,23 @@
<div class="modal-body"> <div class="modal-body">
<jhi-alert-error></jhi-alert-error> <jhi-alert-error></jhi-alert-error>
<p id="jhi-delete-categoria-heading" jhiTranslate="dataSurveyApp.categoria.delete.question" [translateValues]="{ id: categoria.id }"> <p
Are you sure you want to delete this category? id="jhi-delete-categoria-heading"
jhiTranslate="dataSurveyApp.categoria.delete.question"
[translateValues]="{ nombre: categoria.nombre }"
style="text-align: center"
>
Are you sure you want to toggle this category's status?
</p> </p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary ds-btn ds-btn-secondary" data-dismiss="modal" (click)="cancel()"> <button type="button" class="btn btn-secondary ds-btn ds-btn-secondary" data-dismiss="modal" (click)="cancel()">
<fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span> &nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button> </button>
<button id="jhi-confirm-delete-categoria" data-cy="entityConfirmDeleteButton" type="submit" class="btn btn-danger ds-btn ds-btn-danger"> <button id="jhi-confirm-delete-categoria" data-cy="entityConfirmDeleteButton" type="submit" class="btn btn-danger ds-btn ds-btn-danger">
<fa-icon icon="times"></fa-icon>&nbsp;<span jhiTranslate="entity.action.delete">Delete</span> <span jhiTranslate="entity.action.toggleStatus">Toggle Status</span>
</button> </button>
</div> </div>
</form> </form>

View File

@ -1,8 +1,11 @@
import { HttpResponse } from '@angular/common/http';
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { IEncuesta } from 'app/entities/encuesta/encuesta.model'; import { IEncuesta } from 'app/entities/encuesta/encuesta.model';
import { EncuestaService } from 'app/entities/encuesta/service/encuesta.service'; import { EncuestaService } from 'app/entities/encuesta/service/encuesta.service';
import { EstadoCategoria } from 'app/entities/enumerations/estado-categoria.model'; 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 { Categoria, ICategoria } from '../categoria.model';
import { CategoriaService } from '../service/categoria.service'; import { CategoriaService } from '../service/categoria.service';
@ -19,45 +22,55 @@ export class CategoriaDeleteDialogComponent {
protected categoriaService: CategoriaService, protected categoriaService: CategoriaService,
protected activeModal: NgbActiveModal, protected activeModal: NgbActiveModal,
protected encuestaService: EncuestaService protected encuestaService: EncuestaService
) {} ) {
this.getEncuestas();
}
cancel(): void { cancel(): void {
this.activeModal.dismiss(); this.activeModal.dismiss();
} }
confirmDelete(categoria: ICategoria): void { confirmDelete(categoria: ICategoria): void {
this.ensureNulaExists();
const categoriaNula = new Categoria(0, 'Otra', EstadoCategoria.ACTIVE); const categoriaNula = new Categoria(0, 'Otra', EstadoCategoria.ACTIVE);
this.getEncuestas(categoria); this.getEncuestas();
if (this.encuestas) { if (categoria.estado == EstadoCategoria.INACTIVE) {
categoria.estado = EstadoCategoria.ACTIVE;
} else {
this.encuestas!.forEach(encuesta => { this.encuestas!.forEach(encuesta => {
if (encuesta.categoria != null && encuesta.categoria!.id === categoria.id) {
encuesta.categoria = categoriaNula; encuesta.categoria = categoriaNula;
this.encuestaService.update(encuesta); this.subscribeToSaveResponse(this.encuestaService.update(encuesta));
});
} }
});
categoria.estado = EstadoCategoria.INACTIVE; categoria.estado = EstadoCategoria.INACTIVE;
}
this.categoriaService.update(categoria).subscribe(() => { this.categoriaService.update(categoria).subscribe(() => {
this.activeModal.close('deleted'); 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.encuestaService.query().subscribe(res => {
this.encuestas = res.body ?? []; this.encuestas = res.body ?? [];
}); });
if (this.encuestas) { }
this.encuestasFiltradas = this.encuestas.filter(encuesta => {
encuesta.categoria!.id === categoria.id; protected subscribeToSaveResponse(result: Observable<HttpResponse<IEncuesta>>): 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.
} }
} }

View File

@ -0,0 +1,41 @@
<div class="row justify-content-center">
<div class="col-8">
<div *ngIf="categoria">
<h2 data-cy="categoriaDetailsHeading"><span jhiTranslate="dataSurveyApp.categoria.detail.title">Categoria</span></h2>
<hr />
<jhi-alert-error></jhi-alert-error>
<jhi-alert></jhi-alert>
<dl class="row-md jh-entity-details">
<dt><span jhiTranslate="global.field.id">ID</span></dt>
<dd>
<span>{{ categoria.id }}</span>
</dd>
<dt><span jhiTranslate="dataSurveyApp.categoria.nombre">Nombre</span></dt>
<dd>
<span>{{ categoria.nombre }}</span>
</dd>
<dt><span jhiTranslate="dataSurveyApp.categoria.estado">Estado</span></dt>
<dd>
<span jhiTranslate="{{ 'dataSurveyApp.EstadoCategoria.' + categoria.estado }}">{{ categoria.estado }}</span>
</dd>
</dl>
<button type="submit" (click)="previousState()" class="btn btn-ds btn-info" data-cy="entityDetailsBackButton">
&nbsp;<span jhiTranslate="entity.action.back">Back</span>
</button>
<button
*ngIf="categoria.id != 0"
type="button"
[routerLink]="['/categoria', categoria.id, 'edit']"
class="btn btn-ds btn-ds-primary btn-primary"
>
&nbsp;<span jhiTranslate="entity.action.edit">Edit</span>
</button>
</div>
</div>
</div>

View File

@ -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<CategoriaDetailComponent>;
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 }));
});
});
});
});

View File

@ -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();
}
}

View File

@ -40,9 +40,9 @@
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let categoria of categorias | filter: 'nombre':searchString; trackBy: trackId" data-cy="entityTable"> <tr *ngFor="let categoria of categorias | filter: 'nombre':searchString; trackBy: trackId" data-cy="entityTable">
<td>{{ categoria.nombre }}</td> <td *ngIf="categoria.id != 0">{{ categoria.nombre }}</td>
<td jhiTranslate="{{ 'dataSurveyApp.EstadoCategoria.' + categoria.estado }}">{{ categoria.estado }}</td> <td *ngIf="categoria.id != 0" jhiTranslate="{{ 'dataSurveyApp.EstadoCategoria.' + categoria.estado }}">{{ categoria.estado }}</td>
<td class="text-right"> <td *ngIf="categoria.id != 0" class="text-right">
<div class="btn-group"> <div class="btn-group">
<button <button
type="submit" type="submit"
@ -50,13 +50,11 @@
class="btn-sm ds-btn ds-btn--primary" class="btn-sm ds-btn ds-btn--primary"
data-cy="entityEditButton" data-cy="entityEditButton"
> >
<fa-icon icon="pencil-alt"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span> <span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</button> </button>
<button type="submit" (click)="delete(categoria)" class="btn-sm ds-btn ds-btn--danger" data-cy="entityDeleteButton"> <button type="submit" (click)="toggleStatus(categoria)" class="btn-sm ds-btn ds-btn--toggle" data-cy="entityDeleteButton">
<fa-icon icon="times"></fa-icon> <span class="d-none d-md-inline" jhiTranslate="entity.action.toggleStatus">Toggle Status</span>
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>
</button> </button>
</div> </div>
</td> </td>

View File

@ -42,7 +42,7 @@ export class CategoriaComponent implements OnInit {
return item.id!; return item.id!;
} }
delete(categoria: ICategoria): void { toggleStatus(categoria: ICategoria): void {
const modalRef = this.modalService.open(CategoriaDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); const modalRef = this.modalService.open(CategoriaDeleteDialogComponent, { size: 'lg', backdrop: 'static' });
modalRef.componentInstance.categoria = categoria; modalRef.componentInstance.categoria = categoria;
// unsubscribe not needed because closed completes on modal close // unsubscribe not needed because closed completes on modal close

View File

@ -3,6 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { UserRouteAccessService } from 'app/core/auth/user-route-access.service'; import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
import { CategoriaComponent } from '../list/categoria.component'; import { CategoriaComponent } from '../list/categoria.component';
import { CategoriaDetailComponent } from '../detail/categoria-detail.component';
import { CategoriaUpdateComponent } from '../update/categoria-update.component'; import { CategoriaUpdateComponent } from '../update/categoria-update.component';
import { CategoriaRoutingResolveService } from './categoria-routing-resolve.service'; import { CategoriaRoutingResolveService } from './categoria-routing-resolve.service';
@ -12,6 +13,14 @@ const categoriaRoute: Routes = [
component: CategoriaComponent, component: CategoriaComponent,
canActivate: [UserRouteAccessService], canActivate: [UserRouteAccessService],
}, },
{
path: ':id/view',
component: CategoriaDetailComponent,
resolve: {
categoria: CategoriaRoutingResolveService,
},
canActivate: [UserRouteAccessService],
},
{ {
path: 'new', path: 'new',
component: CategoriaUpdateComponent, component: CategoriaUpdateComponent,

View File

@ -49,17 +49,18 @@
class="btn btn-secondary ds-btn ds-btn-secondary" class="btn btn-secondary ds-btn ds-btn-secondary"
(click)="previousState()" (click)="previousState()"
> >
<fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span> &nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button> </button>
<button <button
*ngIf="this.id != 0"
type="submit" type="submit"
id="save-entity" id="save-entity"
data-cy="entityCreateSaveButton" data-cy="entityCreateSaveButton"
[disabled]="editForm.invalid || isSaving" [disabled]="editForm.invalid || isSaving"
class="btn btn-primary ds-btn ds-btn-primary" class="btn btn-primary ds-btn ds-btn-primary"
> >
<fa-icon icon="save"></fa-icon>&nbsp;<span jhiTranslate="entity.action.save">Save</span> &nbsp;<span jhiTranslate="entity.action.save">Save</span>
</button> </button>
</div> </div>
</form> </form>

View File

@ -22,6 +22,7 @@ export class CategoriaUpdateComponent implements OnInit {
estado: [null, [Validators.required]], estado: [null, [Validators.required]],
}); });
public duplicateName: boolean; public duplicateName: boolean;
id: number | undefined;
constructor(protected categoriaService: CategoriaService, protected activatedRoute: ActivatedRoute, protected fb: FormBuilder) { constructor(protected categoriaService: CategoriaService, protected activatedRoute: ActivatedRoute, protected fb: FormBuilder) {
this.duplicateName = false; this.duplicateName = false;
@ -88,6 +89,7 @@ export class CategoriaUpdateComponent implements OnInit {
} }
protected updateForm(categoria: ICategoria): void { protected updateForm(categoria: ICategoria): void {
this.id = categoria.id;
this.editForm.patchValue({ this.editForm.patchValue({
id: categoria.id, id: categoria.id,
nombre: categoria.nombre, nombre: categoria.nombre,

View File

@ -41,6 +41,15 @@
} }
} }
.ds-btn--toggle {
background-color: #ffaa47;
color: #fff;
&:hover {
background-color: #e09935;
}
}
.ds-btn--secondary { .ds-btn--secondary {
background-color: transparent; background-color: transparent;
color: #2962ff; color: #2962ff;

View File

@ -4,15 +4,15 @@
"home": { "home": {
"title": "Categorías", "title": "Categorías",
"refreshListLabel": "Refrescar lista", "refreshListLabel": "Refrescar lista",
"createLabel": "Crear nueva Categoría", "createLabel": "Crear nueva categoría",
"createOrEditLabel": "Datos de Categoría", "createOrEditLabel": "Datos de categoría",
"notFound": "Ninguna Categoría encontrada" "notFound": "Ninguna categoría encontrada"
}, },
"created": "Una nueva Categoría ha sido creada con el identificador {{ param }}", "created": "Una nueva categoría ha sido creada con el identificador {{ param }}",
"updated": "Una Categoría ha sido actualizado con el identificador {{ param }}", "updated": "Los datos de la categoría {{ nombre }} han sido actualizados",
"deleted": "Una Categoría ha sido eliminado con el identificador {{ param }}", "deleted": "La categoría {{ nombre }} ha sido deshabilitada",
"delete": { "delete": {
"question": "¿Seguro que quiere eliminar Categoría {{ id }}?" "question": "¿Seguro que quiere cambiar el estado de \"{{ nombre }}\"?"
}, },
"detail": { "detail": {
"title": "Categoría" "title": "Categoría"
@ -23,7 +23,7 @@
"encuesta": "Encuesta", "encuesta": "Encuesta",
"plantilla": "Plantilla", "plantilla": "Plantilla",
"errors": { "errors": {
"duplicateName": "Ya existe una categoría con ese nombre." "duplicateName": "Ya existe una categoría con ese nombre"
} }
} }
} }

View File

@ -126,7 +126,10 @@
"open": "Abrir", "open": "Abrir",
"save": "Guardar", "save": "Guardar",
"view": "Vista", "view": "Vista",
"create": "Crear" "create": "Crear",
"enable": "Habilitar",
"disable": "Deshabilitar",
"toggleStatus": "Cambiar Estado"
}, },
"detail": { "detail": {
"field": "Campo", "field": "Campo",