Commit 130b709a authored by Aaron Gutierrez's avatar Aaron Gutierrez

mejoras y correccion de errores

parent 4db650a5
...@@ -2557,15 +2557,17 @@ ...@@ -2557,15 +2557,17 @@
} }
}, },
"@xdf/commons": { "@xdf/commons": {
"version": "file:libs/xdf-commons-1.0.1.tgz", "version": "1.0.4",
"integrity": "sha512-mzohAadB/YBr0C6ZhGBkR8N3cdYLRAGl1bb301AS5mFHMGLbD0weX546tP1JZvh7rP38rtPItkCEfJWpPEg9oA==", "resolved": "http://byteswpe-nexus.tbs.com:8081/repository/npm-public/@xdf/commons/-/commons-1.0.4.tgz",
"integrity": "sha512-as164RDA0Aib0VBYPEeapX7Ux+Qc9dul0/dMacDerEPCseMlkm5FVvNpEVjTtuV2Mfr9juuGXh4w3z/qMvaYhA==",
"requires": { "requires": {
"tslib": "^1.9.0" "tslib": "^1.9.0"
} }
}, },
"@xdf/gallery": { "@xdf/gallery": {
"version": "file:libs/xdf-gallery-1.0.16.tgz", "version": "1.0.18",
"integrity": "sha512-qakpDzql6FBnLUTAdS47Mpbo/+XSM1gv8IDYh5aK0XssEBKI1XM+j7fT1kSZve16gNe8gq7aDU1DREwwPXejQg==", "resolved": "http://byteswpe-nexus.tbs.com:8081/repository/npm-public/@xdf/gallery/-/gallery-1.0.18.tgz",
"integrity": "sha512-VChSY2FD63iskV1LWVkLfZHzWbCuYJVxqPVwEhw+SQgFU1LR3QviBbLdCgpwfZ/fL4j9Z7gu91PU6EPW0RGV2Q==",
"requires": { "requires": {
"tslib": "^1.9.0" "tslib": "^1.9.0"
} }
...@@ -2578,22 +2580,25 @@ ...@@ -2578,22 +2580,25 @@
} }
}, },
"@xdf/layouts": { "@xdf/layouts": {
"version": "file:libs/xdf-layouts-1.0.1.tgz", "version": "1.0.3",
"integrity": "sha512-2DD4jmgskPjKveS1bi0blEyrLCjV9S5Uhvd7TuwiuC11KDXGJuod0VpKdIOZRegpJlYcODbcIr++rmv7Q2y02A==", "resolved": "http://byteswpe-nexus.tbs.com:8081/repository/npm-public/@xdf/layouts/-/layouts-1.0.3.tgz",
"integrity": "sha512-PGIfh97fBKJLHNfMnRs3SksnVA8738UIS8XTQ6mZxyAQDxZIVW6FP0QDe4Qe3CSPbOdZIozldGG2eNDxkReJQg==",
"requires": { "requires": {
"tslib": "^1.9.0" "tslib": "^1.9.0"
} }
}, },
"@xdf/security": { "@xdf/security": {
"version": "file:libs/xdf-security-1.0.0.tgz", "version": "1.0.0",
"integrity": "sha512-3Arppi1D2R+h9pYzkbAFt19PGcBMQQCYEuikqOScZKgCkxJhroaKPNVEASgy+ZfLogO3MQ3/37f7ukXZeVx2IQ==", "resolved": "http://byteswpe-nexus.tbs.com:8081/repository/npm-public/@xdf/security/-/security-1.0.0.tgz",
"integrity": "sha512-Eos3h0clEc3I7cyA3yp7HocN2gNP9KcgjiBUUT/+GjYOon/wAEiD0UK7o72zqalKdCJ9rgt+I1/96oxK728GVA==",
"requires": { "requires": {
"tslib": "^1.9.0" "tslib": "^1.9.0"
} }
}, },
"@xdf/settings": { "@xdf/settings": {
"version": "file:libs/xdf-settings-1.0.3.tgz", "version": "1.0.6",
"integrity": "sha512-v0GwBKkxnAgf/2mBw85a0YByyglHtht6OlN9iu6Zr37ezB395oBVI5+4g9AiWdo0ua6hG47YRG1EjFBiCbZMVQ==", "resolved": "http://byteswpe-nexus.tbs.com:8081/repository/npm-public/@xdf/settings/-/settings-1.0.6.tgz",
"integrity": "sha512-DI92l4H6SaZa3ALxbtiC/VM59MZadFVhvww3Ev9zFxYeE7a3hmWRtpqrRdA3fn0Pb/h4mVmf6oB6U5OiWj0QOg==",
"requires": { "requires": {
"tslib": "^1.9.0" "tslib": "^1.9.0"
} }
......
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
<b>{{'label.channels' | translate}}</b> <b>{{'label.channels' | translate}}</b>
</h4> </h4>
<mat-accordion> <mat-accordion *ngIf="!isLoadingDataChannel">
<form [formGroup]="formGroup" novalidate autocomplete="off">
<mat-expansion-panel *ngFor="let channel of deploymentChannels; let i = index" <mat-expansion-panel *ngFor="let channel of deploymentChannels; let i = index"
[expanded]="step === i" (opened)="setStep(i)"> [expanded]="step === i" (opened)="setStep(i)">
<mat-expansion-panel-header class="right-aligned-header" [collapsedHeight]="'60px'"> <mat-expansion-panel-header class="right-aligned-header" [collapsedHeight]="'60px'">
...@@ -67,8 +68,7 @@ ...@@ -67,8 +68,7 @@
</mat-panel-description> </mat-panel-description>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div> <div formGroupName="{{channel.channelName}}">
<form role="form" novalidate #myForm="ngForm" autocomplete="off">
<div class="row"> <div class="row">
<!-- <div class="col-6"> <!-- <div class="col-6">
<mat-form-field class="amd-form-control"> <mat-form-field class="amd-form-control">
...@@ -94,17 +94,18 @@ ...@@ -94,17 +94,18 @@
<!-- <!--
[pattern]="field.regex" [pattern]="field.regex"
--> -->
<input matInput [maxlength]="field.maxlength" [(ngModel)]="field.value" <input matInput [maxlength]="field.maxlength"
[ngModelOptions]="{standalone: true}" [disabled]="viewMode" [disabled]="viewMode"
#fieldForm='ngModel' [type]="(field.type ? field.type : 'text')" [type]="(field.type ? field.type : 'text')"
[required]="field.required" (ngModelChange)="onChange(fieldForm)" [required]="field.required"
[pattern]="field?.regex"> [pattern]="field?.regex" [formControlName]="field.channelParamName">
<mat-error *ngIf="fieldForm.errors?.pattern"> <!-- <mat-error *ngIf="fieldForm.errors?.pattern">
{{ 'Formato inválido' | translate }}</mat-error> {{ 'Formato inválido' | translate }}</mat-error> -->
<mat-error *ngFor="let error of getErrors(channel.channelName, field.channelParamName, field.label)">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
</form>
</div> </div>
<mat-action-row *ngIf="!viewMode"> <mat-action-row *ngIf="!viewMode">
...@@ -114,6 +115,7 @@ ...@@ -114,6 +115,7 @@
</button> </button>
</mat-action-row> </mat-action-row>
</mat-expansion-panel> </mat-expansion-panel>
</form>
</mat-accordion> </mat-accordion>
<div *ngIf="!(deploymentChannels && deploymentChannels.length)" class="border-all text-center"> <div *ngIf="!(deploymentChannels && deploymentChannels.length)" class="border-all text-center">
......
...@@ -6,7 +6,8 @@ import { first } from 'rxjs/operators'; ...@@ -6,7 +6,8 @@ import { first } from 'rxjs/operators';
import { NotificationType, NotificationService } from '@xdf/commons'; import { NotificationType, NotificationService } from '@xdf/commons';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { Form, FormControl, FormGroup, FormGroupDirective, NgForm } from '@angular/forms'; import { Form, FormArray, FormControl, FormGroup, FormGroupDirective, NgForm, Validators } from '@angular/forms';
import { ValidatorUtils } from '@xdf/gallery';
@Component({ @Component({
selector: 'byte-ca-deployment-channels', selector: 'byte-ca-deployment-channels',
...@@ -34,6 +35,8 @@ export class CaDeploymentChannelsComponent implements OnInit { ...@@ -34,6 +35,8 @@ export class CaDeploymentChannelsComponent implements OnInit {
mode = 'new'; mode = 'new';
detailText = 'Detail'; detailText = 'Detail';
titleText = 'Titulo'; titleText = 'Titulo';
isLoadingDataChannel = true;
formGroup: FormGroup;
constructor( constructor(
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
...@@ -41,12 +44,12 @@ export class CaDeploymentChannelsComponent implements OnInit { ...@@ -41,12 +44,12 @@ export class CaDeploymentChannelsComponent implements OnInit {
private matDialog: MatDialog, private matDialog: MatDialog,
private translateService: TranslateService, private translateService: TranslateService,
private notificationService: NotificationService, private notificationService: NotificationService,
private router: Router private router: Router,
private validatorUtils: ValidatorUtils
) { ) {
this.formGroup = new FormGroup({});
this.mode = this.activatedRoute.snapshot.data.mode; this.mode = this.activatedRoute.snapshot.data.mode;
this.viewMode = this.mode === 'view'; this.viewMode = this.mode === 'view';
} }
ngOnInit() { ngOnInit() {
...@@ -60,6 +63,9 @@ export class CaDeploymentChannelsComponent implements OnInit { ...@@ -60,6 +63,9 @@ export class CaDeploymentChannelsComponent implements OnInit {
this.buildList(); this.buildList();
this.buildAvaliableChannels(); this.buildAvaliableChannels();
this.isLoadingDataChannel = false;
}, error => {
this.isLoadingDataChannel = false;
}); });
} }
...@@ -83,17 +89,21 @@ export class CaDeploymentChannelsComponent implements OnInit { ...@@ -83,17 +89,21 @@ export class CaDeploymentChannelsComponent implements OnInit {
deploymentChannel.suggestTitle = channel.suggestTitle; deploymentChannel.suggestTitle = channel.suggestTitle;
deploymentChannel.suggestDetail = channel.suggestDetail; deploymentChannel.suggestDetail = channel.suggestDetail;
this.formGroup.addControl(channel.name, new FormGroup({}));
for (const parameter of deploymentChannel.parameters) { for (const parameter of deploymentChannel.parameters) {
for (const field of channel.parameters) { for (const field of channel.parameters) {
if (parameter.channelParamName === field.name) { if (parameter.channelParamName === field.name) {
const formArray = this.formGroup.controls[channel.name] as FormGroup;
parameter.label = field.label; parameter.label = field.label;
parameter.type = field.type; parameter.type = field.type;
parameter.required = field.required; parameter.required = field.required;
parameter.traductions = field.traductions; parameter.traductions = field.traductions;
parameter.maxlength = field.maxlength; parameter.maxlength = field.maxlength;
parameter.regex = field.regex; parameter.regex = field.regex;
formArray.addControl(field.name, new FormControl('',field.required ? [Validators.required] : []));
break; break;
} }
...@@ -105,6 +115,7 @@ export class CaDeploymentChannelsComponent implements OnInit { ...@@ -105,6 +115,7 @@ export class CaDeploymentChannelsComponent implements OnInit {
} }
} }
} }
console.log(this.formGroup);
} }
buildAvaliableChannels() { buildAvaliableChannels() {
...@@ -273,4 +284,9 @@ export class CaDeploymentChannelsComponent implements OnInit { ...@@ -273,4 +284,9 @@ export class CaDeploymentChannelsComponent implements OnInit {
return valid; return valid;
} }
getErrors(channelName:string, name: string, placeholder: string) {
const channelFormGroup = (this.formGroup.controls[channelName] as FormGroup);
return channelFormGroup ? this.validatorUtils.getErrors(channelFormGroup.controls[name] as FormControl, name, placeholder) : [];
}
} }
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
<mat-form-field class="amd-form-control"> <mat-form-field class="amd-form-control">
<input matInput [placeholder]="'label.name' | translate" formControlName="name" <input matInput [placeholder]="'label.name' | translate" formControlName="name"
maxlength="50" required> maxlength="50" required>
<mat-error *ngFor="let error of getErrors('name', 'label.name')">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
...@@ -58,6 +60,8 @@ ...@@ -58,6 +60,8 @@
[placeholder]="'label.description' | translate" maxlength="200" [placeholder]="'label.description' | translate" maxlength="200"
formControlName="description" #autosize="cdkTextareaAutosize" cdkAutosizeMinRows="3" formControlName="description" #autosize="cdkTextareaAutosize" cdkAutosizeMinRows="3"
cdkAutosizeMaxRows="6" required></textarea> cdkAutosizeMaxRows="6" required></textarea>
<mat-error *ngFor="let error of getErrors('description', 'label.description')">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
...@@ -67,6 +71,8 @@ ...@@ -67,6 +71,8 @@
<input matInput [placeholder]="'label.version' | translate" formControlName="version" <input matInput [placeholder]="'label.version' | translate" formControlName="version"
maxlength="15" required pattern="[0-9]{1,2}[.]{1}[0-9]{1,2}[.]{1}[0-9]{1,2}"> maxlength="15" required pattern="[0-9]{1,2}[.]{1}[0-9]{1,2}[.]{1}[0-9]{1,2}">
<mat-hint>##.##.##</mat-hint> <mat-hint>##.##.##</mat-hint>
<mat-error *ngFor="let error of getErrors('version', 'label.version')">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
...@@ -79,6 +85,8 @@ ...@@ -79,6 +85,8 @@
{{country.name | translate}} {{country.name | translate}}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error *ngFor="let error of getErrors('country', 'label.country')">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
...@@ -91,6 +99,8 @@ ...@@ -91,6 +99,8 @@
{{timezone | translate}} {{timezone | translate}}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error *ngFor="let error of getErrors('timezone', 'label.timezone')">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
...@@ -102,6 +112,8 @@ ...@@ -102,6 +112,8 @@
{{language.name | translate}} {{language.name | translate}}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error *ngFor="let error of getErrors('language', 'label.language')">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
...@@ -113,6 +125,8 @@ ...@@ -113,6 +125,8 @@
{{type.name | translate}} {{type.name | translate}}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error *ngFor="let error of getErrors('type', 'label.type')">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
......
...@@ -5,6 +5,7 @@ import { ActivatedRoute } from '@angular/router'; ...@@ -5,6 +5,7 @@ import { ActivatedRoute } from '@angular/router';
import { animate, trigger, state, transition, style } from '@angular/animations'; import { animate, trigger, state, transition, style } from '@angular/animations';
import { NotificationService, NotificationType } from '@xdf/commons'; import { NotificationService, NotificationType } from '@xdf/commons';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { ValidatorUtils } from '@xdf/gallery';
export const FILE_TYPE = { export const FILE_TYPE = {
image: /image.*/, image: /image.*/,
...@@ -64,7 +65,8 @@ export class CaGeneralInformationComponent implements OnInit { ...@@ -64,7 +65,8 @@ export class CaGeneralInformationComponent implements OnInit {
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private notificationService: NotificationService, private notificationService: NotificationService,
private translateService: TranslateService private translateService: TranslateService,
private validatorUtils: ValidatorUtils
) { ) {
this.mode = this.activatedRoute.snapshot.data.mode; this.mode = this.activatedRoute.snapshot.data.mode;
...@@ -177,5 +179,9 @@ export class CaGeneralInformationComponent implements OnInit { ...@@ -177,5 +179,9 @@ export class CaGeneralInformationComponent implements OnInit {
this.stepper.next(); this.stepper.next();
} }
} }
getErrors(name: string, placeholder: string) {
return this.validatorUtils.getErrors(this.formGroup.controls[name] as FormControl, name, placeholder);
}
} }
...@@ -60,7 +60,12 @@ ...@@ -60,7 +60,12 @@
"showStrength": false "showStrength": false
}, },
"validators": [ "validators": [
"required" "required",
{
"name": "validatePassword",
"isRemote": true,
"service": "validate/password"
}
] ]
} }
}, },
...@@ -249,7 +254,7 @@ ...@@ -249,7 +254,7 @@
"formOptions": { "formOptions": {
"options": { "options": {
"rightIcon": "mail", "rightIcon": "mail",
"maxLength": 200, "maxLength": 80,
"styleClass": "col-xl-6" "styleClass": "col-xl-6"
}, },
"validators": [ "validators": [
......
...@@ -97,5 +97,7 @@ ...@@ -97,5 +97,7 @@
"dashboards.customer.interaction.avg.intent": "Promedio de intenciones por cliente", "dashboards.customer.interaction.avg.intent": "Promedio de intenciones por cliente",
"dashboards.customer.interaction.goals": "Cantidad de objetivos cumplidos", "dashboards.customer.interaction.goals": "Cantidad de objetivos cumplidos",
"dashboards.customer.interaction.sentences": "Frases no identificadas", "dashboards.customer.interaction.sentences": "Frases no identificadas",
"dashboards.customer.interaction.intents": "Intenciones más utilizadas" "dashboards.customer.interaction.intents": "Intenciones más utilizadas",
"security.password.error.passwordMinLength": "La contraseña no cumple con el mínimo de caracteres configurado.",
"message.error.duplicated": "Registro duplicado"
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment