Skip to content
This repository has been archived by the owner on Jan 3, 2020. It is now read-only.

Commit

Permalink
Persist file name when exits
Browse files Browse the repository at this point in the history
  • Loading branch information
Andries-Smit committed Jan 2, 2019
1 parent a372f2b commit c71c35b
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 20 deletions.
221 changes: 206 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "signature",
"widgetName": "Signature",
"version": "1.0.1",
"version": "1.0.2",
"description": "A signature pad for capturing signatures",
"scripts": {
"build": "grunt release",
Expand Down Expand Up @@ -76,7 +76,7 @@
"karma-spec-reporter": "0.0.32",
"karma-webpack": "^2.0.13",
"mendix-client": "^7.15.3",
"mendix-widget-build-script": "^1.0.0",
"mendix-widget-build-script": "^1.0.3",
"node-sass": "^4.9.4",
"pre-commit": "^1.2.2",
"raw-loader": "^0.5.1",
Expand Down
8 changes: 6 additions & 2 deletions src/components/SignatureContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class SignatureContainer extends Component<SignatureContainerProps, SignatureCon

private saveDocument(callback: () => void) {
if (this.base64Uri && this.state.hasSignature) {
mx.data.saveDocument(this.props.mxObject.getGuid(), this.generateFileName(), { },
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)
Expand All @@ -105,7 +105,11 @@ class SignatureContainer extends Component<SignatureContainerProps, SignatureCon
}
}

private generateFileName(): string {
private generateFileName(mxObject: mendix.lib.MxObject): string {
const currentName = mxObject.get("Name") as string;
if (currentName) {
return currentName;
}
return `signature${Math.floor(Math.random() * 1000000)}.png`;
}

Expand Down
2 changes: 1 addition & 1 deletion src/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="Signature" version="1.0.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="Signature" version="1.0.2" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="Signature.xml" />
</widgetFiles>
Expand Down

0 comments on commit c71c35b

Please sign in to comment.