📄 Edit.cshtml Documentation

Welcome to the comprehensive documentation for the IrbyImaging/Views/AccountingImaging/Edit.cshtml Razor view. This document will cover everything from the purpose of the file to key functional areas, dependencies, view models, and usage examples. Enjoy! 😊


📑 Table of Contents

  1. Overview & Purpose
  2. Index & Category Resolution
  3. File Attachment Section
  4. Edit Document Section
  5. PDF Preview
  6. Dependencies & Technologies
  7. View Model: DocumentImaging
  8. Data Model: IndexItem
  9. Helper Methods & Utilities
  10. Third‑Party Integrations
  11. Usage Examples
  12. UML Class Diagram
  13. Conclusion

🧐 Overview & Purpose

This Razor view allows accounting staff to:

  • Attach additional scanned documents to an existing imaging record.
  • Edit document metadata (indexes, types, attributes).
  • Preview the PDF in-browser before saving.

It is part of the Document Imaging feature in the Irby system, under the AccountingImaging area.


🔍 Index & Category Resolution

At the top of the view, we determine the category based on flags in the model:

@{
  var idxList  = Model.IndexList;
  var category = Model.IsLegalDocument  ? "legal"
               : Model.IsSafety         ? "safety"
               : Model.IsIT             ? "it"
               : Model.IsAccounting     ? "accounting"
               : Model.IsBidding        ? "bidding"
               : null;
}
  • category is passed to controller actions to route data appropriately.
  • idxList holds dynamic attribute definitions to render.

📎 File Attachment Section

This form allows users to drop or browse for additional files:

@using (Html.BeginForm(
    "Attach",
    "LegalImaging",
    new { category = category },
    FormMethod.Post,
    new { enctype = "multipart/form-data" }))
{
  @Html.HiddenFor(m => m.DocumentImageId)

  <div class="card">
    <h4>Attach Additional Documents</h4>
    <input type="file" name="file" multiple class="form-control" style="height:200%" />
    <button type="submit" class="btn btn-primary mt-3">Attach</button>
  </div>
}
Element Purpose
Html.BeginForm POSTS to /LegalImaging/Attach?category=…
input[type=file] Allows multiple file selection
DocumentImageId Hidden field to link new files to existing record
btn btn-primary Submits attachments

✏️ Edit Document Section

This section renders the main metadata editing form.

