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"
jhiTranslate="reset.request.title"
>
RESET YOUR PASSWORDD
RESET YOUR PASSWORD
</h4>
<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.

View File

@ -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 {}

View File

@ -8,18 +8,23 @@
<div class="modal-body">
<jhi-alert-error></jhi-alert-error>
<p id="jhi-delete-categoria-heading" jhiTranslate="dataSurveyApp.categoria.delete.question" [translateValues]="{ id: categoria.id }">
Are you sure you want to delete this category?
<p
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>
</div>
<div class="modal-footer">
<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 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>
</div>
</form>

View File

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

View File

@ -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

View File

@ -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,

View File

@ -49,17 +49,18 @@
class="btn btn-secondary ds-btn ds-btn-secondary"
(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
*ngIf="this.id != 0"
type="submit"
id="save-entity"
data-cy="entityCreateSaveButton"
[disabled]="editForm.invalid || isSaving"
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>
</div>
</form>

View File

@ -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,

View File

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

View File

@ -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"
}
}
}

View File

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