π Edit.cshtml Documentation
File Path: IrbyImaging/Views/HRImaging/Edit.cshtml
Purpose: Razor view for attaching additional files, editing metadata of uploaded HR documents, and previewing the PDF in real time.
π Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Model & ViewData
- Attach Additional Documents
- Edit Document Form
- PDF Preview Panel
- Loading Spinner & Client Scripts
- UML Diagram of ViewModel
- Usage Example
- Conclusion
1. Overview & Purpose
This Edit.cshtml page allows HR users to:
- π Attach additional supporting documents to an existing
DocumentImageId. - βοΈ Edit metadata (index fields) for a document β dynamic fields generated based on attribute definitions in the model.
- π₯ Assign Roles that can view or manage the document.
- π Preview the PDF side-by-side.
2. Dependencies & Technologies
| Layer | Library / Framework | Usage |
|---|---|---|
| Server-side | ASP.NET Core MVC Razor | Page templating & forms |
| Model Binding | IrbyImaging.Models.DocumentImaging |
Primary ViewModel |
| JavaScript UI | Syncfusion EJ2 | Multi-select controls |
| jQuery, Bootstrap 5 | DOM manipulation, styling & components | |
| Select2 | Enhanced <select> dropdowns |
|
| bootstrap-datepicker | Date pickers | |
| TinyMCE | Rich text editing (unused in UI) | |
| jQuery Repeater | Dynamic form field groups | |
| spin.js | Loading spinner |
3. Model & ViewData
@model IrbyImaging.Models.DocumentImaging
@{
ViewData["Title"] = "Edit Uploaded Document";
Layout = "~/Views/Shared/_Layout.cshtml";
var idxList = Model.IndexList;
}
- Model:
DocumentImagingcontains document metadata, index definitions (IndexList), lookup lists (DocumentTypes,EmployeeData, etc.), and document binary data. - ViewData["Title"] sets the browser tab title.
4. Attach Additional Documents π
@using (Html.BeginForm("Attach", "HRImaging", FormMethod.Post, new { enctype = "multipart/form-data" })) {
@Html.HiddenFor(m => m.DocumentImageId)
<h4>Attach Additional Documents</h4>
<input type="file" name="file" multiple class="form-control" style="height:200%"/>
<button type="submit" class="btn btn-primary">Attach</button>
}
- Action:
HRImagingController.Attach(int docId, IFormFile[] file) - Purpose: Upload one or more files to append to the existing document.
- enctype="multipart/form-data": Required for file uploads.
5. Edit Document Form βοΈ
<form asp-action="Edit" id="validation-form" method="post">
<!-- Hidden fields & dynamic metadata go here -->
<button id="saveDocument" class="btn btn-primary">Save Document</button>
</form>
5.1 Hidden Fields
All key properties are posted back, but not shown to the user:
@Html.HiddenFor(m => m.DocumentImageId)
@Html.HiddenFor(m => m.DocumentType)
@Html.HiddenFor(m => m.TotalPages)
@Html.HiddenFor(m => m.Page)
@Html.HiddenFor(m => m.ImageContents)
// ...and so on for OCR contents, reference IDs, etc.
5.2 Document Type Selection
<label>Document Type</label>
<select asp-for="DocumentType" asp-items="Model.DocumentTypes"
class="form-control col-sm-6">
<option value="" disabled selected>@Model.DocumentType</option>
</select>
- asp-items binds to a
SelectListof available document types. - Default selected value is the current
Model.DocumentType.
5.3 Dynamic Metadata Index Fields π
The core of this view loops over Model.IndexList to render appropriate inputs:
@for (var i = 0; i < Model.IndexList.Count; i++)
{
var idx = Model.IndexList[i];
<input type="hidden" asp-for="@idx.Id" />
<input type="hidden" asp-for="@idx.AttributeName" />
// β¦ more hidden metadata flags β¦
if (idx.AttributeType == AttributeType.Text && !idx.IsMultiValue) {
// Render <textarea> for text
}
else if (idx.LinkEmployeeData) {
// Render <select> bound to Model.EmployeeData
}
else if (idx.AttributeType == AttributeType.Date) {
// Render <input type="date">
}
// β¦ cover Character, Number, Currency, Boolean, MultiValue, State lookups β¦
}
AttributeType β Control Mapping
| AttributeType | Condition | Rendered Control |
|---|---|---|
| Text | single-value, no links | <textarea> |
| Character | single-value, no links | <textarea> |
| Date | <input type="date"> |
|
| Number | <input type="number"> |
|
| Currency | $ <input type="number"> |
|
| Boolean | <select> with Yes/No |
|
| Linked Data | LinkEmployee/Job/Customer/State | <select asp-items="β¦"> |
| MultiValue | idx.IsMultiValue == true |
<select asp-items="idx.MultiValueTypes"> |
5.4 Roles Multi-Select π₯
<label>Add Roles</label>
<ejs-multiselect id="roles" mode="CheckBox" dataSource="@ViewBag.Roles"
placeholder="Select a Role" allowFiltering="true">
<e-multiselect-fields text="Name" value="RoleId"></e-multiselect-fields>
</ejs-multiselect>
- Uses Syncfusion EJ2 MultiSelect with checkboxes.
- ViewBag.Roles passed from controller as a list of
{ RoleId, Name }.
6. PDF Preview Panel π
<embed id="frPDF" width="100%" height="100%"
src="@Url.Action("EditDocumentPreview", "HRImaging", new { id = Model.DocumentImageId })#zoom=FitH"
type="application/pdf" />
- Live preview of the document via a PDF embed.
- Zoom parameter
FitHfits width horizontally.
7. Loading Spinner & Client Scripts β³
When the Save Document button is clicked, a full-screen overlay with a spinner appears:
<div id="loading">
<p id="loadingspinner">Saving document. Please waitβ¦</p>
</div>
$("#saveDocument").click(function() {
$("#loading").fadeIn();
var spinner = new Spinner(opts).spin(document.getElementById('loading'));
});
- spin.js creates the animated spinner.
- Overlay CSS ensures user canβt click anything else while saving.
Additional scripts & styles:
- jQuery, Bootstrap, SimpleBar, Waves
- Select2 + CSS for
<select>enhancements - bootstrap-datepicker for date pickers
- tinymce and jquery.repeater (initialized but not heavily used in this view)
8. UML Diagram of ViewModel ποΈ
@startuml
class DocumentImaging {
+int DocumentImageId
+string DocumentType
+int TotalPages
+byte[] ImageContents
+List<IndexItem> IndexList
+SelectList DocumentTypes
+SelectList EmployeeData
+SelectList JobData
+SelectList CustomerData
+SelectList StateData
}
class IndexItem {
+int Id
+string AttributeName
+AttributeType AttributeType
+bool IsMultiValue
+string IndexValue
+SelectList MultiValueTypes
+bool LinkEmployeeData
+bool LinkJobData
+bool LinkCustomerData
+bool IsRequired
}
enum AttributeType {
Text
Character
Date
Number
Currency
Boolean
}
DocumentImaging --> "0..*" IndexItem
IndexItem ..> AttributeType
@enduml
9. Usage Example π
- Navigate in browser to:
GET /HRImaging/Edit/123 - Attach files:
- Click Browse or Drop Files
- Select one or more PDFs/images
- Click Attach β Appends files to document #123
- Edit Metadata:
- Change Document Type from dropdown
- Fill out dynamic index fields (e.g., Date, Currency, Employee lookup)
- Choose Roles who can view/edit
- Save:
- Click Save Document β Loading spinner appears
- On success, page reloads with updated PDF preview & fields.
10. Conclusion π
- This view hybridizes file management, dynamic form generation, and live PDF preview in a single Razor page.
- Thirdβparty controls (Syncfusion, Select2) enhance user experience.
- The dynamic loop over
IndexListsupports arbitrary document schemas defined at runtime.
With this documentation, developers can quickly understand, maintain, and extend the Edit.cshtml view for HR document imaging in the IrbyImaging application.