You can extend an empty or incomplete MDriven model by merging a reusable .modlr model section into it; this page is for MDriven Designer users who want to add a focused capability without starting from a complete application.
Use merge-in examples when you want to add one capability, such as authentication, password reset, an email queue, or a calendar dimension, to your existing model. If you instead want to apply a model and data as a jump-start to a Turnkey site, use Documentation:Example Gist. For standalone, complete demonstrations, see Documentation:Complete model examples.
Merge a model section
- Download the required
.modlrfile from the relevant example below. - Open the target model in MDriven Designer.
- Save the target model before you merge. This gives you a known version to return to if you need to undo or compare the change.
- In MDriven Designer, choose Open Merge Add and select the downloaded
.modlrfile. - Review the imported class diagrams, classes, ViewModels, actions, and AssetsTK content.
- Save the merged model, then run it in your normal development environment and test the imported capability.
For example, after merging the SVG interaction example, you should see a new diagram and related ViewModels. Run the model and confirm that you can add a box, save it, open the drawing, and move the SVG box before adapting the example to your own UI.
When you create a reusable merge example from an existing model, use Save As for Merge before distributing it. This replaces object identities in the saved copy. Identities have priority during a merge; if no matching identity is found, MDriven then matches by name. Reusing a file with identities that conflict with objects in another model can therefore produce unexpected results.
What MDriven merges
MDriven attempts to combine incoming content with the target model and avoid duplicates. Review the result in MDriven Designer because a merge can add or change several kinds of model content.
| Incoming content | Merge behavior |
|---|---|
| Class with a name already used in the target model | MDriven copies the incoming class content into the existing target class. The incoming class is discarded to avoid a duplicate class. |
| Package with a name already used in the target model | MDriven moves the incoming package content into the existing target package. |
| ViewModel with a name already used in the target model | MDriven skips that incoming ViewModel name. New ViewModels are added. |
| Diagram with a name already used in the target model | MDriven merges the diagrams to avoid duplicates. |
| AssetsTK content | MDriven merges the incoming AssetsTK content into the target model's AssetsTK, adding or updating it. |
Review name collisions deliberately
A matching name does not mean that the two model elements have the same intent. Before merging, compare names in the target model with the package you plan to import. After merging, inspect every class and ViewModel that had a matching name.
For example, if your model already has a ViewModel named ResetPasswordPage, an incoming ViewModel with that name is skipped. You must decide whether your existing ViewModel already provides the required behavior or whether you need to rename and adapt one of the ViewModels before retrying the merge.
Merge-in packages
Authentication: SysUserAuthentication
Merge SysUserAuthentication when your Turnkey system needs the SysSingleton and SysUser classes used for login and authentication. This is an architectural pattern rather than a complete user-management application.
- Download SysUserAuthentication.modlr.
- Merge it into the model that you want to extend.
- Inspect the added classes and diagram.
- Run the application and verify login behavior before building dependent features.
Password reset
The password-reset sample adds password-reset functionality to a model that uses the default ASPNETIdentity package for login. It is intended to be adapted in your model rather than treated as built-in Turnkey functionality.
The package adds:
- A reset-password page that an action can open. This page should have no access groups.
- A server-side ViewModel that runs every 20 seconds and sends reset-instruction emails.
- A page where the user sets a password, including information about expired reset tickets and how to send a new ticket.
After you merge the package:
- Set the PasswordReset package's Default superclass if your model requires one.
- Configure an email server for Turnkey/MDrivenServer. The reset-email ViewModel cannot send messages until email settings are available.
- Create an action that opens the
RestetPasswordPageViewModel. - Test a reset request, delivery of the instruction email, use of the reset page, and the expired-ticket path.
Download PasswordResetTemplate.modlr.
Background work: SysAsyncTicket
SysAsyncTicket is an architectural pattern recognized by MDrivenServer for background work. Use it when work should be performed outside the user interaction that initiated it. For example, use an asynchronous ticket for a task that should continue after the user has submitted an action.
Read AsyncTicket for the pattern and download the SysAsync package from that page before merging it.
Localization and translation
The localization and translation pattern stores translations for text in actions and ViewModels. It also provides Translate OCL operators for data that follows the pattern. Use this package when text must be available in more than one language.
Download Translations.modlr and read Localization and Translation before adapting action text or ViewModels.
Turnkey trace logging: SysTurnkeyTraceLog
Use the SysTurnkeyTraceLog pattern when you need to track user activity in a Turnkey application. Model a class that follows the pattern, then MDrivenTurnkey snapshots information for each navigation change and each action execution that can change data. Every 30 seconds, MDrivenTurnkey spools objects of that class.
The example is available from MDrivenComponents. Review the data captured and access to the resulting log before using it in an application.
Extensions
Charge an end user: Consume and Purchase GetPaid#1
This model extension treats a portal user as a SysConsumer. You can charge the SysConsumer by credit card and consume services from your local model. Download ChargeEndUserViaMDrivenPortalService.modlr and review the imported model before connecting it to your service flow.
PayPal checkout: GetPaid#2
This alternative payment extension integrates PayPal checkout. You need a PayPal account, developer registration, and an app ClientID. After merging, paste the ClientID into the supplied ViewModel and test the checkout flow.
Download PayPalCheckout.modlr.
Runtime theme builder
The theme builder model section lets you set CSS variables that affect UI colors and sizes at runtime. Use it to try settings interactively before incorporating them into your application theme.
Download ThemeBuilder.modlr and see Theme as data.
Outgoing email queue
The outgoing email queue pattern adds queued email handling to the standard base model. Use it when email sending should be queued, monitored, retried after failures, and cleaned up after sending.
It includes:
- A seeker ViewModel for finding queued and sent emails.
- An email-detail view for changing queued emails.
- Two server-side ViewModels: one sends emails and one cleans up sent emails.
- File attachments for outgoing messages.
- Exception handling, error viewing, and retries for failed send attempts.
For example, an administrator can use the seeker view to find failed messages, open the detail view to inspect the error, correct a queued email where appropriate, and allow the sender ViewModel to retry it.
Download OutgoingEmailQueue.modlr. Configure and test email delivery in a non-production environment before relying on the queue.
Calendar dimensions
The calendar model provides classes for linking business data to days, weeks, months, and years. It follows a data-analysis dimension pattern: prepopulate the database with calendar objects so that aggregations for statistics can find the relevant period efficiently.
For example, link an event to a calendar day, then aggregate events by that day's week, month, or year for a diagram or table.
Download CalendarPackage.modlr and read Calendar package.
Complete examples
The following examples are complete demonstrations rather than primarily architectural merge packages. You can merge them to inspect and reuse their modeled solution, or open them separately to study the implementation.
| Example | What it demonstrates | Download |
|---|---|---|
| SVG interaction | SVG objects that react to mouse events, can be moved, and can be saved. | SvgInteractionMoveBoxesAround.modlr |
| Google Maps markers | Showing a marker, tracking map settings, and moving the marker. Production use requires your own Google API key. | GoogleMapWithMarkers.modlr |
| Trello-like board | Cards that users move between lists, with card interaction. | TrelloLikeBoard.modlr |
| TinyMCE markup editor | Rich HTML text editing. | HtmlEditor.modlr |
| Interactive Gantt chart | Displaying and interacting with data on a timeline. | GanttChartInteractive.modlr |
See Documentation:Complete model examples for the descriptions of these examples.
