agregar advertencia de que el nombre de la categoria ya existe en la base de datos

This commit is contained in:
Eduardo Quiros 2021-07-11 19:51:04 -06:00
parent 463967c227
commit db5aab4f12
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
3 changed files with 11 additions and 3 deletions

View File

@ -7,6 +7,9 @@
<div>
<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">
<label class="form-control-label" jhiTranslate="global.field.id" for="field_id">ID</label>

View File

@ -21,8 +21,10 @@ export class CategoriaUpdateComponent implements OnInit {
nombre: [null, [Validators.required]],
estado: [null, [Validators.required]],
});
public duplicateName: boolean;
constructor(protected categoriaService: CategoriaService, protected activatedRoute: ActivatedRoute, protected fb: FormBuilder) {
this.duplicateName = false;
this.categorias = [];
this.loadAll();
}
@ -55,14 +57,14 @@ export class CategoriaUpdateComponent implements OnInit {
this.subscribeToSaveResponse(this.categoriaService.create(categoria));
}
} else {
this.previousState();
this.duplicateName = true;
this.isSaving = false;
}
}
protected categoryExists(categoria: ICategoria): boolean {
this.loadAll();
var condicion = this.categorias!.some(cat => cat.nombre === categoria.nombre);
debugger;
return condicion;
}

View File

@ -21,7 +21,10 @@
"nombre": "Nombre",
"estado": "Estado",
"encuesta": "Encuesta",
"plantilla": "Plantilla"
"plantilla": "Plantilla",
"errors": {
"duplicateName": "Ya existe una categoría con ese nombre."
}
}
}
}