📄 IrbyImaging/Views/LegalImaging/Edit.cshtml Documentation
Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Model & ViewModel
- Layout & Styles
- Attach Additional Documents Section
5.1. Form & Fields - Edit Document Section
6.1. Hidden Metadata Fields
6.2. Document Type Selector
6.3. Dynamic Indexing Fields Rendering - Document Preview Embed
- Scripts & Client‑Side Behavior
8.1. Included Libraries & Plugins
8.2. Custom JavaScript Snippets - Third‑Party Integrations
- Sample Usage
- UML Class Diagram
- Conclusion
1. Overview & Purpose
This Razor view renders the Edit Uploaded Document page for the Legal Imaging module of the IrbyImaging application. It allows users to:
- 🚀 Attach one or more additional files to an existing document.
- 🛠 Edit the document’s metadata and indexing attributes dynamically.
- 📑 Preview the PDF in real time.
Key Goals
- Provide a seamless UI for updating scanned/legal documents.
- Dynamically generate form fields based on the document’s index definition.
- Offer instant feedback with a loading spinner and PDF preview.
2. Dependencies & Technologies
| Category | Technology / Library |
|---|---|
| Framework | ASP.NET Core MVC, Razor Views |
| CSS / Layout | Bootstrap 4, Dropzone.css, Select2.css |
| JavaScript / Plugins | jQuery, Bootstrap Datepicker, Select2, spin.js, tinymce, jquery.repeater |
| Custom Styling | _LegalLayout.cshtml, inline <style> blocks |
| PDF Preview | <embed> tag pointing to EditDocumentPreview action |
3. Model & ViewModel
This view is strongly typed to the IrbyImaging.Models.DocumentImaging model:
@model IrbyImaging.Models.DocumentImaging
DocumentImaging (Key Properties)
| Property | Type | Description |
|---|---|---|
| DocumentImageId | int | Unique identifier for the document |
| DocumentType | string | Code/type of the document |
| IndexList | List | Collection of dynamic indexing definitions |
| DocumentTypes | IEnumerable | Available document type dropdown items |
| EmployeeData, JobData… | IEnumerable | Data sources for linked dropdowns |
| StateData | IEnumerable | U.S. state list for “State” fields |
| IsLegalDocument, IsSafety, IsIT | bool | Flags for category routing |
IndexItem (Excerpt)
| Property | Type | Description |
|---|---|---|
| Id | int | Index field identifier |
| AttributeName | string | Label/key for indexing |
| AttributeType | AttributeType (enum) | Data type: Text, Number, Date, Currency, Boolean… |
| IsMultiValue | bool | Determines if multiple values are allowed |
| IndexValue | string | Current/initial value |
| MultiValueTypes | IEnumerable | Dropdown options for multi‑value attributes |
| LinkEmployeeData… | bool | Flags for special linked‑data dropdowns |
4. Layout & Styles
- Layout: Uses the shared layout at
~/Views/Shared/_LegalLayout.cshtml. - Title: Set via
ViewData["Title"] = "Edit Uploaded Document";. - Custom Styles:
@section styles{ <link href="~/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet"> <link href="~/libs/dropzone/min/dropzone.min.css" rel="stylesheet" /> } - Loading Overlay CSS: Inline
<style>controlling the “Saving…” spinner overlay.
5. Attach Additional Documents Section
5.1. Form & Fields
@using (Html.BeginForm("Attach", "LegalImaging",
new { category = category },
FormMethod.Post,
new { enctype = "multipart/form-data" }))
{
@Html.HiddenFor(m => m.DocumentImageId)
<h4>Attach Additional Documents</h4>
<input type="file" name="file" multiple />
<button type="submit" class="btn btn-primary">Attach</button>
}
- Action:
LegalImagingController.Attach(int docId, IFormFile[] file, string category) - Field:
<input type="file" multiple>allows multi‑upload. - Hidden: Document ID maintained via
Html.HiddenFor.
6. Edit Document Section
Wrapped in a standard <form asp-action="Edit"> (commented Html.BeginForm).
6.1. Hidden Metadata Fields
All core properties are posted back via hidden inputs:
@Html.HiddenFor(m => m.DocumentImageId)
@Html.HiddenFor(m => m.DocumentType)
@Html.HiddenFor(m => m.TotalPages)
@* … many more hidden fields … *@
6.2. Document Type Selector
<label>Document Type</label>
<select asp-for="DocumentType"
asp-items="@Model.DocumentTypes"
class="form-control">
<option disabled selected>@Model.DocumentType</option>
</select>
6.3. Dynamic Indexing Fields Rendering
The view loops through Model.IndexList and renders inputs based on each item’s configuration:
@for (var i = 0; i < Model.IndexList.Count; i++)
{
var item = Model.IndexList[i];
if (item.AttributeType == AttributeType.Text && !item.IsMultiValue)
{
<!-- Render <textarea> for plain text -->
}
else if (item.LinkEmployeeData)
{
<!-- Render <select> populated by EmployeeData -->
}
else if (item.AttributeType == AttributeType.Date)
{
<input type="date" asp-for="@item.IndexValue" />
}
else if (item.AttributeType == AttributeType.Number)
{
<input type="number" step="0.01" asp-for="@item.IndexValue" />
}
else if (item.AttributeType == AttributeType.Boolean)
{
<select asp-for="@item.IndexValue">
<option>Yes</option>
<option>No</option>
</select>
}
<!-- … other cases: Currency, State, MultiValue … -->
}
💡 Tip: This pattern ensures the form adapts automatically to any new index definitions without view changes.
7. Document Preview Embed
A real‐time PDF preview on the right column:
<embed id="frPDF"
src="@Url.Action("EditDocumentPreview",
"LegalImaging",
new { id = Model.DocumentImageId, category = category })#zoom=FitH"
type="application/pdf"
width="100%" height="100%" />
- Action:
EditDocumentPreview(int id, string category)returns a FileStreamResult with the PDF.
8. Scripts & Client‑Side Behavior
8.1. Included Libraries & Plugins
<script src="~/libs/jquery/jquery.min.js"></script>
<script src="~/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="~/libs/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="~/libs/jquery.repeater/jquery.repeater.min.js"></script>
<script src="~/libs/tinymce/tinymce.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2/dist/js/select2.min.js"></script>
<script src="~/assets/js/spin.js"></script>
8.2. Custom JavaScript Snippets
-
Select2 Initialization
$(document).ready(function() { $('.js-example-basic-single').select2(); }); -
Loading Spinner on Save
$('#saveDocument').click(function () { $('#loading').fadeIn(); new Spinner({ /* options */ }).spin(document.getElementById('loading')); }); -
Auto‑Populate Customer Name
$('#Customer\\ Number').on('change', function(){ let val = $(this).val().split('-').slice(1).join('-'); $('#Customer\\ Name').val(val).attr('readonly','readonly'); });
9. Third‑Party Integrations
| Plugin | Purpose |
|---|---|
| Dropzone | (CSS linked; JS usage commented out) |
| Bootstrap Datepicker | Date inputs with calendar picker |
| Select2 | Enhanced dropdown UI + search box |
| spin.js | Loading spinner overlay |
| tinymce | Rich text editing (commented init) |
| jquery.repeater | Dynamic form repeaters (commented) |
10. Sample Usage
public IActionResult Edit(int id, string category)
{
var model = _documentService.GetDocumentImaging(id, category);
return View(model); // Renders Edit.cshtml
}
- Pass a fully‑populated
DocumentImagingobject into the view. - The view automatically renders attach/upload & editing UI.
11. UML Class Diagram
@startuml
package Models {
class DocumentImaging {
+int DocumentImageId
+string DocumentType
+List<IndexItem> IndexList
+IEnumerable<SelectListItem> DocumentTypes
+… other data sources …
}
class IndexItem {
+int Id
+string AttributeName
+AttributeType AttributeType
+bool IsMultiValue
+string IndexValue
+IEnumerable<SelectListItem> MultiValueTypes
+bool LinkEmployeeData…
}
}
package Controllers {
class LegalImagingController {
+IActionResult Edit(int id, string category)
+IActionResult Attach(int docId, IFormFile[] file, string category)
+IActionResult EditDocumentPreview(int id, string category)
}
}
DocumentImaging --> IndexItem
LegalImagingController --> DocumentImaging : uses
LegalImagingController --> Edit.cshtml
@enduml
12. Conclusion
This Edit.cshtml view is the cornerstone of the Legal Imaging workflow in IrbyImaging. It elegantly combines:
- A flexible file‑attachment UI
- A dynamic, metadata‑driven form
- A live PDF preview
- Client‑side enhancements (Select2, datepicker, spinner)
…to empower users in indexing and updating legal/safety/IT documents with minimal code changes when the underlying data model evolves. 🚀
Happy coding! 🎉