Commit 1f689361 authored by huriarte's avatar huriarte

Asincrono validación

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