📄 Search Uploaded Document View Documentation (Search.cshtml)

Welcome to the comprehensive documentation for IrbyImaging/Views/HRImaging/Search.cshtml. This view powers the Search Uploaded Document feature in the HR Imaging module, allowing users to pick a document type, fill in index fields dynamically, and retrieve matching documents in a rich DataTable.


📑 Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Data & Models
  4. View Structure & Key Sections
  5. Flow & Interactions
  6. Usage Example
  7. Conclusion

1. Overview & Purpose 🚀

The Search.cshtml view enables end-users to:

  • Select a document type from a drop‑down.
  • Dynamically render indexing fields (text, date, number, dropdowns, etc.) based on the chosen document type.
  • Search existing uploaded documents by entering index values.
  • View, Preview, Edit, Delete, or see Details of matching documents.

This multi‑stage process improves user experience by only showing relevant fields for each document type.


2. Dependencies & Technologies 🔧

Category Technology / Library
ASP.NET Core MVC Razor View (.cshtml), Tag Helpers
JavaScript Plugins jQuery, Select2, DataTables, Bootstrap Datepicker, Dropzone CSS
Syncfusion Syncfusion.JavaScript, Syncfusion.EJ2 (commented/outlined)
JSON Newtonsoft.Json
Styling Bootstrap 4, custom styles

3. Data & Models 📦

3.1. ViewModel: DocumentImaging

The view is strongly typed to:

@model IrbyImaging.Models.DocumentImaging

Key properties:

  • Guid DocumentImageId
  • string FilePath, string Preview
  • List<Guid> BatchIds
  • string DocumentType & SelectList DocumentTypes
  • List<IndexModel> IndexList
  • SelectList EmployeeData, JobData, CustomerData, StateData
  • List<DocumentImaging> ImagingList (for result display)

📘 The actual DocumentImaging class defines all necessary fields for indexing and search results.

3.2. Index Model

Each IndexModel in IndexList represents a searchable attribute:

Property Type Purpose
int Id int Unique identifier
string AttributeName string Label shown to user
AttributeType enum Field type: Text, Number, Date, Boolean, Currency…
bool IsMultiValue bool Indicates dropdown (SelectList) vs. single input
bool LinkEmployeeData/JobData/CustomerData bool Dropdown populated from respective source
SelectList MultiValueTypes SelectList Options for multi-value or boolean fields
string IndexValue string Bound value for search parameter

4. View Structure & Key Sections 🏗️

4.1. Header & Usings

@model IrbyImaging.Models.DocumentImaging
@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@using Syncfusion.EJ2
@using Newtonsoft.Json

@{
    ViewData["Title"] = "Search Uploaded Document";
    Layout = "~/Views/Shared/_Layout.cshtml";
    // Prepare batch GUID list for hidden field
    var guidList = string.Join(",", Model.BatchIds);
}
  • @model: Declares the ViewModel
  • @using: Imports Syncfusion & JSON libs
  • ViewBag / locals: Pre-computed values for hidden inputs

4.2. CSS Styles Section

@section styles {
  <link href="~/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" />
  <link href="~/libs/dropzone/min/dropzone.min.css" rel="stylesheet" type="text/css" />
}
  • Includes Datepicker & Dropzone CSS for future enhancements.

4.3. Form 1: Document Type Selection

<form asp-action="Search" method="post" id="validation-form">
  @Html.AntiForgeryToken()
  @Html.HiddenFor(m => m.BatchIds, new { Value = lists })
  <div class="card">
    <div class="card-body">
      <h4>Select Document Type</h4>
      <div class="form-group">
        <label>Document Type</label>
        <select asp-for="DocumentType" asp-items="Model.DocumentTypes"
                class="form-control">
          <option value="" disabled selected>Select Document Type</option>
        </select>
      </div>
      <button type="submit" class="btn btn-primary">Get Indexes</button>
    </div>
  </div>
</form>
  • Posts to HRImagingController.Search
  • Renders a dropdown of available document types
  • On submit, triggers retrieval of IndexList for the selected type

4.4. Form 2: Dynamic Search Fields

Displayed only if Model.IndexList.Count > 0:

