Commit 1f689361 authored by huriarte's avatar huriarte

Asincrono validación

parent ecfc6a97
...@@ -40,5 +40,5 @@ ...@@ -40,5 +40,5 @@
<mat-dialog-actions align="end"> <mat-dialog-actions align="end">
<button mat-button mat-dialog-close>{{'btn.cancel' | translate}}</button> <button mat-button mat-dialog-close>{{'btn.cancel' | translate}}</button>
<button mat-button (click)="ok()" cdkFocusInitial <button mat-button (click)="ok()" cdkFocusInitial
[disabled]="formGroup.invalid">{{'btn.accept' | translate}}</button> [disabled]="formGroup.invalid || !enabledOK">{{'btn.accept' | translate}}</button>
</mat-dialog-actions> </mat-dialog-actions>
\ No newline at end of file
...@@ -29,6 +29,8 @@ export class CaFileUploadModalComponent implements OnInit { ...@@ -29,6 +29,8 @@ export class CaFileUploadModalComponent implements OnInit {
accept = '.xls,.xlsx'; accept = '.xls,.xlsx';
enabledOK = false;
fileInfo = new FileUploadModel(); fileInfo = new FileUploadModel();
constructor( constructor(
...@@ -91,6 +93,7 @@ export class CaFileUploadModalComponent implements OnInit { ...@@ -91,6 +93,7 @@ export class CaFileUploadModalComponent implements OnInit {
}) })
).subscribe((event: any) => { ).subscribe((event: any) => {
if (typeof (event) === 'object') { if (typeof (event) === 'object') {
this.enabledOK = false;
let info = event.body; let info = event.body;
this.fileInfo = new FileUploadModel(); this.fileInfo = new FileUploadModel();
if (info) { if (info) {
...@@ -98,27 +101,34 @@ export class CaFileUploadModalComponent implements OnInit { ...@@ -98,27 +101,34 @@ export class CaFileUploadModalComponent implements OnInit {
if ("OK" === status) { if ("OK" === status) {
this.fileInfo.id = info.id; this.fileInfo.id = info.id;
this.fileInfo.description = this.formGroup.controls.description.value;
this.fileInfo.uuid = info.uuid; this.fileInfo.uuid = info.uuid;
this.fileInfo.filename = info.fileName; this.fileInfo.filename = info.fileName;
this.fileInfo.status = info.status; this.fileInfo.status = info.status;
this.fileInfo.user = info.user; this.fileInfo.user = info.user;
this.fileInfo.uploadDate = info.uploadDate; this.fileInfo.uploadDate = info.uploadDate;
this.enabledOK = true;
} else if ("INCOMPATIBLE_EXTENSION" === status) { } else if ("INCOMPATIBLE_EXTENSION" === status) {
this.formGroup.controls.file.setValue(null); this.formGroup.controls.file.setValue(null);
let message = "label.file.incompatible.extension"; let message = "label.file.incompatible.extension";
this.enabledOK = false;
this._notificationService.showMessage(this._translateService.instant(message) + "[" + this.accept + "]", null, NotificationType.error); this._notificationService.showMessage(this._translateService.instant(message) + "[" + this.accept + "]", null, NotificationType.error);
} else if ("CONTENT_ERROR" === status) { } else if ("CONTENT_ERROR" === status) {
this.formGroup.controls.file.setValue(null); this.formGroup.controls.file.setValue(null);
this.enabledOK = false;
console.log(info.fileValidationResult); console.log(info.fileValidationResult);
} else if ("HEADER_ERROR" === status) { } else if ("HEADER_ERROR" === status) {
this.formGroup.controls.file.setValue(null); this.formGroup.controls.file.setValue(null);
this.enabledOK = false;
console.log(info.fileValidationResult); console.log(info.fileValidationResult);
} }
} else { } else {
this.enabledOK = false;
this.formGroup.controls.file.setValue(null); this.formGroup.controls.file.setValue(null);
} }
} }
......
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