Dialog Manager

Modal support for common modal types

Purpose of Component

The RfDialogManager adds support to show common modals like those in JavaScript: window.alert, window.confirm, and window.prompt.

When to Use

Use RfDialogManager when there is a need to ask or tell the user something straight forward. For example:

  • Confirm when confirming an item should be deleted.
  • Prompt when asking the user for a simple comment in during a saving process.
  • Alert when you want to make sure they read something and would like it to be confirmed before going forward.
  • Multi Action when you need to present the user with more than two choices, such as "Save", "Don't Save", or "Cancel", allowing for more complex decision flows than a simple confirm dialog.

When not to Use

RfDialogManager is a helpful and easy to use tool but there are several instances of when it would be better to create a custom modal. Such cases as:

  • When you need validation beyond requirement.
  • Need an edit form.

Basic Usage

It takes two parts to use RfDialogManager. First the page will need to have an

<RfDialogManager />
registered somewhere that isn't inside of a overflow hidden element. Pererrabley it should be as high up the DOM tree to ensure some CSS rule doesn't affect it.

Secondly, the page will need to inject RForgeBlazor.Services.IDialogManager.cs. This interface is used to communicate between RfDialogManager and the page. This interface supports several overloads for each alert, confirm, and prompt.

NOTE: In projects that use rendermode: InteractiveServer. The backend may take advantage of IDialogManagerBackend.cs. I caution on using this. This should only be done if you are sure the project won't switch over to WASM.

Standard Request Flow

The RfDialogManager works off calling RForgeBlazor.Services.IDialogManager.cs and providing the method a callback function when completed.

How to Setup

Setting up RForge is simple. Follow the below steps to add RForge Blazor components to your project.

  1. Install the Nuget package
  2. Import the namespaces (optional)
  3. Register RForge services
  4. Include Bulma CSS

Install the Nuget Package

RForge Blazor components are installed via Nuget. There are two packages. One for the blazor app and one for the library if any.

Blazor Project Installation

Command Line
dotnet add package RForge.Blazor
Package Manager Console
Install-Package RForge.Blazor

Library Project Installation

This is optional but may be useful if you want to use common enums across the backend and frontend.

Command Line
dotnet add package RForge.Abstractions
Package Manager Console
Install-Package RForge.Abstractions

Import the namespaces

To simplify namespacing while using RForge, the package is designed with most all components sitting within the root RForge namespace.

You may want to include the following namespaces in your _import.razor for ease of use.

@using RForgeBlazor
@using RForgeBlazor.Services
@using RForge.Abstractions
Namespace Purpose
RForgeBlaozr Houses all of the blazor components.
RForgeBlaozr.Services Houses interfaces you may need to communicate with certain components.
RForgeBlaozr.Abstractions Common enums used through out the components.

Register RForge Services

In order for some components to work they must first have their services registered.

Open up Program.cs and add the following line before the var app = builder.Build();.

Heads Up!
If your project is using the multi project solution where one project is server and the other is client. You will need to register the services in both projects.

using RForgeBlazor;
//...
builder.Services.AddRfForgeBlazorServices();
//...
var app = builder.Build();
    

Include Bulma CSS

RForge makes use of Bulma CSS to stylize the components. Add / install Bulma and add the CSS file to the head. Link to download: Bulma releases.

An unhandled error has occurred. Reload 🗙