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
stringThe name of the action.
Properties
ActionName
Gets the name of the action.
public string ActionName { get; init; }
Property Value
AsUrlCallback
Gets or sets the delegate used to generate URLs.
protected TrinityAction<T>.AsUrlDelegate? AsUrlCallback { get; set; }
Property Value
CancelButtonClassNames
The CSS class names to apply to the cancel button.
public virtual string? CancelButtonClassNames { get; protected set; }
Property Value
CancelButtonIcon
The icon to display on the cancel button.
public virtual string? CancelButtonIcon { get; protected set; }
Property Value
CancelButtonText
The text to display in the cancel button.
public virtual string? CancelButtonText { get; protected set; }
Property Value
ComponentName
The component name in the front-end side.
public override string ComponentName { get; }
Property Value
ConfirmButtonClassNames
The CSS class names to apply to the confirm button.
public virtual string? ConfirmButtonClassNames { get; protected set; }
Property Value
ConfirmButtonIcon
The icon to display on the confirm button.
public virtual string? ConfirmButtonIcon { get; protected set; }
Property Value
ConfirmButtonText
The text to display in the confirm button.
public virtual string? ConfirmButtonText { get; protected set; }
Property Value
ConfirmHeader
Gets or sets the confirmation header text.
public virtual string? ConfirmHeader { get; protected set; }
Property Value
ConfirmHeaderClassNames
Gets or sets the class names associated with the confirmation header.
public virtual string? ConfirmHeaderClassNames { get; protected set; }
Property Value
ConfirmText
Gets or sets the confirmation text.
public virtual string? ConfirmText { get; protected set; }
Property Value
ConfirmTextClassNames
Gets or sets the class names associated with the confirmation text.
public virtual string? ConfirmTextClassNames { get; protected set; }
Property Value
ConfirmTextIcon
Gets or sets the icon associated with the confirmation text.
public virtual string? ConfirmTextIcon { get; protected set; }
Property Value
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
HandleActionUsing
Delegate for handling an action using a form data and a record.
protected virtual TrinityAction<T>.HandleActionUsingDelegate? HandleActionUsing { get; }
Property Value
Icon
Gets or sets the icon for the action.
public virtual string? Icon { get; protected set; }
Property Value
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
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
Schema
Gets or sets the schema for the action.
public List<object>? Schema { get; }
Property Value
Severity
Gets or sets the severity of the action.
public virtual string Severity { get; protected set; }
Property Value
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
Url
Gets or sets the URL associated with the action, to open on click.
public string? Url { get; protected set; }
Property Value
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
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
NotificationSeverityThe severity level of the notification.
message
stringThe message of the notification.
title
stringThe title of the notification (optional).
lifeTimeMs
intThe amount of time (in milliseconds) that the notification should be displayed (default: 3000ms).
closable
boolWhether the notification can be closed by the user (default: true).
sticky
boolWhether 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
stringThe URL to redirect to.
openUrlInNewTab
boolWhether 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>.AsUrlDelegateThe 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
stringThe URL to set.
openUrlInNewTab
boolA 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
stringThe text to display on the cancel button.
icon
stringThe icon to display on the cancel button.
classes
stringThe 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
stringThe text to display on the confirm button.
icon
stringThe icon to display on the confirm button.
classes
stringThe 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
stringThe confirmation header text.
classes
stringThe 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
stringThe confirmation text.
icon
stringThe icon associated with the confirmation text.
classes
stringThe 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
TrinityFormThe 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>.HandleActionUsingDelegateThe 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
stringThe 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
boolWhether 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
boolA 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
ActionSeverityThe 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()