πŸ“„ WorkOrderDirectory.cshtml Documentation


πŸ“‘ Table of Contents

  1. 🎯 Overview & Purpose
  2. πŸ”‘ Key Functional Areas
  3. βš™οΈ Dependencies & Technologies
  4. 🧩 View Models & Data Models
  5. πŸ› οΈ Helper Methods & Utilities
  6. 🚨 Error Handling & Validation
  7. πŸ”— API Endpoints & Routing
  8. 🎨 UI Components & Layout
  9. πŸ’» Sample Code Snippets
  10. πŸ“ˆ UML Diagrams
  11. πŸš€ Usage Examples
  12. πŸ”š Conclusion

🎯 Overview & Purpose

The WorkOrderDirectory.cshtml Razor View is part of the JDE area of the IrbyImaging web application. It serves two primary purposes:

  1. πŸ” Search Interface
    Provides a rich, form-based search panel to filter work orders by criteria such as type, status, numbers, names, and references.

  2. πŸ“Š Data Presentation
    Displays the resulting work orders in an interactive Syncfusion EJ2 TreeGrid, supporting paging, sorting, filtering, searching, and export (Excel/PDF).

This page empowers users to find, explore, and export work order data seamlessly.


πŸ”‘ Key Functional Areas

Section Description
1. Search Form A <form> with dropdowns and text inputs to specify search filters.
2. Work Order List A <ejs-grid> (TreeGrid) to render hierarchical work order data.
3. Client-Side Scripts JavaScript functions for data binding, searching, exporting, and templating.
4. Styles & Assets CSS overrides and references to Bootstrap, Select2, and other libraries.

βš™οΈ Dependencies & Technologies

Category Libraries / Frameworks
Server-Side ASP.NET Core MVC (Razor), Model Binding, Anti-Forgery
Grid UI Syncfusion EJ2 (TreeGrid, Button, Export)
Client-Side jQuery, Bootstrap, Select2, SimpleBar, Waves.js, Tinymce
Date/Time Picker Bootstrap Datepicker
Form Utilities jQuery Repeater
Others Spin.js (loading indicator)

🧩 View Models & Data Models

1. IrbyImaging.UI.Models.WorkOrders

The view strongly-types to this model. Internally, WorkOrderDirectory.cshtml binds a list of work orders to the grid via ViewBag.datasource.

@model IrbyImaging.UI.Models.WorkOrders
@* Model likely contains:
   List<WorkOrder> Items;
   // ... additional metadata or filter defaults
*@

2. WorkOrder Data Model

classDiagram
    class WorkOrder {
        +string Name
        +string WorkOrderNumber
        +string WorkOrderType
        +Job Job
        +string Status
        +string Reference
        +decimal EstimatedHours
        +decimal EstimatedAmount
        +DateTime DateAssigned
        +DateTime DateStart
        +DateTime DateComplete
        +List~WorkOrder~ Children
    }
    class Job {
        +int JobId
        +string JdeNumber
        +string Name
    }
    WorkOrder *-- Job
    WorkOrder *-- WorkOrder : Children
  • Children: Enables hierarchical (tree) display of related work orders.

πŸ› οΈ Helper Methods & Utilities

1. JavaScript Event Handlers

  • dataBound(args)
    Auto-fits all columns after data is bound.

    function dataBound(args) {
      this.autoFitColumns([
        'Name', 'WorkOrderNumber', 'WorkOrderType',
        'Job.JdeNumber', 'Job.Name', 'Status',
        'Reference', 'EstimatedHours', 'EstimatedAmount',
        'DateAssigned', 'DateStart', 'DateComplete'
      ]);
    }
    
  • load(args)
    Formats date columns (MM/dd/yyyy) on grid load.

    function load(args) {
      this.columns[9].format = { type: 'date', format: 'MM/dd/yyyy' };
      this.columns[10].format = { type: 'date', format: 'MM/dd/yyyy' };
      this.columns[11].format = { type: 'date', format: 'MM/dd/yyyy' };
    }
    
  • toolbarClick(args)
    Handles Excel/PDF export commands.

    function toolbarClick(args) {
      var gridObj = document.getElementById("TreeGrid").ej2_instances[0];
      if (args.item.id === 'TreeGrid_pdfexport') gridObj.pdfExport();
      if (args.item.id === 'TreeGrid_excelexport') gridObj.excelExport();
    }
    
  • Search Integration
    Binds the Search button to the grid's search() method.

    document.getElementById('Search').addEventListener('click', function () {
      var val = document.getElementById('searchText').value;
      var grid = document.getElementById('TreeGrid').ej2_instances[0];
      grid.search(val);
    });
    
<script id="jobtemplate" type="text/x-template">
  <div class="image" id="edit">
    <a target="_blank" href="/Jobs/Details/${JobId}">${Job.Name}</a>
  </div>
</script>

