Skip to content

Commit 1f5cbfe

Browse files
authored
Merge pull request #20 from formkiq/web-form-enhancements
Web form enhancements
2 parents 3a972df + 103cf5d commit 1f5cbfe

File tree

4 files changed

+40
-11
lines changed

4 files changed

+40
-11
lines changed

build/dist/web-cjs/formkiq-client-sdk-cjs.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8206,7 +8206,8 @@ class AddOrUpdateDocumentParameters {
82068206

82078207
constructor(content, contentType, path, tags) {
82088208
if (content) {
8209-
this.content = btoa(content);
8209+
// this.content = btoa(content);
8210+
this.content = content;
82108211
}
82118212
if (contentType) {
82128213
this.contentType = contentType;
@@ -8224,8 +8225,8 @@ class AddOrUpdateDocumentParameters {
82248225
this.documents.push(document);
82258226
}
82268227

8227-
addAttachment(tags) {
8228-
const document = new AddOrUpdateDocumentParameters(null, null, null, tags);
8228+
addAttachment(path, tags) {
8229+
const document = new AddOrUpdateDocumentParameters(null, null, path, tags);
82298230
this.documents.push(document);
82308231
}
82318232

@@ -8369,11 +8370,25 @@ class WebFormsHandler {
83698370
}
83708371
});
83718372
const content = JSON.stringify(data);
8372-
const addOrUpdateDocumentParameters = this.documentsApi.buildDocumentParametersForAddOrUpdate(content);
8373+
const tags = [];
8374+
if (data.formName) {
8375+
tags.push(
8376+
{
8377+
key: 'webformName',
8378+
value: JSON.stringify(data.formName).replace(/\"/g, '')
8379+
}
8380+
);
8381+
}
8382+
let path = null;
8383+
if (window.location.href) {
8384+
path = window.location.href;
8385+
}
8386+
const addOrUpdateDocumentParameters = this.documentsApi.buildDocumentParametersForAddOrUpdate(content, 'application/json', path, tags);
83738387
const fileInputElements = Array.from(fkqFormElement.getElementsByTagName('INPUT')).filter((input) => input.type === 'file');
83748388
fileInputElements.forEach((fileInputElement) => {
83758389
if (fileInputElement.value) {
8376-
addOrUpdateDocumentParameters.addAttachment([this.documentsApi.buildDocumentTagParametersForAdd('fieldName', fileInputElement.getAttribute('name'))]);
8390+
const path = fileInputElement.value.replace('C:\\fakepath\\', '');
8391+
addOrUpdateDocumentParameters.addAttachment(path, [this.documentsApi.buildDocumentTagParametersForAdd('fieldName', fileInputElement.getAttribute('name'))]);
83778392
}
83788393
});
83798394
const response = await this.sendFormRequests(addOrUpdateDocumentParameters, fileInputElements);

build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "formkiq-client-sdk-javascript",
33
"description": "FormKiQ Client SDK for JavaScript",
4-
"version": "1.0.4",
4+
"version": "1.1.0",
55
"license": "MIT",
66
"main": "./dist/web-cjs/formkiq-client-sdk-cjs.js",
77
"author": {

build/src/WebFormsHandler.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,25 @@ export class WebFormsHandler {
126126
}
127127
});
128128
const content = JSON.stringify(data);
129-
const addOrUpdateDocumentParameters = this.documentsApi.buildDocumentParametersForAddOrUpdate(content);
129+
const tags = [];
130+
if (data.formName) {
131+
tags.push(
132+
{
133+
key: 'webformName',
134+
value: JSON.stringify(data.formName).replace(/\"/g, '')
135+
}
136+
);
137+
}
138+
let path = null;
139+
if (window.location.href) {
140+
path = window.location.href;
141+
}
142+
const addOrUpdateDocumentParameters = this.documentsApi.buildDocumentParametersForAddOrUpdate(content, 'application/json', path, tags);
130143
const fileInputElements = Array.from(fkqFormElement.getElementsByTagName('INPUT')).filter((input) => input.type === 'file');
131144
fileInputElements.forEach((fileInputElement) => {
132145
if (fileInputElement.value) {
133-
addOrUpdateDocumentParameters.addAttachment([this.documentsApi.buildDocumentTagParametersForAdd('fieldName', fileInputElement.getAttribute('name'))]);
146+
const path = fileInputElement.value.replace('C:\\fakepath\\', '');
147+
addOrUpdateDocumentParameters.addAttachment(path, [this.documentsApi.buildDocumentTagParametersForAdd('fieldName', fileInputElement.getAttribute('name'))]);
134148
}
135149
});
136150
const response = await this.sendFormRequests(addOrUpdateDocumentParameters, fileInputElements);

build/src/api/DocumentsApi.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export class AddOrUpdateDocumentParameters {
259259

260260
constructor(content, contentType, path, tags) {
261261
if (content) {
262-
this.content = btoa(content);
262+
this.content = content;
263263
}
264264
if (contentType) {
265265
this.contentType = contentType;
@@ -277,8 +277,8 @@ export class AddOrUpdateDocumentParameters {
277277
this.documents.push(document);
278278
}
279279

280-
addAttachment(tags) {
281-
const document = new AddOrUpdateDocumentParameters(null, null, null, tags);
280+
addAttachment(path, tags) {
281+
const document = new AddOrUpdateDocumentParameters(null, null, path, tags);
282282
this.documents.push(document);
283283
}
284284

0 commit comments

Comments
 (0)