One of the great things about developing with Umbraco is the many ways you can show your users information, and one of the hard things with umbraco is there are so many ways to show information!.
The overlay service is available in Umbraco v8 and v7.13+ and it allows you to put dialog boxes over the rest of the page.
Overlays as confirmation box.
Probably the quickest way you can use the overlay service is as a confirmation dialog for your users.
A confirm overlay requires a simplified set of options so you don’t have to set to much to get it to show.
|
More complex overlays.
At the more powerful end of things the overlay service lets you provide your own custom view to use in the overlay (via the view
option).
|
The view for your overlay, works in a similar way to other views in umbraco in that you can have a controller, and you get to control the html.
Example view:<div ng-controller="doStuffCustomOverlayController as vm">
<div class="flex justify-center flex-column items-center">
<i class="large icon {{vm.icon}}"></i>
<h3>{{vm.content}}</h3>
</div>
</div>
N.B For an overlay, your custom view sits beneath the title & description and above the buttons, that is you don’t get to control those values directly in your markup. but they are available via $scope.model within your controller.
Multi-step overlays
The overlay service is really designed to show the user a dialog over the content and then do a thing and go away. but there are cases where you might want to have multiple steps in the dialog, or have something that is long running.
For example in uSync.Complete we have multiple steps to the publish process where users have to pick servers and options before we push the content to another site.
,
While this is a complex use of the overlay service, it is possible to do this when you understand the flow of an overlay dialog.
All button presses go back to the parent.
So when ever a user presses a button on the dialog they will be hitting hte submit or close functions of the dialog.
While you could indeed intercept these in your overlay controller, they will almost always go back to the submit and close functions you setup when opening the overlay.
|
As you can see here we are responsible for calling the overlayService.close()
function. So if we don’t then the overlay doesn’t close.
|
When the process is not complete we need to call something to carry on the process. Here we could call a method in the calling controller, but as we have access to the model that is passed between the calling and overlay controller we can put the method in the overlay.
|
within our overlay process we need to make sure the processStep
method is attached to the model.
|
Show me the code.
You can see this code in the DoStuffWithUmbraco repo
Open a custom overlay from overlayController.js
|
customOverlayController.js
|