[TikiWiki-commits] [Git][tikiwiki/tiki][29.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 <689489f7a4037_2c125535410221e@gitlab-sidekiq-low-urgency-cpu-bound-v2-fcfcfbbb-wxrfj.mail>

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


Commits:
c09d8616 by MAGENE Sem Joel at 2025-08-07T14:04:03+03:00
[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

- - - - -


1 changed file:

- templates/tiki-view_tracker.tpl


Changes:

=====================================
templates/tiki-view_tracker.tpl
=====================================
@@ -330,7 +330,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}
@@ -459,3 +459,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}
\ No newline at end of file



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/c09d8616fcdf37ad17eeff97fb494c4f5e2a19a5
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.