📝 Documentation: IrbyImaging/Views/LegalImaging/DocPreview.cshtml


Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. View Model: DocumentImaging
  4. Key Functional Areas
    4.1 Data Initialization
    4.2 Styling & Assets
    4.3 Form Generation & Submission
    4.4 Document Thumbnails & Preview
  5. API Endpoints Overview
  6. Helper Methods & Utilities
  7. Error Handling & Confirmation
  8. Third‑Party Integrations
  9. UML Diagrams
  10. Sample Code Blocks & Usage Examples
  11. Conclusion

1. Overview & Purpose

This Razor view (DocPreview.cshtml) is part of the Legal Imaging module in the IrbyImaging application. It provides a user interface for:

  • Previewing uploaded PDF documents 📰
  • Selecting multiple documents for indexing 📂
  • Deleting unwanted documents ❌

It renders a grid of document thumbnails, supports “Select All” functionality, and uses AJAX to load preview details in a modal dialog. Submissions are posted to the SaveDocument action in the LegalImaging controller.


2. Dependencies & Technologies

Category Library / Framework Usage
Front‑end CSS Bootstrap, Dropzone, Bootstrap‑Datepicker Layout, file-drop styling, datepickers
JavaScript & UI jQuery, Bootstrap, MetisMenu, SimpleBar, Waves DOM manipulation, modals, menus
Rich Text Editor TinyMCE (Loaded but not used in this view)
Server‑side ASP.NET Core MVC Razor Views View rendering & model binding

Key Assets Loaded

<link href="~/assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">
<link href="~/assets/libs/dropzone/min/dropzone.min.css" rel="stylesheet">
<script src="~/assets/libs/jquery/jquery.min.js"></script>
<script src="~/assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- ... other libs ... -->
<script src="~/assets/libs/tinymce/tinymce.min.js"></script>

3. View Model: DocumentImaging

This view binds to the IrbyImaging.Models.DocumentImaging model.

Property Type Description
DocumentImageId Guid Unique identifier for the overall document batch
BatchIds List<Guid> Collection of individual document GUIDs to preview/index
ImagingType string Category or process type (from ViewBag.category)
IsLegalDocument bool Flag indicating a legal document
IsSafety bool Flag indicating a safety-related document
DeleteFiles bool Toggle for deletion of selected documents

4. Key Functional Areas

4.1 Data Initialization

@model IrbyImaging.Models.DocumentImaging
@{
    ViewData["Title"] = "Save Uploaded Document";
    Layout = "~/Views/Shared/_LegalLayout.cshtml";

    var lists = new List<Guid>();
    string guidList = "";
    var category = ViewBag.category;

    if (Model?.BatchIds != null) {
        lists = Model.BatchIds;
        foreach (var id in lists) {
            guidList += id + ",";
        }
    }
}
  • ViewData["Title"] sets the page title dynamically.
  • Layout points to the shared legal layout.
  • lists & guidList accumulate a comma‑separated list of Batch IDs for potential client‑side use.
  • category is pulled from ViewBag (controller sets this).

4.2 Styling & Assets

  • CSS Includes
    • bootstrap-datepicker.min.css
    • dropzone.min.css
  • Inline Styles
    .flex-container {
      display: flex;
      flex-wrap: wrap;
    }
    .flex-container > div {
      background-color: #f1f1f1;
      /* etc. */
    }
    
  • Layout: a series of <div class="row"> and <div class="col-md-3"> blocks form a responsive grid.

4.3 Form Generation & Submission

Depending on the number of documents (BatchIds.Count), the view renders a single or multi‑document form. Both post to:

POST /LegalImaging/SaveDocument?category={category}

Form Example (multi‑document)

@using (Html.BeginForm("SaveDocument", "LegalImaging", new { category = category }, FormMethod.Post, null, Model))
{
    @Html.HiddenFor(m => m.DocumentImageId)
    @Html.HiddenFor(m => m.BatchIds)
    @Html.HiddenFor(m => m.ImagingType)
    @Html.HiddenFor(m => m.IsLegalDocument)
    @Html.HiddenFor(m => m.IsSafety)
    @Html.HiddenFor(m => m.DeleteFiles)

    <div class="preference">
      <label>Select All</label>
      <input id="ckbCheckAll" type="checkbox" />
      <div style="float:right;">
        <input type="submit" class="btn btn-primary" value="Index Selected Documents" />
        <button type="submit" onclick="deleteFiles();" class="btn btn-danger">Delete</button>
      </div>
    </div>
    <!-- Document grid here -->
}
  • HiddenFor fields ensure model integrity on postback.
  • Index Selected Documents submits for indexing; Delete triggers a confirmation via JavaScript.

4.4 Document Thumbnails & Preview

Each BatchId generates:

  1. An <embed> PDF preview
  2. A Select checkbox
  3. A Preview link (AJAX modal)
@for (int k = 0; k < Model.BatchIds.Count; k++) {
  var id = Model.BatchIds[k];
  <div class="col-md-3">
    <div class="thumbnail">
      <embed src="@Url.Action("Preview","LegalImaging", new { id = id })#zoom=FitH" type="application/pdf" />
      <div class="preference">
        <label>Select</label>
        <input class="checkBoxClass" type="checkbox" name="docIds" value="@id" />
      </div>
      <a href="javascript:void(0);" class="previewDetail" data-id="@id">Preview</a>
      <!-- Modal placeholder -->
      <div id="myModal" class="modal">
        <div class="modal-dialog">
          <div class="modal-content">
            <div id="myModalContent"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
}
  • Grid Layout: 4 items per row, new <div class="row"> created every 4 thumbnails.
  • embed tag renders inline PDF previews.
  • AJAX Preview uses the .previewDetail link to fetch details without full‑page refresh.