<form asp-action="List" method="post">
  @Html.AntiForgeryToken()
  @Html.HiddenFor(m => m.DocumentType)
  @Html.HiddenFor(m => m.BatchIds, new { Value = lists })
  
  @* Loop through IndexList and render appropriate input *@
  @for (int i=0; i < Model.IndexList.Count; i++) {
    var idx = Model.IndexList[i];
    <input type="hidden" asp-for="Model.IndexList[i].Id" />
    <div class="row mb-4">
      <label class="col-lg-3">@idx.AttributeName</label>
      <div class="col-lg-9">
        @* Conditional rendering based on idx.AttributeType and flags *@
        @if (idx.AttributeType == DomainClasses.AttributeType.Date) {
          <input asp-for="@idx.IndexValue" type="date" class="form-control"/>
        }
        else if (idx.IsMultiValue) {
          <select asp-for="@idx.IndexValue"
                  asp-items="@idx.MultiValueTypes"
                  class="form-control">
            <option>Select @idx.AttributeName Value</option>
          </select>
        }
        else if (idx.LinkEmployeeData) {
          <select asp-for="@idx.IndexValue"
                  asp-items="Model.EmployeeData"
                  class="js-example-basic-single form-control">
            <option>Select @idx.AttributeName Value</option>
          </select>
        }
        @* ... other types: Textarea, Number, Currency, Boolean ... *@
      </div>
    </div>
  }
  
  <input type="hidden" id="batchId" value="@guidList" />
  <button type="submit" class="btn btn-primary">Search Document</button>
</form>
  • Dynamic field generation covers:
    • Text (<textarea>), Character, Multi‑value, Date, Number, Currency, Boolean, Linked dropdowns
  • Hidden inputs preserve essential metadata (IDs, batch list)
  • Leverages select2 for searchable dropdowns (js-example-basic-single class)

4.5. Results Table (DataTables)

When Model.ImagingList is populated, a DataTable displays results:

<table id="datatable-buttons"
       class="table table-striped table-bordered dt-responsive nowrap">
  <thead>
    <tr>
      <th>Document Type</th>
      @foreach(var hdr in Model.ImagingList.First().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 doc in Model.ImagingList) {
      <tr>
        <td>@doc.DocumentType</td>
        @for(int j=0; j<doc.IndexList.Count; j++){
          <td>@doc.IndexList[j].IndexValue</td>
        }
        <td><a class="anchorDetail" data-id="@doc.DocumentImageId">Details</a></td>
        <td><a class="anchorDetail1" data-prev="preview" data-id="@doc.DocumentImageId">Preview</a></td>
        <td>@Html.ActionLink("View", "ViewOCR", new { id=doc.DocumentImageId }, new { target = "_blank" })</td>
        <td>@Html.ActionLink("Edit", "Edit", new { id=doc.DocumentImageId }, new { target = "_blank" })</td>
        <td>@Html.ActionLink("Delete", "DeleteUploadedDocument", new { id=doc.DocumentImageId }, new { target = "_blank" })</td>
      </tr>
    }
  </tbody>
</table>
  • DataTables styling & responsive layout
  • Action Links for CRUD operations
  • Modals (via anchorDetail/anchorDetail1) are placeholders for AJAX-loaded content

4.6. Scripts Section

@section Scripts {
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <link  href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet" />
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>
  <script>
    $(document).ready(function() {
      $('.js-example-basic-single').select2();
    });
  </script>
}
  • Select2 initialization for enhanced dropdown UX
  • jQuery for future modal/event handlers

5. Flow & Interactions 🔄

  1. Page Load
    • Renders Form 1 with document type dropdown.
  2. Select & Submit → Search action
    • Controller loads IndexList for that type.
    • View re-renders showing Form 2.
  3. Fill Index Fields & Submit → List action
    • Controller queries and returns matching ImagingList.
    • View re-renders both forms & Results Table.
  4. Interact with results:
    • Details / Preview via modal
    • View/Edit/Delete via new windows

5.1. Sequence Diagram (Mermaid)

sequenceDiagram
  participant U as User
  participant V as Search.cshtml
  participant C as HRImagingController

  U->>V: GET /HRImaging/Search
  V-->>U: Render Form 1

  U->>V: POST /Search (DocumentType)
  V->>C: Search(DocumentType, BatchIds)
  C-->>V: DocumentImaging (with IndexList)
  V-->>U: Render Form 1 & Form 2

  U->>V: POST /List (Index values, DocumentType)
  V->>C: List(SearchCriteria)
  C-->>V: DocumentImaging (with ImagingList)
  V-->>U: Render Forms & Results Table

6. Usage Example 🛠️

  1. Navigate to /HRImaging/Search.
  2. Select “Employee Onboarding Form” from the dropdown.
  3. Click Get Indexes.
  4. Enter values:
    • Employee Name (linked dropdown)
    • Date of Joining (date picker)
    • Department (multi-value)
  5. Click Search Document.
  6. View matching records in the table.
  7. Preview or Edit as needed.

7. Conclusion ✅

Search.cshtml is a fully dynamic, multi-step Razor view, blending ASP.NET Core MVC with powerful JS plugins:

  • Modular Forms that evolve based on back-end metadata (IndexList).
  • Rich UX via Select2, DataTables, datepickers, and modals.
  • Scalable: Easily extend new document types or index attributes.

With clear structure and separation of concerns, customizing or extending this view for additional document types or fields is straightforward. Happy coding! 🎉