arreglo input password perfil

This commit is contained in:
Paola 2021-07-15 15:08:53 -06:00
parent b183dce88a
commit 167ff39036
3 changed files with 43 additions and 27 deletions

View File

@ -190,15 +190,21 @@
(ngSubmit)="save()" (ngSubmit)="save()"
[formGroup]="editForm" [formGroup]="editForm"
> >
<div class="alert alert-danger" *ngIf="error" jhiTranslate="global.messages.info.authenticated.updateForm" data-cy="loginError"></div> <div class="row mb-2">
<div
class="alert alert-danger"
*ngIf="error"
jhiTranslate="global.messages.info.authenticated.updateForm"
data-cy="loginError"
></div>
<div *ngIf="success" class="alert alert-success alert-dismissible fade show" role="alert"> <div *ngIf="success" class="alert alert-success alert-dismissible fade show" role="alert">
Sus datos fueron actualizados de manera exitosa Sus datos fueron actualizados de manera exitosa
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> <!--<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>-->
</div> </div>
<div class="row mb-2">
<div class="form-group w-100"> <div class="form-group w-100">
<label class="form-control-label" for="field_email">Correo electrónico</label> <label class="form-control-label" for="field_email">Correo electrónico</label>
<input type="text" class="form-control" name="email" id="field_email" data-cy="email" formControlName="email" [readonly]="true" /> <input type="text" class="form-control" name="email" id="field_email" data-cy="email" formControlName="email" [readonly]="true" />
@ -296,22 +302,29 @@
(ngSubmit)="savePassword()" (ngSubmit)="savePassword()"
[formGroup]="passwordForm" [formGroup]="passwordForm"
> >
<div *ngIf="success" class="alert alert-success alert-dismissible fade show" role="alert"> <div class="row mb-3 pb-3" style="border-bottom: 1px solid #e7ebf3">
<div
class="alert alert-danger"
*ngIf="errorPassword && !doNotMatch && !successPassword"
jhiTranslate="global.messages.info.authenticated.passwordForm"
data-cy="loginError"
></div>
<div *ngIf="successPassword" class="alert alert-success alert-dismissible fade show" role="alert">
Sus contraseña fue actualizada de manera exitosa Sus contraseña fue actualizada de manera exitosa
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> <!-- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>-->
</div> </div>
<div class="row mb-3 pb-3" style="border-bottom: 1px solid #e7ebf3"> <div class="alert alert-danger" *ngIf="doNotMatch && !successPassword" jhiTranslate="global.messages.error.dontmatch">
<div class="alert alert-danger" *ngIf="doNotMatch" jhiTranslate="global.messages.error.dontmatch">
The password and its confirmation do not match! The password and its confirmation do not match!
</div> </div>
<div class="form-group w-100"> <div class="form-group w-100">
<label class="form-control-label" for="field_password">Contraseña actual</label> <label class="form-control-label" for="field_password">Contraseña actual</label>
<input <input
type="text" type="password"
class="form-control" class="form-control"
name="password" name="password"
id="field_password" id="field_password"
@ -357,7 +370,7 @@
<div class="form-group w-100"> <div class="form-group w-100">
<label class="form-control-label" for="field_passwordNew">Contraseña nueva</label> <label class="form-control-label" for="field_passwordNew">Contraseña nueva</label>
<input <input
type="text" type="password"
class="form-control" class="form-control"
name="passwordNew" name="passwordNew"
id="field_passwordNew" id="field_passwordNew"
@ -404,7 +417,7 @@
<div class="form-group w-100"> <div class="form-group w-100">
<label class="form-control-label" for="field_passwordNewConfirm">Confirmar contraseña nueva</label> <label class="form-control-label" for="field_passwordNewConfirm">Confirmar contraseña nueva</label>
<input <input
type="text" type="password"
class="form-control" class="form-control"
name="passwordNewConfirm" name="passwordNewConfirm"
id="field_passwordNewConfirm" id="field_passwordNewConfirm"
@ -463,7 +476,7 @@
type="submit" type="submit"
id="save-entity" id="save-entity"
data-cy="entityCreateSaveButton" data-cy="entityCreateSaveButton"
[disabled]="passwordForm.invalid || isSaving" [disabled]="isSaving"
class="ds-btn ds-btn--primary" class="ds-btn ds-btn--primary"
> >
<span jhiTranslate="entity.action.save">Save</span> <span jhiTranslate="entity.action.save">Save</span>

View File

@ -25,7 +25,9 @@ import { PasswordService } from '../password/password.service';
export class SettingsComponent implements OnInit { export class SettingsComponent implements OnInit {
isSaving = false; isSaving = false;
success = false; success = false;
successPassword = false;
error = false; error = false;
errorPassword = false;
doNotMatch = false; doNotMatch = false;
usersSharedCollection: IUser[] = []; usersSharedCollection: IUser[] = [];
plantillasSharedCollection: IPlantilla[] = []; plantillasSharedCollection: IPlantilla[] = [];
@ -135,17 +137,17 @@ export class SettingsComponent implements OnInit {
this.subscribeToSaveResponse(this.usuarioExtraService.update(usuarioExtra)); this.subscribeToSaveResponse(this.usuarioExtraService.update(usuarioExtra));
window.location.reload(); //reload
} }
savePassword(): void { savePassword(): void {
const password = this.passwordForm.get(['password'])!.value; const passwordNew = this.passwordForm.get(['passwordNew'])!.value;
if (password !== this.passwordForm.get(['passwordNew'])!.value) { if (passwordNew !== this.passwordForm.get(['passwordNewConfirm'])!.value) {
this.doNotMatch = true; this.doNotMatch = true;
} else { } else {
this.passwordService.save(this.passwordForm.get(['passwordNew'])!.value, password).subscribe( this.passwordService.save(this.passwordForm.get(['passwordNew'])!.value, this.passwordForm.get(['password'])!.value).subscribe(
() => (this.success = true), () => (this.successPassword = true),
() => (this.error = true) () => (this.errorPassword = true)
); );
} }
} }

View File

@ -66,7 +66,8 @@
"prefix": "Si desea ", "prefix": "Si desea ",
"link": "iniciar sesión", "link": "iniciar sesión",
"suffix": ", puede intentar con las cuentas predeterminadas:<br/>- Administrador (usuario=\"admin\" y contraseña=\"admin\") <br/>- Usuario (usuario=\"user\" y contraseña=\"user\").", "suffix": ", puede intentar con las cuentas predeterminadas:<br/>- Administrador (usuario=\"admin\" y contraseña=\"admin\") <br/>- Usuario (usuario=\"user\" y contraseña=\"user\").",
"updateForm": "Ocurrió un error al actualizar su información, favor revisar los campos e intentar de nuevo" "updateForm": "Ocurrió un error al actualizar su información, favor revisar los campos e intentar de nuevo",
"passwordForm": "Ocurrió un error al actualizar su contraseña, favor revisar los campos e intentar de nuevo"
}, },
"register": { "register": {
"noaccount": "¿Aún no tienes una cuenta?", "noaccount": "¿Aún no tienes una cuenta?",