From 38a202bbc7b93a55d4c46dff09407ee47d9a85f1 Mon Sep 17 00:00:00 2001 From: Deep Choudhery <54324771+deepchoudhery@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:37:52 -0800 Subject: [PATCH] updates for razor pages crud and blazor crud templates (#3086) * updates for razor pages crud and blazor crud templates * PR fixes --- eng/Versions.DotNetScaffold.props | 15 + scripts/install-scaffold-all.cmd | 25 + .../VS.Web.CG.Mvc/Templates/Blazor/Create.cs | 10 +- .../VS.Web.CG.Mvc/Templates/Blazor/Create.tt | 8 +- .../VS.Web.CG.Mvc/Templates/Blazor/Edit.cs | 10 +- .../VS.Web.CG.Mvc/Templates/Blazor/Edit.tt | 8 +- .../Bootstrap5/Create.cshtml | 13 +- .../RazorPageGenerator/Bootstrap5/Edit.cshtml | 13 +- .../Templates/BlazorCrud/Create.cs | 473 ++++++++++++++++ .../Templates/BlazorCrud/Create.tt | 80 +++ .../Templates/BlazorCrud/Edit.cs | 529 ++++++++++++++++++ .../Templates/BlazorCrud/Edit.tt | 129 +++++ .../Templates/RazorPages/Create.cs | 447 +++++++++++++++ .../Templates/RazorPages/Create.tt | 64 +++ .../Templates/RazorPages/Edit.cs | 451 +++++++++++++++ .../Templates/RazorPages/Edit.tt | 65 +++ 16 files changed, 2316 insertions(+), 24 deletions(-) create mode 100644 eng/Versions.DotNetScaffold.props create mode 100644 scripts/install-scaffold-all.cmd create mode 100644 src/dotnet-scaffolding/dotnet-scaffold-aspnet/Templates/BlazorCrud/Create.cs create mode 100644 src/dotnet-scaffolding/dotnet-scaffold-aspnet/Templates/BlazorCrud/Create.tt create mode 100644 src/dotnet-scaffolding/dotnet-scaffold-aspnet/Templates/BlazorCrud/Edit.cs create mode 100644 src/dotnet-scaffolding/dotnet-scaffold-aspnet/Templates/BlazorCrud/Edit.tt create mode 100644 src/dotnet-scaffolding/dotnet-scaffold-aspnet/Templates/RazorPages/Create.cs create mode 100644 src/dotnet-scaffolding/dotnet-scaffold-aspnet/Templates/RazorPages/Create.tt create mode 100644 src/dotnet-scaffolding/dotnet-scaffold-aspnet/Templates/RazorPages/Edit.cs create mode 100644 src/dotnet-scaffolding/dotnet-scaffold-aspnet/Templates/RazorPages/Edit.tt diff --git a/eng/Versions.DotNetScaffold.props b/eng/Versions.DotNetScaffold.props new file mode 100644 index 000000000..c49807c67 --- /dev/null +++ b/eng/Versions.DotNetScaffold.props @@ -0,0 +1,15 @@ + + + +9.0.0 + preview + 10 + False + true + + false + release + + diff --git a/scripts/install-scaffold-all.cmd b/scripts/install-scaffold-all.cmd new file mode 100644 index 000000000..b1533c7ec --- /dev/null +++ b/scripts/install-scaffold-all.cmd @@ -0,0 +1,25 @@ +set VERSION=10.0.0-dev +set DEFAULT_NUPKG_PATH=%userprofile%/.nuget/packages +set SRC_DIR=%cd% +set NUPKG=artifacts/packages/Debug/Shipping/ +call taskkill /f /im dotnet.exe +call rd /Q /S artifacts +call dotnet pack src\dotnet-scaffolding\dotnet-scaffold\dotnet-scaffold.csproj -c Debug +call dotnet pack src\dotnet-scaffolding\dotnet-scaffold-aspire\dotnet-scaffold-aspire.csproj -c Debug +call dotnet pack src\dotnet-scaffolding\dotnet-scaffold-aspnet\dotnet-scaffold-aspnet.csproj -c Debug +call dotnet tool uninstall -g Microsoft.dotnet-scaffold +call dotnet tool uninstall -g Microsoft.dotnet-scaffold-aspire +call dotnet tool uninstall -g Microsoft.dotnet-scaffold-aspnet + +call cd %DEFAULT_NUPKG_PATH% +call rd /Q /S Microsoft.dotnet-scaffold +call rd /Q /S Microsoft.dotnet-scaffold-aspire +call rd /Q /S Microsoft.dotnet-scaffold-aspnet +call rd /Q /S Microsoft.DotNet.Scaffolding.Internal +call rd /Q /S Microsoft.DotNet.Scaffolding.Core + +call cd %SRC_DIR%/%NUPKG% +call dotnet tool install -g Microsoft.dotnet-scaffold --add-source %SRC_DIR%\%NUPKG% --version %VERSION% +call dotnet tool install -g Microsoft.dotnet-scaffold-aspire --add-source %SRC_DIR%\%NUPKG% --version %VERSION% +call dotnet tool install -g Microsoft.dotnet-scaffold-aspnet --add-source %SRC_DIR%\%NUPKG% --version %VERSION% +call cd %SRC_DIR% diff --git a/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Create.cs b/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Create.cs index a485b29ac..25d2be790 100644 --- a/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Create.cs +++ b/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Create.cs @@ -68,9 +68,13 @@ public virtual string TransformText() string propertyShortTypeName = property.ShortTypeName.Replace("?", string.Empty); var inputTypeName = Model.GetInputType(propertyShortTypeName); var inputClass = Model.GetInputClassType(propertyShortTypeName); - var requiredAttributeHtml = property.IsRequired ? "aria-required=\"true\"" : string.Empty; + var ariaRequiredAttributeHtml = property.IsRequired ? "aria-required=\"true\"" : string.Empty; + var divWhitespace = new string(' ', 16); + var requiredSpanAttributeHtml = property.IsRequired ? $"\r\n{divWhitespace}*" : string.Empty; - this.Write("
\r\n