Skip to content

Commit

Permalink
Files: Fix ajax request removing to many elements for action delete
Browse files Browse the repository at this point in the history
TYPE: Bugfix
LINK: ogc-1851
  • Loading branch information
Tschuppi81 authored Nov 18, 2024
1 parent 6e8ccdc commit 6b23b2e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/onegov/org/templates/macros.pt
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,6 @@
ic-on-success="
var info = $(elt).closest('tr');
info.prev().remove();
info.next().remove();
info.remove();
"
data-confirm="Do you really want to delete this file?"
Expand Down Expand Up @@ -2231,7 +2230,7 @@
<p tal:repeat="value results.get(field.id, [])">"${value}"</p>
</tal:b>
</p>
<tal:b tal:condition="field.type in aggregated">
<tal:b tal:condition="field.type in aggregated">
<div class="chart-wrap" tal:condition="field.type == 'MultiCheckboxField'">
<div tal:define="maximum max(results[field.id].values())" class="grid horizontal">
<tal:b tal:repeat="choice field.choices">
Expand All @@ -2249,7 +2248,7 @@
</tal:b>
</tal:b>
</div>
</div>
</div>
</tal:b>
</tal:b>
</metal:display_results>
19 changes: 15 additions & 4 deletions src/onegov/town6/templates/macros.pt
Original file line number Diff line number Diff line change
Expand Up @@ -2353,10 +2353,21 @@
<a class="button secondary confirm delete" role="button"
ic-delete-from="${request.link(file)}?csrf-token=${layout.csrf_token}"
ic-on-success="
var info = $(elt).closest('tr');
info.prev().remove();
info.next().remove();
info.remove();
var cfd = $(elt).closest('tr'); // current file details row
var cfi = cfd.prev(); // current file info row
var rbfi = cfi.prev(); // row before current file info
var rafd = cfd.next(); // row after current file details
cfi.remove(); // remove current file info row
cfd.remove(); // remove current file details row
// if file is last in group, remove the group tr as well
if (!rbfi.is('[id^=\'details-\']') &&
!rbfi.hasClass('file-info') &&
!rafd.is('[id^=\'details-\']') &&
!rafd.hasClass('file-info')) {
rbfi.remove(); // remove line before file-info row
}
"
data-confirm="Do you really want to delete this file?"
data-confirm-extra="${file.name}"
Expand Down

0 comments on commit 6b23b2e

Please sign in to comment.