π WorkOrderDirectory.cshtml Documentation
π Table of Contents
- π― Overview & Purpose
- π Key Functional Areas
- βοΈ Dependencies & Technologies
- π§© View Models & Data Models
- π οΈ Helper Methods & Utilities
- π¨ Error Handling & Validation
- π API Endpoints & Routing
- π¨ UI Components & Layout
- π» Sample Code Snippets
- π UML Diagrams
- π Usage Examples
- π Conclusion
π― Overview & Purpose
The WorkOrderDirectory.cshtml Razor View is part of the JDE area of the IrbyImaging web application. It serves two primary purposes:
-
π Search Interface
Provides a rich, form-based search panel to filter work orders by criteria such as type, status, numbers, names, and references. -
π 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'ssearch()method.document.getElementById('Search').addEventListener('click', function () { var val = document.getElementById('searchText').value; var grid = document.getElementById('TreeGrid').ej2_instances[0]; grid.search(val); });
2. Template for Job Link
<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:
_ValidationScriptsPartialinjects 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
-
Search Panel
- Uses Bootstrap grid system (
.row,.col-md-*). - Form Repeater is initialized via
jquery.repeater.js, but only one group is defined here.
- Uses Bootstrap grid system (
-
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.
- Paging (
- Toolbar: Excel & PDF export buttons.
- Syncfusion EJ2
-
Enhanced Selects
- Select2 initialized on elements with
.js-example-basic-single.
- Select2 initialized on elements with
-
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
-
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.
-
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.
-
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