Table of Contents

Class TrinityField<T, TDeserialization>

Namespace
AbanoubNassem.Trinity.Components.TrinityField
Assembly
AbanoubNassem.Trinity.dll

Represents an abstract class that provides a base implementation for a field component in Trinity Framework.

public abstract class TrinityField<T, TDeserialization> : TrinityComponent<T, TDeserialization>, ITrinityComponent, ITrinityField, IFormComponent where T : TrinityField<T, TDeserialization>, ITrinityField

Type Parameters

T

The type of the field component.

TDeserialization

The type of the deserialization object.

Inheritance
TrinityComponent<T, TDeserialization>
TrinityField<T, TDeserialization>
Implements
Derived
Inherited Members

Constructors

TrinityField(string)

Initializes a new instance of the TrinityField<T, TDeserialization> class.

protected TrinityField(string columnName)

Parameters

columnName string

The name of the column.

Fields

FillUsing

The fill using function for the form field.

protected TrinityField<T, TDeserialization>.ActionFormWithRecord? FillUsing

Field Value

TrinityField<T, TDeserialization>.ActionFormWithRecord

FillUsingProperties

The fill using properties function for the form field.

protected TrinityField<T, TDeserialization>.ActionWithRecordProperties? FillUsingProperties

Field Value

TrinityField<T, TDeserialization>.ActionWithRecordProperties

FillUsingProperty

The fill using property function for the form field.

protected TrinityField<T, TDeserialization>.ActionWithRecordProperty? FillUsingProperty

Field Value

TrinityField<T, TDeserialization>.ActionWithRecordProperty

Rules

The action to apply validation rules for the Trinity field.

protected Action<IRuleBuilderInitial<Dictionary<string, object?>, TDeserialization?>>? Rules

Field Value

Action<IRuleBuilderInitial<Dictionary<string, object>, TDeserialization>>

ValidateUsingCallback

The validation delegate for the Trinity field.

protected TrinityField<T, TDeserialization>.ValidateUsingDelegate? ValidateUsingCallback

Field Value

TrinityField<T, TDeserialization>.ValidateUsingDelegate

Properties

ColumnName

Gets or sets the name of the column associated with the field.

public string ColumnName { get; set; }

Property Value

string

ExtraAttributes

Gets or sets the extra attributes for this field wrapper.

public Dictionary<string, string>? ExtraAttributes { get; set; }

Property Value

Dictionary<string, string>

ExtraInputAttributes

Gets or sets the extra attributes for this field.

public Dictionary<string, string>? ExtraInputAttributes { get; set; }

Property Value

Dictionary<string, string>

FilterQueryUsing

Gets or sets the filter query using action.

protected Action<Query, string>? FilterQueryUsing { get; set; }

Property Value

Action<Query, string>

HelperText

Gets or sets the helper text for the input field.

public string? HelperText { get; protected set; }

Property Value

string

InputType

Gets or sets the placeholder text for the input field.

public string? InputType { get; protected set; }

Property Value

string

IsRequired

Gets or sets whether to use a red asterisk to indicate a field is required or not.

public bool IsRequired { get; protected set; }

Property Value

bool

IsSavable

Whether the field should be saved into the database or not.

public virtual bool IsSavable { get; set; }

Property Value

bool

Locale

Gets or sets the locale to be used for the input field.

public string? Locale { get; protected set; }

Property Value

string

OnlyOnCreate

Gets or sets a value indicating whether the field should be used only during creation.

public bool OnlyOnCreate { get; set; }

Property Value

bool

OnlyOnUpdate

Gets or sets a value indicating whether the field should be used only during updates.

public bool OnlyOnUpdate { get; set; }

Property Value

bool

Placeholder

Gets or sets the placeholder text for the input field.

public string? Placeholder { get; protected set; }

Property Value

string

Prefixes

Gets or sets the prefixes of the field.

public string[]? Prefixes { get; protected set; }

Property Value

string[]

An array of strings representing the prefixes.

PrefixIcons

Gets or sets the prefix icons of the field.

public string[]? PrefixIcons { get; protected set; }

Property Value

string[]

An array of strings representing the prefix icons.

SelectQueryUsing

Gets or sets the select query using action.

protected Action<Query>? SelectQueryUsing { get; set; }

