Merge branch 'dev' into feature/US-06-fix

This commit is contained in:
Pablo Bonilla 2021-07-11 20:37:54 -06:00
commit 4fb98dca73
No known key found for this signature in database
GPG Key ID: 46877262B8DE47E2
10 changed files with 66 additions and 38 deletions

View File

@ -1,8 +1,8 @@
<form *ngIf="categoria" name="deleteForm" (ngSubmit)="confirmDelete(categoria.id!)"> <form class="ds-form" *ngIf="categoria" name="deleteForm" (ngSubmit)="confirmDelete(categoria.id!)">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title" data-cy="categoriaDeleteDialogHeading" jhiTranslate="entity.delete.title">Confirm delete operation</h4> <h4 class="modal-title" data-cy="categoriaDeleteDialogHeading" jhiTranslate="entity.delete.title">Confirm delete operation</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="cancel()">&times;</button> <button type="button" class="ds-btn close" data-dismiss="modal" aria-hidden="true" (click)="cancel()">&times;</button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
@ -14,11 +14,11 @@
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn 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> <fa-icon icon="ban"></fa-icon>&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"> <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> <fa-icon icon="times"></fa-icon>&nbsp;<span jhiTranslate="entity.action.delete">Delete</span>
</button> </button>
</div> </div>

View File

@ -24,11 +24,11 @@
</dd> </dd>
</dl> </dl>
<button type="submit" (click)="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton"> <button type="submit" (click)="previousState()" class="btn btn-ds btn-info" data-cy="entityDetailsBackButton">
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.back">Back</span> <fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.back">Back</span>
</button> </button>
<button type="button" [routerLink]="['/categoria', categoria.id, 'edit']" class="btn btn-primary"> <button type="button" [routerLink]="['/categoria', categoria.id, 'edit']" class="btn btn-ds btn-ds-primary btn-primary">
<fa-icon icon="pencil-alt"></fa-icon>&nbsp;<span jhiTranslate="entity.action.edit">Edit</span> <fa-icon icon="pencil-alt"></fa-icon>&nbsp;<span jhiTranslate="entity.action.edit">Edit</span>
</button> </button>
</div> </div>

View File

@ -3,15 +3,10 @@
<span jhiTranslate="dataSurveyApp.categoria.home.title">Categorias</span> <span jhiTranslate="dataSurveyApp.categoria.home.title">Categorias</span>
<div class="d-flex justify-content-end"> <div class="d-flex justify-content-end">
<button class="btn btn-info mr-2" (click)="loadAll()" [disabled]="isLoading">
<fa-icon icon="sync" [spin]="isLoading"></fa-icon>
<span jhiTranslate="dataSurveyApp.categoria.home.refreshListLabel">Refresh List</span>
</button>
<button <button
id="jh-create-entity" id="jh-create-entity"
data-cy="entityCreateButton" data-cy="entityCreateButton"
class="btn btn-primary jh-create-entity create-categoria" class="btn btn-primary jh-create-entity create-categoria ds-btn ds-btn-primary"
[routerLink]="['/categoria/new']" [routerLink]="['/categoria/new']"
> >
<fa-icon icon="plus"></fa-icon> <fa-icon icon="plus"></fa-icon>
@ -32,7 +27,7 @@
<form class="ds-form"> <form class="ds-form">
<div class="input-group"> <div class="input-group">
<div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div> <div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
<input type="text" class="form-control" name="searchString" placeholder="Type to search..." [(ngModel)]="searchString" /> <input type="text" name="searchString" placeholder="Buscar..." [(ngModel)]="searchString" />
</div> </div>
</form> </form>
<table class="table table-striped" aria-describedby="page-heading"> <table class="table table-striped" aria-describedby="page-heading">
@ -53,27 +48,22 @@
<td jhiTranslate="{{ 'dataSurveyApp.EstadoCategoria.' + categoria.estado }}">{{ categoria.estado }}</td> <td jhiTranslate="{{ 'dataSurveyApp.EstadoCategoria.' + categoria.estado }}">{{ categoria.estado }}</td>
<td class="text-right"> <td class="text-right">
<div class="btn-group"> <div class="btn-group">
<button
type="submit"
[routerLink]="['/categoria', categoria.id, 'view']"
class="btn btn-info btn-sm"
data-cy="entityDetailsButton"
>
<fa-icon icon="eye"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
</button>
<button <button
type="submit" type="submit"
[routerLink]="['/categoria', categoria.id, 'edit']" [routerLink]="['/categoria', categoria.id, 'edit']"
class="btn btn-primary btn-sm" class="btn btn-primary btn-sm ds-btn ds-btn-primary"
data-cy="entityEditButton" data-cy="entityEditButton"
> >
<fa-icon icon="pencil-alt"></fa-icon> <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 btn-danger btn-sm" data-cy="entityDeleteButton"> <button
type="submit"
(click)="delete(categoria)"
class="btn btn-danger btn-sm ds-btn ds-btn-danger"
data-cy="entityDeleteButton"
>
<fa-icon icon="times"></fa-icon> <fa-icon icon="times"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span> <span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>
</button> </button>

