diff --git a/projects/dxc-ngx-cdk/src/lib/dxc-file-input/dxc-file-input.component.ts b/projects/dxc-ngx-cdk/src/lib/dxc-file-input/dxc-file-input.component.ts index 6a06c5938..6f28201eb 100644 --- a/projects/dxc-ngx-cdk/src/lib/dxc-file-input/dxc-file-input.component.ts +++ b/projects/dxc-ngx-cdk/src/lib/dxc-file-input/dxc-file-input.component.ts @@ -38,6 +38,7 @@ import { HttpResponse, } from "@angular/common/http"; import { FileAddService } from "./services/file.add.service"; +import { ToastrService } from "ngx-toastr"; @Component({ selector: "dxc-file-input", templateUrl: "./dxc-file-input.component.html", @@ -83,7 +84,9 @@ export class DxcFileInputComponent /** * The file types that the component accepts. Its value must be one of all the possible values of the HTML file input's accept attribute. */ - @Input() public accept: string; + @Input() public accept: any; + + @Input() public extCheckmsg: string; /** * If true, the component allows multiple file items and will show all of them. If false, only one file will be shown, * and if there is already one file selected and a new one is chosen, it will be replaced by the new selected one. @@ -242,7 +245,8 @@ export class DxcFileInputComponent constructor( @Inject(FILE_SERVICE) private fileService: IFileService, private utils: CssUtils, - private fileAddService: FileAddService + private fileAddService: FileAddService, + private toastr: ToastrService ) { this.Subscription = this.fileAddService.files.subscribe(({ files, event }) => { if (event !== "reset" && (files.length || this.hasValue)) { @@ -330,7 +334,16 @@ export class DxcFileInputComponent checkFileSize(file: File) { if(file.name!=null){ let fileExtension = file.name.split('.').pop(); - if(!this.accept.includes(fileExtension)){ + fileExtension = '.'+ fileExtension; + let accepted = this.accept.split(','); + accepted = accepted.filter((x)=>x == fileExtension) + if(accepted != fileExtension){ + this.extCheckmsg = this.extCheckmsg === '' || this.extCheckmsg === undefined ? this.resources.acceptedFiles.description + this.accept:this.extCheckmsg; + this.toastr.error(this.extCheckmsg, '', { + disableTimeOut: true, + positionClass: 'toast-top-full-width', + + }); return this.resources.acceptedFiles.description + this.accept; } } diff --git a/projects/dxc-ngx-cdk/src/lib/dxc-file-input/dxc-file-input.module.ts b/projects/dxc-ngx-cdk/src/lib/dxc-file-input/dxc-file-input.module.ts index a9bae1fec..7744f28e9 100644 --- a/projects/dxc-ngx-cdk/src/lib/dxc-file-input/dxc-file-input.module.ts +++ b/projects/dxc-ngx-cdk/src/lib/dxc-file-input/dxc-file-input.module.ts @@ -10,6 +10,8 @@ import { FormsModule, ReactiveFormsModule } from "@angular/forms"; import { HttpClientModule } from "@angular/common/http"; import { FilesService } from "./services/files.services"; import { IFileService } from "./model/IFileService"; +import { ToastrModule } from 'ngx-toastr'; + import { FILE_SERVICE, IFileServiceProvider, @@ -31,7 +33,8 @@ import { MatTooltipModule } from "@angular/material/tooltip"; ReactiveFormsModule, DxcProgressbarModule, HttpClientModule, - MatTooltipModule + MatTooltipModule, + ToastrModule ], exports: [DxcFileInputComponent], })