Skip to content

Commit

Permalink
New SetTextArea method for the column definition
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavnavar committed Mar 17, 2022
1 parent 6ff10ca commit 189cdf6
Show file tree
Hide file tree
Showing 26 changed files with 89 additions and 27 deletions.
13 changes: 13 additions & 0 deletions GridBlazor/Columns/GridColumnBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public abstract class GridColumnBase<T> : GridStyledColumn, IGridColumn<T>, IExp

public InputType InputType { get; protected set; }

public int TextAreaRows { get; set; } = 5;

public bool MultipleInput { get; protected set; } = false;

public bool ToggleSwitch { get; protected set; } = false;
Expand Down Expand Up @@ -625,6 +627,17 @@ public IGridColumn<T> SetInputType(InputType inputType)
return this;
}

public IGridColumn<T> SetTextArea()
{
return SetInputType(InputType.TextArea);
}

public IGridColumn<T> SetTextArea(int rows)
{
TextAreaRows = rows;
return SetTextArea();
}

public IGridColumn<T> SetInputFileType(bool? multiple = null)
{
IsSelectField = (false, null, null, null, null);
Expand Down
4 changes: 2 additions & 2 deletions GridBlazor/GridBlazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<LangVersion>8.0</LangVersion>
<GenerateEmbeddedFilesManifest>True</GenerateEmbeddedFilesManifest>
<EnableDefaultEmbeddedResourceItems>False</EnableDefaultEmbeddedResourceItems>
<Version>3.2.1</Version>
<Version>3.2.2</Version>
<Title>GridBlazor</Title>
<Description>Grid components for Blazor</Description>
<Summary>Grid components for Blazor</Summary>
Expand Down Expand Up @@ -48,7 +48,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Agno.BlazorInputFile" Version="0.3.0" />
<PackageReference Include="Agno.BlazorInputFile" Version="0.4.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.11" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions GridBlazor/Pages/GridCreateComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</select>
<span class="field-validation-error">
<span>@ColumnErrors.Get(column.FieldName)</span>
</span>
</span>
}
}
else if (((IGridColumn<T>)column).IsSelectColumn.IsSelectKey)
Expand Down Expand Up @@ -147,7 +147,7 @@
}
else if (type == typeof(string) && ((IGridColumn<T>)column).InputType == InputType.TextArea)
{
<textarea id="@column.FieldName" name="@column.FieldName" class="form-control" rows="5" readonly="readonly" value="@column.GetFormatedValue(value)" />
<textarea id="@column.FieldName" name="@column.FieldName" class="form-control" rows="@column.TextAreaRows" readonly="readonly" value="@column.GetFormatedValue(value)" />
}
else
{
Expand All @@ -162,7 +162,7 @@
}
else if (type == typeof(string) && ((IGridColumn<T>)column).InputType == InputType.TextArea)
{
<textarea id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" rows="5" value="@column.GetFormatedValue(value)" @onchange="(e) => ChangeValue(e, column)" />
<textarea id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" rows="@column.TextAreaRows" value="@column.GetFormatedValue(value)" @onchange="(e) => ChangeValue(e, column)" />
}
else if (((IGridColumn<T>)column).InputType == InputType.File)
{
Expand Down
2 changes: 1 addition & 1 deletion GridBlazor/Pages/GridDeleteComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{
if (((IGridColumn<T>)column).InputType == InputType.TextArea)
{
<textarea id="@column.FieldName" class="form-control" rows="5" readonly="readonly" value="@column.GetFormatedValue(value)" />
<textarea id="@column.FieldName" class="form-control" rows="@column.TextAreaRows" readonly="readonly" value="@column.GetFormatedValue(value)" />
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion GridBlazor/Pages/GridReadComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
{
if (((IGridColumn<T>)column).InputType == InputType.TextArea)
{
<textarea id="@column.FieldName" class="form-control" rows="5" readonly="readonly" value="@column.GetFormatedValue(value)" />
<textarea id="@column.FieldName" class="form-control" rows="@column.TextAreaRows" readonly="readonly" value="@column.GetFormatedValue(value)" />
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions GridBlazor/Pages/GridUpdateComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
}
else if (type == typeof(string) && ((IGridColumn<T>)column).InputType == InputType.TextArea)
{
<textarea id="@column.FieldName" name="@column.FieldName" class="form-control" rows="5" readonly="readonly" value="@column.GetFormatedValue(value)" />
<textarea id="@column.FieldName" name="@column.FieldName" class="form-control" rows="@column.TextAreaRows" readonly="readonly" value="@column.GetFormatedValue(value)" />
}
else
{
Expand All @@ -162,7 +162,7 @@
{
if (type == typeof(string) && ((IGridColumn<T>)column).InputType == InputType.TextArea)
{
<textarea id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" rows="5" value="@column.GetFormatedValue(value)" @onchange="(e) => ChangeValue(e, column)" />
<textarea id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" rows="@column.TextAreaRows" value="@column.GetFormatedValue(value)" @onchange="(e) => ChangeValue(e, column)" />
}
else if (((IGridColumn<T>)column).InputType == InputType.File)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ public class ColumnCollections
c.Add(o => o.HomePhone, true);
c.Add(o => o.Extension, true);
c.Add(o => o.ReportsTo, true);
c.Add(o => o.Notes, true).SetInputType(InputType.TextArea);
c.Add(o => o.Notes, true).SetTextArea(8);
c.Add(o => o.PhotoPath, true);
c.Add(true, "PhotoFile").Titled("Photo").SetInputFileType();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>3.1.1</Version>
<Version>3.2.2</Version>
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion GridBlazorOData.Client/GridBlazorOData.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>3.1.1</Version>
<Version>3.2.2</Version>
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion GridBlazorOData.Client/Pages/EmployeeComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ else
c.Add(o => o.HomePhone, true);
c.Add(o => o.Extension, true);
c.Add(o => o.ReportsTo, true);
c.Add(o => o.Notes, true).SetInputType(InputType.TextArea);
c.Add(o => o.Notes, true).SetTextArea(8);
c.Add(o => o.PhotoPath, true);
c.Add(true, "PhotoFile").Titled("Photo").SetInputFileType();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ public class ColumnCollections
c.Add(o => o.HomePhone, true);
c.Add(o => o.Extension, true);
c.Add(o => o.ReportsTo, true);
c.Add(o => o.Notes, true).SetInputType(InputType.TextArea);
c.Add(o => o.Notes, true).SetTextArea(8);
c.Add(o => o.PhotoPath, true);
c.Add(true, "PhotoFile").Titled("Photo").SetInputFileType();
};
Expand Down
2 changes: 1 addition & 1 deletion GridBlazorServerSide/GridBlazorServerSide.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>3.1.1</Version>
<Version>3.2.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ public class ColumnCollections
c.Add(o => o.HomePhone, true);
c.Add(o => o.Extension, true);
c.Add(o => o.ReportsTo, true);
c.Add(o => o.Notes, true).SetInputType(InputType.TextArea);
c.Add(o => o.Notes, true).SetTextArea(8);
c.Add(o => o.PhotoPath, true);
c.Add(true, "PhotoFile").Titled("Photo").SetInputFileType();
};
Expand Down
2 changes: 1 addition & 1 deletion GridBlazorStandalone/GridBlazorStandalone.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>3.1.1</Version>
<Version>3.2.2</Version>
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
</PropertyGroup>

Expand Down
13 changes: 13 additions & 0 deletions GridCore/Columns/GridCoreColumnBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public abstract class GridCoreColumnBase<T> : GridStyledColumn, IGridColumn<T>,

public InputType InputType { get; protected set; }

public int TextAreaRows { get; set; } = 5;

public bool MultipleInput { get; protected set; } = false;

public bool ToggleSwitch { get; protected set; } = false;
Expand Down Expand Up @@ -628,6 +630,17 @@ public IGridColumn<T> SetInputType(InputType inputType)
return this;
}

public IGridColumn<T> SetTextArea()
{
return SetInputType(InputType.TextArea);
}

public IGridColumn<T> SetTextArea(int rows)
{
TextAreaRows = rows;
return SetTextArea();
}

public IGridColumn<T> SetInputFileType(bool? multiple = null)
{
IsSelectField = (false, null, null, null, null);
Expand Down
2 changes: 1 addition & 1 deletion GridCore/GridCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<EnableDefaultEmbeddedResourceItems>False</EnableDefaultEmbeddedResourceItems>
<Product>GridCore</Product>
<PackageId>GridCore</PackageId>
<Version>5.2.1</Version>
<Version>5.2.2</Version>
<Title>GridCore</Title>
<Description>Grid core component</Description>
<Summary>Grid core component</Summary>
Expand Down
2 changes: 1 addition & 1 deletion GridMvc.Demo/BlazorComponents/EmployeeComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ else
c.Add(o => o.HomePhone, true);
c.Add(o => o.Extension, true);
c.Add(o => o.ReportsTo, true);
c.Add(o => o.Notes, true).SetInputType(InputType.TextArea);
c.Add(o => o.Notes, true).SetTextArea(8);
c.Add(o => o.PhotoPath, true);
c.Add(true, "PhotoFile").Titled("Photo").SetInputFileType();
};
Expand Down
2 changes: 1 addition & 1 deletion GridMvc.Demo/GridMvc.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TypeScriptToolsVersion>3.1</TypeScriptToolsVersion>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<Version>5.0.3</Version>
<Version>5.2.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion GridMvc/GridMvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<EnableDefaultEmbeddedResourceItems>False</EnableDefaultEmbeddedResourceItems>
<Product>GridMvc</Product>
<PackageId>GridMvcCore</PackageId>
<Version>5.2.1</Version>
<Version>5.2.2</Version>
<Title>GridMvc</Title>
<Description>ASP.NET MVC Grid component</Description>
<Summary>ASP.NET MVC Grid component</Summary>
Expand Down
11 changes: 11 additions & 0 deletions GridShared/Columns/IGridColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public interface IGridColumn : ISortableColumn, IFilterableColumn
string TrueLabel { get; }
string FalseLabel { get; }
InputType InputType { get; }
int TextAreaRows { get; }
void SetGroupLabel(Func<object, Task<string>> function);
}

Expand Down Expand Up @@ -424,6 +425,16 @@ public interface IColumn<T>
/// </summary>
IGridColumn<T> SetInputType(InputType inputType);

/// <summary>
/// Sets the column input type to type area for CRUD components
/// </summary>
IGridColumn<T> SetTextArea();

/// <summary>
/// Sets the column input type type area for CRUD components
/// </summary>
IGridColumn<T> SetTextArea(int rows);

/// <summary>
/// Sets the column input type for CRUD components
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion GridShared/GridShared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.1;net5.0;net6.0</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<Version>5.2.1</Version>
<Version>5.2.2</Version>
<Title>GridShared</Title>
<Description>Support library for GridBlazor and GridMvcCore component libraries</Description>
<Summary>Support library for GridBlazor and GridMvcCore component libraries</Summary>
Expand Down
7 changes: 6 additions & 1 deletion docs/blazor_client/Crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,18 @@ You can also configure the "read only on create" and/or "read only on update" be

If a column is a date that has to be shown as ```date```, ```time```, ```week```, ```month``` or ```datetime-local``` in the CRUD forms, the column definition should use the **SetInputType** method in order to get the correct format.

If a column is a string that has to be shown as ```<textarea>``` in the CRUD forms, the column definition should use the **SetInputType** method in order to get the correct html element.
If a column is a string that has to be shown as ```<textarea>``` in the CRUD forms, the column definition should use the **SetTextArea** or the **SetInputType** method in order to get the correct html element.

The **SetInputType** method has 1 required parameter:
Parameter | Description
--------- | -----------
inputType | ```InputType``` enum. Its value can be ```InputType.TextArea```, ```InputType.Date```, ```InputType.Time```, ```InputType.Month```, ```InputType.Week``` or ```InputType.DateTimeLocal```

The **SetTextArea** method has 1 optional parameter:
Parameter | Description
--------- | -----------
rows | integer to select the number or rows of the ```<textarea>``` element

You can also add components on the CRUD forms using the ```RenderCrudComponentAs<TComponent>``` method. You must define these columns as **Hidden** to show them just on CRUD forms.

You can configure the width of the column input element using the ```SetCrudWidth(int width)``` and ```SetCrudWidth(int width, int labelWidtth)``` methods. The default value for the column width is 5 and and for the label width is 2. You can configure them from 1 to 11, but the sum of both can not be more than 12.
Expand Down
7 changes: 6 additions & 1 deletion docs/blazor_local/Crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,18 @@ You can also configure the "read only on create" and/or "read only on update" be

If a column is a date that has to be shown as ```date```, ```time```, ```week```, ```month``` or ```datetime-local``` in the CRUD forms, the column definition should use the **SetInputType** method in order to get the correct format.

If a column is a string that has to be shown as ```<textarea>``` in the CRUD forms, the column definition should use the **SetInputType** method in order to get the correct html element.
If a column is a string that has to be shown as ```<textarea>``` in the CRUD forms, the column definition should use the **SetTextArea** or the **SetInputType** method in order to get the correct html element.

The **SetInputType** method has 1 required parameter:
Parameter | Description
--------- | -----------
inputType | ```InputType``` enum. Its value can be ```InputType.TextArea```, ```InputType.Date```, ```InputType.Time```, ```InputType.Month```, ```InputType.Week``` or ```InputType.DateTimeLocal```

The **SetTextArea** method has 1 optional parameter:
Parameter | Description
--------- | -----------
rows | integer to select the number or rows of the ```<textarea>``` element

You can also add components on the CRUD forms using the ```RenderCrudComponentAs<TComponent>``` method. You must define these columns as **Hidden** to show them just on CRUD forms.

You can configure the width of the column input element using the ```SetCrudWidth(int width)``` and ```SetCrudWidth(int width, int labelWidtth)``` methods. The default value for the column width is 5 and and for the label width is 2. You can configure them from 1 to 11, but the sum of both can not be more than 12.
Expand Down
7 changes: 6 additions & 1 deletion docs/blazor_odata/Crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,18 @@ You can also configure the "read only on create" and/or "read only on update" be

If a column is a date that has to be shown as ```date```, ```time```, ```week```, ```month``` or ```datetime-local``` in the CRUD forms, the column definition should use the **SetInputType** method in order to get the correct format.

If a column is a string that has to be shown as ```<textarea>``` in the CRUD forms, the column definition should use the **SetInputType** method in order to get the correct html element.
If a column is a string that has to be shown as ```<textarea>``` in the CRUD forms, the column definition should use the **SetTextArea** or the **SetInputType** method in order to get the correct html element.

The **SetInputType** method has 1 required parameter:
Parameter | Description
--------- | -----------
inputType | ```InputType``` enum. Its value can be ```InputType.TextArea```, ```InputType.Date```, ```InputType.Time```, ```InputType.Month```, ```InputType.Week``` or ```InputType.DateTimeLocal```

The **SetTextArea** method has 1 optional parameter:
Parameter | Description
--------- | -----------
rows | integer to select the number or rows of the ```<textarea>``` element

You can also add components on the CRUD forms using the ```RenderCrudComponentAs<TComponent>``` method. You must define these columns as **Hidden** to show them just on CRUD forms.

You can configure the width of the column input element using the ```SetCrudWidth(int width)``` and ```SetCrudWidth(int width, int labelWidtth)``` methods. The default value for the column width is 5 and and for the label width is 2. You can configure them from 1 to 11, but the sum of both can not be more than 12.
Expand Down
7 changes: 6 additions & 1 deletion docs/blazor_server/Crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,18 @@ You can also configure the "read only on create" and/or "read only on update" be

If a column is a date that has to be shown as ```date```, ```time```, ```week```, ```month``` or ```datetime-local``` in the CRUD forms, the column definition should use the **SetInputType** method in order to get the correct format.

If a column is a string that has to be shown as ```<textarea>``` in the CRUD forms, the column definition should use the **SetInputType** method in order to get the correct html element.
If a column is a string that has to be shown as ```<textarea>``` in the CRUD forms, the column definition should use the **SetTextArea** or the **SetInputType** method in order to get the correct html element.

The **SetInputType** method has 1 required parameter:
Parameter | Description
--------- | -----------
inputType | ```InputType``` enum. Its value can be ```InputType.TextArea```, ```InputType.Date```, ```InputType.Time```, ```InputType.Month```, ```InputType.Week``` or ```InputType.DateTimeLocal```

The **SetTextArea** method has 1 optional parameter:
Parameter | Description
--------- | -----------
rows | integer to select the number or rows of the ```<textarea>``` element

You can also add components on the CRUD forms using the ```RenderCrudComponentAs<TComponent>``` method. You must define these columns as **Hidden** to show them just on CRUD forms.

You can configure the width of the column input element using the ```SetCrudWidth(int width)``` and ```SetCrudWidth(int width, int labelWidtth)``` methods. The default value for the column width is 5 and and for the label width is 2. You can configure them from 1 to 11, but the sum of both can not be more than 12.
Expand Down
Loading

0 comments on commit 189cdf6

Please sign in to comment.