diff --git a/build/dist/web-cjs/formkiq-client-sdk-cjs.js b/build/dist/web-cjs/formkiq-client-sdk-cjs.js index 829d627..44e3216 100644 --- a/build/dist/web-cjs/formkiq-client-sdk-cjs.js +++ b/build/dist/web-cjs/formkiq-client-sdk-cjs.js @@ -8206,7 +8206,8 @@ class AddOrUpdateDocumentParameters { constructor(content, contentType, path, tags) { if (content) { - this.content = btoa(content); + // this.content = btoa(content); + this.content = content; } if (contentType) { this.contentType = contentType; @@ -8224,8 +8225,8 @@ class AddOrUpdateDocumentParameters { this.documents.push(document); } - addAttachment(tags) { - const document = new AddOrUpdateDocumentParameters(null, null, null, tags); + addAttachment(path, tags) { + const document = new AddOrUpdateDocumentParameters(null, null, path, tags); this.documents.push(document); } @@ -8369,11 +8370,25 @@ class WebFormsHandler { } }); const content = JSON.stringify(data); - const addOrUpdateDocumentParameters = this.documentsApi.buildDocumentParametersForAddOrUpdate(content); + const tags = []; + if (data.formName) { + tags.push( + { + key: 'webformName', + value: JSON.stringify(data.formName).replace(/\"/g, '') + } + ); + } + let path = null; + if (window.location.href) { + path = window.location.href; + } + const addOrUpdateDocumentParameters = this.documentsApi.buildDocumentParametersForAddOrUpdate(content, 'application/json', path, tags); const fileInputElements = Array.from(fkqFormElement.getElementsByTagName('INPUT')).filter((input) => input.type === 'file'); fileInputElements.forEach((fileInputElement) => { if (fileInputElement.value) { - addOrUpdateDocumentParameters.addAttachment([this.documentsApi.buildDocumentTagParametersForAdd('fieldName', fileInputElement.getAttribute('name'))]); + const path = fileInputElement.value.replace('C:\\fakepath\\', ''); + addOrUpdateDocumentParameters.addAttachment(path, [this.documentsApi.buildDocumentTagParametersForAdd('fieldName', fileInputElement.getAttribute('name'))]); } }); const response = await this.sendFormRequests(addOrUpdateDocumentParameters, fileInputElements); diff --git a/build/package.json b/build/package.json index eef3505..3c27c69 100644 --- a/build/package.json +++ b/build/package.json @@ -1,7 +1,7 @@ { "name": "formkiq-client-sdk-javascript", "description": "FormKiQ Client SDK for JavaScript", - "version": "1.0.4", + "version": "1.1.0", "license": "MIT", "main": "./dist/web-cjs/formkiq-client-sdk-cjs.js", "author": { diff --git a/build/src/WebFormsHandler.js b/build/src/WebFormsHandler.js index 2a58e74..6b8b8ba 100644 --- a/build/src/WebFormsHandler.js +++ b/build/src/WebFormsHandler.js @@ -126,11 +126,25 @@ export class WebFormsHandler { } }); const content = JSON.stringify(data); - const addOrUpdateDocumentParameters = this.documentsApi.buildDocumentParametersForAddOrUpdate(content); + const tags = []; + if (data.formName) { + tags.push( + { + key: 'webformName', + value: JSON.stringify(data.formName).replace(/\"/g, '') + } + ); + } + let path = null; + if (window.location.href) { + path = window.location.href; + } + const addOrUpdateDocumentParameters = this.documentsApi.buildDocumentParametersForAddOrUpdate(content, 'application/json', path, tags); const fileInputElements = Array.from(fkqFormElement.getElementsByTagName('INPUT')).filter((input) => input.type === 'file'); fileInputElements.forEach((fileInputElement) => { if (fileInputElement.value) { - addOrUpdateDocumentParameters.addAttachment([this.documentsApi.buildDocumentTagParametersForAdd('fieldName', fileInputElement.getAttribute('name'))]); + const path = fileInputElement.value.replace('C:\\fakepath\\', ''); + addOrUpdateDocumentParameters.addAttachment(path, [this.documentsApi.buildDocumentTagParametersForAdd('fieldName', fileInputElement.getAttribute('name'))]); } }); const response = await this.sendFormRequests(addOrUpdateDocumentParameters, fileInputElements); diff --git a/build/src/api/DocumentsApi.js b/build/src/api/DocumentsApi.js index 471bf24..c5a0cd1 100644 --- a/build/src/api/DocumentsApi.js +++ b/build/src/api/DocumentsApi.js @@ -259,7 +259,7 @@ export class AddOrUpdateDocumentParameters { constructor(content, contentType, path, tags) { if (content) { - this.content = btoa(content); + this.content = content; } if (contentType) { this.contentType = contentType; @@ -277,8 +277,8 @@ export class AddOrUpdateDocumentParameters { this.documents.push(document); } - addAttachment(tags) { - const document = new AddOrUpdateDocumentParameters(null, null, null, tags); + addAttachment(path, tags) { + const document = new AddOrUpdateDocumentParameters(null, null, path, tags); this.documents.push(document); }