NobGit
public nobgit read

NobMail

Based on mailcow: dockerized

Languages

Repository composition by tracked source files.

PHP
PHP 49% JavaScript 35% HTML 9% CSS 4% Shell 2% Python 1% Lua 0% Perl 0% Ruby 0% SCSS 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git

Commit

[Web] Fix selection bug (reproduce: select an item, select all, deselect all, click an action and find previously selected items)

eb5d7f06
andryyy <[email protected]> 6 years ago
data/web/js/build/012-api.js | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Diff

diff --git a/data/web/js/build/012-api.js b/data/web/js/build/012-api.js
index 17cf6542..9b34904f 100644
--- a/data/web/js/build/012-api.js
+++ b/data/web/js/build/012-api.js
@@ -1,4 +1,5 @@
 $(document).ready(function() {
+  mass_action = false;
   function validateEmail(email) {
     var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
     return re.test(email);
@@ -35,7 +36,11 @@ $(document).ready(function() {
   };
   // Collect values of input fields with name "multi_select" and same data-id to js array multi_data[data-id]
   var multi_data = [];
-  $(document).on('change', 'input[name=multi_select]:checkbox', function() {
+  $(document).on('change', 'input[name=multi_select]:checkbox', function(e) {
+    if(mass_action === true) {
+      multi_data = [];
+      mass_action = false;
+    }
     if ($(this).is(':checked') && $(this).data('id')) {
       var id = $(this).data('id');
       if (typeof multi_data[id] == "undefined") {
@@ -45,7 +50,9 @@ $(document).ready(function() {
     }
     else {
       var id = $(this).data('id');
-      multi_data[id].splice($.inArray($(this).val(), multi_data[id]),1);
+      if (typeof multi_data[id] !== "undefined") {
+        multi_data[id].splice($.inArray($(this).val(), multi_data[id]),1);
+      }
     }
   });
 
@@ -68,6 +75,7 @@ $(document).ready(function() {
 
   // Select or deselect all checkboxes with same data-id
   $(document).on('click', '#toggle_multi_select_all', function(e) {
+    mass_action = true
     e.preventDefault();
     id = $(this).data("id");
     var all_checkboxes = $("input[data-id=" + id + "]:enabled");