[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [BP][FIX] tracker(list page): Add client-side validation for batch item deletion

"Baraka Kinywa \(@bkinywa24\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <689522e3d3aa_2cd5ca0687ed@gitlab-sidekiq-low-urgency-cpu-bound-v2-54bd675fbf-7pwt9.mail>

Baraka Kinywa pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki


Commits:
e7560cb3 by MAGENE Sem Joel at 2025-08-08T00:57:20+03:00
[BP][FIX] tracker(list page): Add client-side validation for batch item deletion
---
* [BP][FIX] tracker(list page): Add client-side validation for batch item deletion
---
* [BP][FIX] tracker(list page): Add client-side validation for batch item deletion
---
* [FIX] tracker(list page): Add client-side validation for batch item deletion
---
* [FIX] tracker(list page): Add client-side validation for batch item deletion

See merge request tikiwiki/tiki!8016

See merge request tikiwiki/tiki!8220

See merge request tikiwiki/tiki!8222

See merge request tikiwiki/tiki!8228

- - - - -


1 changed file:

- templates/tiki-view_tracker.tpl


Changes:

=====================================
templates/tiki-view_tracker.tpl
=====================================
@@ -358,7 +358,7 @@
                                 </select>
                                 {ticket}
                                 <input type="hidden" name="trackerId" value="{$trackerId}">
-                                <input type="submit" class="btn btn-primary" onclick="if($('select.trackerbatchaction').children('option:selected').val() == 'delete')confirmPopup('{tr}Are you sure you want to delete the selected items?{/tr}')" name="act" value="{tr}OK{/tr}">
+                                <input type="submit" class="btn btn-primary js-confirm-delete" name="act" value="{tr}OK{/tr}">
                             </div>
                         </div>
                     {/if}
@@ -487,3 +487,29 @@
         {/tab}
     {/if}
 {/tabset}
+
+{jq}
+    const confirmDeleteMsg = '{tr}Are you sure you want to delete the selected items?{/tr}';
+    const selectItemMsg = '{tr}Please select at least one item.{/tr}';
+    // Target the batch delete button to add validation.
+    $('.js-confirm-delete').on('click', function(event) {
+        const form = $(this).closest('form');
+        const batchAction = form.find('select.trackerbatchaction').val();
+
+        // For any other action, the form submits normally without interference.
+        if (batchAction === 'delete') {
+            // Stop the default form submission to perform our checks.
+            event.preventDefault();
+
+            const itemsSelected = form.find('input[name="action[]"]:checked').length;
+
+            if (itemsSelected > 0) {
+                // Validation passed: proceed with the confirmation popup.
+                confirmPopup.call({event: event}, confirmDeleteMsg);
+            } else {
+                // Validation failed: show an feedback and do nothing else.
+                feedback(selectItemMsg,'warning');
+            }
+        }
+    });
+{/jq}



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e7560cb35444e40b1a06f067db2d407301df463c

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e7560cb35444e40b1a06f067db2d407301df463c
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.