📄 DeleteUploadedDocument.cshtml Documentation

Welcome to the in-depth documentation for DeleteUploadedDocument.cshtml, a Razor view in the Legal Imaging area of the IrbyImaging application. This page empowers end‑users to select, preview, and delete one or multiple uploaded documents within a secure legal context.


📑 Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
  3. Dependencies & Technologies
  4. View Models & Data Models
  5. Layout & Styles
  6. Form Structure & Submission
  7. JavaScript & AJAX Operations
  8. API Endpoints Overview
  9. Sample Code Blocks
  10. Usage Examples
  11. Sequence Diagram (UML)
  12. Conclusion

1. Overview & Purpose

DeleteUploadedDocument.cshtml serves as the user interface for the Legal Imaging module to:

  • 🎯 Display all uploaded documents in a batch.
  • 🔍 Allow Preview of each PDF document via embedded viewer or modal.
  • ☑️ Select individual or all documents for deletion.
  • 🗑️ Submit a deletion request with confirmation.

This page is returned by a GET action (e.g., LegalImagingController.Delete) and posts back to LegalImagingController.Delete (POST) to process removals.


2. Key Functional Areas

Functional Area Description
Model Initialization Determines document category (legal/safety/it) and builds GUID list.
Styling & Layout References shared _LegalLayout.cshtml, custom CSS for thumbnails and flex containers.
Document Preview Embeds each PDF via <embed> or AJAX-loaded modal for detailed view.
Selection Management Checkbox UI with Select All and per‑document checkboxes.
Deletion Workflow Client‑side deleteFiles() confirmation → Posts selected IDs and flags to server.
JavaScript Enhancements jQuery for “Select All”, AJAX for modal preview, Bootstrap modal integration.

3. Dependencies & Technologies

⚙️ Front‑End Libraries & Plugins

Library / Plugin Purpose Path / CDN
Bootstrap CSS & JS Grid, buttons, modal dialogs ~/assets/libs/bootstrap/...
jQuery DOM manipulation, AJAX ~/assets/libs/jquery/jquery.min.js
MetisMenu Side‑menu handling ~/assets/libs/metismenu/metisMenu.min.js
SimpleBar Custom scrollbars ~/assets/libs/simplebar/simplebar.min.js
Waves.js Ripple effects ~/assets/libs/node-waves/waves.min.js
Bootstrap Datepicker (CSS/JS) Date inputs (not used here) ~/assets/libs/bootstrap-datepicker/...
Dropzone (CSS) Drag‑drop uploads (CSS only) ~/assets/libs/dropzone/min/dropzone.min.css
TinyMCE Rich‑text editing (not used here) ~/assets/libs/tinymce/tinymce.min.js

🛠️ ASP.NET Core MVC

  • Razor View: .cshtml file.
  • Html Helpers: Html.BeginForm(...), Html.HiddenFor(...).
  • Url Helpers: Url.Action(...).

4. View Models & Data Models

The view is strongly typed to:

@model IrbyImaging.Models.DocumentImaging

DocumentImaging (simplified)

Property Type Description
DocumentImageId Guid Primary document identifier.
BatchIds List<Guid> List of document IDs being managed.
DeleteFiles bool Flag to indicate deletion when form posted.
IsLegalDocument bool Category flag for legal documents.
IsSafety bool Category flag for safety documents.
IsIT bool Category flag for IT documents.

5. Layout & Styles

@{
    ViewData["Title"] = "Delete Uploaded Document";
    Layout = "~/Views/Shared/_LegalLayout.cshtml";
}

Custom CSS

<link href="~/assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" />
<link href="~/assets/libs/dropzone/min/dropzone.min.css" rel="stylesheet" />

