From bb34ad7e33f8bfb015c3e17755029bfd66af014d Mon Sep 17 00:00:00 2001 From: akdalin Date: Thu, 8 May 2025 14:56:16 +0100 Subject: [PATCH] Replace URLs with ASP attributes where necessary. Add XML documentation. Minor corrections. --- .../BreadcrumbsViewComponent.cs | 7 +--- .../ViewComponents/ButtonViewComponent.cs | 20 +++-------- .../ViewComponents/CardViewComponent.cs | 21 ++++------- .../CharacterCountViewComponent.cs | 14 +------- .../ContentsListViewComponent.cs | 9 ++--- .../ViewComponents/DetailsViewComponent.cs | 8 +---- .../ViewComponents/DoDontListViewComponent.cs | 3 ++ .../ViewComponents/FooterViewComponent.cs | 3 ++ .../ViewComponents/ImageViewComponent.cs | 3 ++ .../ViewComponents/InsetTextViewComponent.cs | 3 ++ .../ViewComponents/PaginationViewComponent.cs | 3 ++ .../ViewComponents/SkipLinkViewComponent.cs | 3 ++ .../SummaryListViewComponent.cs | 3 ++ .../ViewComponents/TableViewComponent.cs | 3 ++ .../ViewComponents/TabsViewComponent.cs | 3 ++ .../ViewComponents/TagViewComponent.cs | 3 ++ .../ViewComponents/TaskListViewComponent.cs | 3 ++ .../ViewModels/BreadcrumbsViewModel.cs | 11 ++++-- .../ViewModels/ButtonViewModel.cs | 14 ++++---- .../ViewModels/CardViewModel.cs | 36 +++++++++++++------ .../ViewModels/CharacterCountViewModel.cs | 12 +++---- .../ViewModels/ContentListItemViewModel.cs | 29 ++++++++++----- .../ViewModels/ContentsListViewModel.cs | 3 -- .../ViewModels/DetailsViewModel.cs | 3 -- .../ViewModels/DoDontListViewModel.cs | 11 ++++++ .../ViewModels/FooterItemViewModel.cs | 33 +++++++++++++++-- .../ViewModels/FooterViewModel.cs | 26 ++++++++++++++ .../ViewModels/ImageViewModel.cs | 21 ++++++++++- .../ViewModels/InsetTextViewModel.cs | 7 ++++ .../ViewModels/PaginationViewModel.cs | 11 +++--- .../ViewModels/SkipLinkViewModel.cs | 11 ++++++ .../ViewModels/SummaryListItemViewModel.cs | 35 +++++++++++++++--- .../ViewModels/SummaryListViewModel.cs | 11 ++++++ .../ViewModels/TableViewModel.cs | 34 ++++++++++++++++-- .../ViewModels/TabsViewModel.cs | 27 ++++++++++++++ .../ViewModels/TagViewModel.cs | 13 ++++++- .../Components/Breadcrumbs/Default.cshtml | 6 ++-- .../Shared/Components/Card/Default.cshtml | 7 ++-- .../Components/ContentsList/Default.cshtml | 2 +- .../Shared/Components/Footer/Default.cshtml | 2 +- 40 files changed, 349 insertions(+), 128 deletions(-) diff --git a/DotnetViewComponents/ViewComponents/BreadcrumbsViewComponent.cs b/DotnetViewComponents/ViewComponents/BreadcrumbsViewComponent.cs index a06f3292fa..dc6f92fc08 100644 --- a/DotnetViewComponents/ViewComponents/BreadcrumbsViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/BreadcrumbsViewComponent.cs @@ -9,12 +9,7 @@ namespace DotnetViewComponents.ViewComponents /// public class BreadcrumbsViewComponent : ViewComponent { - /// - /// Invokes the ViewComponent and returns the view with the breadcrumb model. - /// - /// A list of tuples representing the breadcrumb links where each tuple contains a title and a URL. - /// An that renders the breadcrumb view. - public IViewComponentResult Invoke(List<(string Title, string Url)> links) + public IViewComponentResult Invoke(List<(string Title, string spController, string aspAction, Dictionary? aspRouteData)> links) { var model = new BreadcrumbsViewModel(links); diff --git a/DotnetViewComponents/ViewComponents/ButtonViewComponent.cs b/DotnetViewComponents/ViewComponents/ButtonViewComponent.cs index d03162ec02..bb7c0f38b7 100644 --- a/DotnetViewComponents/ViewComponents/ButtonViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/ButtonViewComponent.cs @@ -4,29 +4,17 @@ namespace DotnetViewComponents.ViewComponents using DotnetViewComponents.ViewModels; /// - /// Represents a view component for rendering a button. + /// A ViewComponent that renders a button. /// public class ButtonViewComponent : ViewComponent { - /// - /// Invokes the button view component with the specified parameters. - /// - /// The text to be displayed on the button. - /// The asp-controller to dynamically set the controller path of the link. - /// The asp-action to dynamically set the action path of the link.. - /// The asp-all-route-data to dynamically set the extra parameters to the path of the link. - /// The url for the link. - /// The style attributes for the button.The style attributes for the button. - /// The styling class for the button. Receives predefined styles from . Defaults to if no input is passed to it. - /// Indicates whether to prevent double-clicking the button. Defaults to false. - /// An that renders the button view. public IViewComponentResult Invoke( string text, string style, string styling = ButtonStyle.PRIMARY, - string aspController = null, - string aspAction = null, - Dictionary aspRouteData = null, + string? aspController = null, + string? aspAction = null, + Dictionary? aspRouteData = null, bool preventDoubleClick = false) { var model = new ButtonViewModel(text, aspController, aspAction, aspRouteData, styling, style, preventDoubleClick); diff --git a/DotnetViewComponents/ViewComponents/CardViewComponent.cs b/DotnetViewComponents/ViewComponents/CardViewComponent.cs index 2b4b3a8e98..f16e755306 100644 --- a/DotnetViewComponents/ViewComponents/CardViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/CardViewComponent.cs @@ -4,21 +4,10 @@ namespace DotnetViewComponents.ViewComponents using DotnetViewComponents.ViewModels; /// - /// Represents a view component for rendering a card. + /// A ViewComponent that renders a card component. /// public class CardViewComponent : ViewComponent { - /// - /// Invokes the card view component with the specified parameters. - /// - /// The title of the card. - /// The content description of the card. Optional. - /// The source URL of the image to be displayed on the card. Optional. - /// The HTML heading level for the title. Defaults to 2, which results in h2. - /// Indicates whether the card should display an arrow. Defaults to false. - /// Indicates whether the card is styled as a secondary card. Defaults to false. - /// Indicates whether the card is clickable. Defaults to true. - /// An that renders the card view. public IViewComponentResult Invoke( string title, string? description = null, @@ -26,7 +15,9 @@ public IViewComponentResult Invoke( int headingLevel = 2, bool hasArrow = false, bool isSecondary = false, - bool isClickable = true) + string? aspController = null, + string? aspAction = null, + Dictionary? aspRouteData = null) { var model = new CardViewModel ( @@ -36,7 +27,9 @@ public IViewComponentResult Invoke( headingLevel, hasArrow, isSecondary, - isClickable + aspController, + aspAction, + aspRouteData ); return View(model); } diff --git a/DotnetViewComponents/ViewComponents/CharacterCountViewComponent.cs b/DotnetViewComponents/ViewComponents/CharacterCountViewComponent.cs index e97d595d3d..c8536aae60 100644 --- a/DotnetViewComponents/ViewComponents/CharacterCountViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/CharacterCountViewComponent.cs @@ -4,22 +4,10 @@ namespace DotnetViewComponents.ViewComponents using DotnetViewComponents.ViewModels; /// - /// Represents a view component for rendering a character-count input. + /// A ViewComponent that renders a character-count input. /// public class CharacterCountViewComponent : ViewComponent { - /// - /// Invokes the character count view component with the specified parameters. - /// - /// The unique identifier for the character count component. - /// The maximum number of characters allowed. - /// The optional maximum number of words allowed. Defaults to null. - /// The optional threshold for character count warnings. Defaults to null. - /// The label for the character count component. Optional. - /// A hint or instruction for the user. Defaults to a predefined message. - /// An optional error message to display when validation fails. Defaults to null. - /// Indicates whether there is a validation error. Defaults to false. - /// An that renders the character count view. public IViewComponentResult Invoke( string id, int maxLength, diff --git a/DotnetViewComponents/ViewComponents/ContentsListViewComponent.cs b/DotnetViewComponents/ViewComponents/ContentsListViewComponent.cs index f95e447756..ffb5698188 100644 --- a/DotnetViewComponents/ViewComponents/ContentsListViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/ContentsListViewComponent.cs @@ -4,14 +4,11 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders a list of contents based on the provided name and list of content items. + /// public class ContentsListViewComponent : ViewComponent { - /// - /// Invokes the contents list view component with the specified parameters. - /// - /// The title of the contents list. - /// The set of items in the contents list. - /// An that renders the contents-list view. public IViewComponentResult Invoke( string name, IEnumerable listItems) diff --git a/DotnetViewComponents/ViewComponents/DetailsViewComponent.cs b/DotnetViewComponents/ViewComponents/DetailsViewComponent.cs index 4a742fd709..ec23718a87 100644 --- a/DotnetViewComponents/ViewComponents/DetailsViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/DetailsViewComponent.cs @@ -4,16 +4,10 @@ namespace DotnetViewComponents.ViewComponents using DotnetViewComponents.ViewModels; /// - /// Represents a view component that displays details using a summary and content. + /// A ViewComponent that displays details using a summary and content. /// public class DetailsViewComponent : ViewComponent { - /// - /// Invokes the view component with the specified summary and content. - /// - /// The summary to be displayed. - /// The content to displayed. - /// An that renders details view. public IViewComponentResult Invoke( string summary, string content diff --git a/DotnetViewComponents/ViewComponents/DoDontListViewComponent.cs b/DotnetViewComponents/ViewComponents/DoDontListViewComponent.cs index f01a665bcf..9b76c7d3bb 100644 --- a/DotnetViewComponents/ViewComponents/DoDontListViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/DoDontListViewComponent.cs @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders a "Do" or "Don't" list based on the provided rules. + /// public class DoDontListViewComponent : ViewComponent { public IViewComponentResult Invoke( diff --git a/DotnetViewComponents/ViewComponents/FooterViewComponent.cs b/DotnetViewComponents/ViewComponents/FooterViewComponent.cs index 5b361d6496..503eefd93e 100644 --- a/DotnetViewComponents/ViewComponents/FooterViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/FooterViewComponent.cs @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders a footer with links. + /// public class FooterViewComponent : ViewComponent { public IViewComponentResult Invoke( diff --git a/DotnetViewComponents/ViewComponents/ImageViewComponent.cs b/DotnetViewComponents/ViewComponents/ImageViewComponent.cs index 1484f879d8..9e1859044f 100644 --- a/DotnetViewComponents/ViewComponents/ImageViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/ImageViewComponent.cs @@ -3,6 +3,9 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders an image with a caption and optional attributes. + /// public class ImageViewComponent : ViewComponent { public IViewComponentResult Invoke( diff --git a/DotnetViewComponents/ViewComponents/InsetTextViewComponent.cs b/DotnetViewComponents/ViewComponents/InsetTextViewComponent.cs index 6601fcf6c8..9c9c537b5d 100644 --- a/DotnetViewComponents/ViewComponents/InsetTextViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/InsetTextViewComponent.cs @@ -3,6 +3,9 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders inset text based on the provided HTML content. + /// public class InsetTextViewComponent : ViewComponent { public IViewComponentResult Invoke(string contentHtml) diff --git a/DotnetViewComponents/ViewComponents/PaginationViewComponent.cs b/DotnetViewComponents/ViewComponents/PaginationViewComponent.cs index 8bd8d2fd6d..27b7458941 100644 --- a/DotnetViewComponents/ViewComponents/PaginationViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/PaginationViewComponent.cs @@ -3,6 +3,9 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders pagination controls based on the current page and total pages. + /// public class PaginationViewComponent : ViewComponent { public IViewComponentResult Invoke( diff --git a/DotnetViewComponents/ViewComponents/SkipLinkViewComponent.cs b/DotnetViewComponents/ViewComponents/SkipLinkViewComponent.cs index fe76d297a0..27c1b3f429 100644 --- a/DotnetViewComponents/ViewComponents/SkipLinkViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/SkipLinkViewComponent.cs @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders a skip link to allow users to jump to the main content of a page. + /// public class SkipLinkViewComponent : ViewComponent { public IViewComponentResult Invoke( diff --git a/DotnetViewComponents/ViewComponents/SummaryListViewComponent.cs b/DotnetViewComponents/ViewComponents/SummaryListViewComponent.cs index 8e97acf339..55b98aa29d 100644 --- a/DotnetViewComponents/ViewComponents/SummaryListViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/SummaryListViewComponent.cs @@ -3,6 +3,9 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders a list of summary items with an optional border. + /// public class SummaryListViewComponent : ViewComponent { public IViewComponentResult Invoke(IEnumerable summaryListItem, diff --git a/DotnetViewComponents/ViewComponents/TableViewComponent.cs b/DotnetViewComponents/ViewComponents/TableViewComponent.cs index 2455830f82..3fd85cb93b 100644 --- a/DotnetViewComponents/ViewComponents/TableViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/TableViewComponent.cs @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders a table based on the provided title and rows of data. + /// public class TableViewComponent : ViewComponent { public IViewComponentResult Invoke( diff --git a/DotnetViewComponents/ViewComponents/TabsViewComponent.cs b/DotnetViewComponents/ViewComponents/TabsViewComponent.cs index 30b6dd0faa..7787e3b219 100644 --- a/DotnetViewComponents/ViewComponents/TabsViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/TabsViewComponent.cs @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders a set of tabs based on the provided title and list of tabs. + /// public class TabsViewComponent : ViewComponent { public IViewComponentResult Invoke( diff --git a/DotnetViewComponents/ViewComponents/TagViewComponent.cs b/DotnetViewComponents/ViewComponents/TagViewComponent.cs index 90c546f015..b521736bad 100644 --- a/DotnetViewComponents/ViewComponents/TagViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/TagViewComponent.cs @@ -3,6 +3,9 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders a tag based on the provided name and styling. + /// public class TagViewComponent : ViewComponent { public IViewComponentResult Invoke( diff --git a/DotnetViewComponents/ViewComponents/TaskListViewComponent.cs b/DotnetViewComponents/ViewComponents/TaskListViewComponent.cs index 6f4f3a7811..5464ad7740 100644 --- a/DotnetViewComponents/ViewComponents/TaskListViewComponent.cs +++ b/DotnetViewComponents/ViewComponents/TaskListViewComponent.cs @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents using Microsoft.AspNetCore.Mvc; using DotnetViewComponents.ViewModels; + /// + /// A ViewComponent that renders a list of tasks based on the provided list of task items. + /// public class TaskListViewComponent : ViewComponent { public IViewComponentResult Invoke( diff --git a/DotnetViewComponents/ViewModels/BreadcrumbsViewModel.cs b/DotnetViewComponents/ViewModels/BreadcrumbsViewModel.cs index 265dea886b..8a985c45d8 100644 --- a/DotnetViewComponents/ViewModels/BreadcrumbsViewModel.cs +++ b/DotnetViewComponents/ViewModels/BreadcrumbsViewModel.cs @@ -6,13 +6,18 @@ public class BreadcrumbsViewModel /// Initializes a new instance of the class. /// It receives a list of of string tuples containing the name/title of the link and the url path to it. /// - /// A list of tuples representing the breadcrumb links where each tuple contains a title and a URL. - public BreadcrumbsViewModel(List<(string Title, string Url)> links) + /// A list of tuples representing the breadcrumb links where each tuple contains a title + /// and a URL in the form of asp-controller, asp-action and asp-routeData. + public BreadcrumbsViewModel(List<(string title, string aspController, string aspAction, Dictionary? aspRouteData)> links) { Links = links; } - public List<(string Title, string Url)> Links { get; set; } + /// + /// Gets or sets the list of breadcrumb links. + /// Each link is represented as a tuple containing the title, ASP.NET controller, ASP.NET action, and optional route data. + /// + public List<(string Title, string aspController, string aspAction, Dictionary? aspRouteData)> Links { get; set; } } } diff --git a/DotnetViewComponents/ViewModels/ButtonViewModel.cs b/DotnetViewComponents/ViewModels/ButtonViewModel.cs index 583bc333c9..8426d92bb1 100644 --- a/DotnetViewComponents/ViewModels/ButtonViewModel.cs +++ b/DotnetViewComponents/ViewModels/ButtonViewModel.cs @@ -15,9 +15,9 @@ public class ButtonViewModel /// Indicates whether to prevent double-clicking the button. Defaults to false. public ButtonViewModel( string text, - string aspController, - string aspAction, - Dictionary aspRouteData, + string? aspController, + string? aspAction, + Dictionary? aspRouteData, string styling, string style, bool preventDoubleClick) @@ -39,17 +39,17 @@ public ButtonViewModel( /// /// Gets or sets the asp-controller of the link. /// - public string AspController { get; set; } + public string? AspController { get; set; } /// - /// Gets or sets the as-action of the link. + /// Gets or sets the asp-action of the link. /// - public string AspAction { get; set; } + public string? AspAction { get; set; } /// /// Gets or sets the asp-all-route-data of the link. /// - public Dictionary AspRouteData { get; set; } + public Dictionary? AspRouteData { get; set; } /// /// Gets or sets the styling for the button. diff --git a/DotnetViewComponents/ViewModels/CardViewModel.cs b/DotnetViewComponents/ViewModels/CardViewModel.cs index bff7754225..ae0445cbca 100644 --- a/DotnetViewComponents/ViewModels/CardViewModel.cs +++ b/DotnetViewComponents/ViewModels/CardViewModel.cs @@ -12,15 +12,19 @@ public class CardViewModel /// The HTML heading level for the title. Defaults to 2, which results in h2. /// Indicates whether the card should display an arrow. Defaults to false. /// Indicates whether the card is styled as a secondary card. Defaults to false. - /// Indicates whether the card is clickable. Defaults to true. + /// The asp-controller to dynamically set the controller path of the link. + /// The asp-action to dynamically set the action path of the link.. + /// The asp-all-route-data to dynamically set the extra parameters to the path of the link. public CardViewModel( string title, - string? description = null, - string? imageSrc = null, - int headingLevel = 2, - bool hasArrow = false, - bool isSecondary = false, - bool isClickable = true) + string? description, + string? imageSrc, + int headingLevel, + bool hasArrow, + bool isSecondary, + string? aspController, + string? aspAction, + Dictionary? aspRouteData) { Title = title; Description = description; @@ -28,7 +32,9 @@ public CardViewModel( HeadingLevel = headingLevel; HasArrow = hasArrow; IsSecondary = isSecondary; - IsClickable = isClickable; + AspController = aspController; + AspAction = aspAction; + AspRouteData = aspRouteData; } /// @@ -62,8 +68,18 @@ public CardViewModel( public bool IsSecondary { get; set; } /// - /// Gets or sets a value indicating whether the card is clickable. + /// Gets or sets the asp-controller of the link. /// - public bool IsClickable { get; set; } + public string? AspController { get; set; } + + /// + /// Gets or sets the asp-action of the link. + /// + public string? AspAction { get; set; } + + /// + /// Gets or sets the asp-all-route-data of the link. + /// + public Dictionary? AspRouteData { get; set; } } } diff --git a/DotnetViewComponents/ViewModels/CharacterCountViewModel.cs b/DotnetViewComponents/ViewModels/CharacterCountViewModel.cs index db36c6b9e6..07e2f80755 100644 --- a/DotnetViewComponents/ViewModels/CharacterCountViewModel.cs +++ b/DotnetViewComponents/ViewModels/CharacterCountViewModel.cs @@ -19,12 +19,12 @@ public class CharacterCountViewModel public CharacterCountViewModel( string id, int maxLength, - int? maxWords = null, - int? threshold = null, - string? label = null, - string hint = "Do not include personal information like your name, date of birth or NHS number.", - string? errorMessage = null, - bool hasError = false) + int? maxWords, + int? threshold, + string? label, + string hint, + string? errorMessage, + bool hasError) { Id = id; MaxLength = maxLength; diff --git a/DotnetViewComponents/ViewModels/ContentListItemViewModel.cs b/DotnetViewComponents/ViewModels/ContentListItemViewModel.cs index 4743e54389..e956644447 100644 --- a/DotnetViewComponents/ViewModels/ContentListItemViewModel.cs +++ b/DotnetViewComponents/ViewModels/ContentListItemViewModel.cs @@ -1,23 +1,26 @@ namespace DotnetViewComponents.ViewModels { - /// - /// Represents the view model for an individual item in a contents list. - /// public class ContentsListItemViewModel { /// /// Initializes a new instance of the class. /// /// The title of the contents-list item. - /// The URL associated with the contents-list item. + /// The asp-controller to dynamically set the controller path of the link. + /// The asp-action to dynamically set the action path of the link.. + /// The asp-all-route-data to dynamically set the extra parameters to the path of the link. /// Indicates whether the item is currently active. Defaults to false. public ContentsListItemViewModel( string title, - string url, + string aspController, + string aspAction, + Dictionary aspRouteData, bool isActive = false) { Title = title; - Url = url; + AspController = aspController; + AspAction = aspAction; + AspRouteData = aspRouteData; IsActive = isActive; } @@ -27,9 +30,19 @@ public ContentsListItemViewModel( public string Title { get; set; } /// - /// Gets or sets the URL associated with the contents-list item. + /// Gets or sets the asp-controller of the link. /// - public string Url { get; set; } + public string AspController { get; set; } + + /// + /// Gets or sets the as-action of the link. + /// + public string AspAction { get; set; } + + /// + /// Gets or sets the asp-all-route-data of the link. + /// + public Dictionary AspRouteData { get; set; } /// /// Gets or sets a value indicating whether the item is currently active. diff --git a/DotnetViewComponents/ViewModels/ContentsListViewModel.cs b/DotnetViewComponents/ViewModels/ContentsListViewModel.cs index 0e213e3f2d..6556376fb3 100644 --- a/DotnetViewComponents/ViewModels/ContentsListViewModel.cs +++ b/DotnetViewComponents/ViewModels/ContentsListViewModel.cs @@ -1,8 +1,5 @@ namespace DotnetViewComponents.ViewModels { - /// - /// Represents the view model for a contents list component. - /// public class ContentsListViewModel { /// diff --git a/DotnetViewComponents/ViewModels/DetailsViewModel.cs b/DotnetViewComponents/ViewModels/DetailsViewModel.cs index 65f05f0928..81f0e55bef 100644 --- a/DotnetViewComponents/ViewModels/DetailsViewModel.cs +++ b/DotnetViewComponents/ViewModels/DetailsViewModel.cs @@ -1,8 +1,5 @@ namespace DotnetViewComponents.ViewModels { - /// - /// Represents the details view model containing summary and content. - /// public class DetailsViewModel { /// diff --git a/DotnetViewComponents/ViewModels/DoDontListViewModel.cs b/DotnetViewComponents/ViewModels/DoDontListViewModel.cs index aec41a38c8..cf2e75daa3 100644 --- a/DotnetViewComponents/ViewModels/DoDontListViewModel.cs +++ b/DotnetViewComponents/ViewModels/DoDontListViewModel.cs @@ -2,6 +2,11 @@ namespace DotnetViewComponents.ViewModels { public class DoDontListViewModel { + /// + /// Initializes a new instance of the class. + /// + /// Indicates whether the list represents "Do" rules (true) or "Don't" rules (false). + /// A list of rules associated with the "Do" or "Don't" category. public DoDontListViewModel( bool isDo, List ruleSet) @@ -10,8 +15,14 @@ public DoDontListViewModel( RuleSet = ruleSet; } + /// + /// Gets or sets a value indicating whether the list represents "Do" rules. + /// public bool IsDo { get; set; } + /// + /// Gets or sets the list of rules associated with the "Do" or "Don't" category. + /// public List RuleSet { get; set; } } } diff --git a/DotnetViewComponents/ViewModels/FooterItemViewModel.cs b/DotnetViewComponents/ViewModels/FooterItemViewModel.cs index b21b82cbc6..c18a05de22 100644 --- a/DotnetViewComponents/ViewModels/FooterItemViewModel.cs +++ b/DotnetViewComponents/ViewModels/FooterItemViewModel.cs @@ -2,17 +2,44 @@ namespace DotnetViewComponents.ViewModels { public class FooterItemViewModel { + /// + /// Initializes a new instance of the class. + /// + /// The title of the footer item. + /// The ASP.NET controller for the link. + /// The ASP.NET action for the link. + /// A dictionary containing additional route data for the link. public FooterItemViewModel( string title, - string? url = "#") + string aspController, + string aspAction, + Dictionary aspRouteData) { Title = title; - Url = url; + AspController = aspController; + AspAction = aspAction; + AspRouteData = aspRouteData; } + /// + /// Gets or sets the title of the link. + /// public string Title { get; set; } - public string? Url { get; set; } + /// + /// Gets or sets the asp-controller of the link. + /// + public string AspController { get; set; } + + /// + /// Gets or sets the asp-action of the link. + /// + public string AspAction { get; set; } + + /// + /// Gets or sets the asp-all-route-data of the link. + /// + public Dictionary AspRouteData { get; set; } } } diff --git a/DotnetViewComponents/ViewModels/FooterViewModel.cs b/DotnetViewComponents/ViewModels/FooterViewModel.cs index 8ce3a94c73..ce00e8a5f4 100644 --- a/DotnetViewComponents/ViewModels/FooterViewModel.cs +++ b/DotnetViewComponents/ViewModels/FooterViewModel.cs @@ -2,6 +2,12 @@ namespace DotnetViewComponents.ViewModels { public class FooterViewModel { + /// + /// Initializes a new instance of the class. + /// + /// The copyright information to display in the footer. + /// A collection of footer item groups. + /// Indicates whether the footer items should be vertically aligned. Default is true. public FooterViewModel( string copyright, IEnumerable footerGroupList, @@ -12,10 +18,19 @@ public FooterViewModel( IsVerticallyAligned = isVerticallyAligned; } + /// + /// Gets or sets the copyright information displayed in the footer. + /// public string Copyright { get; set; } + /// + /// Gets or sets the list of footer item groups. + /// public IEnumerable FooterGroupList { get; set;} + /// + /// Gets or sets a value indicating whether the footer items are vertically aligned. + /// public bool IsVerticallyAligned { get; set; } } @@ -23,6 +38,11 @@ public FooterViewModel( public class FooterItemGroupModel { + /// + /// Initializes a new instance of the class. + /// + /// A collection of footer items in this group. + /// Indicates whether this group contains meta items. Default is false. public FooterItemGroupModel( IEnumerable footerItemList, bool isMeta = false) @@ -31,8 +51,14 @@ public FooterItemGroupModel( IsMeta = isMeta; } + /// + /// Gets or sets the list of footer items in this group. + /// public IEnumerable FooterItemList { get; set; } + /// + /// Gets or sets a value indicating whether this group contains meta items. + /// public bool IsMeta { get; set; } } diff --git a/DotnetViewComponents/ViewModels/ImageViewModel.cs b/DotnetViewComponents/ViewModels/ImageViewModel.cs index 205b6d0ed4..8dd137adda 100644 --- a/DotnetViewComponents/ViewModels/ImageViewModel.cs +++ b/DotnetViewComponents/ViewModels/ImageViewModel.cs @@ -2,11 +2,18 @@ namespace DotnetViewComponents.ViewModels { public class ImageViewModel { + /// + /// Initializes a new instance of the class. + /// + /// The source URL of the image. + /// The alternative text for the image, used for accessibility. + /// The caption to be displayed with the image. + /// Optional additional attributes for the image element. public ImageViewModel( string src, string alt, string caption, - string? additionalAttributes = null) + string? additionalAttributes) { Src = src; Alt = alt; @@ -14,12 +21,24 @@ public ImageViewModel( AdditionalAttributes = additionalAttributes; } + /// + /// Gets or sets the source URL of the image. + /// public string Src { get; set; } + /// + /// Gets or sets the alternative text for the image, used for accessibility. + /// public string Alt { get; set; } + /// + /// Gets or sets the caption to be displayed with the image. + /// public string Caption { get; set; } + /// + /// Gets or sets optional additional attributes for the image element. + /// public string? AdditionalAttributes { get; set; } } diff --git a/DotnetViewComponents/ViewModels/InsetTextViewModel.cs b/DotnetViewComponents/ViewModels/InsetTextViewModel.cs index e876077a9c..5477650ed3 100644 --- a/DotnetViewComponents/ViewModels/InsetTextViewModel.cs +++ b/DotnetViewComponents/ViewModels/InsetTextViewModel.cs @@ -2,11 +2,18 @@ namespace DotnetViewComponents.ViewModels { public class InsetTextViewModel { + /// + /// Initializes a new instance of the class. + /// + /// The HTML content to be displayed as inset text. public InsetTextViewModel(string contentHtml) { ContentHtml = contentHtml; } + /// + /// Gets or sets the HTML content to be displayed as inset text. + /// public string ContentHtml { get; set; } } } diff --git a/DotnetViewComponents/ViewModels/PaginationViewModel.cs b/DotnetViewComponents/ViewModels/PaginationViewModel.cs index 1d74286daf..6baa80321f 100644 --- a/DotnetViewComponents/ViewModels/PaginationViewModel.cs +++ b/DotnetViewComponents/ViewModels/PaginationViewModel.cs @@ -1,8 +1,5 @@ namespace DotnetViewComponents.ViewModels { - /// - /// Defines the . - /// public class PaginationViewModel { /// @@ -21,10 +18,10 @@ public PaginationViewModel() /// Next page url. public PaginationViewModel(int currentPage, int totalPage, string prevUrl, string nextUrl) { - this.CurrentPage = currentPage; - this.TotalPage = totalPage; - this.PreviousUrl = prevUrl; - this.NextUrl = nextUrl; + CurrentPage = currentPage; + TotalPage = totalPage; + PreviousUrl = prevUrl; + NextUrl = nextUrl; } /// diff --git a/DotnetViewComponents/ViewModels/SkipLinkViewModel.cs b/DotnetViewComponents/ViewModels/SkipLinkViewModel.cs index 5c64424649..6e4402a2bc 100644 --- a/DotnetViewComponents/ViewModels/SkipLinkViewModel.cs +++ b/DotnetViewComponents/ViewModels/SkipLinkViewModel.cs @@ -2,6 +2,11 @@ namespace DotnetViewComponents.ViewModels { public class SkipLinkViewModel { + /// + /// Initializes a new instance of the class. + /// + /// The ID of the main content element to which the skip link will navigate. + /// The text to be displayed for the skip link. public SkipLinkViewModel( string maincContentID, string text) @@ -10,8 +15,14 @@ public SkipLinkViewModel( Text = text; } + /// + /// Gets or sets the ID of the main content element to which the skip link will navigate. + /// public string MaincContentID { get; set; } + /// + /// Gets or sets the text to be displayed for the skip link. + /// public string Text { get; set; } } diff --git a/DotnetViewComponents/ViewModels/SummaryListItemViewModel.cs b/DotnetViewComponents/ViewModels/SummaryListItemViewModel.cs index c6f0c20f06..c82c2599d0 100644 --- a/DotnetViewComponents/ViewModels/SummaryListItemViewModel.cs +++ b/DotnetViewComponents/ViewModels/SummaryListItemViewModel.cs @@ -2,32 +2,59 @@ namespace DotnetViewComponents.ViewModels { public class SummaryListItemViewModel { + /// + /// Initializes a new instance of the class. + /// + /// The title of the summary item. + /// The description of the summary item. + /// Optional name of the action associated with the summary item. + /// The asp-controller to dynamically set the controller path of the link. + /// The asp-action to dynamically set the action path of the link.. + /// The asp-all-route-data to dynamically set the extra parameters to the path of the link. public SummaryListItemViewModel( string title, string description, string? actionName = null, - string? aspAction = null, string? aspController = null, + string? aspAction = null, Dictionary? aspRouteData = null) { Title = title; Description = description; ActionName = actionName; - AspAction = aspAction; AspController = aspController; + AspAction = aspAction; AspRouteData = aspRouteData; } + /// + /// Gets or sets the title of the summary item. + /// public string Title { get; set; } + /// + /// Gets or sets the description of the summary item. + /// public string Description { get; set; } + /// + /// Gets or sets the optional name of the action associated with the summary item. + /// public string? ActionName { get; set; } - public string? AspAction { get; set; } - + /// + /// Gets or sets the asp-controller of the link. + /// public string? AspController { get; set; } + /// + /// Gets or sets the as-action of the link. + /// + public string? AspAction { get; set; } + + /// + /// Gets or sets the asp-all-route-data of the link. + /// public Dictionary? AspRouteData { get; set; } } } diff --git a/DotnetViewComponents/ViewModels/SummaryListViewModel.cs b/DotnetViewComponents/ViewModels/SummaryListViewModel.cs index 11109b8b1a..5c67d5eef0 100644 --- a/DotnetViewComponents/ViewModels/SummaryListViewModel.cs +++ b/DotnetViewComponents/ViewModels/SummaryListViewModel.cs @@ -3,6 +3,11 @@ namespace DotnetViewComponents.ViewModels using System.Collections.Generic; public class SummaryListViewModel { + /// + /// Initializes a new instance of the class. + /// + /// The collection of summary list items. + /// Indicates whether the summary list has a border. public SummaryListViewModel( IEnumerable summaryListItem, bool hasBorder) @@ -11,8 +16,14 @@ public SummaryListViewModel( HasBorder = hasBorder; } + /// + /// Gets or sets the collection of summary list items. + /// public IEnumerable SummaryListItem { get; set; } + /// + /// Gets or sets a value indicating whether the summary list has a border. + /// public bool HasBorder { get; set; } } } diff --git a/DotnetViewComponents/ViewModels/TableViewModel.cs b/DotnetViewComponents/ViewModels/TableViewModel.cs index 2f84a6d3fa..fb11aebfc9 100644 --- a/DotnetViewComponents/ViewModels/TableViewModel.cs +++ b/DotnetViewComponents/ViewModels/TableViewModel.cs @@ -2,11 +2,18 @@ namespace DotnetViewComponents.ViewModels { public class TableViewModel { + /// + /// Initializes a new instance of the class. + /// + /// The title of the table. + /// A list of rows, where each row is a list of table columns. + /// Indicates whether the table should be responsive. Default is false. + /// Indicates whether the table contains numeric data. Default is false. public TableViewModel( string title, List> rows, - bool isResponsive = false, - bool hasNumericData = false) + bool isResponsive, + bool hasNumericData) { Title = title; Rows = rows; @@ -14,18 +21,35 @@ public TableViewModel( HasNumericData = hasNumericData; } + /// + /// Gets or sets the title of the table. + /// public string Title { get; set; } + /// + /// Gets or sets the list of rows in the table, where each row is a list of table columns. + /// public List> Rows { get; set; } + /// + /// Gets or sets a value indicating whether the table should be responsive. + /// public bool IsResponsive { get; set; } + /// + /// Gets or sets a value indicating whether the table contains numeric data. + /// public bool HasNumericData { get; set; } } public class TableColumnModel { + /// + /// Initializes a new instance of the class. + /// + /// The header text for the column. + /// The data for the column. public TableColumnModel( string header, string column) @@ -34,8 +58,14 @@ public TableColumnModel( Column = column; } + /// + /// Gets or sets the header text for the column. + /// public string Header { get; set; } + /// + /// Gets or sets the data for the column. + /// public string Column { get; set; } } } diff --git a/DotnetViewComponents/ViewModels/TabsViewModel.cs b/DotnetViewComponents/ViewModels/TabsViewModel.cs index 2093b53557..27955826a3 100644 --- a/DotnetViewComponents/ViewModels/TabsViewModel.cs +++ b/DotnetViewComponents/ViewModels/TabsViewModel.cs @@ -2,6 +2,11 @@ namespace DotnetViewComponents.ViewModels { + /// + /// Initializes a new instance of the class. + /// + /// The title of the tab set. + /// A list of tabs contained in the tab set. public class TabsViewModel { public TabsViewModel( @@ -12,13 +17,26 @@ public TabsViewModel( TabsList = tabsList; } + /// + /// Gets or sets the title of the tab set. + /// public string Title { get; set; } + + /// + /// Gets or sets the list of tabs in the tab set. + /// public List TabsList { get; set; } } public class TabViewModel { + /// + /// Initializes a new instance of the class. + /// + /// The name of the tab. + /// A function that generates the HTML content for the tab. + /// Indicates whether the tab is currently active. public TabViewModel( string name, Func content, @@ -29,10 +47,19 @@ public TabViewModel( IsActive = isActive; } + /// + /// Gets or sets the name of the tab. + /// public string Name { get; set; } + /// + /// Gets or sets a function that generates the HTML content for the tab. + /// public Func Content { get; set; } + /// + /// Gets or sets a value indicating whether the tab is currently active. + /// public bool IsActive { get; set; } } } diff --git a/DotnetViewComponents/ViewModels/TagViewModel.cs b/DotnetViewComponents/ViewModels/TagViewModel.cs index baa0c9656b..9c0f34c9b8 100644 --- a/DotnetViewComponents/ViewModels/TagViewModel.cs +++ b/DotnetViewComponents/ViewModels/TagViewModel.cs @@ -2,16 +2,27 @@ namespace DotnetViewComponents.ViewModels { public class TagViewModel { + /// + /// Initializes a new instance of the class. + /// + /// The name of the tag. + /// The styling class for the tag. Defaults to . public TagViewModel( string name, - string styling = TagStyle.INPROGRESS) + string styling) { Name = name; Styling = styling; } + /// + /// Gets or sets the name of the tag. + /// public string Name { get; set; } + /// + /// Gets or sets the styling class for the tag. + /// public string? Styling { get; set;} } diff --git a/DotnetViewComponents/Views/Shared/Components/Breadcrumbs/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/Breadcrumbs/Default.cshtml index e3c4475c00..b0cd01c801 100644 --- a/DotnetViewComponents/Views/Shared/Components/Breadcrumbs/Default.cshtml +++ b/DotnetViewComponents/Views/Shared/Components/Breadcrumbs/Default.cshtml @@ -2,7 +2,7 @@ @model BreadcrumbsViewModel @{ - var lastLink = Model.Links.Count > 0 ? Model.Links[Model.Links.Count - 1] : (null, null); + var lastLink = Model.Links.Count > 0 ? Model.Links[Model.Links.Count - 1] : (null, null, null, null); }