Skip to content

Fixes #259 Reflect file deletion by removing the whole entry #2922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions app/assets/javascripts/exercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ $(document).on('turbolinks:load', function () {
// validate fileUrl
const matches = fileUrl.match(/files\/(\d+)/);
if (matches) {
// select the file form based on the delete button
const fileForm = $(`*[data-file-url="${fileUrl}"]`).parent().parent().parent();
fileForm.remove();

// now remove the hidden input representing the file
const fileId = matches[1];

$(`#file-form-${fileId}`).remove();

// The remaining hidden input field associated with the
// deleted file needs to be removed.
const input = $(`input[type="hidden"][value="${fileId}"]`)
input.remove()
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/exercises/_file_form.html.slim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- id = f.object.id

li.card.mt-2
li.card.mt-2 id="file-form-#{id}"
.card-header#heading role='tab'
- collapsed_class = f.index == 'index' ? nil : 'collapsed'
- aria_expanded = f.index == 'index' ? 'true' : 'false'
Expand Down