📄 ViewDoc.cshtml Documentation
Table of Contents
- Overview & Purpose
- Data Models & ViewModels
- Key Functional Areas
- View Structure & Layout
- Form & Hidden Fields
- Index Metadata Rendering
- PDF Preview Embed
- Client-side Dependencies & Integrations
- JavaScript & Event Handling
- CSS & Loader Overlay
- UML Diagram
- Usage Example
- Conclusion
1. Overview & Purpose 🚀
ViewDoc.cshtml is an ASP.NET Core Razor view under the IrbyImaging/Views/LegalImaging folder. Its core purpose is:
- Display a scanned or uploaded document (PDF) for Legal, Safety, or IT contexts.
- Render document metadata (index fields) in a read-only form.
- Embed a PDF viewer with zoom and navigation.
- Provide client-side interactivity (loading spinner, select2 dropdowns).
This view is used by the LegalImagingController to allow users to view document details and preview the PDF in a unified, styled layout.
2. Data Models & ViewModels 🛠️
2.1 DocumentImaging ViewModel
| Property | Type | Description |
|---|---|---|
DocumentImageId |
int |
Unique ID of the scanned document. |
DocumentType |
string |
Category/type of the document. |
TotalPages, Page |
int |
Pagination details for multi-page documents. |
ImageContents |
byte[] |
Raw image/PDF binary data. |
ImageOCRContents, ImageOCRText |
string |
OCR results (if any). |
ReferenceId, OriginalReferenceId |
int / int? |
Link to business entities. |
IsLegalDocument, IsSafety, IsIT |
bool |
Flags for context selection. |
DocumentUploadedBy |
string |
Uploader’s username. |
DocumentUploadedDate |
DateTime |
Upload timestamp. |
LegalDocumentType, SafetyDocumentType, ITDocumentType |
string |
Sub-types per context. |
ImagingType |
string |
Internal imaging workflow type. |
DocumentTypes |
List<SelectListItem> |
Drop‑down options for document types. |
IndexList |
List<IndexAttribute> |
Custom index fields & values. |
EmployeeData, JobData, CustomerData, StateData |
List<SelectListItem> |
Lookup lists for linked data. |
2.2 IndexAttribute Model
Each entry in IndexList represents one metadata field:
| Property | Type | Description |
|---|---|---|
Id |
int |
Unique identifier for the attribute. |
AttributeName |
string |
Label to display. |
AttributeType |
AttributeType (enum) |
Data type (Text, Number, Date, etc.). |
IsRequired |
bool |
Whether the field is mandatory. |
IsMultiValue |
bool |
Multiple-selection allowed? |
LinkEmployeeData |
bool |
Populate from EmployeeData. |
LinkJobData |
bool |
Populate from JobData. |
LinkCustomerData |
bool |
Populate from CustomerData. |
IndexValue |
string |
The actual saved value. |
MultiValueTypes |
List<SelectListItem> |
Options for multi-value fields. |
3. Key Functional Areas 🎯
- Layout & Styling
- Read‑Only Metadata Form
- Dynamic Attribute Rendering
- PDF Embedding & Preview
- Client‑Side Scripts & Spinner
4. View Structure & Layout 🏗️
@model IrbyImaging.Models.DocumentImaging
@{
ViewData["Title"] = "View Document";
Layout = "~/Views/Shared/_LegalLayout.cshtml";
var category = Model.IsLegalDocument ? "legal"
: Model.IsSafety ? "safety"
: Model.IsIT ? "it"
: null;
}
Layout: Uses a shared_LegalLayoutfor consistent header/sidebar.ViewData["Title"]: Sets the browser/tab title.
5. Form & Hidden Fields 📝
A form posts back to LegalImaging/Edit (though most fields are disabled/read‑only).
Hidden fields preserve data across post-backs:
<form asp-action="Edit" class="form-horizontal" id="validation-form" method="post">
@Html.HiddenFor(m => m.DocumentImageId)
@Html.HiddenFor(m => m.DocumentType)
@Html.HiddenFor(m => m.TotalPages)
... (other hidden fields) ...
</form>
6. Index Metadata Rendering 🔍
The view iterates Model.IndexList and renders each attribute as one of:
- TextArea (for
Text/Characterwithout links) <select>dropdown with linked data (EmployeeData,JobData,CustomerData,StateData)- Single/multi‑select for
IsMultiValue <input type="date">forDate<input type="number">forNumber/Currency- Boolean dropdown (
Yes/No)
Each control is rendered in a .row.mb-4 block with disabled attribute:
<div class="row mb-4">
<label class="col-form-label col-lg-3">@attr.AttributeName</label>
<div class="col-lg-9">
<input type="date"
id="@attr.AttributeName"
disabled="true"
asp-for="@attr.IndexValue"
value="@attr.IndexValue" />
</div>
</div>
7. PDF Preview Embed 📑
A responsive <embed> tag loads the PDF via a controller action:
<div class="col-lg-6">
<embed id="frPDF"
height="100%"
width="100%"
src="@Url.Action("EditDocumentPreview", "LegalImaging",
new { id = Model.DocumentImageId, category = category })#zoom=FitH"
type="application/pdf" />
</div>
- Zoom:
#zoom=FitHfits width. - Category: influences server‐side routing and watermarking.
8. Client-side Dependencies & Integrations 🔌
| Library | Purpose |
|---|---|
| bootstrap-datepicker.css / js | Date picker styling & behavior. |
| dropzone.css | (Placeholder for drag‐drop, not used here). |
| select2 | Enhanced dropdowns. |
| tinymce | Rich‑text editor (unused in read‑only). |
| jquery.repeater | Dynamic form groups (unused in view). |
| spin.js | Loading spinner generation. |
| metisMenu, simplebar, node-waves | UI interactions (menu, scrollbars, ripple). |
<link href="~/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>
9. JavaScript & Event Handling ⚙️
-
Select2 Initialization
$(document).ready(function () { $('.js-example-basic-single').select2(); }); -
Save Button Spinner
$("#saveDocument").click(function () { $("#loading").fadeIn(); var spinner = new Spinner(opts).spin(document.getElementById('loading')); }); -
Loading Overlay (see next section)
10. CSS & Loader Overlay 🎨
A full‐screen overlay is shown during save:
#loading {
display: none; /* hidden by default */
position: fixed; top: 0; left: 0;
width: 100%; height: 100%;
background: rgba(255,255,255,0.8);
z-index: 1000;
}
#loadingcontent {
display: table; width: 100%; height: 100%;
}
#loadingspinner {
display: table-cell;
vertical-align: middle;
text-align: center;
font-size: larger;
padding-top: 80px;
}
<div id="loading">
<div id="loadingcontent">
<p id="loadingspinner">Saving document. Please wait…</p>
</div>
</div>
11. UML Diagram 📊
@startuml
enum AttributeType {
Text
Character
Date
Number
Currency
Boolean
}
class IndexAttribute {
+int Id
+string AttributeName
+AttributeType AttributeType
+bool IsRequired
+bool IsMultiValue
+bool LinkEmployeeData
+bool LinkJobData
+bool LinkCustomerData
+string IndexValue
+List<SelectListItem> MultiValueTypes
}
class DocumentImaging {
+int DocumentImageId
+string DocumentType
+int TotalPages
+int Page
+byte[] ImageContents
+string ImageOCRContents
+string ImageOCRText
+int ReferenceId
+int? OriginalReferenceId
+bool IsLegalDocument
+string DocumentUploadedBy
+DateTime DocumentUploadedDate
+string LegalDocumentType
+string ImagingType
+bool IsSafety
+string SafetyDocumentType
+bool IsIT
+string ITDocumentType
+List<IndexAttribute> IndexList
+List<SelectListItem> DocumentTypes
+List<SelectListItem> EmployeeData
+List<SelectListItem> JobData
+List<SelectListItem> CustomerData
+List<SelectListItem> StateData
}
DocumentImaging "1" *-- "*" IndexAttribute
@enduml
12. Usage Example 📋
// In LegalImagingController.cs
public IActionResult ViewDoc(int id) {
var model = _documentService.GetDocumentImaging(id);
return View("ViewDoc", model);
}
- Navigate to
/LegalImaging/ViewDoc/123 - Inspect metadata on the left, preview PDF on the right.
- Click “Save” (if enabled) to trigger loading spinner.
13. Conclusion 🎉
The ViewDoc.cshtml is a read-only, user‑friendly interface for legal/safety/IT document review. It dynamically renders metadata fields, seamlessly integrates third‑party scripts (Select2, Spin.js), and embeds a cross‑browser PDF viewer. The code follows standard Razor patterns, enabling extensibility for new attribute types or workflows. With its modular design, teams can easily:
- Add new AttributeType branches.
- Customize the PDF preview (watermarks, annotations).
- Extend the loading spinner or error handling.
Happy coding! 👍