532 lines
24 KiB
HTML
532 lines
24 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Widget - Hospital Management{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="content">
|
|
<div class="container-fluid">
|
|
<!-- Page Header -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-header">
|
|
<div class="page-title">
|
|
<h4>Delete Widget</h4>
|
|
<h6>Confirm widget deletion from dashboard</h6>
|
|
</div>
|
|
<div class="page-btn">
|
|
<a href="{% url 'analytics:dashboard_widget_detail' widget.pk|default:1 %}" class="btn btn-secondary">
|
|
<i class="fas fa-arrow-left me-1"></i>Back to Widget
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-8">
|
|
<!-- Warning Alert -->
|
|
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
|
<div class="d-flex align-items-center">
|
|
<i class="fas fa-exclamation-triangle fa-2x me-3"></i>
|
|
<div>
|
|
<h5 class="alert-heading mb-1">Confirm Widget Deletion</h5>
|
|
<p class="mb-0">This action will permanently remove the widget from your dashboard. This cannot be undone.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Widget Information -->
|
|
<div class="card">
|
|
<div class="card-header bg-warning text-dark">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-trash me-2"></i>Widget to be Deleted
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<div class="widget-info">
|
|
<h4 class="text-warning">{{ widget.title|default:"Revenue Trends" }}</h4>
|
|
<p class="text-muted mb-3">{{ widget.description|default:"Monthly revenue analysis with trend indicators and growth metrics" }}</p>
|
|
|
|
<div class="row">
|
|
<div class="col-sm-6">
|
|
<div class="info-item">
|
|
<label class="form-label">Widget Type:</label>
|
|
<span class="badge bg-primary">{{ widget.widget_type|default:"Chart" }}</span>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<div class="info-item">
|
|
<label class="form-label">Chart Type:</label>
|
|
<span class="text-muted">{{ widget.chart_type|default:"Line Chart" }}</span>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<div class="info-item">
|
|
<label class="form-label">Data Source:</label>
|
|
<span class="text-muted">{{ widget.data_source|default:"Financial Data" }}</span>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<div class="info-item">
|
|
<label class="form-label">Position:</label>
|
|
<span class="text-muted">{{ widget.position|default:"Row 1, Col 1-8" }}</span>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<div class="info-item">
|
|
<label class="form-label">Created By:</label>
|
|
<span class="text-muted">{{ widget.created_by|default:"Dr. Sarah Johnson" }}</span>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<div class="info-item">
|
|
<label class="form-label">Created Date:</label>
|
|
<span class="text-muted">{{ widget.created_at|default:"January 10, 2024" }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="widget-preview-card">
|
|
<div class="preview-header">
|
|
<h6>{{ widget.title|default:"Revenue Trends" }}</h6>
|
|
</div>
|
|
<div class="preview-content">
|
|
<i class="fas fa-chart-line fa-3x text-primary"></i>
|
|
<p class="mt-2 text-muted">{{ widget.widget_type|default:"Chart" }} Widget</p>
|
|
</div>
|
|
<div class="preview-footer">
|
|
<small class="text-muted">
|
|
<i class="fas fa-clock me-1"></i>Updates every {{ widget.refresh_interval|default:"5 minutes" }}
|
|
</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Impact Analysis -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title">
|
|
<i class="fas fa-chart-line me-2"></i>Deletion Impact
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h6 class="text-warning">What will be lost:</h6>
|
|
<ul class="list-group list-group-flush">
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<i class="fas fa-cog text-warning me-2"></i>
|
|
Widget configuration
|
|
</div>
|
|
<span class="badge bg-warning rounded-pill">1</span>
|
|
</li>
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<i class="fas fa-chart-bar text-warning me-2"></i>
|
|
Custom chart settings
|
|
</div>
|
|
<span class="badge bg-warning rounded-pill">All</span>
|
|
</li>
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<i class="fas fa-th-large text-warning me-2"></i>
|
|
Dashboard position
|
|
</div>
|
|
<span class="badge bg-warning rounded-pill">1</span>
|
|
</li>
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<i class="fas fa-history text-warning me-2"></i>
|
|
Widget usage history
|
|
</div>
|
|
<span class="badge bg-warning rounded-pill">All</span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6 class="text-info">What will remain:</h6>
|
|
<ul class="list-group list-group-flush">
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<i class="fas fa-database text-success me-2"></i>
|
|
Source data
|
|
</div>
|
|
<span class="badge bg-success rounded-pill">Safe</span>
|
|
</li>
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<i class="fas fa-tachometer-alt text-success me-2"></i>
|
|
Dashboard layout
|
|
</div>
|
|
<span class="badge bg-success rounded-pill">Safe</span>
|
|
</li>
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<i class="fas fa-users text-success me-2"></i>
|
|
Other widgets
|
|
</div>
|
|
<span class="badge bg-success rounded-pill">Safe</span>
|
|
</li>
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<i class="fas fa-key text-success me-2"></i>
|
|
Access permissions
|
|
</div>
|
|
<span class="badge bg-success rounded-pill">Safe</span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="alert alert-info mt-3">
|
|
<i class="fas fa-info-circle me-2"></i>
|
|
<strong>Note:</strong> The data source and dashboard will remain intact. Only this specific widget configuration will be removed.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alternative Actions -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title">
|
|
<i class="fas fa-lightbulb me-2"></i>Alternative Actions
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="text-muted mb-3">Consider these alternatives before deleting the widget:</p>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="alternative-action">
|
|
<div class="action-icon">
|
|
<i class="fas fa-eye-slash text-warning"></i>
|
|
</div>
|
|
<div class="action-content">
|
|
<h6>Hide Widget</h6>
|
|
<p class="text-muted">Temporarily hide the widget without deleting it.</p>
|
|
<button type="button" class="btn btn-outline-warning btn-sm" onclick="hideWidget()">
|
|
<i class="fas fa-eye-slash me-1"></i>Hide Instead
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="alternative-action">
|
|
<div class="action-icon">
|
|
<i class="fas fa-copy text-info"></i>
|
|
</div>
|
|
<div class="action-content">
|
|
<h6>Duplicate Widget</h6>
|
|
<p class="text-muted">Create a backup copy before deletion.</p>
|
|
<button type="button" class="btn btn-outline-info btn-sm" onclick="duplicateWidget()">
|
|
<i class="fas fa-copy me-1"></i>Duplicate First
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mt-3">
|
|
<div class="col-md-6">
|
|
<div class="alternative-action">
|
|
<div class="action-icon">
|
|
<i class="fas fa-arrows-alt text-success"></i>
|
|
</div>
|
|
<div class="action-content">
|
|
<h6>Move Widget</h6>
|
|
<p class="text-muted">Move to a different position or dashboard.</p>
|
|
<button type="button" class="btn btn-outline-success btn-sm" onclick="moveWidget()">
|
|
<i class="fas fa-arrows-alt me-1"></i>Move Instead
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="alternative-action">
|
|
<div class="action-icon">
|
|
<i class="fas fa-edit text-primary"></i>
|
|
</div>
|
|
<div class="action-content">
|
|
<h6>Edit Widget</h6>
|
|
<p class="text-muted">Modify the widget instead of deleting it.</p>
|
|
<a href="{% url 'analytics:dashboard_widget_update' widget.pk|default:1 %}" class="btn btn-outline-primary btn-sm">
|
|
<i class="fas fa-edit me-1"></i>Edit Instead
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Confirmation Form -->
|
|
<div class="card border-warning">
|
|
<div class="card-header bg-warning text-dark">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>Confirm Deletion
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="post" id="deleteForm">
|
|
{% csrf_token %}
|
|
|
|
<div class="form-group">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="confirmUnderstand" name="confirm_understand" required>
|
|
<label class="form-check-label" for="confirmUnderstand">
|
|
I understand that this widget will be permanently removed from the dashboard.
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="confirmBackup" name="confirm_backup">
|
|
<label class="form-check-label" for="confirmBackup">
|
|
I have considered creating a backup or duplicate of this widget.
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="deletionReason" class="form-label">Reason for Deletion (Optional):</label>
|
|
<select class="form-select" id="deletionReason" name="deletion_reason">
|
|
<option value="">Select a reason</option>
|
|
<option value="outdated">Widget is outdated</option>
|
|
<option value="duplicate">Duplicate widget</option>
|
|
<option value="not_useful">No longer useful</option>
|
|
<option value="performance">Performance issues</option>
|
|
<option value="reorganizing">Dashboard reorganization</option>
|
|
<option value="other">Other reason</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group" id="otherReasonGroup" style="display: none;">
|
|
<label for="otherReason" class="form-label">Please specify:</label>
|
|
<textarea class="form-control" id="otherReason" name="other_reason" rows="2"
|
|
placeholder="Please provide more details..."></textarea>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between align-items-center mt-4">
|
|
<div class="deletion-actions">
|
|
<a href="{% url 'analytics:dashboard_widget_detail' widget.pk|default:1 %}" class="btn btn-secondary me-2">
|
|
<i class="fas fa-times me-1"></i>Cancel
|
|
</a>
|
|
<a href="{% url 'analytics:dashboard_widget_list' dashboard.pk|default:1 %}" class="btn btn-outline-secondary">
|
|
<i class="fas fa-list me-1"></i>Back to Widgets
|
|
</a>
|
|
</div>
|
|
<button type="submit" class="btn btn-warning" id="deleteButton" disabled>
|
|
<i class="fas fa-trash me-1"></i>Delete Widget
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const confirmUnderstand = document.getElementById('confirmUnderstand');
|
|
const deleteButton = document.getElementById('deleteButton');
|
|
const deleteForm = document.getElementById('deleteForm');
|
|
const deletionReason = document.getElementById('deletionReason');
|
|
const otherReasonGroup = document.getElementById('otherReasonGroup');
|
|
|
|
// Enable/disable delete button based on confirmation
|
|
confirmUnderstand.addEventListener('change', function() {
|
|
deleteButton.disabled = !this.checked;
|
|
});
|
|
|
|
// Show/hide other reason field
|
|
deletionReason.addEventListener('change', function() {
|
|
if (this.value === 'other') {
|
|
otherReasonGroup.style.display = 'block';
|
|
} else {
|
|
otherReasonGroup.style.display = 'none';
|
|
}
|
|
});
|
|
|
|
// Form submission with confirmation
|
|
deleteForm.addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
|
|
const finalConfirm = confirm(
|
|
'Are you sure you want to delete this widget?\n\n' +
|
|
'This action cannot be undone.\n\n' +
|
|
'Click OK to proceed or Cancel to abort.'
|
|
);
|
|
|
|
if (finalConfirm) {
|
|
// Show loading state
|
|
deleteButton.innerHTML = '<i class="fas fa-spinner fa-spin me-1"></i>Deleting...';
|
|
deleteButton.disabled = true;
|
|
|
|
// Simulate deletion process
|
|
setTimeout(() => {
|
|
alert('Widget deleted successfully!');
|
|
window.location.href = "{% url 'analytics:dashboard_widget_list' dashboard.pk|default:1 %}";
|
|
}, 1500);
|
|
}
|
|
});
|
|
});
|
|
|
|
function hideWidget() {
|
|
if (confirm('Hide this widget instead of deleting it?')) {
|
|
alert('Widget hidden successfully! You can show it again from widget settings.');
|
|
window.location.href = "{% url 'analytics:dashboard_widget_list' dashboard.pk|default:1 %}";
|
|
}
|
|
}
|
|
|
|
function duplicateWidget() {
|
|
if (confirm('Create a copy of this widget before deletion?')) {
|
|
alert('Widget duplicated successfully! You can now safely delete the original.');
|
|
}
|
|
}
|
|
|
|
function moveWidget() {
|
|
alert('Opening widget positioning tool...');
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.info-item {
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.info-item label {
|
|
font-weight: 600;
|
|
margin-bottom: 5px;
|
|
display: block;
|
|
color: #2c3e50;
|
|
}
|
|
|
|
.widget-preview-card {
|
|
border: 1px solid #e9ecef;
|
|
border-radius: 8px;
|
|
background: white;
|
|
overflow: hidden;
|
|
height: 100%;
|
|
}
|
|
|
|
.preview-header {
|
|
background: #f8f9fa;
|
|
padding: 15px;
|
|
border-bottom: 1px solid #e9ecef;
|
|
}
|
|
|
|
.preview-header h6 {
|
|
margin: 0;
|
|
font-weight: 600;
|
|
color: #2c3e50;
|
|
}
|
|
|
|
.preview-content {
|
|
padding: 30px 20px;
|
|
text-align: center;
|
|
color: #6c757d;
|
|
}
|
|
|
|
.preview-footer {
|
|
background: #f8f9fa;
|
|
padding: 10px 15px;
|
|
border-top: 1px solid #e9ecef;
|
|
text-align: center;
|
|
}
|
|
|
|
.alternative-action {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
padding: 20px;
|
|
border: 1px solid #e9ecef;
|
|
border-radius: 8px;
|
|
background: #f8f9fa;
|
|
margin-bottom: 15px;
|
|
height: 100%;
|
|
}
|
|
|
|
.action-icon {
|
|
width: 50px;
|
|
height: 50px;
|
|
border-radius: 50%;
|
|
background: white;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin-right: 15px;
|
|
font-size: 1.5rem;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.action-content {
|
|
flex: 1;
|
|
}
|
|
|
|
.action-content h6 {
|
|
margin: 0 0 8px 0;
|
|
font-weight: 600;
|
|
color: #2c3e50;
|
|
}
|
|
|
|
.action-content p {
|
|
margin-bottom: 12px;
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.deletion-actions {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
#deleteButton:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.widget-preview-card {
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.alternative-action {
|
|
flex-direction: column;
|
|
text-align: center;
|
|
}
|
|
|
|
.action-icon {
|
|
margin-right: 0;
|
|
margin-bottom: 15px;
|
|
align-self: center;
|
|
}
|
|
|
|
.deletion-actions {
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
width: 100%;
|
|
}
|
|
|
|
.deletion-actions .btn {
|
|
width: 100%;
|
|
}
|
|
|
|
#deleteButton {
|
|
width: 100%;
|
|
margin-top: 15px;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|