π 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
- Overview & Purpose
- Dependencies & Technologies
- Data Models & View Models
- Structure & Key Functional Areas
- Helper Methods & Utilities
- Error Handling & Return Types
- Third-Party Integrations
- Sample Code Blocks
- Usage Examples
- UML Class Diagram
- 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.IndexListto 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"withstep="0.01" - Number:
type="number"withstep="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 ofAttributeName(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
-
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); } -
Select2 Initialization
Enhances all.js-example-basic-singleselects:$(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
- Include Partial in a Modal
<div class="modal-body"> @await Html.PartialAsync("_myModalIndexes", Model.DocumentImaging) </div> - 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! π