Bug 20616: Prevent "edit serials" form submission if no serial is selected
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 23 Apr 2018 19:19:50 +0000 (16:19 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 24 Apr 2018 14:30:29 +0000 (11:30 -0300)
In order to prevent the form to submit and gives an ugly error if no
issues are selected we will make sure at least one is checked otherwise
an alert will be displayed.

Test plan:
- create a subscrpition
- go to the serials collection page
- don't check any checkboxes for serials
- click 'Edit serials'

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt

index a5e1b1e..64c856e 100644 (file)
             $('#multi_receiving').on('show', function () {
                $(this).find(".modal-body").html($(".serials_multi_receiving")[0].outerHTML);
             });
+
+            $("form[name='edition']").on('submit', function(e){
+                if ( $(this).find("input[name='serialid']:checked").size() == 0 ) {
+                    e.preventDefault();
+                    alert("You must select at least one serial to edit");
+                    return 0;
+                }
+                return 1;
+            });
         });
 
     </script>