📄 IrbyImaging/Views/LegalImaging/Search.cshtml Documentation

Welcome to the comprehensive documentation for the Search.cshtml Razor View in the IrbyImaging application. This file underpins the Search Uploaded Document page for legal imaging workflows: letting users select a document type, fill in dynamic indexing fields, perform searches, and view results.


📑 Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
    2.1. Document Type Selection
    2.2. Dynamic Index Field Generation
    2.3. Search Results Table
  3. Dependencies & Technologies
  4. View Models & Data Models
  5. Helper Methods & Utilities
  6. Error Handling & Validation
  7. API Endpoints Overview
  8. Third‑Party Integrations
  9. Sample Code Blocks
  10. Usage Example
  11. UML Diagram
  12. Conclusion

1. Overview & Purpose

Search.cshtml is a Razor view rendered by the LegalImaging controller. It provides a user interface to:

  • 🔍 Select a document type from a predefined list.
  • ⚙️ Dynamically generate search/index fields based on the selected type.
  • 📑 Submit search criteria and display matching documents in a data table.
  • 📂 Offer detail, preview, view OCR, edit, and delete operations on each document.

This facilitates indexing and retrieval of scanned legal documents.


2. Key Functional Areas

2.1. Document Type Selection

  • Form: <form asp-action="Search" ...>
  • Hidden Inputs: Persist DocumentImageId, BatchIds, FilePath, etc.
  • Dropdown: <select asp-for="DocumentType" ... asp-items="@Model.DocumentTypes">
  • Submit Button: <button id="searchDocument">Get Indexes</button>
<h4>Select Document Type</h4>
<select asp-for="DocumentType" asp-items="@Model.DocumentTypes">
  <option disabled selected>Select Document Type</option>
</select>
<button type="submit" id="searchDocument" class="btn btn-primary">Get Indexes</button>

2.2. Dynamic Index Field Generation

Once the Get Indexes form submits, the controller populates Model.IndexList. The view:

  • Iterates Model.IndexList entries.

  • For each, inspects properties:

    • AttributeType (Text, Character, Date, Number, Currency, Boolean)
    • IsMultiValue
    • LinkEmployeeData, LinkJobData, LinkCustomerData
    • AttributeName (e.g., contains “State”)
  • Renders appropriate input:

    • TextArea for AttributeType.Text/Character
    • Select2-enabled <select> for employee, job, customer, state, multi-values
    • Date input for AttributeType.Date
    • Number/Currency inputs
    • Yes/No select for AttributeType.Boolean
@for (int i = 0; i < Model.IndexList.Count; i++) {
  var idx = Model.IndexList[i];
  if (idx.AttributeType == AttributeType.Text) {
    <textarea asp-for="idx.IndexValue">Select @idx.AttributeName</textarea>
  }
  else if (idx.LinkEmployeeData) {
    <select asp-for="idx.IndexValue" asp-items="@Model.EmployeeData" class="js-example-basic-single"></select>
  }
  // ... other cases ...
}

2.3. Search Results Table

After searching, Model.ImagingList holds results. The view:

  • Includes DataTables CSS/JS
  • Builds <table id="datatable-buttons"> with column headers:
    • Document Type, all IndexList.AttributeName fields, Details, Preview, View, Edit, Delete
  • For each document (item):
    • Displays index values
    • Provides modal detail/preview (.anchorDetail, .anchorDetail1)
    • Links:
      • ViewOCR (new window)
      • Edit (new window)
      • DeleteUploadedDocument
<table id="datatable-buttons" class="table ...">
  <thead>
    <tr>
      <th>Document Type</th>
      @foreach(var hdr in rec.IndexList) { <th>@hdr.AttributeName</th> }
      <th>Details</th><th>Preview</th><th>View</th><th>Edit</th><th>Delete</th>
    </tr>
  </thead>
  <tbody>
    @foreach(var item in Model.ImagingList) {
      <tr>
        <td>@item.DocumentType</td>
        @for(int j=0; j<item.IndexList.Count; j++) {
          <td>@item.IndexList[j].IndexValue</td>
        }
        <td><a class="anchorDetail" data-id="@item.DocumentImageId">Details</a></td>
        <!-- ... -->
      </tr>
    }
  </tbody>
