Skip to content

Commit

Permalink
Fix for child tables display error (#241)
Browse files Browse the repository at this point in the history
* Working on removing field

* Fixed bug on multiple child tables

* Remove item from child table now shows message when empty

* Simplified code as suggested and tested
  • Loading branch information
droberts-ctrlo authored Oct 11, 2023
1 parent 164e86c commit 18a0d1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/frontend/components/button/lib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,22 @@ class ButtonComponent extends Component {

if ($btn.closest('.table-curval-group').length) {
if (confirm("Are you sure want to permanently remove this item?")) {
$btn.closest(".table-curval-item").remove()
const curvalItem=$btn.closest(".table-curval-item");
const parent = curvalItem.parent();
curvalItem.remove();
if(parent && parent.children().length==1) {
parent.children('.odd').children('.dataTables_empty').show();
}
} else {
e.preventDefault()
ev.preventDefault()
}
} else if ($btn.closest('.select-widget').length) {
const fieldId = $btn.closest(".answer").find("input").prop("id")
const $current = $btn.closest(".select-widget").find(".current")

$current.find(`li[data-list-item=${fieldId}]`).remove()
$btn.closest(".answer").remove()

const $visible = $current.children("[data-list-item]:not([hidden])")
$current.toggleClass("empty", $visible.length === 0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class CurvalModalComponent extends ModalComponent {
hidden.closest(".table-curval-item").replaceWith(row_cells)
} else {
$(`#curval_list_${col_id}`).find("tbody").prepend(row_cells)
$(`#curval_list_${col_id}`).find(".dataTables_empty").hide();
}
} else {
const $widget = $formGroup.find(".select-widget").first()
Expand Down

0 comments on commit 18a0d1a

Please sign in to comment.