View File

@ -1,12 +1,15 @@
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-8"> <div class="col-8">
<form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm"> <form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm" class="ds-form">
<h2 id="jhi-categoria-heading" data-cy="CategoriaCreateUpdateHeading" jhiTranslate="dataSurveyApp.categoria.home.createOrEditLabel"> <h2 id="jhi-categoria-heading" data-cy="CategoriaCreateUpdateHeading" jhiTranslate="dataSurveyApp.categoria.home.createOrEditLabel">
Create or edit a Categoria Create or edit a Category
</h2> </h2>
<div> <div>
<jhi-alert-error></jhi-alert-error> <jhi-alert-error></jhi-alert-error>
<div class="alert alert-danger" *ngIf="duplicateName" jhiTranslate="dataSurveyApp.categoria.errors.duplicateName">
A category with that name already exists.
</div>
<div class="form-group" [hidden]="editForm.get('id')!.value == null"> <div class="form-group" [hidden]="editForm.get('id')!.value == null">
<label class="form-control-label" jhiTranslate="global.field.id" for="field_id">ID</label> <label class="form-control-label" jhiTranslate="global.field.id" for="field_id">ID</label>
@ -39,7 +42,13 @@
</div> </div>
<div> <div>
<button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" (click)="previousState()"> <button
type="button"
id="cancel-save"
data-cy="entityCreateCancelButton"
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> <fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button> </button>
@ -48,7 +57,7 @@
id="save-entity" id="save-entity"
data-cy="entityCreateSaveButton" data-cy="entityCreateSaveButton"
[disabled]="editForm.invalid || isSaving" [disabled]="editForm.invalid || isSaving"
class="btn 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> <fa-icon icon="save"></fa-icon>&nbsp;<span jhiTranslate="entity.action.save">Save</span>
</button> </button>

View File

