πŸ“š Documentation for _myModalIndexes.cshtml

Location: IrbyImaging/Views/AccountingImaging/_myModalIndexes.cshtml
Type: Razor Partial View
Purpose: Dynamically render indexing fields in a modal popup for the Document Imaging module.


πŸ—‚ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Data Models & View Models
  4. Structure & Key Functional Areas
  5. Helper Methods & Utilities
  6. Error Handling & Return Types
  7. Third-Party Integrations
  8. Sample Code Blocks
  9. Usage Examples
  10. UML Class Diagram
  11. Conclusion

πŸ” Overview & Purpose

This Razor partial view generates a dynamic form inside a modal dialog, where each field corresponds to an indexable attribute of a document. The indexes (metadata) drive search, filtering, and retrieval of scanned documents in the Accounting Imaging module.

  • Dynamic: Loops through Model.IndexList to build fields.
  • Conditional Rendering: Chooses control types (date pickers, dropdowns, checkboxes, text areas) based on attribute metadata.
  • Hidden Fields: Embeds metadata IDs, names, types and flags for each index.
  • Integration: Uses external libraries (Select2, jQuery, Syncfusion) for rich UI.

βš™οΈ Dependencies & Technologies

Library/Framework Purpose
ASP.NET Core Razor View engine
Syncfusion EJ2 (Commented out) advanced controls
Newtonsoft.Json Serializing ViewBag data
jQuery DOM manipulation & ready event
Select2 Enhanced <select> UI/UX
HTML5 Input Types date, number, checkbox
@model IrbyImaging.Models.DocumentImaging
@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@using Syncfusion.EJ2
@using Newtonsoft.Json

πŸ— Data Models & View Models

DocumentImaging (ViewModel)

Property Type Description
IndexList List List of metadata to render
EmployeeData IEnumerable Employee dropdown values
JobData IEnumerable Job dropdown values
CustomerData IEnumerable Customer Number dropdown
CustomerData1 IEnumerable Customer Name dropdown
StateData IEnumerable U.S. states dropdown

IndexField (DomainClasses)

Property Type Description
Id int Unique identifier
AttributeName string Display name of the field
IndexValue string Bound value (via asp-for)
IsMultiValue bool Renders <select multiple> if true
AttributeType AttributeType (enum) Type: Date, Currency, Number, Boolean
IsRequired bool Marks field as required (not used here)
LinkEmployeeData bool Renders Employee dropdown
LinkJobData bool Renders Job dropdown
LinkCustomerData bool Renders Customer dropdown

πŸ”‘ Structure & Key Functional Areas

The core of the view is a for-loop over Model.IndexList:

@for (var i = 0; i < Model.IndexList.Count; i++)
{
    <!-- Hidden metadata inputs -->
    <input type="hidden" asp-for="@Model.IndexList[i].Id" />
    ...
    <!-- Conditional field rendering -->
}

4.1 Hidden Metadata Inputs

All index items are first rendered as hidden fields to preserve metadata upon form submission.

Input Binds To
Id Index identifier
AttributeName Display name
IndexValue Stored value
IsMultiValue, etc. Boolean flags & enums

4.2 Multi-Value Select Fields 🎯

Condition: IsMultiValue == true
Renders a <select> with multiple items:

<select name="IndexValue" id="@Model.IndexList[i].AttributeName"
        class="form-control col-sm-6"
        asp-items="@Model.IndexList[i].MultiValueTypes">
  <option disabled hidden>Select @Model.IndexList[i].AttributeName Value</option>
</select>

4.3 Date Picker Fields πŸ“…

Condition: AttributeType == Date

<input name="IndexValue" type="date" autocomplete="off" />

4.4 Currency & Number Inputs πŸ’²πŸ”’

  • Currency: type="number" with step="0.01"
  • Number: type="number" with step="0.01"
<!-- Currency -->
$ <input name="IndexValue" type="number" min="0" step="0.01" value="0.00" />

<!-- Number -->
<input name="IndexValue" type="number" min="0" step="0.01" value="0" />

4.5 Boolean Checkboxes β˜‘οΈ

Condition: AttributeType == Boolean

<input name="IndexValue" type="checkbox" value="false" />

4.6 Linked Data Drop-downs 🌐

