Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Unable to save signature in hybrid apps. #1391

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,53 @@

private saveDocument(callback: () => void): void {
if (this.base64Uri && this.state.hasSignature && this.props.mxObject) {
mx.data.saveDocument(
this.props.mxObject.getGuid(),
this.generateFileName(this.props.mxObject),
{},
Utils.convertUrlToBlob(this.base64Uri),
callback,
error => mx.ui.error("Error saving signature: " + error.message)
);
var error = function(callback:any) {

Check failure on line 104 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Unexpected var, use let or const instead

Check warning on line 104 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Missing return type on function

Check failure on line 104 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Replace `(callback:` with `·(callback:·`
return mx.ui.error("Error saving signature: " + callback.message)

Check failure on line 105 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Insert `;`
}

Check failure on line 106 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Replace `··}` with `};`
// @ts-ignore

Check warning on line 107 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
let cdv=window.cordova;

Check failure on line 108 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

'cdv' is never reassigned. Use 'const' instead

Check failure on line 108 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Replace `=` with `·=·`
Praveen-MX marked this conversation as resolved.
Show resolved Hide resolved
if (cdv) {
// @ts-ignore

Check warning on line 110 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
var options = new FileUploadOptions();

Check failure on line 111 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Unexpected var, use let or const instead
options.fileKey = "blob";

Check failure on line 112 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Delete `······`
options.fileName = this.generateFileName(this.props.mxObject);

Check failure on line 113 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Replace `······················` with `················`
options.mimeType = "image/png";
Praveen-MX marked this conversation as resolved.
Show resolved Hide resolved
options.chunkedMode = false;
var headers={
Praveen-MX marked this conversation as resolved.
Show resolved Hide resolved
'Accept':"application/json",
// @ts-ignore

Check warning on line 118 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
'X-Csrf-Token': mx.session.sessionData.csrftoken,
'X-Mx-ReqToken': new Date().getTime()
};
options.headers = headers;
var isHttps = mx.remoteUrl.includes('https');
var remoteUrlWithoutScheme = decodeURIComponent(mx.remoteUrl.replace(/.*\_http[s]?_proxy\_/, ""));
var remoteUrl = (isHttps ? 'https://' : 'http://') + remoteUrlWithoutScheme;
var guid = this.props.mxObject.getGuid();
var dataUri = this.base64Uri;

mx.data.commit({
mxobj: this.props.mxObject,
callback: function () {
// @ts-ignore

Check warning on line 132 in packages/customWidgets/signature-web/src/components/SignatureContainer.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
var ft = new FileTransfer();
var fileUploadUrl = remoteUrl + "file?guid="+guid;
ft.upload(dataUri, fileUploadUrl, callback, error, options);

},
error: error
});

} else {
mx.data.saveDocument(
this.props.mxObject.getGuid(),
this.generateFileName(this.props.mxObject),
{},
Utils.convertUrlToBlob(this.base64Uri),
callback,
error => mx.ui.error("Error saving signature: " + error.message)
);
}
} else {
callback();
}
Expand Down
Loading