Property Value

Action<Query>

Suffixes

Gets or sets the suffixes of the field.

public string[]? Suffixes { get; protected set; }

Property Value

string[]

An array of strings representing the suffixes.

SuffixIcons

Gets or sets the suffix icons of the field.

public string[]? SuffixIcons { get; protected set; }

Property Value

string[]

An array of strings representing the suffix icons.

Title

The value that should be used to represent the column when being displayed.

public string Title { 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

Methods

Fill(ref Dictionary<string, object?>, IReadOnlyDictionary<string, object?>?)

Fills a form with data from a record for the field.

public virtual void Fill(ref Dictionary<string, object?> form, IReadOnlyDictionary<string, object?>? record = null)

Parameters

form Dictionary<string, object>

The form to fill.

record IReadOnlyDictionary<string, object>

FilterQuery(Query, string)

Adds a filter query for the field to a query builder.

public virtual void FilterQuery(Query query, string search)

Parameters

query Query

The query builder to use.

search string

The search term to use.

Format(ref IDictionary<string, object?>)

Formats a record for the field, after it is retrieved from the database, but before it is sent to the Trinity front-end.

public virtual void Format(ref IDictionary<string, object?> record)

Parameters

record IDictionary<string, object>

The record to format.

FormatUsing(ActionFormWithRecord)

Sets the format using function for the form field.

public T FormatUsing(TrinityField<T, TDeserialization>.ActionFormWithRecord formatUsing)

Parameters

formatUsing TrinityField<T, TDeserialization>.ActionFormWithRecord

The format using function to set.

Returns

T

The current instance of the T field.

GetDeserializationType()

Gets the deserialization type for the field, to be deserialized from JSON.

public Type GetDeserializationType()

Returns

Type

The deserialization type for the field.

PrepareForValidation(IValidator, IReadOnlyDictionary<string, object?>, ModelStateDictionary)

Prepares the field for validation.

public virtual void PrepareForValidation(IValidator validator, IReadOnlyDictionary<string, object?> form, ModelStateDictionary _)

Parameters

validator IValidator

The validator to use.

form IReadOnlyDictionary<string, object>

The form to validate.

_ ModelStateDictionary

SelectQuery(Query)

Adds a select query for the field to a query builder.

public virtual void SelectQuery(Query query)

Parameters

query Query

The query builder to use.

SetAsRequired(bool)

Sets whether to use a red asterisk to indicate a field is required or not.

public T SetAsRequired(bool isRequired = true)

Parameters

isRequired bool

whether to use a red asterisk or not.

Returns

T

The current instance of the T field.

SetColumnName(string)

Sets the column name of the form field.

public T SetColumnName(string value)

Parameters

value string

The column name to set.

Returns

T

The current instance of the T field.

SetExtraAttributes(Dictionary<string, string>)

Sets the extra attributes for this field wrapper.

public T SetExtraAttributes(Dictionary<string, string> extraAttributes)

Parameters

extraAttributes Dictionary<string, string>

The extra attributes for this field wrapper.

Returns

T

The current instance of the T field.

SetExtraInputAttributes(Dictionary<string, string>)

Sets the extra attributes for this field.

public T SetExtraInputAttributes(Dictionary<string, string> extraInputAttributes)

Parameters

extraInputAttributes Dictionary<string, string>

The extra attributes for this field.

Returns

T

The current instance of the T field.

SetFillUsing(ActionFormWithRecord)

Sets the fill using function for the form field.

public T SetFillUsing(TrinityField<T, TDeserialization>.ActionFormWithRecord fillUsing)

Parameters

fillUsing TrinityField<T, TDeserialization>.ActionFormWithRecord

The fill using function to set.

Returns

T

The current instance of the T field.

SetFillUsing(ActionWithRecordProperty)

Sets the fill using property function for the form field.

public T SetFillUsing(TrinityField<T, TDeserialization>.ActionWithRecordProperty fillUsingProperty)

Parameters

fillUsingProperty TrinityField<T, TDeserialization>.ActionWithRecordProperty

The fill using property function to set.

Returns

T

The current instance of the T field.

SetFillUsingProperties(ActionWithRecordProperties)

Sets the fill using properties function for the form field.

public T SetFillUsingProperties(TrinityField<T, TDeserialization>.ActionWithRecordProperties fillUsingProperties)

Parameters

fillUsingProperties TrinityField<T, TDeserialization>.ActionWithRecordProperties

The fill using properties function to set.

Returns

T

The current instance of the T field.

SetFilterQueryUsing(Action<Query, string>)

Sets the filter query for the field using a callback function.

public void SetFilterQueryUsing(Action<Query, string> filter)

Parameters

filter Action<Query, string>

The callback function to use.

SetHelperText(string)

Sets the helper text for the input field.

public T SetHelperText(string helperText)

Parameters

helperText string

The text to be used as helper text.

Returns

T

The current instance of the T field.

SetInputType(string)

Sets the html input type of the field.

public T SetInputType(string inputType)

Parameters

inputType string

The html input type.

Returns

T

The current instance of the T field.

SetIsSavable(bool)

Sets a value indicating whether the input field should saved into the database or not.

public virtual T SetIsSavable(bool isSavable = true)

Parameters

isSavable bool

A value indicating whether the input field should saved into the database or not.

Returns

T

The current instance of the T field.

SetLocale(string)

Sets the locale to be used for the input field.

public T SetLocale(string locale)

Parameters

locale string

The locale to be used.

Returns

T

The current instance of the T field.

SetOnlyOnCreate(bool)

Sets a value indicating whether the input field should only be displayed on creation.

public T SetOnlyOnCreate(bool only = true)

Parameters

only bool

A value indicating whether the input field should only be displayed on creation.

Returns

T

The current instance of the T field.

SetOnlyOnUpdate(bool)

Sets a value indicating whether the input field should only be displayed on update.

public T SetOnlyOnUpdate(bool only = true)

Parameters

only bool

A value indicating whether the input field should only be displayed on update.

Returns

T

The current instance of the T field.

SetPlaceholder(string)

Sets the placeholder text for the input field.

public T SetPlaceholder(string placeholder)

Parameters

placeholder string

The text to be used as placeholder.

Returns

T

The current instance of the T field.

SetPrefixes(params string[])

Sets the prefixes of the field.

public T SetPrefixes(params string[] prefixes)

Parameters

prefixes string[]

An array of strings representing the prefixes to set.

Returns

T

The current instance of the T field.

SetPrefixIcons(params string[])

Sets the prefix icons of the field.

public T SetPrefixIcons(params string[] prefixIcons)

Parameters

prefixIcons string[]

An array of strings representing the prefix icons to set.

Returns

T

The current instance of the T field.

SetSelectQueryUsing(Action<Query>)

Sets the select query for the field using a callback function.

public void SetSelectQueryUsing(Action<Query> query)

Parameters

query Action<Query>

The callback function to use.

SetSuffixes(params string[])

Sets the suffixes of the field.

public T SetSuffixes(params string[] suffixes)

Parameters

suffixes string[]

An array of strings representing the suffixes to set.

Returns

T

The current instance of the T field.

SetSuffixIcons(params string[])

Sets the suffix icons of the field.

public T SetSuffixIcons(params string[] suffixIcons)

Parameters

suffixIcons string[]

An array of strings representing the suffix icons to set.

Returns

T

The current instance of the T field.

SetTitle(string)

Sets the title of the form field.

public T SetTitle(string value)

Parameters

value string

The title to set.

Returns

T

The current instance of the T field.

SetValidateUsing(ValidateUsingDelegate)

Sets the validation delegate for the Trinity field.

public virtual T SetValidateUsing(TrinityField<T, TDeserialization>.ValidateUsingDelegate validateUsingCallback)

Parameters

validateUsingCallback TrinityField<T, TDeserialization>.ValidateUsingDelegate

The validation delegate to set.

Returns

T

The current instance of the T field.

SetValidationRules(Action<IRuleBuilderInitial<Dictionary<string, object?>, TDeserialization?>>)

Sets the validation rules for the Trinity field.

public virtual T SetValidationRules(Action<IRuleBuilderInitial<Dictionary<string, object?>, TDeserialization?>> rules)

Parameters

rules Action<IRuleBuilderInitial<Dictionary<string, object>, TDeserialization>>

The action to apply validation rules.

Returns

T

The current instance of the T field.