</table>

3. Dependencies & Technologies

Category Library / Framework
UI Framework Bootstrap v4
Date Picker bootstrap-datepicker
File Upload Dropzone
JavaScript jQuery
Select Dropdown Select2
Data Grids DataTables (+ Buttons extension)
Syncfusion Syncfusion.EJ2 & Syncfusion.JavaScript
JSON Newtonsoft.Json

4. View Models & Data Models

  • Model: IrbyImaging.Models.DocumentImaging

    • DocumentImageId (GUID)
    • ReferenceId, FilePath, ContentType
    • BatchIds (IEnumerable<GUID>)
    • DocumentTypes (SelectList)
    • IndexList (List<IndexModel>)
    • ImagingList (List<DocumentImaging> for results)
    • IndexModel properties:
      • Id, AttributeName, AttributeType (enum), IsMultiValue, LinkEmployeeData, LinkJobData, LinkCustomerData, IsRequired, IndexValue, MultiValueTypes (SelectList)
  • Enum: IrbyImaging.DomainClasses.AttributeType

    • Text, Character, Date, Number, Currency, Boolean

5. Helper Methods & Utilities

  • Razor Sections:

    • @section styles{...} – includes CSS assets
    • @section Scripts{...} – includes JS assets & initialization (Select2)
  • Batch GUID List:

    var guidList = string.Join(",", Model.BatchIds);
    <input type="hidden" id="batchId" value="@guidList" />
    
  • Anti‑Forgery: @Html.AntiForgeryToken()


6. Error Handling & Validation

  • Validation Summary:
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    
  • Required Fields: Controlled server‑side via Model attributes ([Required], etc.)
  • Client‑side: Basic HTML5 (required attributes not shown, but can be added)

7. API Endpoints Overview

Action HTTP Controller Purpose
Search POST LegalImaging Retrieve index metadata
List POST LegalImaging Perform document search
ViewOCR GET LegalImaging Display OCR view
Edit GET LegalImaging Edit document indexing
DeleteUploadedDocument GET LegalImaging Delete a document entry

8. Third‑Party Integrations

  • Syncfusion EJ2: (commented-out <ejs-multiselect>) – for rich multiselect if re‑enabled.
  • Select2: Enhanced dropdowns:
    $(document).ready(() => $('.js-example-basic-single').select2());
    
  • DataTables: Sorting, pagination, export buttons (CSV/PDF) – CSS included, JS assumed elsewhere.

9. Sample Code Blocks

Dynamic Field Rendering

@if (idx.LinkJobData) {
  <select asp-for="idx.IndexValue" class="js-example-basic-single" asp-items="@Model.JobData">
    <option>Select @idx.AttributeName Value</option>
  </select>
}

DataTable Initialization

<link rel="stylesheet" href="https://cdn.datatables.net/...">
<table id="datatable-buttons" class="table table-striped">
  <!-- thead, tbody -->
</table>

10. Usage Example

  1. Navigate to /LegalImaging/Search.
  2. Select “Document Type” → Click Get Indexes.
  3. Fill dynamic fields (e.g., Date, Text, Select).
  4. Click Search Document.
  5. Review results in the DataTable → use actions (Details, Preview, View, Edit, Delete).

11. UML Diagram

+----------------------+          +---------------------+
| DocumentImaging      |1       * | IndexModel          |
+----------------------+----------+---------------------+
| - DocumentImageId    |          | - Id                |
| - DocumentType       |          | - AttributeName     |
| - BatchIds[]         |          | - AttributeType     |
| - IndexList[]        |          | - IsMultiValue      |
| - ImagingList[]      |          | - LinkEmployeeData  |
+----------------------+          | - IndexValue        |
                                  +---------------------+

12. Conclusion

This Search.cshtml view orchestrates a dynamic, data‑driven UI for legal document retrieval, leveraging Razor, ASP.NET Core MVC, and modern JS plugins. It cleanly separates concerns:

  • Form 1: Retrieve indexing schema.
  • Form 2: Execute search with generated fields.
  • Results: Interactive DataTable with full CRUD-like actions.

By understanding each section, you can extend attribute types, integrate additional UI widgets (Syncfusion Multiselect), or hook custom client‑side validation. Happy coding! 🚀