Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions resources/views/flashcards/partials/flashcard-modal.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
hx-post="{{ route('units.flashcards.store', $unit->id) }}"
@endif
@endif
hx-target="#flashcards-list"
hx-target="{{ isset($topic) ? '#topic-flashcards-list' : '#flashcards-list' }}"
hx-swap="innerHTML"

Check notice on line 32 in resources/views/flashcards/partials/flashcard-modal.blade.php

View check run for this annotation

probelabs / Visor: quality

maintainability Issue

The conditional logic for `hx-target` makes this partial context-dependent. While this is necessary for the fix, the reason for the condition is not immediately apparent from the code alone, which can slightly impact maintainability.
Raw output
Add a brief HTML comment explaining why the `hx-target` is dynamic. This will help future developers understand that the modal is used in different contexts (topic pages vs. unit pages) without needing to trace its inclusion points.
hx-on::before-request="console.log('HTMX: Flashcard form submission starting...', event.detail)"
hx-on::after-request="console.log('HTMX: Flashcard form submission completed', event.detail); if(event.detail.xhr.status >= 200 && event.detail.xhr.status < 300) { setTimeout(() => { const modal = event.target.closest('.fixed'); if(modal) { console.log('Removing flashcard modal...'); modal.remove(); } }, 100); }"
hx-on::response-error="console.error('HTMX: Flashcard form error occurred', event.detail)"
Expand Down Expand Up @@ -324,11 +324,15 @@

<!-- JavaScript for dynamic form behavior -->
<script>
let choiceCount = 0;

// Modal form response is now handled by HTMX events

function toggleCardTypeFields(cardType) {
// Avoid global variable conflicts by scoping variables but keeping functions global
(function() {
// Private variables to avoid conflicts
let modalChoiceCount = 0;

// Modal form response is now handled by HTMX events

// Make functions global so they can be called from HTML
window.toggleCardTypeFields = function(cardType) {
// Hide all card-specific fields
const fieldGroups = ['basic-fields', 'multiple-choice-fields', 'true-false-fields', 'cloze-fields', 'image-occlusion-fields'];
fieldGroups.forEach(group => {
Expand Down
Loading