Update retrieve data from usuario extra to display on profile
This commit is contained in:
parent
34597f8209
commit
f5c2f626df
|
@ -163,7 +163,9 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div>
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
-->
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
|
@ -178,263 +180,184 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg ml-lg-5 mr-lg-5 pr-lg-5">
|
|
||||||
|
<div class="col-lg ml-lg-5 mr-lg-5 pr-lg-5" name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group w-100">
|
<div class="form-group w-100">
|
||||||
<label class="form-control-label" for="email" jhiTranslate="global.form.email.label">Email</label>
|
<label class="form-control-label" for="field_email">Correo electrónico</label>
|
||||||
<input
|
|
||||||
type="email"
|
|
||||||
class="form-control"
|
|
||||||
id="email"
|
|
||||||
name="email"
|
|
||||||
placeholder="{{ 'global.form.email.placeholder' | translate }}"
|
|
||||||
formControlName="email"
|
|
||||||
data-cy="email"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div *ngIf="settingsForm.get('email')!.invalid && (settingsForm.get('email')!.dirty || settingsForm.get('email')!.touched)">
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('email')?.errors?.required"
|
|
||||||
jhiTranslate="global.messages.validate.email.required"
|
|
||||||
>
|
|
||||||
Your email is required.
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('email')?.errors?.email"
|
|
||||||
jhiTranslate="global.messages.validate.email.invalid"
|
|
||||||
>
|
|
||||||
Your email is invalid.
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('email')?.errors?.minlength"
|
|
||||||
jhiTranslate="global.messages.validate.email.minlength"
|
|
||||||
>
|
|
||||||
Your email is required to be at least 5 characters.
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('email')?.errors?.maxlength"
|
|
||||||
jhiTranslate="global.messages.validate.email.maxlength"
|
|
||||||
>
|
|
||||||
Your email cannot be longer than 100 characters.
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group w-100">
|
|
||||||
<label class="form-control-label" for="firstName" jhiTranslate="settings.form.firstname">First Name</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="firstName"
|
name="email"
|
||||||
name="firstName"
|
id="field_email"
|
||||||
placeholder="{{ 'settings.form.firstname.placeholder' | translate }}"
|
data-cy="email"
|
||||||
formControlName="firstName"
|
formControlName="email"
|
||||||
data-cy="firstname"
|
[readonly]="true"
|
||||||
/>
|
/>
|
||||||
|
<div *ngIf="editForm.get('email')!.invalid && (editForm.get('email')!.dirty || editForm.get('email')!.touched)">
|
||||||
<div
|
|
||||||
*ngIf="
|
|
||||||
settingsForm.get('firstName')!.invalid && (settingsForm.get('firstName')!.dirty || settingsForm.get('firstName')!.touched)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<small
|
<small
|
||||||
class="form-text text-danger"
|
class="form-text text-danger"
|
||||||
*ngIf="settingsForm.get('firstName')?.errors?.required"
|
*ngIf="editForm.get('email')?.errors?.required"
|
||||||
jhiTranslate="settings.messages.validate.firstname.required"
|
jhiTranslate="entity.validation.required"
|
||||||
>
|
>
|
||||||
Your first name is required.
|
This field is required.
|
||||||
</small>
|
|
||||||
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('firstName')?.errors?.minlength"
|
|
||||||
jhiTranslate="settings.messages.validate.firstname.minlength"
|
|
||||||
>
|
|
||||||
Your first name is required to be at least 1 character.
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('firstName')?.errors?.maxlength"
|
|
||||||
jhiTranslate="settings.messages.validate.firstname.maxlength"
|
|
||||||
>
|
|
||||||
Your first name cannot be longer than 50 characters.
|
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group w-100">
|
||||||
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.nombre" for="field_nombre">Nombre</label>
|
||||||
|
<input type="text" class="form-control" name="nombre" id="field_nombre" data-cy="nombre" formControlName="nombre" />
|
||||||
|
<div *ngIf="editForm.get('nombre')!.invalid && (editForm.get('nombre')!.dirty || editForm.get('nombre')!.touched)">
|
||||||
|
<small
|
||||||
|
class="form-text text-danger"
|
||||||
|
*ngIf="editForm.get('nombre')?.errors?.required"
|
||||||
|
jhiTranslate="entity.validation.required"
|
||||||
|
>
|
||||||
|
This field is required.
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group w-100">
|
||||||
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.fechaNacimiento" for="field_fechaNacimiento"
|
||||||
|
>Fecha de nacimiento</label
|
||||||
|
>
|
||||||
|
<div class="d-flex">
|
||||||
|
<input
|
||||||
|
id="field_fechaNacimiento"
|
||||||
|
data-cy="fechaNacimiento"
|
||||||
|
type="datetime-local"
|
||||||
|
class="form-control"
|
||||||
|
name="fechaNacimiento"
|
||||||
|
formControlName="fechaNacimiento"
|
||||||
|
placeholder="YYYY-MM-DD HH:mm"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <div class="col-md-8">
|
<!-- <div class="row justify-content-center">
|
||||||
<h2 jhiTranslate="settings.title" [translateValues]="{ username: account.login }" *ngIf="account">
|
<div class="col-8">
|
||||||
User settings for [<strong>{{ account.login }}</strong
|
<form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
|
||||||
>]
|
<h2
|
||||||
|
id="jhi-usuario-extra-heading"
|
||||||
|
data-cy="UsuarioExtraCreateUpdateHeading"
|
||||||
|
jhiTranslate="dataSurveyApp.usuarioExtra.home.createOrEditLabel"
|
||||||
|
>
|
||||||
|
Create or edit a Usuario Extra
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div class="alert alert-success" *ngIf="success" jhiTranslate="settings.messages.success">
|
<div>
|
||||||
<strong>Settings saved!</strong>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<jhi-alert-error></jhi-alert-error>
|
<jhi-alert-error></jhi-alert-error>
|
||||||
|
|
||||||
<form name="form" role="form" (ngSubmit)="save()" [formGroup]="settingsForm" *ngIf="account" novalidate>
|
<div class="form-group" [hidden]="editForm.get('id')!.value == null">
|
||||||
|
<label class="form-control-label" jhiTranslate="global.field.id" for="field_id">ID</label>
|
||||||
|
<input type="number" class="form-control" name="id" id="field_id" data-cy="id" formControlName="id" [readonly]="true" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-control-label" for="firstName" jhiTranslate="settings.form.firstname">First Name</label>
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.nombre" for="field_nombre">Nombre</label>
|
||||||
|
<input type="text" class="form-control" name="nombre" id="field_nombre" data-cy="nombre" formControlName="nombre" />
|
||||||
|
<div *ngIf="editForm.get('nombre')!.invalid && (editForm.get('nombre')!.dirty || editForm.get('nombre')!.touched)">
|
||||||
|
<small class="form-text text-danger" *ngIf="editForm.get('nombre')?.errors?.required" jhiTranslate="entity.validation.required">
|
||||||
|
This field is required.
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.iconoPerfil" for="field_iconoPerfil"
|
||||||
|
>Icono Perfil</label
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="firstName"
|
name="iconoPerfil"
|
||||||
name="firstName"
|
id="field_iconoPerfil"
|
||||||
placeholder="{{ 'settings.form.firstname.placeholder' | translate }}"
|
data-cy="iconoPerfil"
|
||||||
formControlName="firstName"
|
formControlName="iconoPerfil"
|
||||||
data-cy="firstname"
|
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div
|
<div class="form-group">
|
||||||
*ngIf="
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.fechaNacimiento" for="field_fechaNacimiento"
|
||||||
settingsForm.get('firstName')!.invalid && (settingsForm.get('firstName')!.dirty || settingsForm.get('firstName')!.touched)
|
>Fecha Nacimiento</label
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<small
|
<div class="d-flex">
|
||||||
class="form-text text-danger"
|
<input
|
||||||
*ngIf="settingsForm.get('firstName')?.errors?.required"
|
id="field_fechaNacimiento"
|
||||||
jhiTranslate="settings.messages.validate.firstname.required"
|
data-cy="fechaNacimiento"
|
||||||
>
|
type="datetime-local"
|
||||||
Your first name is required.
|
class="form-control"
|
||||||
</small>
|
name="fechaNacimiento"
|
||||||
|
formControlName="fechaNacimiento"
|
||||||
|
placeholder="YYYY-MM-DD HH:mm"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<small
|
<div class="form-group">
|
||||||
class="form-text text-danger"
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.estado" for="field_estado">Estado</label>
|
||||||
*ngIf="settingsForm.get('firstName')?.errors?.minlength"
|
<select class="form-control" name="estado" formControlName="estado" id="field_estado" data-cy="estado">
|
||||||
jhiTranslate="settings.messages.validate.firstname.minlength"
|
<option [ngValue]="null">{{ 'dataSurveyApp.EstadoUsuario.null' | translate }}</option>
|
||||||
>
|
<option value="ACTIVE">{{ 'dataSurveyApp.EstadoUsuario.ACTIVE' | translate }}</option>
|
||||||
Your first name is required to be at least 1 character.
|
<option value="SUSPENDED">{{ 'dataSurveyApp.EstadoUsuario.SUSPENDED' | translate }}</option>
|
||||||
</small>
|
</select>
|
||||||
|
<div *ngIf="editForm.get('estado')!.invalid && (editForm.get('estado')!.dirty || editForm.get('estado')!.touched)">
|
||||||
<small
|
<small class="form-text text-danger" *ngIf="editForm.get('estado')?.errors?.required" jhiTranslate="entity.validation.required">
|
||||||
class="form-text text-danger"
|
This field is required.
|
||||||
*ngIf="settingsForm.get('firstName')?.errors?.maxlength"
|
|
||||||
jhiTranslate="settings.messages.validate.firstname.maxlength"
|
|
||||||
>
|
|
||||||
Your first name cannot be longer than 50 characters.
|
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-control-label" for="lastName" jhiTranslate="settings.form.lastname">Last Name</label>
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.user" for="field_user">User</label>
|
||||||
<input
|
<select class="form-control" id="field_user" data-cy="user" name="user" formControlName="user">
|
||||||
type="text"
|
<option [ngValue]="null"></option>
|
||||||
class="form-control"
|
<option
|
||||||
id="lastName"
|
[ngValue]="userOption.id === editForm.get('user')!.value?.id ? editForm.get('user')!.value : userOption"
|
||||||
name="lastName"
|
*ngFor="let userOption of usersSharedCollection; trackBy: trackUserById"
|
||||||
placeholder="{{ 'settings.form.lastname.placeholder' | translate }}"
|
|
||||||
formControlName="lastName"
|
|
||||||
data-cy="lastname"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div
|
|
||||||
*ngIf="settingsForm.get('lastName')!.invalid && (settingsForm.get('lastName')!.dirty || settingsForm.get('lastName')!.touched)"
|
|
||||||
>
|
>
|
||||||
<small
|
{{ userOption.id }}
|
||||||
class="form-text text-danger"
|
</option>
|
||||||
*ngIf="settingsForm.get('lastName')?.errors?.required"
|
|
||||||
jhiTranslate="settings.messages.validate.lastname.required"
|
|
||||||
>
|
|
||||||
Your last name is required.
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('lastName')?.errors?.minlength"
|
|
||||||
jhiTranslate="settings.messages.validate.lastname.minlength"
|
|
||||||
>
|
|
||||||
Your last name is required to be at least 1 character.
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('lastName')?.errors?.maxlength"
|
|
||||||
jhiTranslate="settings.messages.validate.lastname.maxlength"
|
|
||||||
>
|
|
||||||
Your last name cannot be longer than 50 characters.
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-control-label" for="email" jhiTranslate="global.form.email.label">Email</label>
|
|
||||||
<input
|
|
||||||
type="email"
|
|
||||||
class="form-control"
|
|
||||||
id="email"
|
|
||||||
name="email"
|
|
||||||
placeholder="{{ 'global.form.email.placeholder' | translate }}"
|
|
||||||
formControlName="email"
|
|
||||||
data-cy="email"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div *ngIf="settingsForm.get('email')!.invalid && (settingsForm.get('email')!.dirty || settingsForm.get('email')!.touched)">
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('email')?.errors?.required"
|
|
||||||
jhiTranslate="global.messages.validate.email.required"
|
|
||||||
>
|
|
||||||
Your email is required.
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('email')?.errors?.email"
|
|
||||||
jhiTranslate="global.messages.validate.email.invalid"
|
|
||||||
>
|
|
||||||
Your email is invalid.
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('email')?.errors?.minlength"
|
|
||||||
jhiTranslate="global.messages.validate.email.minlength"
|
|
||||||
>
|
|
||||||
Your email is required to be at least 5 characters.
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<small
|
|
||||||
class="form-text text-danger"
|
|
||||||
*ngIf="settingsForm.get('email')?.errors?.maxlength"
|
|
||||||
jhiTranslate="global.messages.validate.email.maxlength"
|
|
||||||
>
|
|
||||||
Your email cannot be longer than 100 characters.
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group" *ngIf="languages && languages.length > 0">
|
|
||||||
<label for="langKey" jhiTranslate="settings.form.language">Language</label>
|
|
||||||
<select class="form-control" id="langKey" name="langKey" formControlName="langKey" data-cy="langKey">
|
|
||||||
<option *ngFor="let language of languages" [value]="language">{{ language | findLanguageFromKey }}</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label jhiTranslate="dataSurveyApp.usuarioExtra.plantilla" for="field_plantillas">Plantilla</label>
|
||||||
|
<select class="form-control" id="field_plantillas" data-cy="plantilla" multiple name="plantillas" formControlName="plantillas">
|
||||||
|
<option
|
||||||
|
[ngValue]="getSelectedPlantilla(plantillaOption, editForm.get('plantillas')!.value)"
|
||||||
|
*ngFor="let plantillaOption of plantillasSharedCollection; trackBy: trackPlantillaById"
|
||||||
|
>
|
||||||
|
{{ plantillaOption.id }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" (click)="previousState()">
|
||||||
|
<fa-icon icon="ban"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
[disabled]="settingsForm.invalid"
|
id="save-entity"
|
||||||
|
data-cy="entityCreateSaveButton"
|
||||||
|
[disabled]="editForm.invalid || isSaving"
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
jhiTranslate="settings.form.button"
|
|
||||||
data-cy="submit"
|
|
||||||
>
|
>
|
||||||
Save
|
<fa-icon icon="save"></fa-icon> <span jhiTranslate="entity.action.save">Save</span>
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
|
@ -1,59 +1,177 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { HttpResponse } from '@angular/common/http';
|
||||||
import { FormBuilder, Validators } from '@angular/forms';
|
import { FormBuilder, Validators } from '@angular/forms';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { finalize, map } from 'rxjs/operators';
|
||||||
|
|
||||||
|
import * as dayjs from 'dayjs';
|
||||||
|
import { DATE_TIME_FORMAT } from 'app/config/input.constants';
|
||||||
|
import { IUser } from 'app/entities/user/user.model';
|
||||||
|
import { UserService } from 'app/entities/user/user.service';
|
||||||
|
import { IPlantilla } from 'app/entities/plantilla/plantilla.model';
|
||||||
|
import { PlantillaService } from 'app/entities/plantilla/service/plantilla.service';
|
||||||
|
import { IUsuarioExtra, UsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model';
|
||||||
|
import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario-extra.service';
|
||||||
import { AccountService } from 'app/core/auth/account.service';
|
import { AccountService } from 'app/core/auth/account.service';
|
||||||
import { Account } from 'app/core/auth/account.model';
|
|
||||||
import { LANGUAGES } from 'app/config/language.constants';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'jhi-settings',
|
selector: 'jhi-settings',
|
||||||
templateUrl: './settings.component.html',
|
templateUrl: './settings.component.html',
|
||||||
})
|
})
|
||||||
export class SettingsComponent implements OnInit {
|
export class SettingsComponent implements OnInit {
|
||||||
account!: Account;
|
isSaving = false;
|
||||||
success = false;
|
|
||||||
languages = LANGUAGES;
|
usersSharedCollection: IUser[] = [];
|
||||||
settingsForm = this.fb.group({
|
plantillasSharedCollection: IPlantilla[] = [];
|
||||||
firstName: [undefined, [Validators.required, Validators.minLength(1), Validators.maxLength(50)]],
|
|
||||||
lastName: [undefined, [Validators.required, Validators.minLength(1), Validators.maxLength(50)]],
|
editForm = this.fb.group({
|
||||||
email: [undefined, [Validators.required, Validators.minLength(5), Validators.maxLength(254), Validators.email]],
|
email: [null, [Validators.required]],
|
||||||
langKey: [undefined],
|
id: [],
|
||||||
|
nombre: [null, [Validators.required]],
|
||||||
|
iconoPerfil: [],
|
||||||
|
fechaNacimiento: [],
|
||||||
|
estado: [null, [Validators.required]],
|
||||||
|
user: [],
|
||||||
|
plantillas: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
constructor(private accountService: AccountService, private fb: FormBuilder, private translateService: TranslateService) {}
|
usuarioExtra: UsuarioExtra | null = null;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
protected usuarioExtraService: UsuarioExtraService,
|
||||||
|
protected userService: UserService,
|
||||||
|
protected plantillaService: PlantillaService,
|
||||||
|
protected activatedRoute: ActivatedRoute,
|
||||||
|
protected fb: FormBuilder,
|
||||||
|
protected accountService: AccountService
|
||||||
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.accountService.identity().subscribe(account => {
|
// Get jhi_user and usuario_extra information
|
||||||
if (account) {
|
this.accountService.getAuthenticationState().subscribe(account => {
|
||||||
this.settingsForm.patchValue({
|
if (account !== null) {
|
||||||
firstName: account.firstName,
|
this.usuarioExtraService.find(account.id).subscribe(usuarioExtra => {
|
||||||
lastName: account.lastName,
|
this.usuarioExtra = usuarioExtra.body;
|
||||||
email: account.email,
|
if (this.usuarioExtra !== null) {
|
||||||
langKey: account.langKey,
|
if (this.usuarioExtra.id === undefined) {
|
||||||
});
|
const today = dayjs().startOf('day');
|
||||||
|
this.usuarioExtra.fechaNacimiento = today;
|
||||||
|
}
|
||||||
|
this.updateForm(this.usuarioExtra);
|
||||||
|
}
|
||||||
|
|
||||||
this.account = account;
|
// this.loadRelationshipsOptions();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// this.activatedRoute.data.subscribe(({ usuarioExtra }) => {
|
||||||
|
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
previousState(): void {
|
||||||
|
window.history.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
save(): void {
|
save(): void {
|
||||||
this.success = false;
|
this.isSaving = true;
|
||||||
|
const usuarioExtra = this.createFromForm();
|
||||||
this.account.firstName = this.settingsForm.get('firstName')!.value;
|
if (usuarioExtra.id !== undefined) {
|
||||||
this.account.lastName = this.settingsForm.get('lastName')!.value;
|
this.subscribeToSaveResponse(this.usuarioExtraService.update(usuarioExtra));
|
||||||
this.account.email = this.settingsForm.get('email')!.value;
|
} else {
|
||||||
this.account.langKey = this.settingsForm.get('langKey')!.value;
|
this.subscribeToSaveResponse(this.usuarioExtraService.create(usuarioExtra));
|
||||||
|
|
||||||
this.accountService.save(this.account).subscribe(() => {
|
|
||||||
this.success = true;
|
|
||||||
|
|
||||||
this.accountService.authenticate(this.account);
|
|
||||||
|
|
||||||
if (this.account.langKey !== this.translateService.currentLang) {
|
|
||||||
this.translateService.use(this.account.langKey);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trackUserById(index: number, item: IUser): number {
|
||||||
|
return item.id!;
|
||||||
|
}
|
||||||
|
|
||||||
|
trackPlantillaById(index: number, item: IPlantilla): number {
|
||||||
|
return item.id!;
|
||||||
|
}
|
||||||
|
|
||||||
|
getSelectedPlantilla(option: IPlantilla, selectedVals?: IPlantilla[]): IPlantilla {
|
||||||
|
if (selectedVals) {
|
||||||
|
for (const selectedVal of selectedVals) {
|
||||||
|
if (option.id === selectedVal.id) {
|
||||||
|
return selectedVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected subscribeToSaveResponse(result: Observable<HttpResponse<IUsuarioExtra>>): void {
|
||||||
|
result.pipe(finalize(() => this.onSaveFinalize())).subscribe(
|
||||||
|
() => this.onSaveSuccess(),
|
||||||
|
() => this.onSaveError()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onSaveSuccess(): void {
|
||||||
|
this.previousState();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onSaveError(): void {
|
||||||
|
// Api for inheritance.
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onSaveFinalize(): void {
|
||||||
|
this.isSaving = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected updateForm(usuarioExtra: IUsuarioExtra): void {
|
||||||
|
this.editForm.patchValue({
|
||||||
|
email: usuarioExtra.user?.login,
|
||||||
|
id: usuarioExtra.id,
|
||||||
|
nombre: usuarioExtra.nombre,
|
||||||
|
iconoPerfil: usuarioExtra.iconoPerfil,
|
||||||
|
fechaNacimiento: usuarioExtra.fechaNacimiento ? usuarioExtra.fechaNacimiento.format(DATE_TIME_FORMAT) : null,
|
||||||
|
estado: usuarioExtra.estado,
|
||||||
|
user: usuarioExtra.user,
|
||||||
|
plantillas: usuarioExtra.plantillas,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.usersSharedCollection = this.userService.addUserToCollectionIfMissing(this.usersSharedCollection, usuarioExtra.user);
|
||||||
|
this.plantillasSharedCollection = this.plantillaService.addPlantillaToCollectionIfMissing(
|
||||||
|
this.plantillasSharedCollection,
|
||||||
|
...(usuarioExtra.plantillas ?? [])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected loadRelationshipsOptions(): void {
|
||||||
|
this.userService
|
||||||
|
.query()
|
||||||
|
.pipe(map((res: HttpResponse<IUser[]>) => res.body ?? []))
|
||||||
|
.pipe(map((users: IUser[]) => this.userService.addUserToCollectionIfMissing(users, this.editForm.get('user')!.value)))
|
||||||
|
.subscribe((users: IUser[]) => (this.usersSharedCollection = users));
|
||||||
|
|
||||||
|
this.plantillaService
|
||||||
|
.query()
|
||||||
|
.pipe(map((res: HttpResponse<IPlantilla[]>) => res.body ?? []))
|
||||||
|
.pipe(
|
||||||
|
map((plantillas: IPlantilla[]) =>
|
||||||
|
this.plantillaService.addPlantillaToCollectionIfMissing(plantillas, ...(this.editForm.get('plantillas')!.value ?? []))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.subscribe((plantillas: IPlantilla[]) => (this.plantillasSharedCollection = plantillas));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected createFromForm(): IUsuarioExtra {
|
||||||
|
return {
|
||||||
|
...new UsuarioExtra(),
|
||||||
|
id: this.editForm.get(['id'])!.value,
|
||||||
|
nombre: this.editForm.get(['nombre'])!.value,
|
||||||
|
iconoPerfil: this.editForm.get(['iconoPerfil'])!.value,
|
||||||
|
fechaNacimiento: this.editForm.get(['fechaNacimiento'])!.value
|
||||||
|
? dayjs(this.editForm.get(['fechaNacimiento'])!.value, DATE_TIME_FORMAT)
|
||||||
|
: undefined,
|
||||||
|
estado: this.editForm.get(['estado'])!.value,
|
||||||
|
user: this.editForm.get(['user'])!.value,
|
||||||
|
plantillas: this.editForm.get(['plantillas'])!.value,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,3 +244,122 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- <div class="row justify-content-center">
|
||||||
|
<div class="col-8">
|
||||||
|
<form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
|
||||||
|
<h2
|
||||||
|
id="jhi-usuario-extra-heading"
|
||||||
|
data-cy="UsuarioExtraCreateUpdateHeading"
|
||||||
|
jhiTranslate="dataSurveyApp.usuarioExtra.home.createOrEditLabel"
|
||||||
|
>
|
||||||
|
Create or edit a Usuario Extra
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<jhi-alert-error></jhi-alert-error>
|
||||||
|
|
||||||
|
<div class="form-group" [hidden]="editForm.get('id')!.value == null">
|
||||||
|
<label class="form-control-label" jhiTranslate="global.field.id" for="field_id">ID</label>
|
||||||
|
<input type="number" class="form-control" name="id" id="field_id" data-cy="id" formControlName="id" [readonly]="true" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.nombre" for="field_nombre">Nombre</label>
|
||||||
|
<input type="text" class="form-control" name="nombre" id="field_nombre" data-cy="nombre" formControlName="nombre" />
|
||||||
|
<div *ngIf="editForm.get('nombre')!.invalid && (editForm.get('nombre')!.dirty || editForm.get('nombre')!.touched)">
|
||||||
|
<small class="form-text text-danger" *ngIf="editForm.get('nombre')?.errors?.required" jhiTranslate="entity.validation.required">
|
||||||
|
This field is required.
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.iconoPerfil" for="field_iconoPerfil"
|
||||||
|
>Icono Perfil</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
name="iconoPerfil"
|
||||||
|
id="field_iconoPerfil"
|
||||||
|
data-cy="iconoPerfil"
|
||||||
|
formControlName="iconoPerfil"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.fechaNacimiento" for="field_fechaNacimiento"
|
||||||
|
>Fecha Nacimiento</label
|
||||||
|
>
|
||||||
|
<div class="d-flex">
|
||||||
|
<input
|
||||||
|
id="field_fechaNacimiento"
|
||||||
|
data-cy="fechaNacimiento"
|
||||||
|
type="datetime-local"
|
||||||
|
class="form-control"
|
||||||
|
name="fechaNacimiento"
|
||||||
|
formControlName="fechaNacimiento"
|
||||||
|
placeholder="YYYY-MM-DD HH:mm"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.estado" for="field_estado">Estado</label>
|
||||||
|
<select class="form-control" name="estado" formControlName="estado" id="field_estado" data-cy="estado">
|
||||||
|
<option [ngValue]="null">{{ 'dataSurveyApp.EstadoUsuario.null' | translate }}</option>
|
||||||
|
<option value="ACTIVE">{{ 'dataSurveyApp.EstadoUsuario.ACTIVE' | translate }}</option>
|
||||||
|
<option value="SUSPENDED">{{ 'dataSurveyApp.EstadoUsuario.SUSPENDED' | translate }}</option>
|
||||||
|
</select>
|
||||||
|
<div *ngIf="editForm.get('estado')!.invalid && (editForm.get('estado')!.dirty || editForm.get('estado')!.touched)">
|
||||||
|
<small class="form-text text-danger" *ngIf="editForm.get('estado')?.errors?.required" jhiTranslate="entity.validation.required">
|
||||||
|
This field is required.
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-control-label" jhiTranslate="dataSurveyApp.usuarioExtra.user" for="field_user">User</label>
|
||||||
|
<select class="form-control" id="field_user" data-cy="user" name="user" formControlName="user">
|
||||||
|
<option [ngValue]="null"></option>
|
||||||
|
<option
|
||||||
|
[ngValue]="userOption.id === editForm.get('user')!.value?.id ? editForm.get('user')!.value : userOption"
|
||||||
|
*ngFor="let userOption of usersSharedCollection; trackBy: trackUserById"
|
||||||
|
>
|
||||||
|
{{ userOption.id }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label jhiTranslate="dataSurveyApp.usuarioExtra.plantilla" for="field_plantillas">Plantilla</label>
|
||||||
|
<select class="form-control" id="field_plantillas" data-cy="plantilla" multiple name="plantillas" formControlName="plantillas">
|
||||||
|
<option
|
||||||
|
[ngValue]="getSelectedPlantilla(plantillaOption, editForm.get('plantillas')!.value)"
|
||||||
|
*ngFor="let plantillaOption of plantillasSharedCollection; trackBy: trackPlantillaById"
|
||||||
|
>
|
||||||
|
{{ plantillaOption.id }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" (click)="previousState()">
|
||||||
|
<fa-icon icon="ban"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
id="save-entity"
|
||||||
|
data-cy="entityCreateSaveButton"
|
||||||
|
[disabled]="editForm.invalid || isSaving"
|
||||||
|
class="btn btn-primary"
|
||||||
|
>
|
||||||
|
<fa-icon icon="save"></fa-icon> <span jhiTranslate="entity.action.save">Save</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
|
|
Loading…
Reference in New Issue