Spaces:
Running
Running
make it so i can pick which forms class to remove
Browse files- admin-dashboard.html +48 -43
admin-dashboard.html
CHANGED
|
@@ -152,24 +152,39 @@
|
|
| 152 |
</button>
|
| 153 |
</form>
|
| 154 |
</div>
|
| 155 |
-
|
| 156 |
<!-- Remove Class -->
|
| 157 |
<div class="bg-gray-50 p-4 rounded-lg">
|
| 158 |
<h4 class="font-medium mb-2">Remove Existing Class</h4>
|
| 159 |
-
<form id="remove-class-form" class="
|
| 160 |
-
<
|
| 161 |
-
<
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
</button>
|
| 170 |
</form>
|
| 171 |
</div>
|
| 172 |
-
|
| 173 |
</div>
|
| 174 |
<!-- Reports Section -->
|
| 175 |
<div class="hidden" id="reports-section">
|
|
@@ -423,41 +438,31 @@
|
|
| 423 |
showManagementMessage(`Class ${newClassName} added successfully!`);
|
| 424 |
this.reset();
|
| 425 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
if (!classToRemove) {
|
| 433 |
-
showManagementMessage('Please select a class to remove', 'error');
|
| 434 |
-
return;
|
| 435 |
-
}
|
| 436 |
-
|
| 437 |
-
// Remove class from all selects
|
| 438 |
-
const classSelects = document.querySelectorAll('select[id$="-class"], select[id^="class-"]');
|
| 439 |
-
classSelects.forEach(select => {
|
| 440 |
-
Array.from(select.options).forEach(option => {
|
| 441 |
-
if (option.value === classToRemove) {
|
| 442 |
-
option.remove();
|
| 443 |
-
}
|
| 444 |
-
});
|
| 445 |
-
});
|
| 446 |
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
|
|
|
| 450 |
delete students[key];
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
}
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
showManagementMessage(`Class ${classToRemove} and all its students removed successfully!`);
|
| 458 |
-
this.reset();
|
| 459 |
-
});
|
| 460 |
-
// Load students for management dropdown
|
| 461 |
function loadStudentsForManagement() {
|
| 462 |
const classVal = document.getElementById('student-class').value;
|
| 463 |
const formVal = document.getElementById('student-form').value;
|
|
|
|
| 152 |
</button>
|
| 153 |
</form>
|
| 154 |
</div>
|
|
|
|
| 155 |
<!-- Remove Class -->
|
| 156 |
<div class="bg-gray-50 p-4 rounded-lg">
|
| 157 |
<h4 class="font-medium mb-2">Remove Existing Class</h4>
|
| 158 |
+
<form id="remove-class-form" class="space-y-3">
|
| 159 |
+
<div class="grid grid-cols-2 gap-3">
|
| 160 |
+
<div>
|
| 161 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Class</label>
|
| 162 |
+
<select class="w-full px-3 py-2 border rounded" id="class-to-remove" required>
|
| 163 |
+
<option value="">Select Class</option>
|
| 164 |
+
<option value="BUDI">BUDI</option>
|
| 165 |
+
<option value="USAHA">USAHA</option>
|
| 166 |
+
<option value="MAJU">MAJU</option>
|
| 167 |
+
<option value="JAYA">JAYA</option>
|
| 168 |
+
</select>
|
| 169 |
+
</div>
|
| 170 |
+
<div>
|
| 171 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Form</label>
|
| 172 |
+
<select class="w-full px-3 py-2 border rounded" id="form-to-remove" required>
|
| 173 |
+
<option value="">Select Form</option>
|
| 174 |
+
<option value="1">Form 1</option>
|
| 175 |
+
<option value="2">Form 2</option>
|
| 176 |
+
<option value="3">Form 3</option>
|
| 177 |
+
<option value="4">Form 4</option>
|
| 178 |
+
<option value="5">Form 5</option>
|
| 179 |
+
</select>
|
| 180 |
+
</div>
|
| 181 |
+
</div>
|
| 182 |
+
<button type="submit" class="w-full bg-red-600 text-white px-4 py-2 rounded hover:bg-red-700">
|
| 183 |
+
Remove Class/Form
|
| 184 |
</button>
|
| 185 |
</form>
|
| 186 |
</div>
|
| 187 |
+
</div>
|
| 188 |
</div>
|
| 189 |
<!-- Reports Section -->
|
| 190 |
<div class="hidden" id="reports-section">
|
|
|
|
| 438 |
showManagementMessage(`Class ${newClassName} added successfully!`);
|
| 439 |
this.reset();
|
| 440 |
});
|
| 441 |
+
// Remove class form
|
| 442 |
+
document.getElementById('remove-class-form').addEventListener('submit', function(e) {
|
| 443 |
+
e.preventDefault();
|
| 444 |
+
const classToRemove = document.getElementById('class-to-remove').value;
|
| 445 |
+
const formToRemove = document.getElementById('form-to-remove').value;
|
| 446 |
|
| 447 |
+
if (!classToRemove || !formToRemove) {
|
| 448 |
+
showManagementMessage('Please select both class and form', 'error');
|
| 449 |
+
return;
|
| 450 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
|
| 452 |
+
const key = `${classToRemove}-${formToRemove}`;
|
| 453 |
+
|
| 454 |
+
// Remove the specific class-form combination
|
| 455 |
+
if (students[key]) {
|
| 456 |
delete students[key];
|
| 457 |
+
localStorage.setItem('studentData', JSON.stringify(students));
|
| 458 |
+
showManagementMessage(`Class ${classToRemove} Form ${formToRemove} and all its students removed successfully!`);
|
| 459 |
+
} else {
|
| 460 |
+
showManagementMessage(`No students found for ${classToRemove} Form ${formToRemove}`, 'error');
|
| 461 |
}
|
| 462 |
+
|
| 463 |
+
this.reset();
|
| 464 |
+
});
|
| 465 |
+
// Load students for management dropdown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 466 |
function loadStudentsForManagement() {
|
| 467 |
const classVal = document.getElementById('student-class').value;
|
| 468 |
const formVal = document.getElementById('student-form').value;
|