brainloper-ui 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,9 +51,11 @@ import { MatTableModule } from '@angular/material/table';
51
51
  import * as i1$3 from '@ng-bootstrap/ng-bootstrap';
52
52
  import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
53
53
  import * as i10 from '@angular/forms';
54
- import { FormControl, FormGroup, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
54
+ import { FormGroup, FormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
55
55
  import * as i1$1 from '@angular/common/http';
56
56
  import { HttpParams, HttpClientModule } from '@angular/common/http';
57
+ import { forkJoin } from 'rxjs';
58
+ import { map } from 'rxjs/operators';
57
59
  import Swal from 'sweetalert2';
58
60
  import * as i5 from 'mat-select-filter';
59
61
  import { MatSelectFilterModule } from 'mat-select-filter';
@@ -441,83 +443,71 @@ class TableModalComponent {
441
443
  this.data = data;
442
444
  this.formBuilder = formBuilder;
443
445
  this.http = http;
444
- this.modalForm = {};
446
+ this.modalForm = new FormGroup({});
445
447
  this.dataCombo = {};
446
448
  }
447
449
  onNoClick() {
448
450
  this.dialogRef.close();
449
451
  }
450
452
  ngOnInit() {
451
- let columns = this.data.columns;
452
- //console.log('data columns', this.data.columns);
453
+ let group = {};
454
+ let httpRequests = [];
453
455
  this.data.columns.forEach((element, index) => {
454
- let text = `{"${element.ID}":""}`;
455
- let json = JSON.parse(text);
456
- Object.assign(this.modalForm, json);
456
+ if (element.disregardForAdd) {
457
+ return;
458
+ }
457
459
  if (element.type == 'combo') {
458
- Object.assign(this.dataCombo, json);
460
+ Object.assign(this.dataCombo, { [element.ID]: '' });
459
461
  }
462
+ let initialValue = '';
460
463
  if (this.data.action == 'edit') {
461
- this.modalForm[element.ID] = element.value;
462
- if (element.type === 'date') {
463
- if (element.value) {
464
- let s = element.value.split('/');
465
- element.value = `${s[2]}-${s[1]}-${s[0]}`;
466
- }
464
+ initialValue = element.value;
465
+ if (element.type === 'date' && element.value) {
466
+ let s = element.value.split('/');
467
+ initialValue = `${s[2]}-${s[1]}-${s[0]}`;
467
468
  }
468
469
  }
470
+ group[element.ID] = element.required ? new FormControl(initialValue, Validators.required) : new FormControl(initialValue);
469
471
  if (element.paramsCombo) {
470
- //console.log(element.paramsCombo.url);
471
- //console.log(element.paramsCombo.urlParams);
472
- this.http
472
+ httpRequests.push(this.http
473
473
  .getData(element.paramsCombo.url, element.paramsCombo.urlParams)
474
- .subscribe((res) => {
474
+ .pipe(map((res) => {
475
475
  if (res['code'] === 0) {
476
476
  this.dataCombo[element.ID] = res['body'];
477
- //console.log(this.dataCombo);
478
477
  this.dataCombo[element.ID].forEach((data) => {
479
- // console.log(data[element.paramsCombo.visibleField], element.value)
480
- if (data[element.paramsCombo.visibleField] == element.value) {
481
- this.modalForm[element.ID] =
482
- data[element.paramsCombo.selectionField];
483
- this.data.columns[index].value =
484
- data[element.paramsCombo.selectionField].toString();
478
+ if (data[element.paramsCombo.selectionField] == element.value) {
479
+ group[element.ID].setValue(data[element.paramsCombo.selectionField]);
485
480
  }
486
481
  });
487
482
  }
488
- else {
489
- console.log('error en la consulta');
490
- }
491
- }, (err) => {
492
- console.log(err);
493
- });
483
+ })));
494
484
  }
495
485
  });
496
- //console.log(this.dataCombo);
486
+ forkJoin(httpRequests).subscribe(() => {
487
+ this.modalForm = new FormGroup(group);
488
+ });
497
489
  }
498
490
  onSubmit() {
499
- this.dialogRef.close(this.modalForm);
491
+ if (this.modalForm.valid) {
492
+ this.dialogRef.close(this.modalForm.value);
493
+ }
500
494
  }
501
495
  onChange(id, $event, type) {
502
496
  switch (type) {
503
- // case 'date':
504
- // this.modalForm[id] = $event.target.value;
505
- // break;
506
497
  case 'combo':
507
- this.modalForm[id] = $event.value;
498
+ this.modalForm.get(id).setValue($event.value);
508
499
  break;
509
500
  default:
510
- this.modalForm[id] = $event.target.value;
501
+ this.modalForm.get(id).setValue($event.target.value);
511
502
  break;
512
503
  }
513
- //console.log('onChange', $event, id);
514
504
  }
515
505
  }
516
506
  TableModalComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: TableModalComponent, deps: [{ token: i1.MatDialogRef }, { token: MAT_DIALOG_DATA }, { token: i10.FormBuilder }, { token: HttpService }], target: i0.ɵɵFactoryTarget.Component });
517
- TableModalComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: TableModalComponent, selector: "app-table-modal", ngImport: i0, template: "<div>\r\n <div style='display:flex; justify-content: space-between;'>\r\n <div>\r\n <strong>\r\n <h3 *ngIf='data.action==\"edit\"'> Editar </h3>\r\n <h3 *ngIf='data.action==\"add\"'> Agregar </h3>\r\n </strong>\r\n </div>\r\n <div mat-dialog-close>\r\n <i class=\"fa fa-times-circle\" style=\"font-size: 150%; position: relative;\"></i>\r\n </div>\r\n </div>\r\n\r\n <form>\r\n\r\n <div *ngFor='let input of data.columns'>\r\n\r\n\r\n\r\n <div *ngIf='data.action==\"edit\"; else Agregar'>\r\n <mat-form-field *ngIf=\"!input.disregardForEdit\">\r\n <div *ngIf='input.type==\"combo\"; else otherInputEdit'>\r\n\r\n <mat-select [value]='input.value' (selectionChange)='onChange(input.ID,$event, input.type)'\r\n placeholder='{{input.label}}'>\r\n <mat-option *ngFor='let data of dataCombo[input.ID]'\r\n value='{{data[input.paramsCombo.selectionField]}}'>\r\n {{data[input.paramsCombo.visibleField]}}</mat-option>\r\n </mat-select>\r\n </div>\r\n\r\n <ng-template #otherInputEdit>\r\n <input [type]='input.type' [name]='input.ID' [value]='input.value'\r\n (input)='onChange(input.ID,$event, input.type)' matInput [placeholder]='input.label' [required]=\"input.required\" />\r\n </ng-template>\r\n\r\n <mat-error>Campo Obligatorio</mat-error>\r\n </mat-form-field>\r\n\r\n </div>\r\n\r\n <ng-template #Agregar>\r\n <mat-form-field *ngIf=\"!input.disregardForAdd\">\r\n <div *ngIf='input.type==\"combo\"; else otherInput'>\r\n\r\n <mat-select (selectionChange)='onChange(input.ID,$event, input.type)' placeholder='{{input.label}}'>\r\n <mat-option *ngFor='let data of dataCombo[input.ID]'\r\n value='{{data[input.paramsCombo.selectionField]}}'>\r\n {{data[input.paramsCombo.visibleField]}}</mat-option>\r\n </mat-select>\r\n\r\n </div>\r\n\r\n <ng-template #otherInput>\r\n <input [type]='input.type' [name]='input.ID' (input)='onChange(input.ID, $event, input.type)'\r\n matInput [placeholder]='input.label' [required]=\"input.required\" />\r\n\r\n </ng-template>\r\n <mat-error>Campo Obligatorio</mat-error>\r\n </mat-form-field>\r\n </ng-template>\r\n\r\n\r\n\r\n\r\n </div>\r\n\r\n <button *ngIf='data.action==\"add\" || data.action==\"edit\"' (click)='onSubmit()' color='primary' mat-raised-button>Guardar</button>\r\n\r\n </form>\r\n</div>\r\n\r\n", styles: ["button{width:100%}mat-form-field{width:100%}\n"], components: [{ type: i3.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i4.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i6.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i3$1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { type: i10.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i10.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i10.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i11.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i3.MatError, selector: "mat-error", inputs: ["id"] }] });
507
+ TableModalComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: TableModalComponent, selector: "app-table-modal", ngImport: i0, template: "<div>\r\n <div style='display:flex; justify-content: space-between;'>\r\n <div>\r\n <strong>\r\n <h3 *ngIf='data.action==\"edit\"'> Editar </h3>\r\n <h3 *ngIf='data.action==\"add\"'> Agregar </h3>\r\n </strong>\r\n </div>\r\n <div mat-dialog-close>\r\n <i class=\"fa fa-times-circle\" style=\"font-size: 150%; position: relative;\"></i>\r\n </div>\r\n </div>\r\n\r\n <form [formGroup]=\"modalForm\">\r\n\r\n <div *ngFor='let input of data.columns'>\r\n\r\n\r\n\r\n <div *ngIf='data.action==\"edit\"; else Agregar'>\r\n <mat-form-field *ngIf=\"!input.disregardForEdit\">\r\n <div *ngIf='input.type==\"combo\"; else otherInputEdit'>\r\n\r\n <mat-select [value]=\"input.value\" (selectionChange)='onChange(input.ID,$event, input.type)'\r\n placeholder='{{input.label}}' [required]=\"input.required\">\r\n <mat-option *ngFor='let data of dataCombo[input.ID]'\r\n [value]='data[input.paramsCombo.selectionField]'>\r\n {{data[input.paramsCombo.visibleField]}}</mat-option>\r\n </mat-select>\r\n </div>\r\n\r\n <ng-template #otherInputEdit>\r\n <input [type]='input.type' [name]='input.ID' [value]='input.value'\r\n (input)='onChange(input.ID,$event, input.type)' matInput [placeholder]='input.label' [required]=\"input.required\" />\r\n </ng-template>\r\n\r\n <mat-error>Campo Obligatorio</mat-error>\r\n </mat-form-field>\r\n\r\n </div>\r\n\r\n <ng-template #Agregar>\r\n <mat-form-field *ngIf=\"!input.disregardForAdd\">\r\n <div *ngIf='input.type==\"combo\"; else otherInput'>\r\n\r\n <mat-select (selectionChange)='onChange(input.ID,$event, input.type)' placeholder='{{input.label}}' [required]=\"input.required\">\r\n <mat-option *ngFor='let data of dataCombo[input.ID]'\r\n [value]='data[input.paramsCombo.selectionField]'>\r\n {{data[input.paramsCombo.visibleField]}}</mat-option>\r\n </mat-select>\r\n\r\n </div>\r\n\r\n <ng-template #otherInput>\r\n <input [type]='input.type' [name]='input.ID' (input)='onChange(input.ID, $event, input.type)'\r\n matInput [placeholder]='input.label' [required]=\"input.required\" />\r\n\r\n </ng-template>\r\n <mat-error>Campo Obligatorio</mat-error>\r\n </mat-form-field>\r\n </ng-template>\r\n\r\n\r\n\r\n\r\n </div>\r\n\r\n <button *ngIf='data.action==\"add\" || data.action==\"edit\"'\r\n (click)='onSubmit()'\r\n color='primary'\r\n mat-raised-button\r\n [disabled]=\"!modalForm.valid\">Guardar</button>\r\n\r\n </form>\r\n</div>\r\n\r\n", styles: ["button{width:100%}mat-form-field{width:100%}\n"], components: [{ type: i3.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i4.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i6.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i3$1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { type: i10.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i10.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i10.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i11.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i3.MatError, selector: "mat-error", inputs: ["id"] }] });
518
508
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: TableModalComponent, decorators: [{
519
509
  type: Component,
520
- args: [{ selector: 'app-table-modal', template: "<div>\r\n <div style='display:flex; justify-content: space-between;'>\r\n <div>\r\n <strong>\r\n <h3 *ngIf='data.action==\"edit\"'> Editar </h3>\r\n <h3 *ngIf='data.action==\"add\"'> Agregar </h3>\r\n </strong>\r\n </div>\r\n <div mat-dialog-close>\r\n <i class=\"fa fa-times-circle\" style=\"font-size: 150%; position: relative;\"></i>\r\n </div>\r\n </div>\r\n\r\n <form>\r\n\r\n <div *ngFor='let input of data.columns'>\r\n\r\n\r\n\r\n <div *ngIf='data.action==\"edit\"; else Agregar'>\r\n <mat-form-field *ngIf=\"!input.disregardForEdit\">\r\n <div *ngIf='input.type==\"combo\"; else otherInputEdit'>\r\n\r\n <mat-select [value]='input.value' (selectionChange)='onChange(input.ID,$event, input.type)'\r\n placeholder='{{input.label}}'>\r\n <mat-option *ngFor='let data of dataCombo[input.ID]'\r\n value='{{data[input.paramsCombo.selectionField]}}'>\r\n {{data[input.paramsCombo.visibleField]}}</mat-option>\r\n </mat-select>\r\n </div>\r\n\r\n <ng-template #otherInputEdit>\r\n <input [type]='input.type' [name]='input.ID' [value]='input.value'\r\n (input)='onChange(input.ID,$event, input.type)' matInput [placeholder]='input.label' [required]=\"input.required\" />\r\n </ng-template>\r\n\r\n <mat-error>Campo Obligatorio</mat-error>\r\n </mat-form-field>\r\n\r\n </div>\r\n\r\n <ng-template #Agregar>\r\n <mat-form-field *ngIf=\"!input.disregardForAdd\">\r\n <div *ngIf='input.type==\"combo\"; else otherInput'>\r\n\r\n <mat-select (selectionChange)='onChange(input.ID,$event, input.type)' placeholder='{{input.label}}'>\r\n <mat-option *ngFor='let data of dataCombo[input.ID]'\r\n value='{{data[input.paramsCombo.selectionField]}}'>\r\n {{data[input.paramsCombo.visibleField]}}</mat-option>\r\n </mat-select>\r\n\r\n </div>\r\n\r\n <ng-template #otherInput>\r\n <input [type]='input.type' [name]='input.ID' (input)='onChange(input.ID, $event, input.type)'\r\n matInput [placeholder]='input.label' [required]=\"input.required\" />\r\n\r\n </ng-template>\r\n <mat-error>Campo Obligatorio</mat-error>\r\n </mat-form-field>\r\n </ng-template>\r\n\r\n\r\n\r\n\r\n </div>\r\n\r\n <button *ngIf='data.action==\"add\" || data.action==\"edit\"' (click)='onSubmit()' color='primary' mat-raised-button>Guardar</button>\r\n\r\n </form>\r\n</div>\r\n\r\n", styles: ["button{width:100%}mat-form-field{width:100%}\n"] }]
510
+ args: [{ selector: 'app-table-modal', template: "<div>\r\n <div style='display:flex; justify-content: space-between;'>\r\n <div>\r\n <strong>\r\n <h3 *ngIf='data.action==\"edit\"'> Editar </h3>\r\n <h3 *ngIf='data.action==\"add\"'> Agregar </h3>\r\n </strong>\r\n </div>\r\n <div mat-dialog-close>\r\n <i class=\"fa fa-times-circle\" style=\"font-size: 150%; position: relative;\"></i>\r\n </div>\r\n </div>\r\n\r\n <form [formGroup]=\"modalForm\">\r\n\r\n <div *ngFor='let input of data.columns'>\r\n\r\n\r\n\r\n <div *ngIf='data.action==\"edit\"; else Agregar'>\r\n <mat-form-field *ngIf=\"!input.disregardForEdit\">\r\n <div *ngIf='input.type==\"combo\"; else otherInputEdit'>\r\n\r\n <mat-select [value]=\"input.value\" (selectionChange)='onChange(input.ID,$event, input.type)'\r\n placeholder='{{input.label}}' [required]=\"input.required\">\r\n <mat-option *ngFor='let data of dataCombo[input.ID]'\r\n [value]='data[input.paramsCombo.selectionField]'>\r\n {{data[input.paramsCombo.visibleField]}}</mat-option>\r\n </mat-select>\r\n </div>\r\n\r\n <ng-template #otherInputEdit>\r\n <input [type]='input.type' [name]='input.ID' [value]='input.value'\r\n (input)='onChange(input.ID,$event, input.type)' matInput [placeholder]='input.label' [required]=\"input.required\" />\r\n </ng-template>\r\n\r\n <mat-error>Campo Obligatorio</mat-error>\r\n </mat-form-field>\r\n\r\n </div>\r\n\r\n <ng-template #Agregar>\r\n <mat-form-field *ngIf=\"!input.disregardForAdd\">\r\n <div *ngIf='input.type==\"combo\"; else otherInput'>\r\n\r\n <mat-select (selectionChange)='onChange(input.ID,$event, input.type)' placeholder='{{input.label}}' [required]=\"input.required\">\r\n <mat-option *ngFor='let data of dataCombo[input.ID]'\r\n [value]='data[input.paramsCombo.selectionField]'>\r\n {{data[input.paramsCombo.visibleField]}}</mat-option>\r\n </mat-select>\r\n\r\n </div>\r\n\r\n <ng-template #otherInput>\r\n <input [type]='input.type' [name]='input.ID' (input)='onChange(input.ID, $event, input.type)'\r\n matInput [placeholder]='input.label' [required]=\"input.required\" />\r\n\r\n </ng-template>\r\n <mat-error>Campo Obligatorio</mat-error>\r\n </mat-form-field>\r\n </ng-template>\r\n\r\n\r\n\r\n\r\n </div>\r\n\r\n <button *ngIf='data.action==\"add\" || data.action==\"edit\"'\r\n (click)='onSubmit()'\r\n color='primary'\r\n mat-raised-button\r\n [disabled]=\"!modalForm.valid\">Guardar</button>\r\n\r\n </form>\r\n</div>\r\n\r\n", styles: ["button{width:100%}mat-form-field{width:100%}\n"] }]
521
511
  }], ctorParameters: function () { return [{ type: i1.MatDialogRef }, { type: undefined, decorators: [{
522
512
  type: Inject,
523
513
  args: [MAT_DIALOG_DATA]