<form asp-action="Edit"
      class="form-horizontal"
      id="validation-form"
      method="post"
      defaultbutton="saveDocument">
  <!-- Hidden fields for model binding -->
  @Html.HiddenFor(m => m.DocumentImageId)
  @* … many more HiddenFor fields … *@

  <!-- Card container -->
  <div class="card">
    <h4>Edit Document</h4>
    <div data-repeater-list="outer-group" class="outer">
      <!-- Dynamic repeater: multiple grouped fields -->
      <div data-repeater-item class="outer">
        <!-- Document Type selector -->
        … See [4.1 Document Type Selector](#41-document-type-selector) …

        <!-- Dynamic Index Fields -->
        … See [4.2 Dynamic Index Fields](#42-dynamic-index-fields) …
      </div>
    </div>

    <!-- Save button triggers spinner -->
    <input type="hidden" id="category" name="category" value="@category" />
    <button type="submit" id="saveDocument" class="btn btn-primary">
      Save Document
    </button>
  </div>
</form>

4.1 Document Type Selector

<div class="row mb-3">
  <label class="col-md-3">Document Type</label>
  <div class="col-md-9">
    <select asp-for="DocumentType"
            asp-items="@Model.DocumentTypes"
            class="form-control col-sm-6">
      <option value="" disabled selected>@Model.DocumentType</option>
    </select>
  </div>
</div>
  • asp-items bound to Model.DocumentTypes (SelectList).
  • Pre-selects current Model.DocumentType.

4.2 Dynamic Index Fields

Depending on each IndexItem in Model.IndexList, the view renders the appropriate input:

Condition Rendered Control
`AttributeType == Text
LinkEmployeeData <select> populated by Model.EmployeeData
LinkJobData <select> populated by Model.JobData
LinkCustomerData <select> populated by Model.CustomerData
AttributeName contains "State" <select> populated by Model.StateData
IsMultiValue <select> using IndexItem.MultiValueTypes
AttributeType == Date <input type="date">
AttributeType == Number <input type="number">
AttributeType == Currency <input type="number"> with $ prefix
AttributeType == Boolean <select> Yes / No
Default <textarea> fallback

Code sample for a date field:

<div class="row mb-4">
  <label class="col-form-label col-lg-3">
    @item.AttributeName
  </label>
  <div class="col-lg-9">
    <input id="@item.AttributeName"
           asp-for="@item.IndexValue"
           type="date"
           value="@item.IndexValue" />
  </div>
</div>

4.3 Save Button & Loading Spinner

  • #saveDocument click triggers a spinner overlay via spin.js.
  • CSS styles in-page ensure a center‑screen translucent overlay:
#loading { display: none; /* … overlay styling … */ }
$("#saveDocument").click(function() {
  $("#loading").fadeIn();
  new Spinner(opts).spin(document.getElementById('loading'));
});

📑 PDF Preview

On the right-hand side, an <embed> shows the current document:

<embed id="frPDF"
       width="100%"
       height="100%"
       src="@Url.Action(
               "EditDocumentPreview",
               "AccountingImaging",
               new { id = Model.DocumentImageId, category = category }
             )#zoom=FitH"
       type="application/pdf">
  • Zoom=FitH makes the PDF fit horizontally.
  • Dynamically loaded via the EditDocumentPreview action.

🛠 Dependencies & Technologies

Library / Framework Purpose
ASP.NET Core Razor View templating
jQuery DOM manipulation and AJAX
Bootstrap 4/5 Layout & styling, datepicker
bootstrap-datepicker Datepicker widget
dropzone.css Drag‑n‑drop file upload styles
select2 Enhanced <select> styling & filtering
tinymce Rich-text editor (currently unused)
jquery.repeater Repeatable form groups
spin.js Loading spinner
MetisMenu, SimpleBar Sidebar & scrollbars
node-waves Ripple effect on buttons

👤 View Model: DocumentImaging

public class DocumentImaging
{
  public int DocumentImageId       { get; set; }
  public string DocumentType       { get; set; }
  public List<SelectListItem> DocumentTypes { get; set; }
  public List<IndexItem> IndexList { get; set; }
  public bool IsLegalDocument      { get; set; }
  public bool IsSafety             { get; set; }
  public bool IsIT                 { get; set; }
  public bool IsAccounting         { get; set; }
  public bool IsBidding            { get; set; }
  public IEnumerable<SelectListItem> EmployeeData { get; set; }
  public IEnumerable<SelectListItem> JobData      { get; set; }
  public IEnumerable<SelectListItem> CustomerData { get; set; }
  public IEnumerable<SelectListItem> StateData    { get; set; }
  // … plus hidden fields for internal tracking …
}

📊 Data Model: IndexItem

public class IndexItem
{
  public int Id                   { get; set; }
  public string AttributeName     { get; set; }
  public AttributeType AttributeType { get; set; }
  public bool IsMultiValue        { get; set; }
  public bool IsRequired          { get; set; }
  public bool LinkEmployeeData    { get; set; }
  public bool LinkJobData         { get; set; }
  public bool LinkCustomerData    { get; set; }
  public string IndexValue        { get; set; }
  public IEnumerable<SelectListItem> MultiValueTypes { get; set; }
}

AttributeType is an enum:

public enum AttributeType
{
  Text,
  Character,
  Date,
  Number,
  Currency,
  Boolean
}

🔧 Helper Methods & Utilities

  • Url.Action(...): Generates URLs for preview and forms.
  • jQuery .select2(): Enhances <select> with search/filter.
  • Spin.js: Creates and configures the loading spinner.
  • Inline JS for:
    • Customer–Name sync: Splits Customer Number on - and updates Customer Name readonly.

🔌 Third‑Party Integrations

  • Select2 (v4.1.0): Autocomplete dropdowns.
  • Bootstrap Datepicker: Calendar UI for date fields.
  • jQuery Repeater: Group repeated fields for dynamic indexing.
  • Spin.js: Loading indicator overlay.

🖥 Usage Examples

  1. Navigate to Accounting Imaging > Edit on a scanned document.
  2. Attach any new pages/files on the left.
  3. Modify Document Type or any index fields on the right.
  4. Click Save Document → observe the spinner → redirected or confirmation message.
  5. Preview updates in the embedded PDF viewer.

🏷 UML Class Diagram

classDiagram
    DocumentImaging o-- IndexItem
    DocumentImaging : +int DocumentImageId
    DocumentImaging : +string DocumentType
    DocumentImaging : +List<SelectListItem> DocumentTypes
    DocumentImaging : +List<IndexItem> IndexList
    DocumentImaging : +bool IsAccounting
    IndexItem : +int Id
    IndexItem : +string AttributeName
    IndexItem : +AttributeType AttributeType
    IndexItem : +bool IsMultiValue
    IndexItem : +string IndexValue
    IndexItem : +IEnumerable<SelectListItem> MultiValueTypes

🎯 Conclusion

The Edit.cshtml view is a powerful, dynamic interface for managing scanned documents in the Accounting area. It supports:

  • File attachments
  • Dynamic metadata editing
  • Real-time PDF preview
  • Responsive UX with spinners and enhanced dropdowns

Use this documentation to understand, maintain, or extend the edit workflow for the IrbyImaging application. Happy coding! 🚀