π Documentation: _myModalDet.cshtml
Path:
IrbyImaging/Views/AccountingImaging/_myModalDet.cshtml
Table of Contents
- Overview & Purpose
- Key Functional Areas
- Dependencies & Technologies
- View Model & Data Model
- Template Structure
- Conditional Rendering
- API Endpoint Integration
- Sequence & UML Diagram
- Sample Usage & Code Snippets
- Styling & UX Considerations
- Error Handling & Edge Cases
- Conclusion
1. Overview & Purpose
_myModalDet.cshtml is a Razor partial view designed to display document details inside a Bootstrap modal dialog. It supports two modes:
- Preview Mode: Embeds a PDF for visual inspection.
- OCR Mode: Displays extracted OCR text in a scrollable pane.
This partial can be injected dynamically (via AJAX or server-side Html.Partial) whenever a user requests details on a specific document in the AccountingImaging area.
2. Key Functional Areas
| Section | Responsibility |
|---|---|
| Modal Header | Title (βDocument Detailsβ) + Close button π |
| Preview Mode Body | Shows document type, category & embedded PDF preview |
| Non-Preview Mode Body | Shows document type, category & OCR text |
| Modal Footer | Action buttons (Close) |
3. Dependencies & Technologies
- ASP.NET MVC 5 / .NET Core MVC
- Razor View Engine
- Bootstrap 5 (modal, btn-close, responsive classes)
- jQuery or Vanilla JS for modal triggering
- Server Action:
LegalImagingController.RenderImage(int id, bool preview)returns a PDF stream
4. View Model & Data Model
View Model
namespace IrbyImaging.Models
{
public class DocumentImaging
{
public int DocumentImageId { get; set; }
public string DocumentType { get; set; }
public string DocumentCategory { get; set; }
public bool Preview { get; set; } // Toggle for PDF vs OCR
public string ImageOCRText { get; set; } // OCRed text from document
}
}
Note: The partial view signature is
@model IrbyImaging.Models.DocumentImaging.
5. Template Structure
@model IrbyImaging.Models.DocumentImaging
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h5 class="modal-title" id="transaction-detailModalLabel">Document Details</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<!-- Body: Preview vs OCR -->
@if (Model.Preview) {
<!-- Embedded PDF Preview -->
}
@else {
<!-- OCR Text Display -->
}
<!-- Modal Footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
6. Conditional Rendering
-
Preview Mode (
Model.Preview == true)- Renders a full-height
<embed>pointing to the server action:<embed height="100%" width="100%" src="@Url.Action("RenderImage", "LegalImaging", new { id = Model.DocumentImageId, preview = true })#zoom=FitH" type="application/pdf"> - Displays Document Type & Category above the PDF.
- Renders a full-height
-
Non-Preview Mode (
Model.Preview == false)- Renders the OCR text inside a
.table-responsivestyled container:<span style="white-space: pre-wrap"> @Model.ImageOCRText </span>
- Renders the OCR text inside a
7. API Endpoint Integration
| Endpoint | Controller | Purpose |
|---|---|---|
RenderImage(int id, bool preview) |
LegalImagingController |
Streams the PDF bytes to <embed> |
- URL Generator
Uses@Url.Action("RenderImage", "LegalImaging", new { β¦ })to build a route.
8. Sequence & UML Diagram
[User]
|-- clicks "View Details" -------------|
v
[AJAX GET /AccountingImaging/DetailPartial?id=...]
|
Returns `_myModalDet.cshtml` with Model
|
[Inject HTML into modal container]
|
[Bootstrap JS opens modal]
sequenceDiagram
participant U as User
participant B as Browser
participant S as Server
U->>B: Click "View Details"
B->>S: GET /AccountingImaging/DetailPartial?id=123
S-->>B: HTML (_myModalDet.cshtml with Model)
B->>B: Inject into <div class="modal-dialog">
B->>B: Bootstrap.showModal()
B->>U: Display modal window
9. Sample Usage & Code Snippets
9.1 Triggering the Modal via AJAX
function showDocumentDetails(id, preview) {
$.get('/AccountingImaging/GetDocumentModal', { id, preview }, function(html) {
$('#myModal .modal-dialog').html(html);
var myModal = new bootstrap.Modal(document.getElementById('myModal'));
myModal.show();
});
}
9.2 In Your Parent View
<button class="btn btn-link"
onclick="showDocumentDetails(@item.DocumentImageId, true)">
Preview PDF π
</button>
<button class="btn btn-link"
onclick="showDocumentDetails(@item.DocumentImageId, false)">
View OCR Text π
</button>
<!-- Modal Container -->
<div id="myModal" class="modal fade" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-xl"></div>
</div>
10. Styling & UX Considerations
- Responsive Height:
The PDF container is set toheight: 600pxto limit overflow. Adjust as needed via inline style or CSS class. - Close Button:
Uses Bootstrap 5βs.btn-closefor a modern UI.
11. Error Handling & Edge Cases
- Missing PDF: If
RenderImagereturns 404 or empty stream, the<embed>may show an error.
Recommendation: Wrap embed in a try/catch or display fallback text. - Large OCR Text: The
.table-responsivewrapper withwhite-space: pre-wrapensures long OCR output wraps and scrolls. - Model Null: Ensure the controller always passes a valid
DocumentImaginginstance.
12. Conclusion
This partial view encapsulates document detail rendering for both visual (PDF) and textual (OCR) inspections. Its clean separation of header, body, and footer, combined with Bootstrap 5 styling, makes it easily reusable across the AccountingImaging area. By leveraging the Preview flag, developers can toggle between display modes dynamically, improving UX and code maintainability.
Feel free to customize the styling, adjust heights, or extend the template to include further document metadata (e.g., upload date, author) as your project evolves. π