SUPPORT-9339: Fix
This commit is contained in:
parent
c512f99e32
commit
4a08b2c7a1
4 changed files with 436 additions and 57 deletions
|
|
@ -5,7 +5,7 @@ import {
|
|||
Event,
|
||||
MessagesService,
|
||||
UnsupportedOperationError,
|
||||
AppConfigService, ObjectRef
|
||||
AppConfigService
|
||||
} from "@webbpm/base-package";
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef} from "@angular/core";
|
||||
import {FileItem, FileUploader} from "ng2-file-upload";
|
||||
|
|
@ -23,10 +23,6 @@ import {TokenConstants} from "../../../modules/security/TokenConstants";
|
|||
export class ErvuFileUpload extends InputControl {
|
||||
private static readonly BACKEND_URL: string = "backend.context";
|
||||
|
||||
@ObjectRef()
|
||||
public signFileUploadRef: ErvuFileUpload;
|
||||
@ObjectRef()
|
||||
public mchdFileUploadRef: ErvuFileUpload;
|
||||
@NotNull("true")
|
||||
public selectFileFieldText: string;
|
||||
@NotNull("true")
|
||||
|
|
@ -65,7 +61,7 @@ export class ErvuFileUpload extends InputControl {
|
|||
private messagesService: MessagesService;
|
||||
private isUploadErrorOccurred = false;
|
||||
private appConfigService: AppConfigService;
|
||||
private cookieService: CookieService;
|
||||
public cookieService: CookieService;
|
||||
|
||||
constructor(el: ElementRef, cd: ChangeDetectorRef) {
|
||||
super(el, cd);
|
||||
|
|
@ -139,34 +135,26 @@ export class ErvuFileUpload extends InputControl {
|
|||
this.cd.markForCheck();
|
||||
}
|
||||
|
||||
private setUploaderMethods() {
|
||||
public setUploaderMethods() {
|
||||
this.uploader.onBeforeUploadItem = (fileItem: FileItem) => {
|
||||
const additionalParams: any = {
|
||||
signFile: this.signFileUploadRef.uploader.queue[0]._file
|
||||
};
|
||||
|
||||
if (this.mchdFileUploadRef && this.mchdFileUploadRef.uploader.queue.length > 0) {
|
||||
additionalParams.mchdFile = this.mchdFileUploadRef.uploader.queue[0]._file;
|
||||
}
|
||||
|
||||
//refresh headers
|
||||
this.uploader.setOptions({
|
||||
headers: [
|
||||
{
|
||||
name: "X-Employee-Info-File-Form-Type",
|
||||
value: EmployeeInfoFileFormType[this.formType]
|
||||
},
|
||||
{
|
||||
name: "Client-Time-Zone",
|
||||
value: Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||
},
|
||||
{
|
||||
name: TokenConstants.CSRF_HEADER_NAME,
|
||||
value: this.cookieService.get(TokenConstants.CSRF_TOKEN_NAME)
|
||||
}
|
||||
],
|
||||
additionalParameter: additionalParams
|
||||
});
|
||||
this.uploader.setOptions({
|
||||
headers: [
|
||||
{
|
||||
name: "X-Employee-Info-File-Form-Type",
|
||||
value: EmployeeInfoFileFormType[this.formType]
|
||||
},
|
||||
{
|
||||
name: "Client-Time-Zone",
|
||||
value: Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||
},
|
||||
{
|
||||
name: TokenConstants.CSRF_HEADER_NAME,
|
||||
value: this.cookieService.get(TokenConstants.CSRF_TOKEN_NAME)
|
||||
}
|
||||
]
|
||||
});
|
||||
this.fileUploadStartEvent.trigger();
|
||||
this.isDropZoneVisible = false;
|
||||
this.isFilesListVisible = false;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
import {ObjectRef} from "@webbpm/base-package";
|
||||
import {ChangeDetectionStrategy, Component} from "@angular/core";
|
||||
import {FileItem} from "ng2-file-upload";
|
||||
import {EmployeeInfoFileFormType} from "./EmployeeInfoFileFormType";
|
||||
import {TokenConstants} from "../../../modules/security/TokenConstants";
|
||||
import {ErvuFileUpload} from "./ErvuFileUpload";
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: "ervu-additional-file-upload",
|
||||
templateUrl: "./../../../../../src/resources/template/ervu/component/ErvuFileUpload.html",
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class ErvuFileUploadWithAdditionalFiles extends ErvuFileUpload {
|
||||
|
||||
@ObjectRef()
|
||||
public signFileUploadRef: ErvuFileUpload;
|
||||
@ObjectRef()
|
||||
public mchdFileUploadRef: ErvuFileUpload;
|
||||
|
||||
public setUploaderMethods() {
|
||||
this.uploader.onBeforeUploadItem = (fileItem: FileItem) => {
|
||||
const additionalParams: any = {
|
||||
signFile: this.signFileUploadRef.uploader.queue[0]._file
|
||||
};
|
||||
|
||||
if (this.mchdFileUploadRef && this.mchdFileUploadRef.uploader.queue.length > 0) {
|
||||
additionalParams.mchdFile = this.mchdFileUploadRef.uploader.queue[0]._file;
|
||||
}
|
||||
|
||||
//refresh headers
|
||||
this.uploader.setOptions({
|
||||
headers: [
|
||||
{
|
||||
name: "X-Employee-Info-File-Form-Type",
|
||||
value: EmployeeInfoFileFormType[this.formType]
|
||||
},
|
||||
{
|
||||
name: "Client-Time-Zone",
|
||||
value: Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||
},
|
||||
{
|
||||
name: TokenConstants.CSRF_HEADER_NAME,
|
||||
value: this.cookieService.get(TokenConstants.CSRF_TOKEN_NAME)
|
||||
}
|
||||
],
|
||||
additionalParameter: additionalParams
|
||||
});
|
||||
this.fileUploadStartEvent.trigger();
|
||||
this.isDropZoneVisible = false;
|
||||
this.isFilesListVisible = false;
|
||||
this.isProgressBarVisible = true;
|
||||
this.cd.markForCheck();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,9 @@ import {ErvuDownloadFileButton} from "../../ervu/component/button/ErvuDownloadFi
|
|||
import {AuthenticationService} from "../security/authentication.service";
|
||||
import {HomeLandingComponent} from "./component/home-landing.component";
|
||||
import {AuditService} from "../../ervu/service/AuditService";
|
||||
import {
|
||||
ErvuFileUploadWithAdditionalFiles
|
||||
} from "../../ervu/component/fileupload/ErvuFileUploadWithAdditionalFiles";
|
||||
|
||||
registerLocaleData(localeRu);
|
||||
export const DIRECTIVES = [
|
||||
|
|
@ -36,6 +39,7 @@ export const DIRECTIVES = [
|
|||
forwardRef(() => AccessDeniedComponent),
|
||||
forwardRef(() => AppProgressIndicationComponent),
|
||||
forwardRef(() => ErvuFileUpload),
|
||||
forwardRef(() => ErvuFileUploadWithAdditionalFiles),
|
||||
forwardRef(() => ErvuDownloadFileButton),
|
||||
forwardRef(() => InMemoryStaticGrid),
|
||||
forwardRef(() => HomeLandingComponent),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue