Table of Contents

Class TrinityAction<T>

Namespace
AbanoubNassem.Trinity.Components.TrinityAction
Assembly
AbanoubNassem.Trinity.dll

Represents a generic action that can be performed.

public abstract class TrinityAction<T> : TrinityComponent<T, object>, ITrinityAction, ITrinityComponent where T : TrinityAction<T>

Type Parameters

T

The type of the action.

Inheritance
TrinityAction<T>
Implements
Derived
Inherited Members

Constructors

TrinityAction(string)

Initializes a new instance of the TrinityAction<T> class.

protected TrinityAction(string action)

Parameters

action string

The name of the action.

Properties

ActionName

Gets the name of the action.

public string ActionName { get; init; }

Property Value

string

AsUrlCallback

Gets or sets the delegate used to generate URLs.

protected TrinityAction<T>.AsUrlDelegate? AsUrlCallback { get; set; }

Property Value

TrinityAction<T>.AsUrlDelegate

CancelButtonClassNames

The CSS class names to apply to the cancel button.

public virtual string? CancelButtonClassNames { get; protected set; }

Property Value

string

CancelButtonIcon

The icon to display on the cancel button.

public virtual string? CancelButtonIcon { get; protected set; }

Property Value

string

CancelButtonText

The text to display in the cancel button.

public virtual string? CancelButtonText { get; protected set; }

Property Value

string

ComponentName

The component name in the front-end side.

public override string ComponentName { get; }

Property Value

string

ConfirmButtonClassNames

The CSS class names to apply to the confirm button.

public virtual string? ConfirmButtonClassNames { get; protected set; }

Property Value

string

ConfirmButtonIcon

The icon to display on the confirm button.

public virtual string? ConfirmButtonIcon { get; protected set; }

Property Value

string

ConfirmButtonText

The text to display in the confirm button.

public virtual string? ConfirmButtonText { get; protected set; }

Property Value

string

ConfirmHeader

Gets or sets the confirmation header text.

public virtual string? ConfirmHeader { get; protected set; }

Property Value

string

ConfirmHeaderClassNames

Gets or sets the class names associated with the confirmation header.

public virtual string? ConfirmHeaderClassNames { get; protected set; }

Property Value

string

ConfirmText

Gets or sets the confirmation text.

public virtual string? ConfirmText { get; protected set; }

Property Value

string

ConfirmTextClassNames

Gets or sets the class names associated with the confirmation text.

public virtual string? ConfirmTextClassNames { get; protected set; }

Property Value

string

ConfirmTextIcon

Gets or sets the icon associated with the confirmation text.

public virtual string? ConfirmTextIcon { get; protected set; }

Property Value

string

Fields

Gets the fields of the form.

public Dictionary<string, object>? Fields { get; }

Property Value

Dictionary<string, object>

The fields of the form.

Form

Gets or sets the form for the action.

[JsonIgnore]
public virtual TrinityForm? Form { get; set; }

Property Value

TrinityForm

HandleActionUsing

Delegate for handling an action using a form data and a record.

protected virtual TrinityAction<T>.HandleActionUsingDelegate? HandleActionUsing { get; }

Property Value

TrinityAction<T>.HandleActionUsingDelegate

Icon

Gets or sets the icon for the action.

public virtual string? Icon { get; protected set; }

Property Value

string

OpenUrlInNewTab

Gets or sets a value indicating whether the URL should be opened in a new tab.

public bool OpenUrlInNewTab { get; protected set; }

Property Value

bool

RequiresConfirmation

Gets or sets a value indicating whether confirmation is required before the action can be performed.

public bool RequiresConfirmation { get; protected set; }

Property Value

bool

Schema

Gets or sets the schema for the action.

public List<object>? Schema { get; }

Property Value

List<object>

Severity

Gets or sets the severity of the action.

public virtual string Severity { get; protected set; }

Property Value

string

Type

Used on the front-end side to determine what type is the component , is it (field, columns , etc).

public override string Type { get; }

Property Value

string

Url

Gets or sets the URL associated with the action, to open on click.

public string? Url { get; protected set; }

Property Value

string

Methods

Download(string, string)

Creates a new instance of the TrinityActionResult class with a "download" result type.

public static TrinityActionResult Download(string url, string filename)

Parameters

url string

The URL to download from.

filename string

The filename to use for the downloaded file.

Returns

TrinityActionResult

A new instance of the TrinityActionResult with a "download" action.

Errors(List<object>, Dictionary<string, string>)

Creates a new TrinityActionResult instance with an "errors" action and the specified notifications and errors.

public static TrinityActionResult Errors(List<object> notifications, Dictionary<string, string> errors)

Parameters

notifications List<object>

The notifications to include in the action.

errors Dictionary<string, string>

The errors to include in the action.

Returns

TrinityActionResult

A new instance of TrinityActionResult with an "errors" action.

Handle(Dictionary<string, object?>, IReadOnlyCollection<IDictionary<string, object?>>)

Handles the action and returns the result of the action.

