From d5b776aac202ce7a7478a6c4078d2062ede21f66 Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Wed, 27 Sep 2023 17:31:54 +0100 Subject: [PATCH 1/4] Working on removing field --- src/frontend/components/button/lib/component.js | 11 +++++++++-- .../components/modal/modals/curval/lib/component.js | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/frontend/components/button/lib/component.js b/src/frontend/components/button/lib/component.js index e5f6c96f3..e0e85d00e 100644 --- a/src/frontend/components/button/lib/component.js +++ b/src/frontend/components/button/lib/component.js @@ -54,8 +54,15 @@ class ButtonComponent extends Component { const $btn = $(ev.target) if ($btn.closest('.table-curval-group').length) { + //WEHERE if (confirm("Are you sure want to permanently remove this item?")) { - $btn.closest(".table-curval-item").remove() + const item = $btn.closest(".table-curval-item"); + const tbody= item.closest(".table-curval-group").parent(); + item.remove(); + const bodyChildren = tbody.children(".odd"); + for(let i=0;i Date: Thu, 28 Sep 2023 14:37:11 +0100 Subject: [PATCH 2/4] Fixed bug on multiple child tables --- src/frontend/components/button/lib/component.js | 15 +++++++-------- .../modal/modals/curval/lib/component.js | 10 ++++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/frontend/components/button/lib/component.js b/src/frontend/components/button/lib/component.js index e0e85d00e..6b60918e0 100644 --- a/src/frontend/components/button/lib/component.js +++ b/src/frontend/components/button/lib/component.js @@ -54,17 +54,16 @@ class ButtonComponent extends Component { const $btn = $(ev.target) if ($btn.closest('.table-curval-group').length) { - //WEHERE if (confirm("Are you sure want to permanently remove this item?")) { - const item = $btn.closest(".table-curval-item"); - const tbody= item.closest(".table-curval-group").parent(); - item.remove(); - const bodyChildren = tbody.children(".odd"); - for(let i=0;i Date: Thu, 28 Sep 2023 15:30:28 +0100 Subject: [PATCH 3/4] Remove item from child table now shows message when empty --- src/frontend/components/button/lib/component.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/frontend/components/button/lib/component.js b/src/frontend/components/button/lib/component.js index 6b60918e0..c991e2612 100644 --- a/src/frontend/components/button/lib/component.js +++ b/src/frontend/components/button/lib/component.js @@ -56,10 +56,12 @@ class ButtonComponent extends Component { if ($btn.closest('.table-curval-group').length) { if (confirm("Are you sure want to permanently remove this item?")) { const curvalItem=$btn.closest(".table-curval-item"); + const parent = curvalItem.parent(); curvalItem.remove(); - if($(".data-table tbody tr").length==1) { - if($('.dataTables_empty').hasClass("hidden")) { - $('.dataTables_empty').removeClass("hidden"); + if(parent && parent.children().length==1) { + const child = parent.children('.odd').children('.dataTables_empty'); + if(child.is(':hidden')) { + child.show(); } } } else { From 3df795a54c5c3d376d8b0b417fbf8b951de4aaca Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Wed, 11 Oct 2023 16:17:23 +0100 Subject: [PATCH 4/4] Simplified code as suggested and tested --- src/frontend/components/button/lib/component.js | 5 +---- .../components/modal/modals/curval/lib/component.js | 7 +------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/frontend/components/button/lib/component.js b/src/frontend/components/button/lib/component.js index c991e2612..9058db839 100644 --- a/src/frontend/components/button/lib/component.js +++ b/src/frontend/components/button/lib/component.js @@ -59,10 +59,7 @@ class ButtonComponent extends Component { const parent = curvalItem.parent(); curvalItem.remove(); if(parent && parent.children().length==1) { - const child = parent.children('.odd').children('.dataTables_empty'); - if(child.is(':hidden')) { - child.show(); - } + parent.children('.odd').children('.dataTables_empty').show(); } } else { ev.preventDefault() diff --git a/src/frontend/components/modal/modals/curval/lib/component.js b/src/frontend/components/modal/modals/curval/lib/component.js index 017b2ba0d..5ac476303 100644 --- a/src/frontend/components/modal/modals/curval/lib/component.js +++ b/src/frontend/components/modal/modals/curval/lib/component.js @@ -74,12 +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("tbody").find(".dataTables_empty").each(function() { - let element = $(this) - if(!element.is(":hidden")) { - element.toggle(); - } - }); + $(`#curval_list_${col_id}`).find(".dataTables_empty").hide(); } } else { const $widget = $formGroup.find(".select-widget").first()