πŸ“ 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

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Model & ViewData
  4. Attach Additional Documents
  5. Edit Document Form
  6. PDF Preview Panel
  7. Loading Spinner & Client Scripts
  8. UML Diagram of ViewModel
  9. Usage Example
  10. 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: DocumentImaging contains 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 SelectList of 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 FitH fits 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 πŸš€

  1. Navigate in browser to:
    GET /HRImaging/Edit/123
    
  2. Attach files:
    • Click Browse or Drop Files
    • Select one or more PDFs/images
    • Click Attach β†’ Appends files to document #123
  3. Edit Metadata:
    • Change Document Type from dropdown
    • Fill out dynamic index fields (e.g., Date, Currency, Employee lookup)
    • Choose Roles who can view/edit
  4. 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 IndexList supports 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.