๐Ÿ“„ DeleteUploadedDocument.cshtml Documentation


๐Ÿ“‘ Table of Contents

  1. Overview & Purpose
  2. File Information
  3. Dependencies & Technologies
  4. Model Binding & ViewModel
  5. Layout, Styles & CSS
  6. Key Functional Areas
  7. JavaScript & Client-side Logic
  8. API Endpoints & AJAX
  9. ViewModel UML Diagram
  10. Sample Usage
  11. Conclusion & Best Practices

๐Ÿง Overview & Purpose

The DeleteUploadedDocument.cshtml Razor view provides a user interface for displaying, selecting, and deleting one or more uploaded documents (PDFs) within the IrbyImaging application. It:

  • Lists all documents in a grid of thumbnails.
  • Supports bulk selection via โ€œSelect Allโ€ and per-document checkboxes.
  • Offers inline preview in a modal window.
  • Submits selected document IDs to the ImagingController.Delete POST action.

This page is typically rendered when a user requests to remove previously uploaded documents from a batch.


๐Ÿ—‚๏ธ File Information

Property Details
Path IrbyImaging/Views/Imaging/DeleteUploadedDocument.cshtml
Layout Uses ~/Views/Shared/_Layout.cshtml
Model IrbyImaging.Models.DocumentImaging
ViewData["Title"] "Delete Uploaded Document"

๐Ÿ› ๏ธ Dependencies & Technologies

Type Library / Feature
CSS Bootstrap, Bootstrap Datepicker, Dropzone
JavaScript jQuery, Bootstrap JS
Razor Syntax ASP.NET Core MVC (@model, @Html, @Url.Action)
Modal Bootstrap Modal
AJAX jQuery .ajax()

๐Ÿ“ฆ Model Binding & ViewModel

The view is strongly-typed to IrbyImaging.Models.DocumentImaging, which exposes:

Property Type Description
DocumentImageId Guid ID of the parent/upload session
BatchIds List<Guid> IDs of individual documents to show
DeleteFiles bool Flag set to true on form submit

Snippet

@model IrbyImaging.Models.DocumentImaging

๐ŸŽจ Layout, Styles & CSS

  1. Layout reference at top:
    Layout = "~/Views/Shared/_Layout.cshtml";
    
  2. Custom Styles loaded in @section styles:
    • bootstrap-datepicker.min.css
    • dropzone.min.css
  3. Inline CSS for a flex container (currently unused):
    .flex-container { display: flex; flex-wrap: wrap; }
    .flex-container > div { /* ... styles ... */ }
    
  4. Page Title via Razor:
    ViewData["Title"] = "Delete Uploaded Document";
    

๐Ÿ”‘ Key Functional Areas

1. Form & Data Submission

  • Form begins with:
    @using (Html.BeginForm("Delete", "Imaging", FormMethod.Post, @Model))
    
  • Hidden Fields:
    @Html.HiddenFor(m => m.DocumentImageId)
    @Html.HiddenFor(m => m.BatchIds)
    @* DeleteFiles is set by JS *@
    <input type="hidden" asp-for="DeleteFiles" />
    
  • Delete Button triggers deleteFiles() confirmation:
    <button type="submit" onclick="deleteFiles();" class="btn btn-danger">
      Delete Selected Documents
    </button>
    

2. Document Grid & Preview

  • Dynamic grid with four thumbnails per row.
  • Each thumbnail uses <embed> to display a PDF via:
    <embed src="@Url.Action("DeletePreview","Imaging", new { id = docId })#zoom=FitH" type="application/pdf">
    
  • Per-document checkbox:
    <input class="checkBoxClass" type="checkbox" name="docIds" value="@docId" />
    
  • Preview Link opens a Bootstrap modal via AJAX:
    <a href="javascript:void(0);" class="previewDetail2" data-id="@docId">
      Preview
    </a>
    

3. Bulk-Select (โ€œSelect Allโ€)

  • A master checkbox:
    <input id="ckbCheckAll" type="checkbox" />
    
  • Toggles all .checkBoxClass inputs on click (see JS below).

๐Ÿ’ป JavaScript & Client-side Logic

Delete Confirmation

function deleteFiles() {
  var r = confirm("Are you sure you want to delete the selected documents?");
  if (!r) {
    return false; // Cancel form submission
  }
  $("#DeleteFiles").val("True");
}
  • Confirms user intent.
  • Sets hidden DeleteFiles flag to True.

Checkbox Toggling

$(document).ready(function () {
  $("#ckbCheckAll").click(function () {
    $(".checkBoxClass").prop('checked', $(this).prop('checked'));
  });
});
  • Bulk-check/uncheck all document checkboxes.
var TeamDetailPostBackURL = '/Imaging/myModalDeletePreview';

$(function () {
  $(".previewDetail2").click(function () {
    var id = $(this).data('id');
    $.ajax({
      type: "GET",
      url: TeamDetailPostBackURL,
      data: { id: id, Preview: true },
      dataType: "html",
      success: function (data) {
        $('#myModalContent').html(data);
        $('#myModal').modal('show');
      },
      error: function () {
        alert("Dynamic content load failed.");
      }
    });
  });
});
  • GETs partial view for the PDF preview.
  • Loads into #myModalContent and displays the modal.

๐Ÿ”— API Endpoints & AJAX

HTTP Verb URL Purpose
GET /Imaging/DeletePreview?id={id} Returns an <embed>โ€‘wrapped PDF snippet
POST /Imaging/Delete Processes deletion of selected docIds
GET /Imaging/myModalDeletePreview AJAX endpoint to fetch modal content dynamically

๐Ÿ“Š ViewModel UML Diagram

classDiagram
    class DocumentImaging {
        +Guid DocumentImageId
        +List<Guid> BatchIds
        +bool DeleteFiles
    }

๐Ÿš€ Sample Usage

// Controller Action
public IActionResult DeleteUploadedDocument(Guid documentImageId) {
    var model = _service.GetDocumentImagingModel(documentImageId);
    return View("DeleteUploadedDocument", model);
}

// POST Handler
[HttpPost]
public IActionResult Delete(DocumentImaging model, List<Guid> docIds) {
    if (model.DeleteFiles && docIds.Any()) {
        _service.DeleteDocuments(docIds);
    }
    return RedirectToAction("Index");
}

On rendering, the user sees a grid of PDF thumbnails, can select them individually or via Select All, preview each doc in a modal, and finally delete selected items with a confirmation dialog.


๐ŸŽฏ Conclusion & Best Practices

  • User Safety: Double-check deletion with a confirmation dialog.
  • Accessibility: Ensure checkboxes & modal have ARIA attributes.
  • Performance: Paginate large batches to avoid slow initial loads.
  • Reusability: Consider factoring out the grid & modal into partial views.
  • Security: Validate docIds server-side to prevent unauthorized deletions.

Thank you for reviewing the DeleteUploadedDocument.cshtml documentation! Feel free to integrate or extend this view according to your projectโ€™s requirements.