Skip to content

Commit

Permalink
Merge pull request #20 from formkiq/web-form-enhancements
Browse files Browse the repository at this point in the history
Web form enhancements
  • Loading branch information
reganwolfrom authored Dec 5, 2020
2 parents 3a972df + 103cf5d commit 1f5cbfe
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
25 changes: 20 additions & 5 deletions build/dist/web-cjs/formkiq-client-sdk-cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion build/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
18 changes: 16 additions & 2 deletions build/src/WebFormsHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions build/src/api/DocumentsApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down

0 comments on commit 1f5cbfe

Please sign in to comment.