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

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6893b9f87732d_2cd58b84902e@gitlab-sidekiq-low-urgency-cpu-bound-v2-f895bbb8c-jjstd.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
3ebdcbcd by MAGENE Sem Joel at 2025-08-06T20:16:21+00:00
[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

- - - - -


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/3ebdcbcd38e5effa11446a5018cff33d9b076dc7

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