-
Notifications
You must be signed in to change notification settings - Fork 23
[MOO-2069] : Signature widget update for 11-12 #607
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
Open
saurabhchavan1711
wants to merge
7
commits into
mx/11.12.x
Choose a base branch
from
moo/MOO-2069-Add-Direct-Image-option-to-signature-widget-with-allowUpload-property-11-12-x
base: mx/11.12.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e3a865a
fix: signature widget update for 11-12
saurabhchavan1711 c3eaf78
fix: update sha for NMR project
saurabhchavan1711 c21d749
fix: updated the NMR ref to 11-12-x branch
saurabhchavan1711 9aca718
fix: fixed pr comments
saurabhchavan1711 7e61794
fix: removed array from temp files and unwanted type from typing
saurabhchavan1711 0134a14
fix: removed consoles
saurabhchavan1711 aa69a90
fix: added configuration guide to Readme instead of separate file
saurabhchavan1711 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,141 @@ | ||
| # Signature widget | ||
|
|
||
| Creates a canvas on which a user can draw. | ||
| The drawing will be saved as a base64 string. | ||
|
|
||
| ## Configuration Guide | ||
|
|
||
| ### Overview | ||
|
|
||
| This guide covers the required configuration and best practices for implementing the Signature widget in your Mendix Native Mobile application. It includes instructions for new implementations as well as migration steps for existing projects using the Signature widget. | ||
|
|
||
| --- | ||
|
|
||
| ### Advantages of the New Signature Widget | ||
|
|
||
| The updated Signature widget simplifies configuration and reduces manual setup: | ||
|
|
||
| - No need to manually assign a base64 string to an entity attribute. | ||
| - The base64DecodeToImage action and commit object activity are no longer required in your nanoflow. | ||
| - For entities with synchronization mode set to **All Objects**, you only need to add a synchronize action if required by your implementation. For entities with synchronization mode set to **Online**, synchronization is not required. | ||
|
|
||
| --- | ||
|
|
||
| ### Required Configuration for New Implementations | ||
|
|
||
| #### 1. Image Property (Required) | ||
|
|
||
| The `Image` property must be configured with an entity that **generalizes System.Image**. | ||
|
|
||
| **Configuration Steps:** | ||
|
|
||
| 1. **Create an entity that generalizes System.Image:** | ||
|
|
||
| ``` | ||
| Example: | ||
| Entity: CustomerSignature | ||
| Generalization: System.Image | ||
| ``` | ||
|
|
||
| 2. **Configure the widget:** | ||
| - In the **Data source** section, for `Image` property select Image type as **Dynamic**. | ||
| - Set the `System.Image` entity object to it. | ||
|
|
||
| **Studio Pro Validation:** | ||
|
|
||
| - Selecting Static images will display the error: _"Image must be a dynamic image type. Static images cannot be uploaded to."_ | ||
|
|
||
| --- | ||
|
|
||
| #### 2. On Sign End Action (Required) | ||
|
|
||
| The `On sign end` action is **required** and triggers when the user clicks the Save button to save the signature to the image object. | ||
|
|
||
| **Supported Action Types:** | ||
|
|
||
| - **Call a nanoflow** | ||
| - **Call a microflow** | ||
| - **Save changes** | ||
|
|
||
| **Important:** | ||
|
|
||
| - If the `On sign end` action is not configured with one of the supported action types, the signature will not be saved. The operation will fail silently without displaying a Studio Pro error. You can set any required actions (for ex.- show pages, close pages) inside that nanoflow/microflow. | ||
|
|
||
| --- | ||
|
|
||
| ### Migration Steps for Existing Projects | ||
|
|
||
| #### What Changed | ||
|
|
||
| Previously, you needed to store the base64-encoded signature string in a String attribute, then call a nanoflow that used the **base64DecodeToImage** action to convert the string into an image, and finally commit the object before continuing with your flow. With this update, the widget now handles the base64-to-image conversion internally, eliminating this overhead. | ||
|
|
||
| **Key Changes:** | ||
|
|
||
| 1. The widget now saves the signature directly to an entity that generalizes `System.Image`, instead of storing a base64-encoded string in a String attribute and then converting it to Image. | ||
| 2. The **On save** event has been renamed to **On sign end** under the **Events** tab. | ||
|
MxKevinBeqo marked this conversation as resolved.
|
||
|
|
||
| #### Example: Migrating from Studio Pro 10.24 or Earlier 11.x.x | ||
|
|
||
| The following is a step-by-step walkthrough of migrating a Mendix app from Studio Pro 10.24 or an earlier 11.x.x version to a version that includes the updated Signature widget. | ||
|
|
||
| 1. **Resolve migration errors** — After converting the app to the new Studio Pro version, you may see errors about outdated modules: **NanoflowCommons** and **Native Mobile Resources**. These errors are unrelated to the Signature widget. Update both modules from the Marketplace to resolve these errors. | ||
|
|
||
|  | ||
|
|
||
| 2. **Update the widget** — If an **Update widget** error appears, click **Update** (or **Update all widgets**) to apply the new version. | ||
|
|
||
|  | ||
|
|
||
| 3. **Configure the Image property** — After updating, a new validation error will appear: _Property Image is required_. | ||
|
|
||
|  | ||
|
|
||
| To resolve this, open the Signature widget configuration and select the appropriate `System.Image` object reference in the **Image** property with image type set to **Dynamic**: | ||
|
|
||
|  | ||
|
|
||
| 4. **Update the On sign end action** — In the **Events** tab, assign the nanoflow or other supported action that was previously used for **On save** to the **On sign end** action. You must assign either a nanoflow, microflow, or save changes action. | ||
|
|
||
|  | ||
|
|
||
| Next, open the nanoflow and remove the **base64DecodeToImage** action and **Commit object** activity, as they are no longer required. Keeping the **base64DecodeToImage** action will fail the signature from being stored. Keep your existing actions for ex.- **Synchronize** or **Close page**. | ||
|
|
||
|  | ||
|
|
||
| --- | ||
|
|
||
| ### Troubleshooting | ||
|
|
||
| #### Error: "Property Image is required" | ||
|
|
||
| **Cause:** The Image property is not configured. | ||
|
|
||
| **Solution:** | ||
|
|
||
| 1. Select the Signature widget. | ||
| 2. In the **Data source** section, configure the Image property. | ||
| 3. Select a System.Image entity object. | ||
|
|
||
| #### Error: "Image must be a dynamic image type. Static images cannot be upload to" | ||
|
|
||
| **Cause:** You selected a static image type. | ||
|
|
||
| **Solution:** | ||
|
|
||
| 1. Create an entity that generalizes System.Image. | ||
| 2. In the Signature widget, set the Image property to use a dynamic image type. | ||
| 3. Select the System.Image entity object. | ||
|
|
||
| #### Signature is not being stored in the object | ||
|
|
||
| **Cause:** The `On sign end` action is not configured with a supported action type. | ||
|
|
||
| **Solution:** | ||
|
|
||
| 1. Configure the `On sign end` action with a supported action type: call a nanoflow, call a microflow, or save changes. | ||
| 2. Implement your project-specific logic inside the nanoflow or microflow. You can use other actions (for ex.- show page or close page) within the nanoflow or microflow as needed. | ||
|
|
||
| --- | ||
|
|
||
| ### Breaking Changes | ||
|
|
||
| - With this update, the previous **Attribute** property has been removed. The widget no longer stores a base64-encoded string into it. If you were using that base64 value as input to any API, integration, or export, those values will be empty going forward, as nothing is written to that attribute anymore. | ||
Binary file added
BIN
+186 KB
...luggableWidgets/signature-native/assets/migration/AssignNanoflowToOnSignEnd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+111 KB
...ggableWidgets/signature-native/assets/migration/AssignObjectToImageProperty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+115 KB
packages/pluggableWidgets/signature-native/assets/migration/NanoflowOnSignEnd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.12 MB
...uggableWidgets/signature-native/assets/migration/PropertyImageRequiredError.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.39 MB
packages/pluggableWidgets/signature-native/assets/migration/Update-NC-NMR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.16 MB
packages/pluggableWidgets/signature-native/assets/migration/Update-Widget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/pluggableWidgets/signature-native/src/Signature.editorConfig.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,21 @@ | ||
| import { StructurePreviewProps, topBar } from "@mendix/piw-utils-internal"; | ||
| import { Problem } from "@mendix/pluggable-widgets-tools"; | ||
|
|
||
| import { SignaturePreviewProps } from "../typings/SignatureProps"; | ||
|
|
||
| export const getPreview = (_: SignaturePreviewProps, isDarkMode: boolean): StructurePreviewProps => | ||
| topBar("Signature", [], isDarkMode); | ||
|
|
||
| export function check(values: SignaturePreviewProps): Problem[] { | ||
| const errors: Problem[] = []; | ||
|
|
||
| if (values.imageSource !== null && values.imageSource.type === "static") { | ||
| errors.push({ | ||
| property: "imageSource", | ||
| severity: "error", | ||
| message: "Image must be a dynamic image type. Static images cannot be uploaded to." | ||
| }); | ||
| } | ||
|
|
||
| return errors; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.