5. API Endpoints Overview

Endpoint Method Description
/LegalImaging/DocPreview GET Renders this view with a DocumentImaging model
/LegalImaging/SaveDocument?category={cat} POST Handles indexing & deletion on server side
/LegalImaging/Preview?id={batchId} GET Returns raw PDF for <embed> tag
/LegalImaging/myModalPreview GET Returns partial HTML for AJAX modal preview

6. Helper Methods & Utilities

  • Html.BeginForm(...) – generates the <form> tag with route values.
  • Html.HiddenFor(...) – strongly‑typed hidden inputs for model binding.
  • Url.Action(...) – constructs URLs for controller actions.

No custom helper extensions are used in this view.


7. Error Handling & Confirmation

Deletion Confirmation

function deleteFiles() {
  var r = confirm("Are you sure you want to delete the selected documents?");
  if (!r) {
    return false;
  }
  $("#DeleteFiles").attr("value", "True");
}
  • confirm() ensures user acknowledgment before deletion.
  • Sets the hidden field DeleteFiles=true for server‑side logic.

AJAX Error Handling

$.ajax({
  // ...
  error: function () {
    alert("Dynamic content load failed.");
  }
});
  • Alerts the user if the preview partial fails to load.

8. Third‑Party Integrations

Integration Description
Bootstrap Responsive grid, buttons, modals
jQuery DOM manipulation, AJAX
Bootstrap‑Datepicker Date picker styling (not used here)
Dropzone Drag‑and‑drop upload styling (CSS only)
TinyMCE Rich text editor (JS loaded, unused)
MetisMenu Sidebar menu behavior
SimpleBar Custom scrollbars
Waves Ripple effects on clicks

9. UML Diagrams

9.1 Class Diagram

classDiagram
    class DocumentImaging {
        +Guid DocumentImageId
        +List<Guid> BatchIds
        +string ImagingType
        +bool IsLegalDocument
        +bool IsSafety
        +bool DeleteFiles
    }

    class LegalImagingController {
        +IActionResult DocPreview(List<Guid> batchIds, string category)
        +IActionResult SaveDocument(DocumentImaging model, string category)
        +FileStreamResult Preview(Guid id)
        +IActionResult myModalPreview(Guid id, bool Preview)
    }

    LegalImagingController --> DocumentImaging

9.2 Sequence Diagram

sequenceDiagram
    participant U as User
    participant V as DocPreview View
    participant C as LegalImagingController

    U->>V: Request /LegalImaging/DocPreview
    V-->>U: Renders grid of thumbnails
    U->>V: Click “Preview” link
    V->>C: AJAX GET /myModalPreview?id={id}
    C-->>V: Partial HTML (modal content)
    V-->>U: Show modal dialog
    U->>V: Click “Index Selected Documents”
    V->>C: POST /SaveDocument
    C-->>U: Redirect / Success message

10. Sample Code Blocks & Usage Examples

10.1 Controller Example

public class LegalImagingController : Controller
{
    [HttpGet]
    public IActionResult DocPreview(List<Guid> batchIds, string category)
    {
        var model = new DocumentImaging {
            DocumentImageId = Guid.NewGuid(),
            BatchIds = batchIds ?? new List<Guid>(),
            ImagingType = category,
            IsLegalDocument = true,
            IsSafety = false
        };
        ViewBag.category = category;
        return View("DocPreview", model);
    }

    [HttpPost]
    public IActionResult SaveDocument(DocumentImaging model, string category)
    {
        if (model.DeleteFiles)
        {
            // Delete logic...
        }
        else
        {
            // Indexing logic...
        }
        return RedirectToAction("IndexComplete");
    }

    [HttpGet]
    public FileStreamResult Preview(Guid id)
    {
        // Retrieve PDF by id
        var stream = _service.GetPdfStream(id);
        return File(stream, "application/pdf");
    }

    [HttpGet]
    public IActionResult myModalPreview(Guid id, bool Preview)
    {
        var detail = _service.GetDocumentDetail(id);
        return PartialView("_PreviewDetail", detail);
    }
}

10.2 How to Use

  1. Upload documents using your upload interface (not in this view).
  2. Navigate to /LegalImaging/DocPreview?batchIds={commaSeparatedGuids}&category=Legal.
  3. Select individual or “Select All” documents.
  4. Click Index Selected Documents to commit indexing or Delete to remove.
  5. Click Preview to view details in a modal popup.

11. Conclusion

This DocPreview.cshtml file is the central UI for indexing and previewing legal documents in the IrbyImaging system. It demonstrates:

  • Razor-based model binding and form generation
  • Responsive thumbnail grid using Bootstrap
  • Inline PDF preview and AJAX‑driven modals
  • Bulk actions (select all, index, delete) with client‑side safeguards

By leveraging standard ASP.NET Core MVC patterns and common front‑end libraries, it provides a user‑friendly interface for document management in a legal context. 🚀


End of Documentation
Generated with care to guide future developers and maintainers.