π Documentation for _myModalAttribute.cshtml
π Table of Contents
- Overview & Purpose
- File Context & Structure
- Key Functional Areas
- Dependencies & Technologies
- View Models & Data Models
- Helper Methods / Utilities
- Error Handling & Return Types
- API Endpoints Overview
- Third-party Integrations
- Sample Code Blocks
- Usage Examples
- UML Sequence Diagram
- Conclusion
1. π§ Overview & Purpose
File Path:
IrbyImaging/Views/HRImaging/_myModalAttribute.cshtml
This partial Razor view renders a Bootstrap modal that displays a Document Category and its associated Document Types in a neat, scrollable container. It is designed to be invoked from other views or via AJAX for showing additional details without a full page refresh.
Key goals:
- Show the Index Name (the category name).
- List out all Document Types assigned to that category.
- Provide a Close button to dismiss the modal.
2. ποΈ File Context & Structure
@model IrbyImaging.UI.Models.DocumentCategoryView
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h5 class="modal-title" id="transaction-detailModalLabel">Document Types</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<!-- Custom CSS for line breaks -->
<style>
.line-breaks { white-space: pre-line; }
</style>
<!-- Modal Body -->
<div class="modal-body">
<p class="mb-2">
Index Name:
<span class="text-primary">
@Html.DisplayFor(model => model.Name)
</span>
</p>
<div class="table-responsive">
@if (Model.TypeList.Any())
{
foreach (var val in Model.TypeList)
{
<span style="white-space: pre-wrap">@val</span>
@Html.Raw("<br />")
}
}
else
{
<span style="white-space: pre-wrap">
No Document Types are Assigned to this Index
</span>
}
</div>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
Close
</button>
</div>
</div>
3. π Key Functional Areas
| Section | Responsibility |
|---|---|
@model |
Declares the view model: DocumentCategoryView. |
| Header | Displays static title βDocument Typesβ and a close button (btn-close). |
| Custom CSS | Adds .line-breaks utility for handling whitespace. |
| Body |
- Shows
Index Namein blue. - Iterates
TypeListand prints each type with line breaks. - Falls back to a βNo Document Typesβ¦β message if empty. | | Footer | A single Close button to dismiss the modal. |
4. βοΈ Dependencies & Technologies
- ASP.NET Core MVC / Razor Views
- Bootstrap 5 (CSS classes:
modal-content,modal-header,btn-close,btn, etc.) - jQuery or Vanilla JS (for triggering and dismissing modals)
- C# (.NET 6+ recommended)
5. π οΈ View Models & Data Models
DocumentCategoryView Model
| Property | Type | Description |
|---|---|---|
| Name | string |
The category/index display name. |
| TypeList | IEnumerable<string> |
A list of document type names. |
| Preview | bool (optional) |
(Commented out) Potential print/preview flag. |
You can find this class in
IrbyImaging.UI.Models.DocumentCategoryView.cs.
public class DocumentCategoryView
{
public string Name { get; set; }
public IEnumerable<string> TypeList { get; set; } = new List<string>();
public bool Preview { get; set; }
}
6. π§° Helper Methods / Utilities
@Html.DisplayFor(...)renders the encoded property value forName.@Html.Raw("<br />")inserts raw HTML for line breaks.- Inline CSS
.line-breaksis provided but not used; can be applied to any<div>or<span>if needed.
7. π¨ Error Handling & Return Types
- Client-side: If
TypeListisnull, an exception will occur.- Recommendation: Ensure the controller always supplies a non-nullable
IEnumerable<string>.
- Recommendation: Ensure the controller always supplies a non-nullable
- Return Type: This view returns an HTML fragment (partial view) with no JSON or status codes.
8. π API Endpoints Overview
Though this is a view, typically itβs rendered by one of the following patterns:
| Invocation | Controller Action |
|---|---|
| Razor Partial | @await Html.PartialAsync("_myModalAttribute", model) |
| AJAX (fetch) | GET /HRImaging/GetDocumentCategoryPartial?id={categoryId} |
// Example Controller
public class HRImagingController : Controller
{
public IActionResult GetDocumentCategoryPartial(int id)
{
var model = _service.GetDocumentCategoryViewById(id);
return PartialView("_myModalAttribute", model);
}
}
9. π Third-party Integrations
- Bootstrap 5 for modal layout & styling.
- No other third-party scripts are directly referenced in this file.
10. π Sample Code Blocks
Rendering the Partial in a Parent View
@model IrbyImaging.UI.Models.MainPageView
<!-- Somewhere in your parent view -->
<button id="showTypes" class="btn btn-primary">
Show Document Types
</button>
<div id="modalContainer"></div>
@section Scripts {
<script>
$("#showTypes").on("click", function() {
const categoryId = 123; // dynamic in real use
$("#modalContainer").load(
`/HRImaging/GetDocumentCategoryPartial?id=${categoryId}`,
function() {
const myModal = new bootstrap.Modal(
document.querySelector('#modalContainer .modal-content'),
{}
);
myModal.show();
}
);
});
</script>
}
11. π Usage Examples
- Server-side rendering
@await Html.PartialAsync("_myModalAttribute", new DocumentCategoryView { Name = "Contracts", TypeList = new [] { "Sales Contract", "Lease Agreement", "NDA" } }) - AJAX + Bootstrap
See Sample Code Blocks above.
12. π UML Sequence Diagram
@startuml
actor User
participant Browser
participant Server
participant DB
User -> Browser : Click βShow Document Typesβ
Browser -> Server : GET /HRImaging/GetDocumentCategoryPartial?id=123
Server -> DB : SELECT Name, TypeList FROM DocumentCategory WHERE Id=123
DB --> Server : { Name, [TypeList...] }
Server --> Browser : HTML (partial view)
Browser -> Browser : Inject & Render .modal-content
Browser -> Browser : bootstrap.Modal.show()
@enduml
13. π Conclusion
- _myModalAttribute.cshtml is a focused partial view for displaying a Document Category and its Document Types inside a Bootstrap modal.
- It relies on a well-formed
DocumentCategoryViewmodel and Bootstrap 5 for styling. - Easily invoked via Razor or AJAX, it enhances user experience by providing a lightweight overlay without full page reloads.
π That wraps up the comprehensive documentation for _myModalAttribute.cshtml. Feel free to adapt styling, add client-side validations, or extend it with action buttons like Print or Edit as your UI evolves!