public virtual Task<List<TrinityActionResult>> Handle(Dictionary<string, object?> form, IReadOnlyCollection<IDictionary<string, object?>> records)

Parameters

form Dictionary<string, object>

The form data associated with the action.

records IReadOnlyCollection<IDictionary<string, object>>

The records associated with the action.

Returns

Task<List<TrinityActionResult>>

The result of the action.

Notification(NotificationSeverity, string, string?, int, bool, bool)

Creates a new instance of the TrinityActionResult class with a "notifications" result type.

public static TrinityActionResult Notification(NotificationSeverity severity, string message, string? title = null, int lifeTimeMs = 3000, bool closable = true, bool sticky = false)

Parameters

severity NotificationSeverity

The severity level of the notification.

message string

The message of the notification.

title string

The title of the notification (optional).

lifeTimeMs int

The amount of time (in milliseconds) that the notification should be displayed (default: 3000ms).

closable bool

Whether the notification can be closed by the user (default: true).

sticky bool

Whether the notification should stick until the user dismisses it (default: false).

Returns

TrinityActionResult

A new instance of the TrinityActionResult class.

Redirect(string, bool)

Creates a new instance of the TrinityActionResult class with a "redirect" result type.

public static TrinityActionResult Redirect(string url, bool openUrlInNewTab = false)

Parameters

url string

The URL to redirect to.

openUrlInNewTab bool

Whether the URL should be opened in a new tab.

Returns

TrinityActionResult

A new instance of the TrinityActionResult with a "redirect" action.

SetAsUrl(AsUrlDelegate)

Sets the delegate used to generate URLs.

public T SetAsUrl(TrinityAction<T>.AsUrlDelegate callback)

Parameters

callback TrinityAction<T>.AsUrlDelegate

The delegate to use for generating URLs.

Returns

T

The current instance of TrinityAction.

SetAsUrl(string, bool)

Sets the URL and whether it should be opened in a new tab.

public T SetAsUrl(string url, bool openUrlInNewTab = false)

Parameters

url string

The URL to set.

openUrlInNewTab bool

A value indicating whether the URL should be opened in a new tab.

Returns

T

The current instance of the T action.

SetCancelButtonText(string, string?, string?)

Sets the text, icon, and CSS class names for the cancel button.

public T SetCancelButtonText(string value, string? icon = null, string? classes = null)

Parameters

value string

The text to display on the cancel button.

icon string

The icon to display on the cancel button.

classes string

The CSS class names to apply to the cancel button.

Returns

T

The current instance of the T action.

SetConfirmButtonText(string, string?, string?)

Sets the text, icon, and CSS class names for the confirm button.

public T SetConfirmButtonText(string value, string? icon = null, string? classes = null)

Parameters

value string

The text to display on the confirm button.

icon string

The icon to display on the confirm button.

classes string

The CSS class names to apply to the confirm button.

Returns

T

The current instance of the T action.

SetConfirmHeader(string, string?)

Sets the confirmation header text and class names.

public T SetConfirmHeader(string value, string? classes = null)

Parameters

value string

The confirmation header text.

classes string

The class names associated with the confirmation header.

Returns

T

The current instance of the T action.

SetConfirmText(string, string?, string?)

Sets the confirmation text, icon, and class names.

public T SetConfirmText(string value, string? icon = null, string? classes = null)

Parameters

value string

The confirmation text.

icon string

The icon associated with the confirmation text.

classes string

The class names associated with the confirmation text.

Returns

T

The current instance of the T action.

SetForm(TrinityForm)

Sets the form for the action.

public T SetForm(TrinityForm form)

Parameters

form TrinityForm

The form to set.

Returns

T

The current instance of the T action.

SetHandleActionUsing(HandleActionUsingDelegate)

Sets the handle action using delegate.

public T SetHandleActionUsing(TrinityAction<T>.HandleActionUsingDelegate handleActionUsing)

Parameters

handleActionUsing TrinityAction<T>.HandleActionUsingDelegate

The handle action using delegate to set.

Returns

T

The current instance of the T action.

SetIcon(string)

Sets the icon for the action.

public T SetIcon(string value)

Parameters

value string

The icon to set.

Returns

T

The current instance of the T action.

SetOpenUrlInNewTab(bool)

Sets whether URLs should be opened in a new tab.

public T SetOpenUrlInNewTab(bool openUrlInNewTab = true)

Parameters

openUrlInNewTab bool

Whether URLs should be opened in a new tab.

Returns

T

The current instance of TrinityAction.

SetRequiresConfirmation(bool)

Sets a value indicating whether confirmation is required before the action can be performed.

public T SetRequiresConfirmation(bool requiresConfirmation = true)

Parameters

requiresConfirmation bool

A value indicating whether confirmation is required.

Returns

T

The current instance of the T action.

SetSeverity(ActionSeverity)

Sets the severity of the action.

public T SetSeverity(ActionSeverity severity)

Parameters

severity ActionSeverity

The severity to set.

Returns

T

The current instance of the T action.

Setup()

Setup is being called on each request, once the Component is resolved. Can be used to resolve extra Services or do some logic before using the Component.

public override void Setup()