Bug 11888: Random password suggestion does not work twice
authorJuhani Seppälä <jseppal@student.uef.fi>
Thu, 17 Jul 2014 08:45:06 +0000 (11:45 +0300)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Wed, 30 Jul 2014 14:56:03 +0000 (11:56 -0300)
This patch adds a simple ajax-call to pull a new suggested password
from the same perl script.

To test:
1) Search for a patron and select "Change password" from the moremember-view.
2) In the member-password-view, click on "Click to fill with a randomly generated suggestion".
3) Confirm that you get a new suggested password and click the same link again.
4) Note that you do not get another suggested password - nothing is happening.
5) Apply patch.
6) Repeat steps 1-3 and confirm that you can keep clicking for a new suggested password.

Patch works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script. Works as desribed.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt

index d035a6d..96544e0 100644 (file)
         });
         $("body").on('click', "#fillrandom",function(e) {
             e.preventDefault();
-            $("#newpassword").after("<input type=\"text\" name=\"newpassword\" value=\"[% defaultnewpassword %]\">").remove();
-            $("#newpassword2").after("<input type=\"text\" name=\"newpassword2\" value=\"[% defaultnewpassword %]\">").remove();
+            $.get("/cgi-bin/koha/members/member-password.pl?member=[% userid %]", function(response) {
+                var defaultnewpass = $(response).find("#defaultnewpassfield").val();
+                $("#newpassword").after("<input type=\"text\" name=\"newpassword\"  id=\"newpassword\" value=\"" + defaultnewpass + "\">").remove();
+                $("#newpassword2").after("<input type=\"text\" name=\"newpassword2\" id=\"newpassword2\" value=\"" + defaultnewpass + "\">").remove();
+            });
         });
         $("div.hint").eq(0).after(" <div class=\"hint\"><a href=\"#\" id=\"fillrandom\">"+_("Click to fill with a randomly generated suggestion. ")+"<strong>"+_("Passwords will be displayed as text")+"</strong>.</a></div>");
+
+        $(document).ajaxStart(function () {
+            $("input[name^=newpassword]").hide();
+            $("label[for=newpassword2]").hide();
+            $(".hint:last").after($(".loading").show());
+        });
+        $(document).ajaxStop(function () {
+            $("input[name^=newpassword]").show();
+            $("label[for=newpassword2]").show();
+            $(".loading").hide();
+        });
     });
 //]]>
 </script>
 
 </div>
 </div>
-
+<input type="hidden" name="defaultnewpassfield" id="defaultnewpassfield" value="[% defaultnewpassword %]" />
+<div class="loading hide"><strong>Processing...</strong><img src="[% interface %]/[% theme %]/img/loading.gif" alt="" /></div>
 <div class="yui-b">
 [% INCLUDE 'circ-menu.inc' %]
 </div>