Skip to content

Commit 3955df3

Browse files
committed
[ISSUE-259] Reflect file deletion by removing the hole entry
Remove the hole file element form the exercise form when a file is deleted.
1 parent 2a4d9cf commit 3955df3

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

app/assets/javascripts/exercises.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,11 @@ $(document).on('turbolinks:load', function () {
8787
// validate fileUrl
8888
const matches = fileUrl.match(/files\/(\d+)/);
8989
if (matches) {
90-
// select the file form based on the delete button
91-
const fileForm = $(`*[data-file-url="${fileUrl}"]`).parent().parent().parent();
92-
fileForm.remove();
90+
const fileId = matches[1];
91+
92+
$(`#file-form-${fileId}`).remove();
9393

9494
// now remove the hidden input representing the file
95-
const fileId = matches[1];
9695
const input = $(`input[type="hidden"][value="${fileId}"]`)
9796
input.remove()
9897
}

app/views/exercises/_file_form.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
- id = f.object.id
22

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

0 commit comments

Comments
 (0)