πŸ“„ Documentation for _myModalAttribute.cshtml


πŸ“‘ Table of Contents

  1. Overview & Purpose
  2. File Context & Structure
  3. Key Functional Areas
  4. Dependencies & Technologies
  5. View Models & Data Models
  6. Helper Methods / Utilities
  7. Error Handling & Return Types
  8. API Endpoints Overview
  9. Third-party Integrations
  10. Sample Code Blocks
  11. Usage Examples
  12. UML Sequence Diagram
  13. 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 Name in blue.
  • Iterates TypeList and 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 for Name.
  • @Html.Raw("<br />") inserts raw HTML for line breaks.
  • Inline CSS .line-breaks is provided but not used; can be applied to any <div> or <span> if needed.

7. 🚨 Error Handling & Return Types

  • Client-side: If TypeList is null, an exception will occur.
    • Recommendation: Ensure the controller always supplies a non-nullable IEnumerable<string>.
  • 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

  1. Server-side rendering
    @await Html.PartialAsync("_myModalAttribute", new DocumentCategoryView {
      Name = "Contracts",
      TypeList = new [] { "Sales Contract", "Lease Agreement", "NDA" }
    })
    
  2. 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 DocumentCategoryView model 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!