One of the most thrilling new features in UI-O-Matic v2 is the ability to plug in your own reposities to handle the crud (thanks to Matt for the idea and implementation). So by default UI-O-Matic works agains the database using PetaPoco but with this feature we can pretty much plug in any third party API.

Example

Let’s say we want to be able to create Github issues from inside the Umbraco UI, well that can be done in a couple of easy steps.

The model consists of a couple of properties of course if we wish that UI-O-Matic picks these up we need to mark them with the correct attributes. One thing that we also need to do is mark 1 property with the primarykeycolumn attribute , this is the property used to identify the object.

As you see on the UIOMatic attribute we setup the RepositoryType to be something custom instead of just the default.

Create the Repository

Next we need to create that custom repo type. We can inherit from the Abstract class class AbstractUIOMaticRepository<TEntity, TId> and override it’s methods, so that’s where we’ll plug in the third party api…

Show me

I’ve downloaded this truncate filter from github and added that to my project, also added a package manifest and a script where I do the include, so I get the following structure in my AppPlugins folder

This uses the great and simple CsvHelper package to easily generate a csv file out of our data and then stores it on disk and returns the file location.

Result

I now got an additional export action I can apply to any model I wish!

Future

Once v2 final is out, I’ll make a nuget package out of this (and probably make some tweaks since this is just a proof of concept at the moment) so you can easiliy install it and extend your UI-O-Matic models

So far this has nothing to do with UI-O-Matic it’s just standard Umbraco, MVC and PetaPoco (to insert a db entry).

But of course we now want to show these entries to the client…

Adding UI-O-Matic V2 into the mix

The only thing we have to do now is install UI-O-Matic v2 (at this moment it’s in beta and you can get it from Nuget or build the latest source from github). In this example I’ve build the latest source and installed that but all these features will make it into the final release.

So first we simply decorate the class with the UIOMatic attribute, providing a unique alias, a singular name and a plural name for our object and some optional parameters like which icon to use and that we would like to render in a list instead of the tree

Then we can mark the items we want in the actual editor (marked with UIOMaticField, can also specify a different editor then textstring as you can see in the example)

And mark the ones we want in the list view (marked with UIOMaticListViewField)

Result

As you see simply by decorating our model with some additional attributes we now get an entries viewer/editor! Kapow!

and I must say I was pretty excited to see the great Matt Brailsford forking the UI-O-Matic repo. In his fork he has taken the project to the next level, housekeeping and improving the codebase and implementing quite a few new features.

What has changed?

The project has undergone major refactoring, a lot has changed, so it is not possible to upgrade from v1 to v2 without having to make a couple of changes. To outline the main differences:

UIOMatic field property is now explicit, so if you want it to show up in the UI you need to mark your properties

Explicit UIOMaticListViewField attribute (use this if you want properties to show up in the listview)

Consistency in the js, no more uppercase properties, this has an impact if you created custom property views, use property.value instead of property.Value

What’s new?

Core project (there are now 2 nuget packages one for the core and 1 for the ui)

Folder Support

List view views (so you can now choose how to render a property in the list view, think image as an example)

Filter option on the list view (with the new UIOMaticListViewFilter attribute)

UIOMaticRepository (so devs can supply a custom repository object)

Map field type

New Logo

Installation

You can install the beta via Nuget:Install-Package Nibble.Umbraco.UIOMatic –Pre

Documentation

We are currently working at updating the docs (and they should be ready when the final hits the shelves), you should be able to get started with what is currently available at http://uiomatic.readthedocs.io/en/stable/

UI-O-Matic provides an simply way to validate your model by implementing the interface IUIOMatic and the member Validate() there you simply return a list of exceptions you wish to display to your editor, so you have full control over the validation logic… (as in the example shown here where it checks wether a value for the FirstName prop and LastName prop have been provider)

But something I have been toying with is the idea to use a .net standard instead which are data annotations. So you can simply decorate your properties with those (like [Required])

And luckily .net provides a way to manually validate those so we can actually use them allready, you’ll just have to write the validation code in the validate method and this end up with a mode like this

A year ago I introduced an Umbraco addon called UI-O-Matic which allows you to build up an integrated UI for your custom db tables in minutes (if you haven’t seen it I would recommend to check it out since it’s a real time saver!)

But of course all the CRUD action happens in the backoffice and I thought it would be nice to allow you to easily genereate forms based on your UI-O-Matic models that you can use in the front end of your site.

So I’m glad to present you a couple of Umbraco Forms addons that will make it super easy to link and submit data from your custom db tables.

Prevalue source type

Simply select the type of object (your available models decorated with the UIOMatic attribute) the sort column and order and that’s it… it will use the primary key column as prevalue id and the ToString() method on the model as the value

Workflow type

The UI-O-Matic workflow type allows you to extend the functionality of a form in this case it will allow you to submit your record to a database table.

If you have ever used the save as Umbraco document workflow type it will look very similar, first select the type of object then you can map the different properties on that object to record fields or setup a static value.

Data source type

And finally there is also a UI-O-Matic datasource type that will give you the option to generate a form based on a Model.

Simply select the type of object and then follow the wizard.

Bonus

A small bonus that you’ll also find in the project is an attribute that can be used to decorate your UI-O-Matic model so that it creates the assiciated table for you [CreateTable]

Where can I get it?

You can simply install it from Nuget. Of course this depends on Umbraco Forms and UI-O-Matic but Nuget should take care of the dependencies if you haven’t already installed them.

Simply run the command Install-Package Nibble.Umbraco.ConfigTree in the package manager console of Visual Studio and you’ll have a new tree where you can edit all files in the /config folder of Umbraco.