๐ DeleteUploadedDocument.cshtml Documentation
๐ Table of Contents
- Overview & Purpose
- File Information
- Dependencies & Technologies
- Model Binding & ViewModel
- Layout, Styles & CSS
- Key Functional Areas
- JavaScript & Client-side Logic
- API Endpoints & AJAX
- ViewModel UML Diagram
- Sample Usage
- 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.DeletePOST 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
- Layout reference at top:
Layout = "~/Views/Shared/_Layout.cshtml"; - Custom Styles loaded in
@section styles:bootstrap-datepicker.min.cssdropzone.min.css
- Inline CSS for a flex container (currently unused):
.flex-container { display: flex; flex-wrap: wrap; } .flex-container > div { /* ... styles ... */ } - 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
.checkBoxClassinputs 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
DeleteFilesflag toTrue.
Checkbox Toggling
$(document).ready(function () {
$("#ckbCheckAll").click(function () {
$(".checkBoxClass").prop('checked', $(this).prop('checked'));
});
});
- Bulk-check/uncheck all document checkboxes.
Modal Preview via AJAX
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
#myModalContentand 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
docIdsserver-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.