Skip to content

Commit

Permalink
feat #228: Selección de evaluadores
Browse files Browse the repository at this point in the history
- Se implementa funcionalidad para filtrar los evaluadores por número de identificación, de acuerdo al Id del endpoint informacion_persona_natural del api administrativa_amazon_crud.
  • Loading branch information
lud committed May 13, 2023
1 parent 27cda88 commit 617d420
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 96 deletions.
69 changes: 69 additions & 0 deletions src/app/@core/data/user.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { Injectable } from '@angular/core';
import { map } from 'rxjs/operators';
import { HttpErrorResponse } from '@angular/common/http';
import { throwError } from 'rxjs';
import { RequestManager } from '../../managers/requestManager';

@Injectable({
providedIn: 'root'
})
export class UserService {
constructor(
private rqManager: RequestManager,
) { }

getPersonaNaturalAmazon() {

const userString = window.localStorage.getItem('user');
if (!userString || !userString.length) {
return;
}

const user = atob(userString);
if (!user) {
return;
}

const userObj = JSON.parse(atob(userString));

if (!userObj || !userObj.userService || !userObj.userService.documento) {
return;
}

const endpoint = 'informacion_persona_natural';
const payload = '?fields=Id,PrimerNombre,SegundoNombre,PrimerApellido,SegundoApellido,TipoDocumento,Cargo&' +
'query=Id:' + userObj.userService.documento;

return this.getAllInfoPersonaNatural(payload);
}

getAllInfoPersonaNatural(payload) {
const path = 'informacion_persona_natural'
this.rqManager.setPath('ADMINISTRIVA_AMAZON');
return this.rqManager.get(path + payload).pipe(
map(
(res) => {
return res;
},
),
);
}

private handleError(error: HttpErrorResponse) {
if (error.error instanceof ErrorEvent) {
// A client-side or network error occurred. Handle it accordingly.
console.error('An error occurred:', error.error.message);
} else {
// The backend returned an unsuccessful response code.
// The response body may contain clues as to what went wrong,
console.error(
`Backend returned code ${error.status}, ` +
`body was: ${error.error}`);
}
// return an observable with a user-facing error message
return throwError({
status: error.status,
message: 'Something bad happened; please try again later.',
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ <h2>{{seccionPadre.Nombre}}</h2>
</div>
<div class="div-seccionHija" *ngFor="let seccionHija of seccionPadre.Seccion_hija_id; let j = index">
<div class="col-12" *ngIf="seccionHija['Item'][0].Tamano==12">
<mat-form-field class="txtArea-full" *ngIf="this.realizar==true">
<mat-form-field class="txtArea-full" *ngIf="realizar">
<textarea matInput placeholder="Item Evaluado" [(ngModel)]="this.json.label"></textarea>
</mat-form-field>
<label class="txtArea-full" matInput placeholder="Item Evaluado"
*ngIf="this.realizar==false">{{this.json.label}}</label>
*ngIf="!realizar">{{this.json.label}}</label>
</div>

<div class="col-12" *ngIf="seccionHija['Item'][0].Tamano==13">
<mat-form-field class="txtArea-full" *ngIf="this.realizar==true">
<mat-form-field class="txtArea-full" *ngIf="realizar">
<textarea matInput placeholder="Observaciones" [(ngModel)]="this.json.observaciones"></textarea>
</mat-form-field>
<label class="txtArea-full" matInput placeholder="Observaciones"
*ngIf="this.realizar==false">{{this.json.observaciones}}</label>
*ngIf="!realizar">{{this.json.observaciones}}</label>
</div>

<div *ngIf="seccionHija['Item'][0].Tamano!=12 && seccionHija['Item'][0].Tamano!=13">
Expand Down Expand Up @@ -70,16 +70,16 @@ <h2>{{seccionPadre.Nombre}}</h2>
{{item['Valor']}}
</p>
<div class="mat-select" *ngSwitchCase="'select'">
<label matInput *ngIf="this.realizar===false">{{seccionHija['Item'][2].Valor.Nombre}}</label>
<mat-select *ngIf="this.realizar===true && this.evaRealizada == false"
<label matInput *ngIf="!realizar">{{seccionHija['Item'][2].Valor.Nombre}}</label>
<mat-select *ngIf="realizar && !evaRealizada"
[(ngModel)]="json.Secciones[i].Seccion_hija_id[j]['Item'][2].Valor"
(selectionChange)="filterChanged(i,'', seccionPadre.Seccion_hija_id[j]['Item'][2].Valor.Nombre)"
placeholder="Opción">
<mat-option *ngFor="let opcion of seccionHija['Item'][2]['Opcion_item']" [value]="opcion['IdOpciones']">
{{opcion['IdOpciones']['Nombre']}}
</mat-option>
</mat-select>
<mat-select *ngIf="this.realizar===true && this.evaRealizada == true"
<mat-select *ngIf="realizar && evaRealizada"
[(ngModel)]="json.Secciones[i].Seccion_hija_id[j]['Item'][2].Valor"
(selectionChange)="filterChanged(i,'', seccionPadre.Seccion_hija_id[j]['Item'][2].Valor.Nombre)"
placeholder="{{seccionHija['Item'][2].Valor.Nombre}}">
Expand Down Expand Up @@ -115,59 +115,38 @@ <h2>{{seccionPadre.Nombre}}</h2>
</div>
</div>

<div class="card card-margin" *ngIf="this.realizar==true">
<div class="card-body">
<div class="row">
<div class="col-12">
<h2>Evaluadores</h2>
</div>
</div>
<div class="row" *ngFor="let evaluador of evaluadoresArray; let i = index">
<div class="col-md-auto">
<p></p>
<p>Nombre: </p>
</div>
<div class="col-9">
<mat-form-field class="txtArea-full">
<textarea rows="1" cols="9" style="resize:none;" matInput [(ngModel)]="evaluador"
placeholder="Nombre del proveedor" (keydown)="deshabilitarBoton(i)">{{evaluador}}</textarea>
</mat-form-field>
</div>
<div class=" col-md-auto">
<button mat-mini-fab color="primary" (click)="asignarEvaluador(evaluador, i)" [disabled]="review_btn[i]">
<mat-icon>check</mat-icon>
</button>
</div>
<div class="col-md-auto">
<button mat-mini-fab color="warn" (click)="eliminarEvaluador(evaluador, i)">
<mat-icon>delete</mat-icon>
</button>
</div>
<div class="card card-margin card-body">
<div class="row">
<div class="col-9">
<h2>Evaluadores</h2>
</div>
<div class="col-md-auto">
<div class="col-3" *ngIf="realizar">
<button (click)="agregarEvaluador()" style="align-items: right;" nbButton class="btn-flotante">
Agregar
</button>
</div>
</div>
</div>

<div class="card card-margin" *ngIf="this.realizar==false">
<div class="card-body">
<div class="row">
<div class="col-12">
<h2>Evaluadores</h2>
</div>
</div>
<div class="row" *ngFor="let evaluadores of evaluadoresArray; let i = index">
<div class="col-2">
<p></p>
<p>Nombre Evaluador {{i+1}}: </p>
</div>
<div class="col-md-auto">
<p></p>
<label class="txtArea-full" matInput placeholder="Nombre del evaluador"
*ngIf="this.realizar==false">{{this.evaluadoresArray[i]}}</label>
<div class="row" [formGroup]="evaluadoresForm">
<div formArrayName="evaluadores">
<div *ngFor="let evaluador of evaluadoresForm_.controls; index as i">
<div class="row card-body" [formGroupName]="i">
<mat-form-field appearance="outline" class="col-8">
<mat-label>Cédula de ciudadanía</mat-label>
<input type="text" placeholder="Ingrese 4 o más caracteres" aria-label="Number" matInput
formControlName="evaluador" [matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete" [displayWith]="muestraTercero">
<mat-option *ngFor="let ev of evaluadores" [value]="ev">
{{muestraTercero(ev)}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
<div class="col-4" *ngIf="realizar">
<button mat-mini-fab color="warn" (click)="eliminarEvaluador(i)">
<mat-icon>delete</mat-icon>
</button>
</div>
</div>
</div>
</div>
</div>
Expand All @@ -190,7 +169,7 @@ <h2>Puntaje total de la evaluación</h2>
</div>
</div>
<div class="col-3">
<button (click)="realizarEvaluacion()" nbButton class="btn-evaluacion" *ngIf="this.realizar==true">
<button (click)="realizarEvaluacion()" nbButton class="btn-evaluacion" *ngIf="realizar">
Enviar Evaluación
</button>
</div>
Expand Down
Loading

0 comments on commit 617d420

Please sign in to comment.