For attributes linked to other domain data (Employee, Job, Customer, State):

<select name="IndexValue"
        class="js-example-basic-single form-control"
        asp-items="@Model.EmployeeData">
    <option value="">Select @Model.IndexList[i].AttributeName</option>
</select>
  • Uses Select2 (.js-example-basic-single) for search/filter.
  • Conditions check LinkEmployeeData, LinkJobData, LinkCustomerData, and substring of AttributeName (e.g., "Customer Number", "Customer Name", "State").

4.7 Default Text Areas πŸ“

Fallback for any other attribute types:

<textarea asp-for="@Model.IndexList[i].IndexValue"
          placeholder="Enter @Model.IndexList[i].AttributeName ...">
</textarea>
<input name="IndexValue" type="hidden" value=" " />

πŸ›  Helper Methods & Utilities

  1. onfiltering (Syncfusion EJ2)
    Filters a Syncfusion data source based on user typing.

    function onfiltering(e) {
        var query = new ej.data.Query();
        if (e.text !== '') {
            query = query.where('Name', 'startswith', e.text, true);
        }
        e.updateData(@Html.Raw(JsonConvert.SerializeObject(ViewBag.data)), query);
    }
    
  2. Select2 Initialization
    Enhances all .js-example-basic-single selects:

    $(document).ready(function() {
      $('.js-example-basic-single').select2();
    });
    

🚨 Error Handling & Return Types

  • Server-side validation: Not present here; rely on ASP.NET Core ModelState in the hosting form.
  • Client-side: HTML5 input types enforce basic rules (e.g., type="date").
  • Select2: Gracefully degrades to normal <select> if JS fails.

πŸ”— Third-Party Integrations

Library Usage
jQuery DOM ready, event wiring
Select2 Searchable dropdowns
Syncfusion EJ2 (Commented out) advanced multi-select
Newtonsoft.Json Serializing server data for JS filters

πŸ“‹ Sample Code Blocks

Rendering a Currency Field

@* Currency Index *@
@if (Model.IndexList[i].AttributeType ==
     IrbyImaging.DomainClasses.AttributeType.Currency)
{
  <div class="row mb-4">
    <label class="col-lg-3 col-form-label">
      @Model.IndexList[i].AttributeName
    </label>
    <div class="col-lg-9">
      $ <input name="IndexValue"
               type="number" min="0" step="0.01" value="0.00" />
    </div>
  </div>
}

Employee Dropdown with Select2

@if (Model.IndexList[i].LinkEmployeeData)
{
  <select name="IndexValue"
          class="js-example-basic-single form-control"
          asp-items="@Model.EmployeeData">
    <option value="">Select Employee...</option>
  </select>
}

πŸš€ Usage Examples

  1. Include Partial in a Modal
    <div class="modal-body">
      @await Html.PartialAsync("_myModalIndexes", Model.DocumentImaging)
    </div>
    
  2. Form Submission
    <form asp-action="SaveIndexes" method="post">
      <!-- Hidden metadata & dynamic fields from partial -->
      <button type="submit" class="btn btn-primary">Save</button>
    </form>
    

πŸ“ˆ UML Class Diagram

+------------------------+
| DocumentImaging        |
+------------------------+
| - List<IndexField>     |
| - EmployeeData         |
| - JobData              |
| - CustomerData         |
| - CustomerData1        |
| - StateData            |
+------------------------+

         1
DocumentImaging <>---- * IndexField
         |
+------------------------+
| IndexField             |
+------------------------+
| - Id : int             |
| - AttributeName:string |
| - IndexValue:string    |
| - IsMultiValue: bool   |
| - AttributeType: enum  |
| - LinkEmployeeData: bool |
| - LinkJobData: bool    |
| - LinkCustomerData: bool|
+------------------------+

🏁 Conclusion

This partial view powers the dynamic indexing interface in the Accounting Imaging module.
By leveraging Razor, HTML5, and third-party UI libraries, it renders context-sensitive inputs for each metadata fieldβ€”ensuring data integrity, improved user experience, and seamless integration with the backend processing pipeline.

Feel free to extend by:

  • Adding client-side validation.
  • Utilizing Syncfusion controls (uncomment and configure).
  • Customizing styles and localization.

Happy coding! πŸš€