π _myModalIndexes.cshtml Documentation
Welcome to the comprehensive documentation for the partial view _myModalIndexes.cshtml located in IrbyImaging/Views/HRImaging/. This file dynamically renders indexing controls for a document-imaging workflow based on metadata provided by a DocumentImaging model.
ποΈ Table of Contents
- Overview & Purpose
- Key Functional Areas
- Dependencies & Technologies
- View Model & Data Models
- Rendering Logic
- Input Fields & Conditional Rendering
- Helper Methods & Utilities
- Third-Party Integrations
- Usage Examples
- UML Diagram
- Conclusion
1. Overview & Purpose
β¨ Purpose
This partial view is designed to dynamically generate form fields inside a modal (or any container) for each index attribute defined in the DocumentImaging.IndexList. It:
- Persists index metadata via hidden inputs.
- Renders the appropriate input control based on property flags and types.
- Leverages Select2 for enhanced dropdowns.
- Integrates with Syncfusion EJ2 for multi-value filtering (optional/commented).
Use this view to capture indexing metadata (e.g., dates, amounts, checkboxes, lookups) when uploading or editing a document in the HR Imaging module.
2. Key Functional Areas
- Hidden Metadata Fields
Ensures all index definitions post back correctly (Id,AttributeName, etc.). - Conditional Control Rendering
Chooses between<select>,<input>,<textarea>, or checkboxes based on:IsMultiValueAttributeType(Date / Currency / Number / Boolean)LinkEmployeeData/LinkJobData/LinkCustomerDataAttributeNamecontent (e.g., βCustomer Numberβ, βStateβ)
- Third-Party Enhancements
- Select2 for single/multi-select dropdowns
- Syncfusion EJ2 filtering hooks (commented out but scaffolded)
3. Dependencies & Technologies
| Technology | Purpose |
|---|---|
| ASP.NET Core MVC (Razor) | Server-side view rendering |
| Syncfusion.EJ2 | Multi-select & filtering (optional) |
| Newtonsoft.Json | JSON serialization for filtering data |
| Select2 | Advanced select dropdowns (jQuery-based) |
| jQuery | DOM manipulation & plugin initialization |
4. View Model & Data Models
4.1 DocumentImaging (CS Model)
public class DocumentImaging {
public List<IndexAttribute> IndexList { get; set; }
public SelectList EmployeeData { get; set; }
public SelectList JobData { get; set; }
public SelectList CustomerData { get; set; }
public SelectList CustomerData1 { get; set; } // e.g., for Customer Name
public SelectList StateData { get; set; }
}
4.2 IndexAttribute (Represents one index field)
| Property | Type | Description |
|---|---|---|
int Id |
Integer | Unique identifier for the attribute. |
string AttributeName |
String | Display name of the attribute. |
string IndexValue |
String | Value entered/selected by the user. |
bool IsMultiValue |
Boolean | Indicates if multiple values allowed. |
AttributeType AttributeType |
Enum | Data type: Date, Currency, Number, Boolean. |
bool IsRequired |
Boolean | Validation flag (not explicitly rendered). |
bool LinkEmployeeData |
Boolean | Should render employee lookup. |
bool LinkJobData |
Boolean | Should render job lookup. |
bool LinkCustomerData |
Boolean | Should render customer lookup(s). |
5. Rendering Logic
The view iterates over Model.IndexList:
@for (var i = 0; i < Model.IndexList.Count; i++) {
<!-- 1) Render hidden fields for all metadata -->
<input type="hidden" asp-for="@Model.IndexList[i].Id" />
<input type="hidden" asp-for="@Model.IndexList[i].AttributeName" />
<!-- ...other hidden fields... -->
<!-- 2) Conditional rendering chain -->
if (Model.IndexList[i].IsMultiValue) {
<!-- Multi-value dropdown -->
}
else if (Model.IndexList[i].AttributeType == AttributeType.Date) {
<!-- Date picker -->
}
// ... currency, number, boolean ...
else {
// Lookup fields or default textarea
}
}
6. Input Fields & Conditional Rendering
6.1 Hidden Metadata
<input type="hidden" asp-for="@Model.IndexList[i].IsMultiValue" />
<input type="hidden" asp-for="@Model.IndexList[i].AttributeType" />
<!-- etc. -->
6.2 Multi-Value (Enumeration)
<select name="IndexValue"
id="@Model.IndexList[i].AttributeName"
class="form-control"
asp-items="@Model.IndexList[i].MultiValueTypes">
<option disabled hidden>Select @Model.IndexList[i].AttributeName</option>
</select>
6.3 Date
<input name="IndexValue"
type="date"
autocomplete="off"
class="form-control" />
6.4 Currency & Number
| Type | Markup Example |
|---|---|
| Currency | $ <input type="number" step="0.01" value="0.00" ... /> |
| Number | <input type="number" step="0.01" value="0" ... /> |
6.5 Boolean
<input name="IndexValue" type="checkbox" value="false" />
<label> @Model.IndexList[i].AttributeName </label>
6.6 Linked Lookups
- Employee:
LinkEmployeeData == trueβasp-items="@Model.EmployeeData" - Job:
LinkJobData == trueβasp-items="@Model.JobData" - Customer:
LinkCustomerData == true- Customer Number β
asp-items="@Model.CustomerData" - Customer Name β
asp-items="@Model.CustomerData1"
- Customer Number β
- State:
AttributeName.Contains("State")βasp-items="@Model.StateData"
Default Text (if no condition met):
<textarea name="IndexValue" class="form-control"
placeholder="Enter @Model.IndexList[i].AttributeName ..."></textarea>
7. Helper Methods & Utilities
7.1 Syncfusion Filtering Hook
(Commented out β requires EJ2 integration)
function onfiltering(e) {
var query = new ej.data.Query();
query = (e.text !== '')
? query.where('Name', 'startswith', e.text, true)
: query;
e.updateData(@Html.Raw(JsonConvert.SerializeObject(ViewBag.data)), query);
}
7.2 Select2 Initialization
<script>
$(document).ready(function() {
$('.js-example-basic-single').select2();
});
</script>
8. Third-Party Integrations
| Library / Plugin | Role |
|---|---|
| Select2 | Enhanced dropdown UX |
| jQuery | DOM ready, plugin init |
| Syncfusion EJ2 | Advanced multi-select/filtering (opt.) |
| Newtonsoft.Json | Serialization in client script |
9. Usage Examples
9.1 Rendering within a Modal
<!-- In your parent view -->
<button data-toggle="modal" data-target="#indexModal">Index Document</button>
<div id="indexModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
@await Html.PartialAsync("_myModalIndexes", Model.DocumentImaging)
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
9.2 Posting Back
When the form is submitted, all hidden fields plus the user-entered IndexValue controls will bind back to your action:
[HttpPost]
public IActionResult IndexDocument(DocumentImaging model) {
// model.IndexList contains updated IndexValue and metadata
// Save to database...
return RedirectToAction("Success");
}
10. UML Diagram
classDiagram
class DocumentImaging {
+List<IndexAttribute> IndexList
+SelectList EmployeeData
+SelectList JobData
+SelectList CustomerData
+SelectList CustomerData1
+SelectList StateData
}
class IndexAttribute {
+int Id
+string AttributeName
+string IndexValue
+bool IsMultiValue
+AttributeType AttributeType
+bool IsRequired
+bool LinkEmployeeData
+bool LinkJobData
+bool LinkCustomerData
}
DocumentImaging "1" o-- "*" IndexAttribute : contains
IndexAttribute --> AttributeType : uses
Note: To render this diagram, ensure your markdown renderer supports Mermaid.
11. Conclusion
π― By using _myModalIndexes.cshtml, you gain a flexible, metadata-driven form generator for indexing documents in your HR Imaging module. It:
- Encapsulates logic in a reusable partial view.
- Adapts to new attribute types without markup changes.
- Leverages hidden fields to ensure data integrity.
- Integrates Select2 & Syncfusion for a polished UI/UX.
Feel free to extend the conditional blocks for new AttributeType values or link against additional lookup data as your application grows!
Happy coding! π