<style>
  .flex-container { display: flex; flex-wrap: wrap; }
  .flex-container > div { background-color: #f1f1f1; width: 50px; margin: 10px; text-align: center; font-size: 30px; }
</style>

6. Form Structure & Submission

Main Form

@using (Html.BeginForm("Delete", "LegalImaging", FormMethod.Post, model: Model))
{
    @Html.HiddenFor(m => m.DocumentImageId)
    @Html.HiddenFor(m => m.BatchIds)
    <input type="hidden" asp-for="DeleteFiles" id="DeleteFiles" />
    <input type="hidden" id="category" name="category" value="@category" />

    <div class="preference">
      <label>Select All</label>
      <input id="ckbCheckAll" type="checkbox" />
    </div>

    <button type="submit" class="btn btn-danger" onclick="return deleteFiles();">
      🗑️ Delete Selected Documents
    </button>
    ...
}

Form Fields Table

Field Name Type Description
DocumentImageId Hidden Single-document identifier
BatchIds Hidden Comma‑separated or list GUIDs
DeleteFiles Hidden Flag Set to True on confirm
category Hidden "legal", "safety" or "it" for logic
docIds Checkbox[] Individual GUIDs of documents to delete

7. JavaScript & AJAX Operations

7.1 Deletion Confirmation

function deleteFiles() {
  var r = confirm("Are you sure you want to delete the selected documents?");
  if (!r) {
    return false; // cancels form submit
  }
  $("#DeleteFiles").val("True");
  return true;    // proceed with POST
}

7.2 Select All Toggle

$(document).ready(function () {
  $("#ckbCheckAll").click(function () {
    $(".checkBoxClass").prop('checked', $(this).prop('checked'));
  });
});

7.3 AJAX‑Powered Preview Modal

var TeamDetailPostBackURL = '/Imaging/myModalDeletePreview';

$(function () {
  $(".previewDetail2").click(function () {
    var id = $(this).data('id');
    $.ajax({
      type: "GET",
      url: TeamDetailPostBackURL,
      data: { id: id, Preview: true },
      success: function (data) {
        $('#myModalContent').html(data);
        $('#myModal').modal('show');
      },
      error: function () {
        alert("Dynamic content load failed.");
      }
    });
  });
});

8. API Endpoints Overview

HTTP Verb URL Purpose
GET /LegalImaging/Delete?id={DocumentImageId} Renders this Razor view with DocumentImaging model.
POST /LegalImaging/Delete Binds form, deletes selected docIds.
GET /Imaging/DeletePreview?id={Guid} Returns inline-embeddable PDF stream.
GET /Imaging/myModalDeletePreview Returns partial HTML for modal preview.

9. Sample Code Blocks

9.1 Rendering Thumbnails

@for (int k = 0; k < Model.BatchIds.Count; k++)
{
    <div class="col-md-3">
      <div class="thumbnail">
        <embed src="@Url.Action("DeletePreview", "Imaging", new { id = Model.BatchIds[k] })#zoom=FitH" type="application/pdf" />
        <div class="preference">
          <label>Select</label>
          <input class="checkBoxClass" type="checkbox" name="docIds"
                 value="@Model.BatchIds[k]" />
        </div>
        <a href="javascript:void(0);" class="previewDetail2"
           data-id="@Model.BatchIds[k]">🔍 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>
}

10. Usage Examples

  1. Navigate to the delete page:
    GET /LegalImaging/Delete?id=3fa85f64-5717-4562-b3fc-2c963f66afa6
  2. View a grid of PDF thumbnails.
  3. Click 🗹 Select All or individual Select checkboxes.
  4. (Optional) Click 🔍 Preview to open a modal with full PDF.
  5. Click 🗑️ Delete Selected Documents & confirm the prompt.
  6. Observe the server removes files and redirects or reloads the list.

11. Sequence Diagram (UML)

sequenceDiagram
    participant User
    participant Browser
    participant LegalImagingController
    participant ImagingController

    User->>Browser: Open Delete page (GET /LegalImaging/Delete)
    Browser->>LegalImagingController: Request Delete view
    LegalImagingController-->>Browser: Renders DeleteUploadedDocument.cshtml
    Browser-->>Browser: Display thumbnails & controls
    User->>Browser: Click "Preview" 🔍
    Browser->>ImagingController: GET /Imaging/myModalDeletePreview?id=…
    ImagingController-->>Browser: Returns partial view HTML
    Browser-->>Browser: Show Bootstrap modal
    User->>Browser: Select checkboxes & click "Delete" 🗑️
    Browser->>Browser: Confirm dialog
    Browser->>LegalImagingController: POST /LegalImaging/Delete
    LegalImagingController-->>Browser: Redirect/refresh after deletion

12. Conclusion

This Razor view is a critical component for secure, user‑friendly deletion of legal documents in the IrbyImaging application. It leverages:

  • ASP.NET Core MVC Razor syntax
  • Bootstrap styling & modals
  • jQuery for DOM and AJAX
  • Strongly‑typed view model binding

By understanding its form structure, JavaScript behaviors, and API endpoints, developers can maintain, extend, and integrate this functionality into broader workflows—ensuring documents are handled with transparency and user confirmation.


Happy Coding! 🚀