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

mejoras y correccion de errores

parent 4db650a5
......@@ -2557,15 +2557,17 @@
}
},
"@xdf/commons": {
"version": "file:libs/xdf-commons-1.0.1.tgz",
"integrity": "sha512-mzohAadB/YBr0C6ZhGBkR8N3cdYLRAGl1bb301AS5mFHMGLbD0weX546tP1JZvh7rP38rtPItkCEfJWpPEg9oA==",
"version": "1.0.4",
"resolved": "http://byteswpe-nexus.tbs.com:8081/repository/npm-public/@xdf/commons/-/commons-1.0.4.tgz",
"integrity": "sha512-as164RDA0Aib0VBYPEeapX7Ux+Qc9dul0/dMacDerEPCseMlkm5FVvNpEVjTtuV2Mfr9juuGXh4w3z/qMvaYhA==",
"requires": {
"tslib": "^1.9.0"
}
},
"@xdf/gallery": {
"version": "file:libs/xdf-gallery-1.0.16.tgz",
"integrity": "sha512-qakpDzql6FBnLUTAdS47Mpbo/+XSM1gv8IDYh5aK0XssEBKI1XM+j7fT1kSZve16gNe8gq7aDU1DREwwPXejQg==",
"version": "1.0.18",
"resolved": "http://byteswpe-nexus.tbs.com:8081/repository/npm-public/@xdf/gallery/-/gallery-1.0.18.tgz",
"integrity": "sha512-VChSY2FD63iskV1LWVkLfZHzWbCuYJVxqPVwEhw+SQgFU1LR3QviBbLdCgpwfZ/fL4j9Z7gu91PU6EPW0RGV2Q==",
"requires": {
"tslib": "^1.9.0"
}
......@@ -2578,22 +2580,25 @@
}
},
"@xdf/layouts": {
"version": "file:libs/xdf-layouts-1.0.1.tgz",
"integrity": "sha512-2DD4jmgskPjKveS1bi0blEyrLCjV9S5Uhvd7TuwiuC11KDXGJuod0VpKdIOZRegpJlYcODbcIr++rmv7Q2y02A==",
"version": "1.0.3",
"resolved": "http://byteswpe-nexus.tbs.com:8081/repository/npm-public/@xdf/layouts/-/layouts-1.0.3.tgz",
"integrity": "sha512-PGIfh97fBKJLHNfMnRs3SksnVA8738UIS8XTQ6mZxyAQDxZIVW6FP0QDe4Qe3CSPbOdZIozldGG2eNDxkReJQg==",
"requires": {
"tslib": "^1.9.0"
}
},
"@xdf/security": {
"version": "file:libs/xdf-security-1.0.0.tgz",
"integrity": "sha512-3Arppi1D2R+h9pYzkbAFt19PGcBMQQCYEuikqOScZKgCkxJhroaKPNVEASgy+ZfLogO3MQ3/37f7ukXZeVx2IQ==",
"version": "1.0.0",
"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": {
"tslib": "^1.9.0"
}
},
"@xdf/settings": {
"version": "file:libs/xdf-settings-1.0.3.tgz",
"integrity": "sha512-v0GwBKkxnAgf/2mBw85a0YByyglHtht6OlN9iu6Zr37ezB395oBVI5+4g9AiWdo0ua6hG47YRG1EjFBiCbZMVQ==",
"version": "1.0.6",
"resolved": "http://byteswpe-nexus.tbs.com:8081/repository/npm-public/@xdf/settings/-/settings-1.0.6.tgz",
"integrity": "sha512-DI92l4H6SaZa3ALxbtiC/VM59MZadFVhvww3Ev9zFxYeE7a3hmWRtpqrRdA3fn0Pb/h4mVmf6oB6U5OiWj0QOg==",
"requires": {
"tslib": "^1.9.0"
}
......
......@@ -35,85 +35,87 @@
<b>{{'label.channels' | translate}}</b>
</h4>
<mat-accordion>
<mat-expansion-panel *ngFor="let channel of deploymentChannels; let i = index"
[expanded]="step === i" (opened)="setStep(i)">
<mat-expansion-panel-header class="right-aligned-header" [collapsedHeight]="'60px'">
<mat-panel-title>
<img [src]="channel.channelImage" class="icon">
<div>
<span style="margin-right: 8px;">{{ channel.channelName }}</span>
<ng-container *ngIf="channel?.suggestTitle && channel?.suggestDetail">
<ng-template #popContent><div [innerHTML]="channel?.suggestDetail"></div></ng-template>
<ng-template #popoverTitle><div [innerHTML]="channel?.suggestTitle"></div></ng-template>
<i class="fa fa-info-circle" placement="top" style="color: rgba(0, 0, 0, 0.54);"
[ngbPopover]="popContent"
[popoverTitle]="popoverTitle" triggers="hover"></i>
</ng-container>
<!-- <small class="text-muted">{{ channel.name }}</small> -->
</div>
</mat-panel-title>
<mat-panel-description>
<!-- <label class="label label-success"
*ngIf="channel.active">{{'label.active' | translate}}</label>
<label class="label label-default"
*ngIf="!channel.active">{{'label.inactive' | translate}}</label> -->
<mat-slide-toggle [(ngModel)]="channel.active" [disabled]="viewMode"
style="margin-top: 0;" [ngModelOptions]="{standalone: true}" color="primary"
(click)="$event.stopPropagation();">
<span *ngIf="channel.active">{{'label.active' | translate}}</span>
<span *ngIf="!channel.active">{{'label.inactive' | translate}}</span>
</mat-slide-toggle>
</mat-panel-description>
</mat-expansion-panel-header>
<mat-accordion *ngIf="!isLoadingDataChannel">
<form [formGroup]="formGroup" novalidate autocomplete="off">
<mat-expansion-panel *ngFor="let channel of deploymentChannels; let i = index"
[expanded]="step === i" (opened)="setStep(i)">
<mat-expansion-panel-header class="right-aligned-header" [collapsedHeight]="'60px'">
<mat-panel-title>
<img [src]="channel.channelImage" class="icon">
<div>
<span style="margin-right: 8px;">{{ channel.channelName }}</span>
<ng-container *ngIf="channel?.suggestTitle && channel?.suggestDetail">
<ng-template #popContent><div [innerHTML]="channel?.suggestDetail"></div></ng-template>
<ng-template #popoverTitle><div [innerHTML]="channel?.suggestTitle"></div></ng-template>
<i class="fa fa-info-circle" placement="top" style="color: rgba(0, 0, 0, 0.54);"
[ngbPopover]="popContent"
[popoverTitle]="popoverTitle" triggers="hover"></i>
</ng-container>
<!-- <small class="text-muted">{{ channel.name }}</small> -->
</div>
</mat-panel-title>
<mat-panel-description>
<!-- <label class="label label-success"
*ngIf="channel.active">{{'label.active' | translate}}</label>
<label class="label label-default"
*ngIf="!channel.active">{{'label.inactive' | translate}}</label> -->
<mat-slide-toggle [(ngModel)]="channel.active" [disabled]="viewMode"
style="margin-top: 0;" [ngModelOptions]="{standalone: true}" color="primary"
(click)="$event.stopPropagation();">
<span *ngIf="channel.active">{{'label.active' | translate}}</span>
<span *ngIf="!channel.active">{{'label.inactive' | translate}}</span>
</mat-slide-toggle>
</mat-panel-description>
</mat-expansion-panel-header>
<div>
<form role="form" novalidate #myForm="ngForm" autocomplete="off">
<div class="row">
<!-- <div class="col-6">
<mat-form-field class="amd-form-control">
<mat-label>{{'label.name' | translate}}</mat-label>
<input matInput maxlength="80" [type]="text" required="true"
[disabled]="viewMode" [(ngModel)]="channel.name"
[ngModelOptions]="{standalone: true}">
</mat-form-field>
</div> -->
<!-- <div class="col-6">
<mat-slide-toggle [(ngModel)]="channel.active" [disabled]="viewMode"
[ngModelOptions]="{standalone: true}" color="primary">
<span *ngIf="channel.active">{{'label.active' | translate}}</span>
<span *ngIf="!channel.active">{{'label.inactive' | translate}}</span>
</mat-slide-toggle>
</div> -->
</div>
<div class="row" *ngFor="let field of channel.parameters">
<div class="col-12">
<mat-form-field class="amd-form-control">
<mat-label>{{field.label | dynamicTranslate: {param: field.traductions } }}:
</mat-label>
<!--
[pattern]="field.regex"
-->
<input matInput [maxlength]="field.maxlength" [(ngModel)]="field.value"
[ngModelOptions]="{standalone: true}" [disabled]="viewMode"
#fieldForm='ngModel' [type]="(field.type ? field.type : 'text')"
[required]="field.required" (ngModelChange)="onChange(fieldForm)"
[pattern]="field?.regex">
<mat-error *ngIf="fieldForm.errors?.pattern">
{{ 'Formato inválido' | translate }}</mat-error>
</mat-form-field>
<div formGroupName="{{channel.channelName}}">
<div class="row">
<!-- <div class="col-6">
<mat-form-field class="amd-form-control">
<mat-label>{{'label.name' | translate}}</mat-label>
<input matInput maxlength="80" [type]="text" required="true"
[disabled]="viewMode" [(ngModel)]="channel.name"
[ngModelOptions]="{standalone: true}">
</mat-form-field>
</div> -->
<!-- <div class="col-6">
<mat-slide-toggle [(ngModel)]="channel.active" [disabled]="viewMode"
[ngModelOptions]="{standalone: true}" color="primary">
<span *ngIf="channel.active">{{'label.active' | translate}}</span>
<span *ngIf="!channel.active">{{'label.inactive' | translate}}</span>
</mat-slide-toggle>
</div> -->
</div>
<div class="row" *ngFor="let field of channel.parameters">
<div class="col-12">
<mat-form-field class="amd-form-control">
<mat-label>{{field.label | dynamicTranslate: {param: field.traductions } }}:
</mat-label>
<!--
[pattern]="field.regex"
-->
<input matInput [maxlength]="field.maxlength"
[disabled]="viewMode"
[type]="(field.type ? field.type : 'text')"
[required]="field.required"
[pattern]="field?.regex" [formControlName]="field.channelParamName">
<!-- <mat-error *ngIf="fieldForm.errors?.pattern">
{{ '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>
</div>
</div>
</div>
</form>
</div>
</div>
<mat-action-row *ngIf="!viewMode">
<button mat-button color="warn" (click)="deleteChannel(i)">
<i
class="fa fa-trash"></i><span>&nbsp;&nbsp;{{'label.delete-channel' | translate}}</span>
</button>
</mat-action-row>
</mat-expansion-panel>
<mat-action-row *ngIf="!viewMode">
<button mat-button color="warn" (click)="deleteChannel(i)">
<i
class="fa fa-trash"></i><span>&nbsp;&nbsp;{{'label.delete-channel' | translate}}</span>
</button>
</mat-action-row>
</mat-expansion-panel>
</form>
</mat-accordion>
<div *ngIf="!(deploymentChannels && deploymentChannels.length)" class="border-all text-center">
......
......@@ -6,7 +6,8 @@ import { first } from 'rxjs/operators';
import { NotificationType, NotificationService } from '@xdf/commons';
import { TranslateService } from '@ngx-translate/core';
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({
selector: 'byte-ca-deployment-channels',
......@@ -34,6 +35,8 @@ export class CaDeploymentChannelsComponent implements OnInit {
mode = 'new';
detailText = 'Detail';
titleText = 'Titulo';
isLoadingDataChannel = true;
formGroup: FormGroup;
constructor(
private activatedRoute: ActivatedRoute,
......@@ -41,12 +44,12 @@ export class CaDeploymentChannelsComponent implements OnInit {
private matDialog: MatDialog,
private translateService: TranslateService,
private notificationService: NotificationService,
private router: Router
private router: Router,
private validatorUtils: ValidatorUtils
) {
this.formGroup = new FormGroup({});
this.mode = this.activatedRoute.snapshot.data.mode;
this.viewMode = this.mode === 'view';
}
ngOnInit() {
......@@ -60,6 +63,9 @@ export class CaDeploymentChannelsComponent implements OnInit {
this.buildList();
this.buildAvaliableChannels();
this.isLoadingDataChannel = false;
}, error => {
this.isLoadingDataChannel = false;
});
}
......@@ -83,17 +89,21 @@ export class CaDeploymentChannelsComponent implements OnInit {
deploymentChannel.suggestTitle = channel.suggestTitle;
deploymentChannel.suggestDetail = channel.suggestDetail;
this.formGroup.addControl(channel.name, new FormGroup({}));
for (const parameter of deploymentChannel.parameters) {
for (const field of channel.parameters) {
if (parameter.channelParamName === field.name) {
const formArray = this.formGroup.controls[channel.name] as FormGroup;
parameter.label = field.label;
parameter.type = field.type;
parameter.required = field.required;
parameter.traductions = field.traductions;
parameter.maxlength = field.maxlength;
parameter.regex = field.regex;
formArray.addControl(field.name, new FormControl('',field.required ? [Validators.required] : []));
break;
}
......@@ -105,6 +115,7 @@ export class CaDeploymentChannelsComponent implements OnInit {
}
}
}
console.log(this.formGroup);
}
buildAvaliableChannels() {
......@@ -273,4 +284,9 @@ export class CaDeploymentChannelsComponent implements OnInit {
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 @@
<mat-form-field class="amd-form-control">
<input matInput [placeholder]="'label.name' | translate" formControlName="name"
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>
</div>
</div>
......@@ -58,6 +60,8 @@
[placeholder]="'label.description' | translate" maxlength="200"
formControlName="description" #autosize="cdkTextareaAutosize" cdkAutosizeMinRows="3"
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>
</div>
</div>
......@@ -67,6 +71,8 @@
<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}">
<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>
</div>
</div>
......@@ -79,6 +85,8 @@
{{country.name | translate}}
</mat-option>
</mat-select>
<mat-error *ngFor="let error of getErrors('country', 'label.country')">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field>
</div>
</div>
......@@ -91,6 +99,8 @@
{{timezone | translate}}
</mat-option>
</mat-select>
<mat-error *ngFor="let error of getErrors('timezone', 'label.timezone')">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field>
</div>
</div>
......@@ -102,6 +112,8 @@
{{language.name | translate}}
</mat-option>
</mat-select>
<mat-error *ngFor="let error of getErrors('language', 'label.language')">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field>
</div>
</div>
......@@ -113,6 +125,8 @@
{{type.name | translate}}
</mat-option>
</mat-select>
<mat-error *ngFor="let error of getErrors('type', 'label.type')">{{ 'message.error.' + error.name | translate : error.prop}}
</mat-error>
</mat-form-field>
</div>
</div>
......
......@@ -5,6 +5,7 @@ import { ActivatedRoute } from '@angular/router';
import { animate, trigger, state, transition, style } from '@angular/animations';
import { NotificationService, NotificationType } from '@xdf/commons';
import { TranslateService } from '@ngx-translate/core';
import { ValidatorUtils } from '@xdf/gallery';
export const FILE_TYPE = {
image: /image.*/,
......@@ -64,7 +65,8 @@ export class CaGeneralInformationComponent implements OnInit {
private formBuilder: FormBuilder,
private activatedRoute: ActivatedRoute,
private notificationService: NotificationService,
private translateService: TranslateService
private translateService: TranslateService,
private validatorUtils: ValidatorUtils
) {
this.mode = this.activatedRoute.snapshot.data.mode;
......@@ -177,5 +179,9 @@ export class CaGeneralInformationComponent implements OnInit {
this.stepper.next();
}
}
getErrors(name: string, placeholder: string) {
return this.validatorUtils.getErrors(this.formGroup.controls[name] as FormControl, name, placeholder);
}
}
......@@ -60,7 +60,12 @@
"showStrength": false
},
"validators": [
"required"
"required",
{
"name": "validatePassword",
"isRemote": true,
"service": "validate/password"
}
]
}
},
......@@ -249,7 +254,7 @@
"formOptions": {
"options": {
"rightIcon": "mail",
"maxLength": 200,
"maxLength": 80,
"styleClass": "col-xl-6"
},
"validators": [
......
......@@ -97,5 +97,7 @@
"dashboards.customer.interaction.avg.intent": "Promedio de intenciones por cliente",
"dashboards.customer.interaction.goals": "Cantidad de objetivos cumplidos",
"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