🚨 Error Handling & Validation

  • Anti-Forgery: @Html.AntiForgeryToken() protects the form.
  • Model Validation: @Html.ValidationSummary(true, "", new { @class = "text-danger" }) displays server-side errors.
  • Client-Side: _ValidationScriptsPartial injects jQuery validation.

πŸ”— API Endpoints & Routing

Action / Endpoint Description
POST /JDE/SearchWO Searches work orders based on form criteria.
GET /Jobs/Details/{id} Returns detail page for a given Job (populated via jobtemplate).

🎨 UI Components & Layout

  1. Search Panel

    • Uses Bootstrap grid system (.row, .col-md-*).
    • Form Repeater is initialized via jquery.repeater.js, but only one group is defined here.
  2. Work Order TreeGrid

    • Syncfusion EJ2 <ejs-grid> tagged helper.
    • Configurable features:
      • Paging (allowPaging), Sorting (allowSorting), Filtering (allowFiltering), Reordering, Multi-sorting, Resizing, Text Wrap, Frozen Columns, Excel/PDF Export, etc.
    • Toolbar: Excel & PDF export buttons.
  3. Enhanced Selects

    • Select2 initialized on elements with .js-example-basic-single.
  4. Date Pickers & Rich Text

    • Bootstrap Datepicker & TinyMCE references for potential future use.

πŸ’» Sample Code Snippets

1. Search Form Field

<div class="form-group row mb-2">
  <label class="col-form-label col-lg-2">Work Order Type</label>
  <div class="col-md-4">
    <select name="WorkOrderType" class="form-select">
      <option>Capital</option>
      <option>Corrective - 3rd Party</option>
      ...  
    </select>
  </div>
  <label class="col-form-label col-lg-2">Status</label>
  <div class="col-md-4">
    <select name="Status" class="form-select">
      <option>Approved ECO</option>
      <option>Order Created</option>
      ...  
    </select>
  </div>
</div>

2. Syncfusion TreeGrid Declaration

<ejs-grid id="TreeGrid"
          load="load"
          dataSource="ViewBag.datasource"
          childMapping="Children"
          showColumnMenu="true"
          allowPaging="true"
          toolbar="@(new List<string>() { "ExcelExport", "PdfExport"})"
          toolbarClick="toolbarClick">
  <e-grid-pagesettings pageSize="10"></e-grid-pagesettings>
  <e-grid-columns>
    <e-grid-column field="Name" headerText="Name" width="150"></e-grid-column>
    <e-grid-column field="WorkOrderNumber" headerText="WO#" width="220"></e-grid-column>
    <!-- More columns... -->
  </e-grid-columns>
</ejs-grid>

πŸ“ˆ UML Diagrams

1. Class Diagram

classDiagram
    class WorkOrder {
        +string Name
        +string WorkOrderNumber
        +string WorkOrderType
        +Job Job
        +string Status
        +string Reference
        +decimal EstimatedHours
        +decimal EstimatedAmount
        +DateTime DateAssigned
        +DateTime DateStart
        +DateTime DateComplete
        +List~WorkOrder~ Children
    }
    class Job {
        +int JobId
        +string JdeNumber
        +string Name
    }
    WorkOrder *-- Job
    WorkOrder *-- WorkOrder : Children

2. Sequence Diagram (Search Flow)

sequenceDiagram
    participant User
    participant View as "WorkOrderDirectory"
    participant Controller as "JDEController"
    participant Service as "WorkOrderService"
    participant DB as "Database"

    User->>View: Fill form & click β€œSearch”
    View->>Controller: POST /JDE/SearchWO
    Controller->>Service: GetWorkOrders(filters)
    Service->>DB: Query WorkOrders
    DB-->>Service: Return data
    Service-->>Controller: List<WorkOrder>
    Controller-->>View: Set ViewBag.datasource
    View-->>User: Render updated TreeGrid

πŸš€ Usage Examples

  1. Search by Work Order Number

    • Enter partial or full WO# in Work Order Number field.
    • Click Search Work Orders.
    • Grid refreshes to show matching entries.
  2. Inline Grid Search

    • Type a term in the grid search box (top-right of TreeGrid).
    • Click Search button.
    • The grid filters rows on-the-fly.
  3. Export to Excel/PDF

    • Use the grid toolbar to export the current view to Excel or PDF.
    • The exported file preserves column order, filters, and sort state.

πŸ”š Conclusion

The WorkOrderDirectory.cshtml view provides a powerful, user-friendly interface for locating and managing work orders within the IrbyImaging application. Leveraging Syncfusion’s robust TreeGrid component, it offers advanced features like hierarchical data display, multi-criteria search, inline searching, and seamless export capabilities. The integration of Bootstrap, Select2, and jQuery ensures a responsive and interactive user experience.

By following this documentation, developers can:

  • Understand the structure and flow of the page
  • Extend the search filters or grid columns
  • Customize export behavior or styling
  • Integrate additional client-side utilities

Enjoy building upon this solid foundation! πŸŽ‰


Authored by IrbyImaging Team