@ -14,19 +14,32 @@ import { CategoriaService } from '../service/categoria.service';
}) })
export class CategoriaUpdateComponent implements OnInit { export class CategoriaUpdateComponent implements OnInit {
isSaving = false; isSaving = false;
public categorias?: ICategoria[];
editForm = this.fb.group({ editForm = this.fb.group({
id: [], id: [],
nombre: [null, [Validators.required]], nombre: [null, [Validators.required]],
estado: [null, [Validators.required]], estado: [null, [Validators.required]],
}); });
public duplicateName: boolean;
constructor(protected categoriaService: CategoriaService, protected activatedRoute: ActivatedRoute, protected fb: FormBuilder) {} constructor(protected categoriaService: CategoriaService, protected activatedRoute: ActivatedRoute, protected fb: FormBuilder) {
this.duplicateName = false;
this.categorias = [];
this.loadAll();
}
ngOnInit(): void { ngOnInit(): void {
this.activatedRoute.data.subscribe(({ categoria }) => { this.activatedRoute.data.subscribe(({ categoria }) => {
this.updateForm(categoria); this.updateForm(categoria);
}); });
this.loadAll();
}
loadAll(): void {
this.categoriaService.query().subscribe(res => {
this.categorias = res.body ?? [];
});
} }
previousState(): void { previousState(): void {
@ -36,13 +49,25 @@ export class CategoriaUpdateComponent implements OnInit {
save(): void { save(): void {
this.isSaving = true; this.isSaving = true;
const categoria = this.createFromForm(); const categoria = this.createFromForm();
if (categoria.id !== undefined) { const condicion = this.categoryExists(categoria);
this.subscribeToSaveResponse(this.categoriaService.update(categoria)); if (!condicion) {
if (categoria.id !== undefined) {
this.subscribeToSaveResponse(this.categoriaService.update(categoria));
} else {
this.subscribeToSaveResponse(this.categoriaService.create(categoria));
}
} else { } else {
this.subscribeToSaveResponse(this.categoriaService.create(categoria)); this.duplicateName = true;
this.isSaving = false;
} }
} }
protected categoryExists(categoria: ICategoria): boolean {
this.loadAll();
var condicion = this.categorias!.some(cat => cat.nombre === categoria.nombre);
return condicion;
}
protected subscribeToSaveResponse(result: Observable<HttpResponse<ICategoria>>): void { protected subscribeToSaveResponse(result: Observable<HttpResponse<ICategoria>>): void {
result.pipe(finalize(() => this.onSaveFinalize())).subscribe( result.pipe(finalize(() => this.onSaveFinalize())).subscribe(
() => this.onSaveSuccess(), () => this.onSaveSuccess(),

View File

@ -12,6 +12,7 @@ import { AccountService } from 'app/core/auth/account.service';
import { LoginService } from './login.service'; import { LoginService } from './login.service';
import { LoginComponent } from './login.component'; import { LoginComponent } from './login.component';
import { SocialAuthService } from 'angularx-social-login';
describe('Component Tests', () => { describe('Component Tests', () => {
describe('LoginComponent', () => { describe('LoginComponent', () => {

View File

@ -5,7 +5,7 @@
"title": "Categorías", "title": "Categorías",
"refreshListLabel": "Refrescar lista", "refreshListLabel": "Refrescar lista",
"createLabel": "Crear nueva Categoría", "createLabel": "Crear nueva Categoría",
"createOrEditLabel": "Crear o editar 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 }}",
@ -21,7 +21,10 @@
"nombre": "Nombre", "nombre": "Nombre",
"estado": "Estado", "estado": "Estado",
"encuesta": "Encuesta", "encuesta": "Encuesta",
"plantilla": "Plantilla" "plantilla": "Plantilla",
"errors": {
"duplicateName": "Ya existe una categoría con ese nombre."
}
} }
} }
} }

View File

@ -31,7 +31,7 @@
"usuarioEncuesta": "Usuario Encuesta", "usuarioEncuesta": "Usuario Encuesta",
"ePreguntaAbierta": "E Pregunta Abierta", "ePreguntaAbierta": "E Pregunta Abierta",
"ePreguntaCerrada": "E Pregunta Cerrada", "ePreguntaCerrada": "E Pregunta Cerrada",
"categoria": "Categoria", "categoria": "Categoría",
"usuarioExtra": "Usuario Extra" "usuarioExtra": "Usuario Extra"
} }
} }

View File

@ -15,7 +15,7 @@
"ePreguntaCerrada": "E Pregunta Cerrada", "ePreguntaCerrada": "E Pregunta Cerrada",
"ePreguntaCerradaOpcion": "E Pregunta Cerrada Opcion", "ePreguntaCerradaOpcion": "E Pregunta Cerrada Opcion",
"usuarioEncuesta": "Usuario Encuesta", "usuarioEncuesta": "Usuario Encuesta",
"categoria": "Categoria", "categoria": "Categoría",
"factura": "Factura", "factura": "Factura",
"plantilla": "Plantilla", "plantilla": "Plantilla",
"pPreguntaAbierta": "P Pregunta Abierta", "pPreguntaAbierta": "P Pregunta Abierta",

View File

@ -26,7 +26,7 @@
"precio": "Precio", "precio": "Precio",
"pPreguntaCerrada": "P Pregunta Cerrada", "pPreguntaCerrada": "P Pregunta Cerrada",
"pPreguntaAbierta": "P Pregunta Abierta", "pPreguntaAbierta": "P Pregunta Abierta",
"categoria": "Categoria", "categoria": "Categoría",
"usuarioExtra": "Usuario Extra" "usuarioExtra": "Usuario Extra"
} }
} }